Skip to content

: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.

fix(web-analytics): make outbound-click URLs and SDK-setup host clickable (#67612)

posthog[bot]9de8d70ae34d
diff --git a/frontend/src/scenes/onboarding/shared/OnboardingDocsContentWrapper.tsx b/frontend/src/scenes/onboarding/shared/OnboardingDocsContentWrapper.tsx
index a8608b09a346..9fb0e383bf97 100644
--- a/frontend/src/scenes/onboarding/shared/OnboardingDocsContentWrapper.tsx
+++ b/frontend/src/scenes/onboarding/shared/OnboardingDocsContentWrapper.tsx
@@ -5,6 +5,7 @@ import { StepProps, StepsProps } from '@posthog/shared-onboarding/steps'
import { StepDefinition, StepModifier } from '@posthog/shared-onboarding/steps'
import { CodeSnippet, getLanguage } from 'lib/components/CodeSnippet'
+import { CopyToClipboardInline } from 'lib/components/CopyToClipboard'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
@@ -158,6 +159,19 @@ function CodeBlock({
]
: []
+ // The API host is substituted into the snippet as inert highlighted text, so surface it as a
+ // standalone, copyable value — users otherwise try (and fail) to click or copy it in the snippet.
+ const rawCodeStrings = blocks ? blocks.map((block) => block.code) : code ? [code] : []
+ const hostUsed = rawCodeStrings.some((codeString) => codeString.includes('<ph_client_api_host>'))
+ const hostHint = hostUsed ? (
+ <div className="flex items-center gap-1 text-xs text-muted mt-1">
+ <span>API host:</span>
+ <CopyToClipboardInline explicitValue={host} description="API host" iconSize="xsmall" selectable>
+ {host}
+ </CopyToClipboardInline>
+ </div>
+ ) : null
+
const uniqueFiles = codeBlocks
.map((block) => block.file || 'default')
.filter((file, index, self) => self.indexOf(file) === index)
@@ -179,9 +193,10 @@ function CodeBlock({
if (codeBlocks.length === 1) {
const block = codeBlocks[0]
return (
- <CodeSnippet className="my-4" language={getLanguage(block.language)}>
- {block.code}
- </CodeSnippet>
+ <div className="my-4">
+ <CodeSnippet language={getLanguage(block.language)}>{block.code}</CodeSnippet>
+ {hostHint}
+ </div>
)
}
@@ -205,6 +220,7 @@ function CodeBlock({
/>
)}
<CodeSnippet language={getLanguage(selectedBlock.language)}>{selectedBlock.code}</CodeSnippet>
+ {hostHint}
</div>
)
}
diff --git a/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx b/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx
index 573d20bc811a..bc26d9532373 100644
--- a/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx
+++ b/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx
@@ -182,6 +182,39 @@ const PathValueWithHoverLink = ({
)
}
+// Outbound clicks come through as a `url` column (not `breakdown_value`), so they don't get the
+// PathValueWithHoverLink affordance. The value is already a full external URL.
+const UrlValueCell: QueryContextColumnComponent = ({ value }) => {
+ const { featureFlags } = useValues(featureFlagLogic)
+
+ if (typeof value !== 'string' || !value) {
+ return <>{value}</>
+ }
+
+ if (!featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_OPEN_URL]) {
+ return <>{value}</>
+ }
+
+ const url = value.startsWith('http') ? value : `https://${value}`
+
+ // The URL text itself is the click target so it stays discoverable on touch and keyboard focus,
+ // and works even when the cell's max-width clips the trailing icon. The icon is a hover-only hint.
+ return (
+ <Link
+ to={url}
+ target="_blank"
+ subtle
+ onClick={(e: React.MouseEvent) => e.stopPropagation()}
+ className="inline-flex items-center gap-1"
+ >
+ {value}
+ <Tooltip title="Open URL">
+ <IconExternal className="text-base opacity-0 transition-opacity [[data-row-key]:hover_&]:opacity-100" />
+ </Tooltip>
+ </Link>
+ )
+}
+
type VariationCellProps = { isPercentage?: boolean; reverseColors?: boolean; isDuration?: boolean }
const VariationCell = (
{ isPercentage, reverseColors, isDuration }: VariationCellProps = {
@@ -629,6 +662,9 @@ export const webAnalyticsDataTableQueryContext: QueryContext = {
render: VariationCell(),
align: 'right',
},
+ url: {
+ render: UrlValueCell,
+ },
action_name: {
title: 'Action',
},