:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { lemonToast } from 'lib/lemon-ui/LemonToast'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { DropdownMenuItem } from 'lib/ui/DropdownMenu/DropdownMenu'
import { hasDangerousScheme } from 'lib/utils/url'
import { CustomMenuProps } from '../types'
interface BrowserLikeMenuProps extends CustomMenuProps {
href: string
resetPanelLayout?: (animate: boolean) => void
onClick?: () => void
}
export function BrowserLikeMenuItems({
MenuItem = DropdownMenuItem,
href,
onClick,
}: BrowserLikeMenuProps): JSX.Element {
return (
<>
<MenuItem
asChild
onClick={(e) => {
e.stopPropagation()
if (hasDangerousScheme(href)) {
return
}
window.open(href, '_blank')
onClick?.()
}}
data-attr="tree-item-menu-open-link-button"
>
<ButtonPrimitive menuItem>Open link in new browser tab</ButtonPrimitive>
</MenuItem>
<MenuItem
asChild
onClick={(e) => {
e.stopPropagation()
void navigator.clipboard.writeText(document.location.origin + href)
lemonToast.success('Link copied to clipboard')
}}
data-attr="tree-item-menu-copy-link-button"
>
<ButtonPrimitive menuItem>Copy link address</ButtonPrimitive>
</MenuItem>
</>
)
}