Skip to content

Commit db0a0c6

Browse files
committed
Add SentryNavigatorObserver in onboarding
Without the SentryNavigatorObserver tracing with spans and errors on page loads and navigations doesn't work OOTB This adds SentryNavigatorObserver() to config snippets in the main page and manual - it is a bit confusing as a follow up to wizard to have any config - what doesn't the wizard do? - explanation for the SentryWidget and SentryNavigatorObserver is needed in these docs. As I don't get what changes in the product experience from this config - do i need all this dart and custom? - i think an image of a page load with an error would help here for the "reason why" - these changes are the same in both files, should it be an include?
1 parent b728484 commit db0a0c6

File tree

2 files changed

+51
-11
lines changed

2 files changed

+51
-11
lines changed

docs/platforms/dart/guides/flutter/index.mdx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ npx @sentry/wizard@latest -i flutter
6161

6262
Configuration should happen as early as possible in your application's lifecycle.
6363

64-
```dart {"onboardingOptions": {"performance": "11-13", "profiling": "14-17"}}
64+
```dart {"onboardingOptions": {"performance": "11-13, 24-31", "profiling": "14-17"}}
6565
import 'package:flutter/widgets.dart';
6666
import 'package:sentry_flutter/sentry_flutter.dart';
6767
@@ -81,8 +81,16 @@ Future<void> main() async {
8181
options.profilesSampleRate = 1.0;
8282
},
8383
appRunner: () => runApp(
84+
// SentryWidget automatically captures widget lifecycle events
85+
// and creates breadcrumbs for important Flutter events
8486
SentryWidget(
85-
child: MyApp(),
87+
child: MyApp(
88+
// When tracing is enabled, add SentryNavigatorObserver to connect
89+
// page navigations, spans, and errors in a single trace
90+
navigatorObservers: [
91+
SentryNavigatorObserver()
92+
],
93+
),
8694
),
8795
),
8896
);
@@ -92,7 +100,7 @@ Future<void> main() async {
92100
}
93101
```
94102

95-
```dart {tabTitle:With custom zone} {"onboardingOptions": {"performance": "19-21", "profiling": "22-25"}}
103+
```dart {tabTitle:With custom zone} {"onboardingOptions": {"performance": "19-21, 34-41", "profiling": "22-25"}}
96104
import 'package:flutter/widgets.dart';
97105
import 'package:sentry_flutter/sentry_flutter.dart';
98106
@@ -120,12 +128,20 @@ Future<void> main() async {
120128
options.profilesSampleRate = 1.0;
121129
},
122130
appRunner: () => runApp(
131+
// SentryWidget automatically captures widget lifecycle events
132+
// and creates breadcrumbs for important Flutter events
123133
SentryWidget(
124-
child: MyApp(),
134+
child: MyApp(
135+
// When tracing is enabled, add SentryNavigatorObserver to connect
136+
// page navigations, spans, and errors in a single trace
137+
navigatorObservers: [
138+
SentryNavigatorObserver()
139+
],
140+
),
125141
),
126142
),
127143
);
128-
} (error, stackTrace) {
144+
}, (error, stackTrace) {
129145
// Automatically sends errors to Sentry, no need to do any
130146
// captureException calls on your part.
131147
// On top of that, you can do your own custom stuff in this callback.
@@ -136,6 +152,10 @@ Future<void> main() async {
136152
}
137153
```
138154

155+
<Alert level="info">
156+
When you enable tracing, make sure to provide route names so Sentry can properly identify and track navigation between screens. <PlatformLink to="/integrations/routing-instrumentation/">Learn more about routing instrumentation</PlatformLink>
157+
</Alert>
158+
139159
## Verify
140160

141161
Verify that your app is sending events to Sentry by adding the following snippet, which includes an intentional error. You should see the error reported in Sentry within a few minutes.

docs/platforms/dart/guides/flutter/manual-setup.mdx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies:
2727
2828
Configuration should happen as early as possible in your application's lifecycle.
2929
30-
```dart {"onboardingOptions": {"performance": "11-13", "profiling": "14-17"}}
30+
```dart {"onboardingOptions": {"performance": "11-13, 24-31", "profiling": "14-17"}}
3131
import 'package:flutter/widgets.dart';
3232
import 'package:sentry_flutter/sentry_flutter.dart';
3333

@@ -47,8 +47,16 @@ Future<void> main() async {
4747
options.profilesSampleRate = 1.0;
4848
},
4949
appRunner: () => runApp(
50+
// SentryWidget automatically captures widget lifecycle events
51+
// and creates breadcrumbs for important Flutter events
5052
SentryWidget(
51-
child: MyApp(),
53+
child: MyApp(
54+
// When tracing is enabled, add SentryNavigatorObserver to connect
55+
// page navigations, spans, and errors in a single trace
56+
navigatorObservers: [
57+
SentryNavigatorObserver()
58+
],
59+
),
5260
),
5361
),
5462
);
@@ -58,7 +66,7 @@ Future<void> main() async {
5866
}
5967
```
6068

61-
```dart {tabTitle:With custom zone} {"onboardingOptions": {"performance": "19-21", "profiling": "22-25"}}
69+
```dart {tabTitle:With custom zone} {"onboardingOptions": {"performance": "19-21, 34-41", "profiling": "22-25"}}
6270
import 'package:flutter/widgets.dart';
6371
import 'package:sentry_flutter/sentry_flutter.dart';
6472
@@ -75,7 +83,7 @@ Future<void> main() async {
7583
(options) {
7684
options.dsn = '___PUBLIC_DSN___';
7785
// Adds request headers and IP for users,
78-
// visit: https://docs.sentry.io/platforms/dart/guides//data-management/data-collected/ for more info
86+
// visit: https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/ for more info
7987
options.sendDefaultPii = true;
8088
// Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
8189
// We recommend adjusting this value in production.
@@ -86,12 +94,20 @@ Future<void> main() async {
8694
options.profilesSampleRate = 1.0;
8795
},
8896
appRunner: () => runApp(
97+
// SentryWidget automatically captures widget lifecycle events
98+
// and creates breadcrumbs for important Flutter events
8999
SentryWidget(
90-
child: MyApp(),
100+
child: MyApp(
101+
// When tracing is enabled, add SentryNavigatorObserver to connect
102+
// page navigations, spans, and errors in a single trace
103+
navigatorObservers: [
104+
SentryNavigatorObserver()
105+
],
106+
),
91107
),
92108
),
93109
);
94-
} (error, stackTrace) {
110+
}, (error, stackTrace) {
95111
// Automatically sends errors to Sentry, no need to do any
96112
// captureException calls on your part.
97113
// On top of that, you can do your own custom stuff in this callback.
@@ -102,6 +118,10 @@ Future<void> main() async {
102118
}
103119
```
104120

121+
<Alert level="info">
122+
When you enable tracing, make sure to provide route names so Sentry can properly identify and track navigation between screens. <PlatformLink to="/integrations/routing-instrumentation/">Learn more about routing instrumentation</PlatformLink>
123+
</Alert>
124+
105125
## Verify
106126

107127
Verify that your app is sending events to Sentry by adding the following snippet, which includes an intentional error. You should see the error reported in Sentry within a few minutes.

0 commit comments

Comments
 (0)