Skip to content

Commit 093c39f

Browse files
authored
ref(tracemetrics): Add metric tab platform-based visibility (#102829)
### Summary Only users that have python or js platform projects at all will see the metric tab in the first place. Refs LOGS-492
1 parent e0949dd commit 093c39f

File tree

3 files changed

+52
-10
lines changed

3 files changed

+52
-10
lines changed

static/app/data/platformCategories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,12 @@ export const withMetricsOnboarding: Set<PlatformKey> = new Set([]);
396396
// List of platforms that do not have metrics support. We make use of this list in the product to not provide any Metrics
397397
export const withoutMetricsSupport: Set<PlatformKey> = new Set([]);
398398

399+
export const limitedMetricsSupportPrefixes: Set<string> = new Set([
400+
'javascript',
401+
'node',
402+
'python',
403+
]);
404+
399405
export const profiling: PlatformKey[] = [
400406
'android',
401407
'apple',
@@ -419,6 +425,7 @@ export const profiling: PlatformKey[] = [
419425
'javascript-sveltekit',
420426
'javascript-tanstackstart-react',
421427
'javascript-vue',
428+
422429
'node',
423430
'node-awslambda',
424431
'node-azurefunctions',

static/app/utils/analytics/metricsAnalyticsEvent.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export type MetricsAnalyticsEventParameters = {
77
platform: PlatformKey | 'unknown';
88
supports_onboarding_checklist: boolean;
99
};
10+
'metrics.nav.rendered': {
11+
metrics_tab_visible: boolean;
12+
organization: Organization;
13+
platforms: Array<PlatformKey | 'unknown'>;
14+
};
1015
'metrics.onboarding': {
1116
organization: Organization;
1217
platform: PlatformKey | 'unknown';
@@ -33,6 +38,7 @@ type MetricsAnalyticsEventKey = keyof MetricsAnalyticsEventParameters;
3338

3439
export const metricsAnalyticsEventMap: Record<MetricsAnalyticsEventKey, string | null> = {
3540
'metrics.explorer.setup_button_clicked': 'Metrics Setup Button Clicked',
41+
'metrics.nav.rendered': 'Metrics Nav Rendered',
3642
'metrics.onboarding': 'Metrics Explore Empty State (Onboarding)',
3743
'metrics.onboarding_platform_docs_viewed':
3844
'Metrics Explore Empty State (Onboarding) - Platform Docs Viewed',

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

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

33
import Feature from 'sentry/components/acl/feature';
44
import {FeatureBadge} from 'sentry/components/core/badge/featureBadge';
5+
import {limitedMetricsSupportPrefixes} from 'sentry/data/platformCategories';
56
import {t} from 'sentry/locale';
7+
import type {PlatformKey} from 'sentry/types/project';
8+
import {trackAnalytics} from 'sentry/utils/analytics';
69
import {useLocation} from 'sentry/utils/useLocation';
710
import useOrganization from 'sentry/utils/useOrganization';
11+
import useProjects from 'sentry/utils/useProjects';
812
import {useGetSavedQueries} from 'sentry/views/explore/hooks/useGetSavedQueries';
913
import {PRIMARY_NAV_GROUP_CONFIG} from 'sentry/views/nav/primary/config';
1014
import {SecondaryNav} from 'sentry/views/nav/secondary/secondary';
@@ -17,6 +21,7 @@ const MAX_STARRED_QUERIES_DISPLAYED = 20;
1721
export function ExploreSecondaryNav() {
1822
const organization = useOrganization();
1923
const location = useLocation();
24+
const {projects} = useProjects();
2025

2126
const baseUrl = `/organizations/${organization.slug}/explore`;
2227

@@ -25,6 +30,28 @@ export function ExploreSecondaryNav() {
2530
perPage: MAX_STARRED_QUERIES_DISPLAYED,
2631
});
2732

33+
const hasMetricsSupportedPlatform = projects.some(project => {
34+
const platform = project.platform || 'unknown';
35+
return Array.from(limitedMetricsSupportPrefixes).some(prefix =>
36+
platform.startsWith(prefix)
37+
);
38+
});
39+
40+
const userPlatforms = useMemo(
41+
() => [
42+
...new Set(projects.map(project => (project.platform as PlatformKey) || 'unknown')),
43+
],
44+
[projects]
45+
);
46+
47+
useEffect(() => {
48+
trackAnalytics('metrics.nav.rendered', {
49+
organization,
50+
metrics_tab_visible: hasMetricsSupportedPlatform,
51+
platforms: userPlatforms,
52+
});
53+
}, [organization, hasMetricsSupportedPlatform, userPlatforms]);
54+
2855
return (
2956
<Fragment>
3057
<SecondaryNav.Header>
@@ -51,15 +78,17 @@ export function ExploreSecondaryNav() {
5178
{t('Logs')}
5279
</SecondaryNav.Item>
5380
</Feature>
54-
<Feature features="tracemetrics-enabled">
55-
<SecondaryNav.Item
56-
to={`${baseUrl}/metrics/`}
57-
analyticsItemName="explore_metrics"
58-
trailingItems={<FeatureBadge type="alpha" />}
59-
>
60-
{t('Metrics')}
61-
</SecondaryNav.Item>
62-
</Feature>
81+
{hasMetricsSupportedPlatform && (
82+
<Feature features="tracemetrics-enabled">
83+
<SecondaryNav.Item
84+
to={`${baseUrl}/metrics/`}
85+
analyticsItemName="explore_metrics"
86+
trailingItems={<FeatureBadge type="alpha" />}
87+
>
88+
{t('Metrics')}
89+
</SecondaryNav.Item>
90+
</Feature>
91+
)}
6392
<Feature
6493
features="discover-basic"
6594
hookName="feature-disabled:discover2-sidebar-item"

0 commit comments

Comments
 (0)