: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
feat(error-tracking): capture event when source maps banner is shown (#63041)
Aleksander Błaszkiewicz04a6dc820f32
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/issues/SourceMapsBanner.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/issues/SourceMapsBanner.tsxindex 9e3ef6c7dceb..15a0e1b55870 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/issues/SourceMapsBanner.tsx+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/issues/SourceMapsBanner.tsx@@ -1,8 +1,12 @@import { useActions, useValues } from 'kea'+import posthog from 'posthog-js'import { IconMagicWand } from '@posthog/icons'import { LemonBanner, LemonButton } from '@posthog/lemon-ui'+import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'+import { lemonBannerLogic } from 'lib/lemon-ui/LemonBanner/lemonBannerLogic'+import { isSourceMapsRecommendation, recommendationsTabLogic } from '../recommendations/recommendationsTabLogic'import { SourceMapsFixModal } from '../recommendations/SourceMapsFixModal'import { SOURCE_MAPS_DOCS_URL, sourceMapsFixWizardLogic } from '../recommendations/sourceMapsFixWizardLogic'@@ -13,18 +17,33 @@ const DISMISS_KEY = 'error-tracking-source-maps-banner'export function SourceMapsBanner(): JSX.Element | null {const { recommendations } = useValues(recommendationsTabLogic)- const { openModal } = useActions(sourceMapsFixWizardLogic)+ const { isDismissed } = useValues(lemonBannerLogic({ dismissKey: DISMISS_KEY }))const sourceMaps = recommendations.find(isSourceMapsRecommendation)// Show only once computed and while there's an actual problem (not completed),// regardless of whether the recommendation itself was dismissed.- if (!sourceMaps || sourceMaps.computed_at === null || sourceMaps.completed) {+ if (!sourceMaps || sourceMaps.computed_at === null || sourceMaps.completed || isDismissed) {return null}const percent = Math.round((sourceMaps.meta.unresolved_pct ?? 0) * 100)const lookbackHours = sourceMaps.meta.lookback_hours+ return <SourceMapsBannerContent percent={percent} lookbackHours={lookbackHours} />+}++// Inner component so the "shown" event fires exactly when the banner becomes visible —+// the outer guards (including dismissal) gate the mount, so mounting here means it was seen.+function SourceMapsBannerContent({ percent, lookbackHours }: { percent: number; lookbackHours: number }): JSX.Element {+ const { openModal } = useActions(sourceMapsFixWizardLogic)++ useOnMountEffect(() => {+ posthog.capture('error_tracking_source_maps_banner_shown', {+ unresolved_pct: percent,+ lookback_hours: lookbackHours,+ })+ })+return (<><LemonBanner