Skip to content

Commit 6d6bd67

Browse files
buenaflorcoolguyzoneGiancarlo Buenaflor
authored andcommitted
flutter v9: update snippets (#13496)
Closes getsentry/sentry-dart#2702 Do not merge until Flutter v9 is GA --------- Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io> Co-authored-by: Giancarlo Buenaflor <giancarlobuenaflor@JL7VJ73Q6N.local>
1 parent 2408302 commit 6d6bd67

File tree

27 files changed

+139
-362
lines changed

27 files changed

+139
-362
lines changed

docs/platforms/dart/common/metrics/index.mdx

Lines changed: 0 additions & 107 deletions
This file was deleted.

docs/platforms/dart/guides/flutter/configuration/options.mdx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,6 @@ Set this boolean to `true` to enable reporting [FlutterErrorDetails.silent](http
361361

362362
</ConfigKey>
363363

364-
<ConfigKey name="autoAppStart">
365-
366-
Set this boolean to `false` to disable automatic app start tracking.
367-
368-
</ConfigKey>
369-
370364
<ConfigKey name="enableAutoNativeBreadcrumbs">
371365

372366
Set this boolean to `false` to disable automatic breadcrumbs on the Native platforms.

docs/platforms/dart/guides/flutter/configuration/releases.mdx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ Monitor the [health of releases](/product/releases/health/) by observing user ad
6464

6565
In order to monitor release health, the SDK sends session data.
6666

67-
<Alert>
68-
69-
Release health in Flutter is only available for Android, iOS, and macOS.
70-
71-
</Alert>
72-
7367
### Sessions
7468

7569
A session represents the interaction between the user and the application. Sessions contain a timestamp, a status (if the session was OK or if it crashed), and are always linked to a release. Most Sentry SDKs can manage sessions automatically.

docs/platforms/dart/guides/flutter/configuration/rewriteframes.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ options.beforeSend = (event, hint) async {
1919
baseUrl,
2020
'${baseUrl}my_prefix/',
2121
);
22-
return frame.copyWith(absPath: modifiedAbsPath);
22+
frame.absPath = modifiedAbsPath;
23+
return frame;
2324
}).toList();
24-
return exception.copyWith(
25-
stackTrace: SentryStackTrace(frames: frames),
26-
);
25+
exception.stackTrace = SentryStackTrace(frames: frames);
26+
return exception;
2727
}
2828
return exception;
2929
}).toList();
30-
return event.copyWith(exceptions: exceptions ?? []);
30+
event.exceptions = exceptions ?? [];
31+
return event;
3132
};
3233
```

docs/platforms/dart/guides/flutter/enriching-events/viewhierarchy/index.mdx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ title: "View Hierarchy"
33
description: "Learn more about debugging the view hierarchy when an error occurs. Sentry pairs the view hierarchy representation with the original event, giving you additional insight into issues."
44
---
55

6-
<Include name="feature-stage-beta.mdx" />
7-
86
Sentry makes it possible to render a JSON representation of the view hierarchy of an error and includes it as an <PlatformLink to="/enriching-events/attachments/">attachment</PlatformLink>.
97

108
This feature only applies to SDKs with a user interface, such as the ones for mobile and desktop applications. In some environments like native iOS, rendering the view hierarchy requires the UI thread and in the event of a crash, that might not be available. Another example where the view hierarchy might not be available is when the event happens before the screen starts to load. So inherently, this feature is a best effort solution.
@@ -23,24 +21,34 @@ View hierarchy debugging is an opt-in feature. You can enable it as shown below:
2321

2422
### Customize View Hierarchy Capturing
2523

26-
<Alert>
24+
By default, Flutter limits view hierarchy captures to once every 2 seconds to minimize performance impact. While this debounce interval cannot be changed, you can customize capture behavior by implementing the `beforeCaptureViewHierarchy` callback in your `SentryFlutterOptions`.
2725

28-
Requires SDK version `8.13.0` or higher.
26+
This callback gives you fine-grained control over view hierarchy captures based on event and hint data, allowing you to implement conditional logic.
2927

30-
</Alert>
28+
<Alert>
3129

32-
Capturing view hierarchies on Flutter is limited to once every 2 seconds by default to minimize performance impact. While this debounce interval is fixed, you can override individual capture decisions by implementing the `beforeCaptureViewHierarchy` option in your `SentryFlutterOptions`.
30+
The `shouldDebounce` parameter is `true` if the debounce is active.
31+
If you want to capture view hierarchies regardless of the debounce, you can ignore the `shouldDebounce` parameter.
3332

34-
The `beforeCaptureViewHierarchy` option allows you to customize behavior based on event data so you can decide when to capture view hierarchy and when not to. For example, you can decide to only capture view hierarchy for fatal events:
33+
</Alert>
3534

36-
```flutter {2-9}
35+
```dart {tabTitle: Respect debounce} {2-9}
3736
await SentryFlutter.init((options) {
38-
options.beforeCaptureViewHierarchy = (event, hint, debounce) async {
37+
options.beforeCaptureViewHierarchy = (event, hint, shouldDebounce) async {
3938
// If debounce is active, skip capturing
40-
if (debounce) {
39+
if (shouldDebounce) {
4140
return false;
4241
}
43-
// Capture if it's a fatal event
42+
// Capture view hierarchy if it's a fatal event
43+
return event.level == SentryLevel.fatal;
44+
};
45+
});
46+
```
47+
48+
```dart {tabTitle: Ignore debounce} {2-4}
49+
await SentryFlutter.init((options) {
50+
options.beforeCaptureViewHierarchy = (event, hint, shouldDebounce) async {
51+
// Capture view hierarchy if it's a fatal event regardless of debounce
4452
return event.level == SentryLevel.fatal;
4553
};
4654
});

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Sentry's Flutter SDK enables automatic reporting of errors and exceptions, and i
99
**Features:**
1010

1111
- Under the hood the SDK relies on <Link to="/platforms/dart">Sentry's Dart SDK</Link>:
12-
- The minimum required version is `2.17.0` and Flutter SDK version is `3.0.0`.
12+
- You need at least Dart `3.5.0` and Flutter `3.24.0`.
1313
- This SDK includes all the <Link to="/platforms/dart/features">Features of Sentry's Dart SDK</Link>.
1414
- Automatic native crash error tracking (using both <Link to="/platforms/android">Android</Link> and <Link to="/platforms/apple/guides/ios">iOS</Link>), including:
1515
- Java, Kotlin, C, and C++ code for Android.
@@ -46,16 +46,13 @@ Sentry supports Flutter Web as well, with the following limitations:
4646
- Stack traces aren't symbolicated when compiled using WebAssembly (WASM).
4747
- Stack traces are not symbolicated when loaded as a browser extension.
4848
- Offline caching isn't supported for exceptions.
49-
- <Link to="/product/releases/health">Release Health</Link> isn't supported.
50-
- Device context data isn't as rich on the web as it is on mobile.
5149

5250
**Desktop Limitations:**
5351

5452
Sentry supports Flutter on Linux and Windows as well, with the following limitations:
5553

5654
- Native crashes are not supported on Windows.
5755
- [Release Health](/product/releases/health/) isn't supported.
58-
- Device context data isn't as rich on Linux and Windows as it is on mobile.
5956

6057
When running on macOS, you can expect the same feature set as on iOS.
6158

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

Lines changed: 0 additions & 107 deletions
This file was deleted.

docs/platforms/dart/guides/flutter/native-init.mdx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,24 @@ By default, the Flutter SDK initializes the native SDK underneath the `init` met
88

99
To do this, set [autoInitializeNativeSdk](/platforms/dart/guides/flutter/configuration/options/#autoInitializeNativeSdk) to `false` in the init options:
1010

11-
12-
```dart
13-
import 'package:flutter/widgets.dart';
14-
import 'package:sentry_flutter/sentry_flutter.dart';
15-
16-
Future<void> main() async {
17-
await SentryFlutter.init(
18-
(options) => options
19-
..dsn = '___PUBLIC_DSN___'
20-
..autoInitializeNativeSdk = false,
21-
appRunner: () => runApp(MyApp()),
22-
);
23-
}
11+
```dart {2}
12+
await SentryFlutter.init((options) {
13+
options.autoInitializeNativeSdk = false;
14+
}, appRunner: () => runApp(SentryWidget(child: const MyApp())));
2415
```
2516

2617
This will prevent the Flutter SDK from initializing the native SDKs automatically.
2718

28-
Next, initialize the [Android](/platforms/android/configuration/manual-init/#manual-initialization) and [iOS (using the configuration guide to initialize the Sentry Cocoa SDK)](/platforms/apple/guides/ios/#configure) native SDKs. Note that you do not need to install the native SDKs as they are already packaged with the Flutter SDK.
19+
Next, initialize the native SDKs as specified in the guides below.
20+
21+
- [Android](/platforms/android/configuration/manual-init/#manual-initialization)
22+
- [iOS](/platforms/apple/guides/ios/manual-setup/)
23+
- [Browser](/platforms/javascript/#configure)
24+
25+
<Alert>
26+
27+
For Web you will need to install the JavaScript SDK by injecting the loader script manually into your HTML's `<head>` tag.
28+
29+
The Android and iOS SDKs are already packaged with the Flutter SDK.
30+
31+
</Alert>

0 commit comments

Comments
 (0)