From 145c1ba42d9e684c66ddbf09947ef16b1127dfdd Mon Sep 17 00:00:00 2001 From: Kev Date: Fri, 7 Nov 2025 13:41:31 -0500 Subject: [PATCH] ref(tracemetrics): Reduce analytic events firing Need to update them to only fire once per dep updates, and not on empty content. --- .../app/views/explore/hooks/useAnalytics.tsx | 2 +- .../sections/explore/exploreSecondaryNav.tsx | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/static/app/views/explore/hooks/useAnalytics.tsx b/static/app/views/explore/hooks/useAnalytics.tsx index 4d937783faf2d6..2cd4eeee616735 100644 --- a/static/app/views/explore/hooks/useAnalytics.tsx +++ b/static/app/views/explore/hooks/useAnalytics.tsx @@ -740,7 +740,7 @@ export function useMetricsPanelAnalytics({ return; } - if (metricSamplesTableResult.result.isFetching) { + if (metricSamplesTableResult.result.isFetching || !dataScanned) { return; } diff --git a/static/app/views/nav/secondary/sections/explore/exploreSecondaryNav.tsx b/static/app/views/nav/secondary/sections/explore/exploreSecondaryNav.tsx index a3bc8be7d5d4bc..f5634d0f155aac 100644 --- a/static/app/views/nav/secondary/sections/explore/exploreSecondaryNav.tsx +++ b/static/app/views/nav/secondary/sections/explore/exploreSecondaryNav.tsx @@ -30,6 +30,14 @@ export function ExploreSecondaryNav() { perPage: MAX_STARRED_QUERIES_DISPLAYED, }); + const userPlatforms = useMemo( + () => + Array.from( + new Set(projects.map(project => (project.platform as PlatformKey) || 'unknown')) + ).sort(), + [projects] + ); + const hasMetricsSupportedPlatform = projects.some(project => { const platform = project.platform || 'unknown'; return Array.from(limitedMetricsSupportPrefixes).some(prefix => @@ -37,14 +45,10 @@ export function ExploreSecondaryNav() { ); }); - const userPlatforms = useMemo( - () => [ - ...new Set(projects.map(project => (project.platform as PlatformKey) || 'unknown')), - ], - [projects] - ); - useEffect(() => { + if (userPlatforms.length === 0) { + return; + } trackAnalytics('metrics.nav.rendered', { organization, metrics_tab_visible: hasMetricsSupportedPlatform,