Skip to content

Commit a56109d

Browse files
committed
update code snippets
1 parent 14aacaa commit a56109d

File tree

1 file changed

+10
-36
lines changed

1 file changed

+10
-36
lines changed

docs/platforms/flutter/integrations/routing-instrumentation.mdx

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Before starting, ensure:
3030

3131
Add an instance of `SentryNavigationObserver` to your application's `navigatorObservers`.
3232

33-
```dart {tabTitle: Flutter Routing}
33+
```dart {8} {tabTitle: Flutter Routing}
3434
import 'package:flutter/material.dart';
3535
import 'package:sentry_flutter/sentry_flutter.dart';
3636
@@ -43,7 +43,7 @@ return MaterialApp(
4343
);
4444
```
4545

46-
```dart {tabTitle: GoRouter}
46+
```dart {6} {tabTitle: GoRouter}
4747
import 'package:go_router/go_router.dart';
4848
import 'package:sentry_flutter/sentry_flutter.dart';
4949
@@ -62,21 +62,15 @@ For transactions to be created when navigation changes, you need to provide rout
6262
- Flutter routing: use `RouteSettings` and set the name in the constructor.
6363
- GoRouter: use the `name` parameter to set the route name.
6464

65-
```dart {tabTitle: Flutter Routing}
66-
import 'package:flutter/material.dart';
67-
import 'package:sentry_flutter/sentry_flutter.dart';
68-
65+
```dart {4} {tabTitle: Flutter Routing}
6966
/// Setting the route name is required
7067
MaterialPageRoute(
7168
builder: (BuildContext context) => MyWidget(),
7269
settings: RouteSettings(name: 'My Widget'),
7370
)
7471
```
7572

76-
```dart {tabTitle: GoRouter}
77-
import 'package:go_router/go_router.dart';
78-
import 'package:sentry_flutter/sentry_flutter.dart';
79-
73+
```dart {13} {tabTitle: GoRouter}
8074
final GoRouter _router = GoRouter(
8175
observers: [SentryNavigatorObserver()],
8276
routes: <RouteBase>[
@@ -110,8 +104,6 @@ There are two ways to set up TTID:
110104
The default setup is enabled automatically, but only provides an approximation of TTID. To set a more accurate TTID, manually wrap the desired widget with `SentryDisplayWidget`, as shown below:
111105

112106
```dart
113-
import 'package:sentry_flutter/sentry_flutter.dart';
114-
115107
SentryDisplayWidget(
116108
child: MyWidget(),
117109
)
@@ -129,23 +121,17 @@ TTFD is disabled by default. To enable TTFD measurements, follow these steps:
129121

130122
1. Enable the `enableTimeToFullDisplayTracing` option in the SDK configuration:
131123

132-
```dart
133-
import 'package:flutter/widgets.dart';
134-
import 'package:sentry_flutter/sentry_flutter.dart';
135-
136-
Future<void> main() async {
137-
await SentryFlutter.init(
138-
(options) => options.enableTimeToFullDisplayTracing = true,
139-
appRunner: () => runApp(MyApp()),
140-
);
141-
}
124+
```dart {3}
125+
await SentryFlutter.init(
126+
(options) {
127+
options.enableTimeToFullDisplayTracing = true;
128+
}, appRunner: () => runApp(MyApp()),
129+
);
142130
```
143131

144132
2. Report the span manually:
145133

146134
```dart
147-
import 'package:sentry_flutter/sentry_flutter.dart';
148-
149135
SentryFlutter.reportFullyDisplayed();
150136
```
151137

@@ -231,9 +217,6 @@ Log into [sentry.io](https://sentry.io) and open your project's performance page
231217
Adjust the duration before a routing transaction automatically finishes. The default is 3 seconds.
232218

233219
```dart
234-
import 'package:sentry_flutter/sentry_flutter.dart';
235-
236-
/// Change how long navigation transactions idle before being finished
237220
SentryNavigatorObserver(
238221
autoFinishAfter: Duration(seconds: 5)
239222
)
@@ -251,9 +234,6 @@ Set `enableAutoTransactions` to `false` if you only want to track navigation bre
251234
Enabled by default.
252235

253236
```dart
254-
import 'package:sentry_flutter/sentry_flutter.dart';
255-
256-
/// Only track navigation breadcrumbs
257237
SentryNavigatorObserver(
258238
enableAutoTransactions: false,
259239
)
@@ -265,9 +245,6 @@ Set `ignoreRoutes` if you want routes to be ignored and not processed by the nav
265245
Empty by default.
266246

267247
```dart
268-
import 'package:sentry_flutter/sentry_flutter.dart';
269-
270-
/// Ignore matching routes
271248
SentryNavigatorObserver(
272249
ignoreRoutes: ["/ignoreThisRoute", "/my/ignored/route"],
273250
)
@@ -280,9 +257,6 @@ An existing transaction in the scope 'CustomTransaction' will be renamed to 'MyW
280257
Disabled by default.
281258

282259
```dart
283-
import 'package:sentry_flutter/sentry_flutter.dart';
284-
285-
/// Override transaction name with route name
286260
SentryNavigatorObserver(
287261
setRouteNameAsTransaction: true,
288262
)

0 commit comments

Comments
 (0)