Skip to content

Commit ef27279

Browse files
denraseadinauer
authored andcommitted
feat(docs): Document flutter autoInitializeNativeSdk (#5029)
1 parent 27f4bbe commit ef27279

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

src/platforms/common/configuration/options.mdx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -571,25 +571,37 @@ An optional property that configures which downstream services receive the `sent
571571

572572
</PlatformSection>
573573

574-
<PlatformSection supported={["react-native", "javascript.cordova", "javascript.capacitor"]}>
574+
<PlatformSection supported={["react-native", "javascript.cordova", "javascript.capacitor", "flutter"]}>
575575

576576
## Hybrid SDK Options
577577

578-
<ConfigKey name="enableNative">
578+
<ConfigKey name="enableNative" supported={["react-native", "javascript.cordova", "javascript.capacitor"]}>
579579

580580
Set this boolean to `false` to disable the native SDK. This will disable all native crash and error handling and, instead, the SDK will only capture errors on the upper layer.
581581

582582
</ConfigKey>
583583

584-
<ConfigKey name="autoInitializeNativeSdk" supported={["react-native"]}>
584+
<ConfigKey name="autoInitializeNativeSdk">
585+
586+
Set this boolean to `false` to disable the auto initialization of the native layer SDK. Doing so means you will need to initialize the native SDK manually. Do not use this to disable the native layer.
587+
588+
<PlatformSection supported={["react-native", "javascript.cordova", "javascript.capacitor"]}>
585589

586-
Set this boolean to `false` to disable the auto initialization of the native layer SDK. Doing so means you will need to initialize the native SDK manually. Do not use this to disable the native layer, but instead use [enableNative](#enableNative).
590+
To disable the native layer, use [enableNative](#enableNative).
587591

588592
You should follow the [guide to native initialization](/platforms/react-native/manual-setup/native-init/) if you chose to use this option.
589593

594+
</PlatformSection>
595+
596+
<PlatformSection supported={["flutter"]}>
597+
598+
You should follow the [guide to native initialization](/platforms/flutter/native-init/) if you chose to use this option.
599+
600+
</PlatformSection>
601+
590602
</ConfigKey>
591603

592-
<ConfigKey name="enableNativeCrashHandling" supported={["react-native", "javascript.capacitor"]}>
604+
<ConfigKey name="enableNativeCrashHandling" supported={["react-native", "javascript.capacitor", "flutter"]}>
593605

594606
Set this boolean to `false` to disable hard crash handling from the native layer. Doing so means that the SDK won't capture events for hard crashes on Android and iOS if the error was caused by native code.
595607

@@ -622,7 +634,6 @@ Set this boolean to `false` to disable the scope sync from Java to NDK on Androi
622634
<ConfigKey name="attachThreads">
623635

624636
Set this boolean to `true` to automatically attach all threads to all logged events on Android.
625-
626637
</ConfigKey>
627638

628639
<ConfigKey name="enableAutoPerformanceTracking" supported={["react-native"]}>
@@ -631,7 +642,7 @@ Set this boolean to `false` to disable auto [performance monitoring](/product/pe
631642

632643
</ConfigKey>
633644

634-
<ConfigKey name="enableOutOfMemoryTracking" supported={["react-native"]}>
645+
<ConfigKey name="enableOutOfMemoryTracking" supported={["react-native", "flutter"]}>
635646

636647
Set this boolean to `false` to disable [out of memory](/platforms/apple/guides/ios/configuration/out-of-memory/) tracking on iOS.
637648

src/platforms/flutter/native-init.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Native Initialization
3+
sidebar_order: 900
4+
description: "Learn how to manually initialize the native SDKs."
5+
---
6+
7+
By default, the Flutter SDK initializes the native SDK underneath the `init` method called on the Flutter layer. As a result, the SDK currenty has a limitation of not capturing native crashes that occur prior to the `init` method being called on the Flutter layer. You can initialize the native SDKs yourself to overcome this limitation or if you want to provide custom options above what the Flutter SDK currently provides.
8+
9+
To do this, set [autoInitializeNativeSdk](/platforms/flutter/configuration/options/#autoInitializeNativeSdk) to `false` in the init options:
10+
11+
```dart
12+
import 'package:flutter/widgets.dart';
13+
import 'package:sentry_flutter/sentry_flutter.dart';
14+
15+
Future<void> main() async {
16+
await SentryFlutter.init(
17+
(options) => options
18+
..dsn = '___PUBLIC_DSN___'
19+
..autoInitializeNativeSdk = false,
20+
appRunner: () => runApp(MyApp()),
21+
);
22+
}
23+
```
24+
25+
This will prevent the Flutter SDK from initializing the native SDKs automatically.
26+
27+
Next, initialize the [Android](/platforms/android/configuration/manual-init/) 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.

0 commit comments

Comments
 (0)