Skip to content

Commit 672e1a2

Browse files
feat(metrics): Add React Native onboarding (#66960)
1 parent 656aee3 commit 672e1a2

File tree

3 files changed

+110
-58
lines changed

3 files changed

+110
-58
lines changed

static/app/components/onboarding/gettingStartedDoc/utils/metricsOnboarding.tsx

+87-58
Original file line numberDiff line numberDiff line change
@@ -39,73 +39,102 @@ export const getJSMetricsOnboarding = ({
3939
configurations: getInstallConfig(params),
4040
},
4141
],
42-
configure: params => [
43-
{
44-
type: StepType.CONFIGURE,
45-
description: tct(
46-
'To enable capturing metrics, you first need to add the metrics aggregator integration under the [codeNamespace:Sentry.metrics] namespace.',
47-
{
48-
codeNamespace: <code />,
49-
}
50-
),
51-
configurations: [
52-
{
53-
code: [
54-
{
55-
label: 'JavaScript',
56-
value: 'javascript',
57-
language: 'javascript',
58-
code: getJSConfigureSnippet(params),
59-
},
60-
],
61-
},
62-
],
63-
},
64-
],
65-
verify: () => [
42+
configure: getJSMetricsOnboardingConfigure,
43+
verify: () =>
44+
getJSMetricsOnboardingVerify({
45+
docsLink: 'https://docs.sentry.io/platforms/javascript/metrics/',
46+
}),
47+
});
48+
49+
export const getReactNativeMetricsOnboarding = ({
50+
getInstallConfig,
51+
}: {
52+
getInstallConfig: (params: DocsParams<any>) => StepProps['configurations'];
53+
}): OnboardingConfig => ({
54+
install: params => [
6655
{
67-
type: StepType.VERIFY,
56+
type: StepType.INSTALL,
6857
description: tct(
69-
"Then you'll be able to add metrics as [codeCounters:counters], [codeSets:sets], [codeDistribution:distributions], and [codeGauge:gauges]. These are available under the [codeNamespace:Sentry.metrics] namespace. Try out this example:",
58+
'You need a minimum version [codeVersion:5.19.0] of the Sentry React Native SDK installed.',
7059
{
71-
codeCounters: <code />,
72-
codeSets: <code />,
73-
codeDistribution: <code />,
74-
codeGauge: <code />,
75-
codeNamespace: <code />,
60+
codeVersion: <code />,
7661
}
7762
),
78-
configurations: [
79-
{
80-
code: [
81-
{
82-
label: 'JavaScript',
83-
value: 'javascript',
84-
language: 'javascript',
85-
code: getJSVerifySnippet(),
86-
},
87-
],
88-
},
89-
{
90-
description: t(
91-
'With a bit of delay you can see the data appear in the Sentry UI.'
92-
),
93-
},
94-
{
95-
description: tct(
96-
'Learn more about metrics and how to configure them, by reading the [docsLink:docs].',
97-
{
98-
docsLink: (
99-
<ExternalLink href="https://docs.sentry.io/platforms/javascript/metrics/" />
100-
),
101-
}
102-
),
103-
},
104-
],
63+
configurations: getInstallConfig(params),
10564
},
10665
],
66+
configure: getJSMetricsOnboardingConfigure,
67+
verify: () =>
68+
getJSMetricsOnboardingVerify({
69+
docsLink: 'https://docs.sentry.io/platforms/react-native/metrics/',
70+
}),
10771
});
10872

73+
const getJSMetricsOnboardingConfigure = (params: DocsParams) => [
74+
{
75+
type: StepType.CONFIGURE,
76+
description: tct(
77+
'To enable capturing metrics, you first need to add the metrics aggregator integration under the [codeNamespace:Sentry.metrics] namespace.',
78+
{
79+
codeNamespace: <code />,
80+
}
81+
),
82+
configurations: [
83+
{
84+
code: [
85+
{
86+
label: 'JavaScript',
87+
value: 'javascript',
88+
language: 'javascript',
89+
code: getJSConfigureSnippet(params),
90+
},
91+
],
92+
},
93+
],
94+
},
95+
];
96+
97+
const getJSMetricsOnboardingVerify = ({docsLink}: {docsLink: string}) => [
98+
{
99+
type: StepType.VERIFY,
100+
description: tct(
101+
"Then you'll be able to add metrics as [codeCounters:counters], [codeSets:sets], [codeDistribution:distributions], and [codeGauge:gauges]. These are available under the [codeNamespace:Sentry.metrics] namespace. Try out this example:",
102+
{
103+
codeCounters: <code />,
104+
codeSets: <code />,
105+
codeDistribution: <code />,
106+
codeGauge: <code />,
107+
codeNamespace: <code />,
108+
}
109+
),
110+
configurations: [
111+
{
112+
code: [
113+
{
114+
label: 'JavaScript',
115+
value: 'javascript',
116+
language: 'javascript',
117+
code: getJSVerifySnippet(),
118+
},
119+
],
120+
},
121+
{
122+
description: t(
123+
'With a bit of delay you can see the data appear in the Sentry UI.'
124+
),
125+
},
126+
{
127+
description: tct(
128+
'Learn more about metrics and how to configure them, by reading the [docsLink:docs].',
129+
{
130+
docsLink: <ExternalLink href={docsLink} />,
131+
}
132+
),
133+
},
134+
],
135+
},
136+
];
137+
109138
const getJSServerConfigureSnippet = (params: DocsParams) => `
110139
Sentry.init({
111140
dsn: "${params.dsn}",

static/app/data/platformCategories.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ const customMetricFrontendPlatforms: readonly PlatformKey[] = [
524524
'javascript-sveltekit',
525525
'javascript-vue',
526526
'javascript',
527+
'react-native',
527528
];
528529

529530
// These are all the platforms that can set up custom metrics.

static/app/gettingStartedDocs/react-native/react-native.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
getCrashReportApiIntroduction,
1414
getCrashReportInstallDescription,
1515
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
16+
import {getReactNativeMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
1617
import {t, tct} from 'sentry/locale';
1718

1819
type Params = DocsParams;
@@ -327,10 +328,31 @@ Sentry.captureUserFeedback(userFeedback);`,
327328
nextSteps: () => [],
328329
};
329330

331+
const getInstallConfig = () => [
332+
{
333+
language: 'bash',
334+
code: [
335+
{
336+
label: 'npm',
337+
value: 'npm',
338+
language: 'bash',
339+
code: 'npm install --save @sentry/react-native',
340+
},
341+
{
342+
label: 'yarn',
343+
value: 'yarn',
344+
language: 'bash',
345+
code: 'yarn add @sentry/react-native',
346+
},
347+
],
348+
},
349+
];
350+
330351
const docs: Docs = {
331352
onboarding,
332353
feedbackOnboardingCrashApi,
333354
crashReportOnboarding: feedbackOnboardingCrashApi,
355+
customMetricsOnboarding: getReactNativeMetricsOnboarding({getInstallConfig}),
334356
};
335357

336358
export default docs;

0 commit comments

Comments
 (0)