Skip to content

Commit ee10b23

Browse files
k-fishandrewshie-sentry
authored andcommitted
feat(tracemetrics): Update nav event (#103244)
Updates with better fields.
1 parent 320a086 commit ee10b23

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

static/app/utils/analytics/metricsAnalyticsEvent.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ export type MetricsAnalyticsEventParameters = {
3838
organization: Organization;
3939
};
4040
'metrics.nav.rendered': {
41+
has_feature_flag: boolean;
42+
has_metrics_supported_platform: boolean;
43+
metrics_supported_platform_name: string | undefined;
4144
metrics_tab_visible: boolean;
4245
organization: Organization;
43-
platforms: Array<PlatformKey | 'unknown'>;
4446
};
4547
'metrics.onboarding': {
4648
organization: Organization;

static/app/views/nav/secondary/sections/explore/exploreSecondaryNav.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Fragment, useEffect, useMemo} from 'react';
1+
import {Fragment, useEffect, useMemo, useRef} from 'react';
22

33
import Feature from 'sentry/components/acl/feature';
44
import {FeatureBadge} from 'sentry/components/core/badge/featureBadge';
@@ -10,6 +10,7 @@ import {useLocation} from 'sentry/utils/useLocation';
1010
import useOrganization from 'sentry/utils/useOrganization';
1111
import useProjects from 'sentry/utils/useProjects';
1212
import {useGetSavedQueries} from 'sentry/views/explore/hooks/useGetSavedQueries';
13+
import {canUseMetricsUI} from 'sentry/views/explore/metrics/metricsFlags';
1314
import {PRIMARY_NAV_GROUP_CONFIG} from 'sentry/views/nav/primary/config';
1415
import {SecondaryNav} from 'sentry/views/nav/secondary/secondary';
1516
import {ExploreSavedQueryNavItems} from 'sentry/views/nav/secondary/sections/explore/exploreSavedQueryNavItems';
@@ -38,23 +39,32 @@ export function ExploreSecondaryNav() {
3839
[projects]
3940
);
4041

41-
const hasMetricsSupportedPlatform = projects.some(project => {
42-
const platform = project.platform || 'unknown';
43-
return Array.from(limitedMetricsSupportPrefixes).some(prefix =>
44-
platform.startsWith(prefix)
45-
);
46-
});
42+
const metricsSupportedPlatformNameRef = useRef<string | undefined>(undefined);
43+
44+
if (!metricsSupportedPlatformNameRef.current) {
45+
const metricsSupportedPlatform = projects.find(project => {
46+
const platform = project.platform || 'unknown';
47+
return Array.from(limitedMetricsSupportPrefixes).find(prefix =>
48+
platform.startsWith(prefix)
49+
);
50+
});
51+
metricsSupportedPlatformNameRef.current = metricsSupportedPlatform?.slug;
52+
}
53+
54+
const hasMetricsSupportedPlatform = !!metricsSupportedPlatformNameRef.current;
4755

4856
useEffect(() => {
4957
if (userPlatforms.length === 0) {
5058
return;
5159
}
5260
trackAnalytics('metrics.nav.rendered', {
5361
organization,
54-
metrics_tab_visible: hasMetricsSupportedPlatform,
55-
platforms: userPlatforms,
62+
has_feature_flag: canUseMetricsUI(organization),
63+
has_metrics_supported_platform: hasMetricsSupportedPlatform,
64+
metrics_supported_platform_name: metricsSupportedPlatformNameRef.current,
65+
metrics_tab_visible: hasMetricsSupportedPlatform && canUseMetricsUI(organization),
5666
});
57-
}, [organization, hasMetricsSupportedPlatform, userPlatforms]);
67+
}, [organization, hasMetricsSupportedPlatform, userPlatforms.length]);
5868

5969
return (
6070
<Fragment>

0 commit comments

Comments
 (0)