Skip to content

Commit e91434e

Browse files
stefanosianogetsantry[bot]ArthurKnaus
authored andcommitted
Add onboarding docs for Dart and Flutter custom Metrics (#68687)
Add onboarding docs instructions for Dart and Flutter custom Metrics Added Dart and Flutter as supported platform for Metrics Closes getsentry/sentry-docs#9642 --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com> Co-authored-by: ArthurKnaus <[email protected]>
1 parent 6ecd14b commit e91434e

File tree

3 files changed

+213
-2
lines changed

3 files changed

+213
-2
lines changed

static/app/data/platformCategories.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ export const feedbackOnboardingPlatforms: readonly PlatformKey[] = [
454454

455455
const customMetricBackendPlatforms: readonly PlatformKey[] = [
456456
'bun',
457+
'dart',
457458
'dotnet',
458459
'dotnet-aspnetcore',
459460
'dotnet-awslambda',
@@ -513,6 +514,7 @@ const customMetricBackendPlatforms: readonly PlatformKey[] = [
513514
const customMetricFrontendPlatforms: readonly PlatformKey[] = [
514515
'android',
515516
'electron',
517+
'flutter',
516518
'java-android',
517519
'javascript-angular',
518520
'javascript-astro',

static/app/gettingStartedDocs/dart/dart.tsx

+105-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ExternalLink from 'sentry/components/links/externalLink';
2+
import Link from 'sentry/components/links/link';
23
import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
34
import type {
45
Docs,
@@ -14,7 +15,7 @@ import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersi
1415

1516
type Params = DocsParams;
1617

17-
const getInstallSnipet = (params: Params) => `
18+
const getInstallSnippet = (params: Params) => `
1819
dependencies:
1920
sentry: ^${getPackageVersion(params, 'sentry.dart', '7.8.0')}`;
2021

@@ -73,6 +74,107 @@ Future<void> processOrderBatch(ISentrySpan span) async {
7374
}
7475
}`;
7576

77+
const getConfigureMetricsSnippet = (params: Params) => `
78+
import 'package:sentry/sentry.dart';
79+
80+
Future<void> main() async {
81+
await Sentry.init((options) {
82+
options.dsn = '${params.dsn}';
83+
options.enableMetrics = true;
84+
},
85+
);`;
86+
87+
const metricsOnboarding: OnboardingConfig = {
88+
install: (params: DocsParams) => [
89+
{
90+
type: StepType.INSTALL,
91+
description: tct(
92+
'You need Sentry Dart SDK version [codeVersion:7.19.0] or higher. Learn more about installation methods in our [docsLink:full documentation].',
93+
{
94+
package: <code />,
95+
codeVersion: <code />,
96+
docsLink: <Link to={`/projects/${params.projectSlug}/getting-started/`} />,
97+
}
98+
),
99+
configurations: [
100+
{
101+
language: 'yml',
102+
partialLoading: params.sourcePackageRegistries?.isLoading,
103+
code: getInstallSnippet(params),
104+
},
105+
],
106+
},
107+
],
108+
configure: (params: DocsParams) => [
109+
{
110+
type: StepType.CONFIGURE,
111+
description: t(
112+
'To enable capturing metrics, you need to enable the metrics feature.'
113+
),
114+
configurations: [
115+
{
116+
code: [
117+
{
118+
label: 'Dart',
119+
value: 'dart',
120+
language: 'dart',
121+
code: getConfigureMetricsSnippet(params),
122+
},
123+
],
124+
},
125+
],
126+
},
127+
],
128+
verify: () => [
129+
{
130+
type: StepType.VERIFY,
131+
description: tct(
132+
"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:",
133+
{
134+
codeCounters: <code />,
135+
codeSets: <code />,
136+
codeDistribution: <code />,
137+
codeGauge: <code />,
138+
codeNamespace: <code />,
139+
}
140+
),
141+
configurations: [
142+
{
143+
configurations: [
144+
{
145+
code: [
146+
{
147+
label: 'Dart',
148+
value: 'dart',
149+
language: 'dart',
150+
code: `
151+
// Add 4 to a counter named "hits"
152+
Sentry.metrics().increment("hits", value: 4);`,
153+
},
154+
],
155+
},
156+
],
157+
},
158+
{
159+
description: t(
160+
'With a bit of delay you can see the data appear in the Sentry UI.'
161+
),
162+
},
163+
{
164+
description: tct(
165+
'Learn more about metrics and how to configure them, by reading the [docsLink:docs].',
166+
{
167+
docsLink: (
168+
<ExternalLink href="https://docs.sentry.io/platforms/dart/metrics/" />
169+
),
170+
}
171+
),
172+
},
173+
],
174+
},
175+
],
176+
};
177+
76178
const onboarding: OnboardingConfig = {
77179
install: params => [
78180
{
@@ -87,7 +189,7 @@ const onboarding: OnboardingConfig = {
87189
{
88190
language: 'yml',
89191
partialLoading: params.sourcePackageRegistries.isLoading,
90-
code: getInstallSnipet(params),
192+
code: getInstallSnippet(params),
91193
},
92194
],
93195
},
@@ -198,6 +300,7 @@ const docs: Docs = {
198300
onboarding,
199301
feedbackOnboardingCrashApi: feedbackOnboardingCrashApiDart,
200302
crashReportOnboarding: feedbackOnboardingCrashApiDart,
303+
customMetricsOnboarding: metricsOnboarding,
201304
};
202305

203306
export default docs;

static/app/gettingStartedDocs/flutter/flutter.tsx

+106
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ExternalLink from 'sentry/components/links/externalLink';
2+
import Link from 'sentry/components/links/link';
23
import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
34
import type {
45
Docs,
@@ -85,6 +86,110 @@ Future<void> processOrderBatch(ISentrySpan span) async {
8586
}
8687
}`;
8788

89+
const getConfigureMetricsSnippet = (params: Params) => `
90+
import 'package:sentry_flutter/sentry_flutter.dart';
91+
92+
Future<void> main() async {
93+
await SentryFlutter.init(
94+
(options) {
95+
options.dsn = '${params.dsn}';
96+
options.enableMetrics = true;
97+
},
98+
appRunner: initApp, // Init your App.
99+
);
100+
};`;
101+
102+
const metricsOnboarding: OnboardingConfig = {
103+
install: (params: DocsParams) => [
104+
{
105+
type: StepType.INSTALL,
106+
description: tct(
107+
'You need Sentry Flutter SDK version [codeVersion:7.19.0] or higher. Learn more about installation methods in our [docsLink:full documentation].',
108+
{
109+
package: <code />,
110+
codeVersion: <code />,
111+
docsLink: <Link to={`/projects/${params.projectSlug}/getting-started/`} />,
112+
}
113+
),
114+
configurations: [
115+
{
116+
language: 'yml',
117+
partialLoading: params.sourcePackageRegistries?.isLoading,
118+
code: getInstallSnippet(params),
119+
},
120+
],
121+
},
122+
],
123+
configure: (params: DocsParams) => [
124+
{
125+
type: StepType.CONFIGURE,
126+
description: t(
127+
'To enable capturing metrics, you need to enable the metrics feature.'
128+
),
129+
configurations: [
130+
{
131+
code: [
132+
{
133+
label: 'Dart',
134+
value: 'dart',
135+
language: 'dart',
136+
code: getConfigureMetricsSnippet(params),
137+
},
138+
],
139+
},
140+
],
141+
},
142+
],
143+
verify: () => [
144+
{
145+
type: StepType.VERIFY,
146+
description: tct(
147+
"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:",
148+
{
149+
codeCounters: <code />,
150+
codeSets: <code />,
151+
codeDistribution: <code />,
152+
codeGauge: <code />,
153+
codeNamespace: <code />,
154+
}
155+
),
156+
configurations: [
157+
{
158+
configurations: [
159+
{
160+
code: [
161+
{
162+
label: 'Dart',
163+
value: 'dart',
164+
language: 'dart',
165+
code: `
166+
// Add 4 to a counter named "hits"
167+
Sentry.metrics().increment("hits", value: 4);`,
168+
},
169+
],
170+
},
171+
],
172+
},
173+
{
174+
description: t(
175+
'With a bit of delay you can see the data appear in the Sentry UI.'
176+
),
177+
},
178+
{
179+
description: tct(
180+
'Learn more about metrics and how to configure them, by reading the [docsLink:docs].',
181+
{
182+
docsLink: (
183+
<ExternalLink href="https://docs.sentry.io/platforms/flutter/metrics/" />
184+
),
185+
}
186+
),
187+
},
188+
],
189+
},
190+
],
191+
};
192+
88193
const onboarding: OnboardingConfig = {
89194
install: params => [
90195
{
@@ -203,6 +308,7 @@ const docs: Docs = {
203308
onboarding,
204309
feedbackOnboardingCrashApi: feedbackOnboardingCrashApiDart,
205310
crashReportOnboarding: feedbackOnboardingCrashApiDart,
311+
customMetricsOnboarding: metricsOnboarding,
206312
};
207313

208314
export default docs;

0 commit comments

Comments
 (0)