Skip to content

Commit 8639115

Browse files
committed
add FlutterWeb with WidgetsBindingIntegration sample tab
1 parent e99f58b commit 8639115

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

docs/platforms/flutter/index.mdx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ dependencies:
4646
4747
Configuration should happen as early as possible in your application's lifecycle.
4848
49-
5049
```dart {"onboardingOptions": {"performance": "8-10", "profiling": "11-14"}}
5150
import 'package:flutter/widgets.dart';
5251
import 'package:sentry_flutter/sentry_flutter.dart';
@@ -71,6 +70,40 @@ Future<void> main() async {
7170
}
7271
```
7372

73+
```dart {tabTitle:FlutterWeb with WidgetsBindingIntegration} {"onboardingOptions": {"performance": "13-15", "profiling": "16-19"}}
74+
import 'package:flutter/widgets.dart';
75+
import 'package:sentry_flutter/sentry_flutter.dart';
76+
77+
Future<void> main() async {
78+
Sentry.runZonedGuarded(() async {
79+
WidgetsBinding.ensureInitialized();
80+
81+
// Errors before init will not be handled by Sentry
82+
83+
await SentryFlutter.init(
84+
(options) {
85+
options.dsn = '___PUBLIC_DSN___';
86+
// Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
87+
// We recommend adjusting this value in production.
88+
options.tracesSampleRate = 1.0;
89+
// The sampling rate for profiling is relative to tracesSampleRate
90+
// Setting to 1.0 will profile 100% of sampled transactions:
91+
// Note: Profiling alpha is available for iOS and macOS since SDK version 7.12.0
92+
options.profilesSampleRate = 1.0;
93+
},
94+
appRunner: () => runApp(MyApp()),
95+
);
96+
} (error, stackTrace) {
97+
// Automatically sends errors to Sentry, no need to do any
98+
// captureException calls on your part.
99+
// On top of that, you can do your own custom stuff in this callback.
100+
});
101+
102+
// you can also configure SENTRY_DSN, SENTRY_RELEASE, SENTRY_DIST, and
103+
// SENTRY_ENVIRONMENT via Dart environment variable (--dart-define)
104+
}
105+
```
106+
74107
## Verify
75108

76109
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)