diff --git a/src/includes/before-breadcrumb/dart.mdx b/src/includes/before-breadcrumb/dart.mdx new file mode 100644 index 0000000000000..d07f84efd3ff1 --- /dev/null +++ b/src/includes/before-breadcrumb/dart.mdx @@ -0,0 +1,11 @@ +```dart +import 'package:sentry/sentry.dart'; + +Breadcrumb beforeBreadcrumb(Breadcrumb breadcrumb, dynamic hint) { + return 'a.spammy.Logger' == breadcrumb.category ? null : breadcrumb; +} + +Future main() async { + await Sentry.init((options) => options.beforeBreadcrumb = beforeBreadcrumb); +} +``` diff --git a/src/includes/breadcrumbs-example/dart.mdx b/src/includes/breadcrumbs-example/dart.mdx new file mode 100644 index 0000000000000..306e6a8843a57 --- /dev/null +++ b/src/includes/breadcrumbs-example/dart.mdx @@ -0,0 +1,5 @@ +```dart +import 'package:sentry/sentry.dart'; + +Sentry.addBreadcrumb(Breadcrumb(message: 'Authenticated user')); +``` diff --git a/src/includes/capture-error/dart.mdx b/src/includes/capture-error/dart.mdx new file mode 100644 index 0000000000000..5c6c58f4c4827 --- /dev/null +++ b/src/includes/capture-error/dart.mdx @@ -0,0 +1,14 @@ +In Dart you can capture any exception object that you caught: + +```dart +import 'package:sentry/sentry.dart'; + +try { + aMethodThatMightFail(); +} catch (exception, stackTrace) { + await Sentry.captureException( + exception, + stackTrace: stackTrace, + ); +} +``` diff --git a/src/includes/capture-error/flutter.mdx b/src/includes/capture-error/flutter.mdx deleted file mode 100644 index 7b3dac89b1a11..0000000000000 --- a/src/includes/capture-error/flutter.mdx +++ /dev/null @@ -1,12 +0,0 @@ -In Flutter you can capture any exception object that you caught: - -```dart -try { - throw null; -} catch (error, stackTrace) { - await sentry.captureException( - exception: error, - stackTrace: stackTrace, - ); -} -``` diff --git a/src/includes/capture-message/dart.mdx b/src/includes/capture-message/dart.mdx new file mode 100644 index 0000000000000..6eed62afe6dd4 --- /dev/null +++ b/src/includes/capture-message/dart.mdx @@ -0,0 +1,5 @@ +```dart +import 'package:sentry/sentry.dart'; + +await Sentry.captureMessage('Something went wrong'); +``` diff --git a/src/includes/capture-message/flutter.mdx b/src/includes/capture-message/flutter.mdx deleted file mode 100644 index 632d0732347cd..0000000000000 --- a/src/includes/capture-message/flutter.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```dart -sentry.captureEvent(const Event(message: 'Something went wrong')); -``` diff --git a/src/includes/configuration/auto-session-tracking/flutter.mdx b/src/includes/configuration/auto-session-tracking/flutter.mdx new file mode 100644 index 0000000000000..70d646ed9a08a --- /dev/null +++ b/src/includes/configuration/auto-session-tracking/flutter.mdx @@ -0,0 +1,14 @@ +```dart +import 'package:flutter/widgets.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; + +Future main() async { + await SentryFlutter.init( + (options) => options.enableAutoSessionTracking = true, // it's enabled by default + () { + // Run your App + runApp(MyApp()); + }, + ); +} +``` diff --git a/src/includes/configuration/before-breadcrumb-hint/dart.mdx b/src/includes/configuration/before-breadcrumb-hint/dart.mdx new file mode 100644 index 0000000000000..c4bf847699003 --- /dev/null +++ b/src/includes/configuration/before-breadcrumb-hint/dart.mdx @@ -0,0 +1,11 @@ +```dart +import 'package:sentry/sentry.dart'; + +Breadcrumb beforeBreadcrumb(Breadcrumb crumb, dynamic hint) { + return hint is MyHint ? null : crumb; +} + +Future main() async { + await Sentry.init((options) => options.beforeBreadcrumb = beforeBreadcrumb); +} +``` diff --git a/src/includes/configuration/before-send-fingerprint/dart.mdx b/src/includes/configuration/before-send-fingerprint/dart.mdx new file mode 100644 index 0000000000000..c8b55dc12d651 --- /dev/null +++ b/src/includes/configuration/before-send-fingerprint/dart.mdx @@ -0,0 +1,14 @@ +```dart +import 'package:sentry/sentry.dart'; + +SentryEvent beforeSend(SentryEvent event, dynamic hint) { + if (event.exception is DatabaseException) { + event = event.copyWith(fingerprint: ['database-connection-error']); + } + return event; +} + +Future main() async { + await Sentry.init((options) => options.beforeSend = beforeSend); +} +``` diff --git a/src/includes/configuration/before-send-hint/dart.mdx b/src/includes/configuration/before-send-hint/dart.mdx new file mode 100644 index 0000000000000..c827b4ede4b7e --- /dev/null +++ b/src/includes/configuration/before-send-hint/dart.mdx @@ -0,0 +1,13 @@ +A `BiFunction` can be used to mutate, discard (return null), or return a completely new event. + +```dart +import 'package:sentry/sentry.dart'; + +SentryEvent beforeSend(SentryEvent event, dynamic hint) { + return hint is MyHint ? null : event; +} + +Future main() async { + await Sentry.init((options) => options.beforeSend = beforeSend); +} +``` diff --git a/src/includes/configuration/before-send/dart.mdx b/src/includes/configuration/before-send/dart.mdx new file mode 100644 index 0000000000000..1e61f6b47403d --- /dev/null +++ b/src/includes/configuration/before-send/dart.mdx @@ -0,0 +1,15 @@ +A `BiFunction` can be used to mutate, discard (return null), or return a completely new event. + +```dart +import 'package:sentry/sentry.dart'; + +SentryEvent beforeSend(SentryEvent event, dynamic hint) { + // Modify the event here: + event = event.copyWith(serverName: null); // Don't send server names. + return event; +} + +Future main() async { + await Sentry.init((options) => options.beforeSend = beforeSend); +} +``` diff --git a/src/includes/configuration/config-intro/dart.mdx b/src/includes/configuration/config-intro/dart.mdx new file mode 100644 index 0000000000000..c88b9f23ac58c --- /dev/null +++ b/src/includes/configuration/config-intro/dart.mdx @@ -0,0 +1,12 @@ +Options are passed to the `Sentry.init` method: + +```dart +import 'package:sentry/sentry.dart'; + +Future main() async { + await Sentry.init((options) => options + ..dsn = '___PUBLIC_DSN___' + ..release = 'my-project-name@2.3.12' + ..environment = 'staging'); +} +``` diff --git a/src/includes/configuration/config-intro/flutter.mdx b/src/includes/configuration/config-intro/flutter.mdx index 7a070fa366cd7..d569868abcb9b 100644 --- a/src/includes/configuration/config-intro/flutter.mdx +++ b/src/includes/configuration/config-intro/flutter.mdx @@ -1,11 +1,19 @@ -Options are passed to the `SentryClient()` class: +Options are passed to the `SentryFlutter.init` method: ```dart -final sentry = SentryClient( - dsn: '___PUBLIC_DSN___', - environmentAttributes: const Event( - release: 'my-project-name@2.3.12', - environment: 'production', - ) -); +import 'package:flutter/widgets.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; + +Future main() async { + await SentryFlutter.init( + (options) => options + ..dsn = '___PUBLIC_DSN___' + ..release = 'my-project-name@2.3.12' + ..environment = 'staging', + () { + // Run your App + runApp(MyApp()); + }, + ); +} ``` diff --git a/src/includes/configuration/drain-example/flutter.mdx b/src/includes/configuration/drain-example/flutter.mdx new file mode 100644 index 0000000000000..7f2457480ccc0 --- /dev/null +++ b/src/includes/configuration/drain-example/flutter.mdx @@ -0,0 +1 @@ +The Flutter SDK for Android and iOS stores the Sentry events on the device's disk before shutdown. diff --git a/src/includes/configuration/sample-rate/dart.mdx b/src/includes/configuration/sample-rate/dart.mdx new file mode 100644 index 0000000000000..20dc2bf4c504d --- /dev/null +++ b/src/includes/configuration/sample-rate/dart.mdx @@ -0,0 +1,8 @@ +```dart +import 'package:sentry/sentry.dart'; + +Future main() async { + // Capture only 25% of events + await Sentry.init((options) => options.sampleRate = 0.25); +} +``` diff --git a/src/includes/configuration/session-tracking-interval/flutter.mdx b/src/includes/configuration/session-tracking-interval/flutter.mdx new file mode 100644 index 0000000000000..ad9f73f5ba1ac --- /dev/null +++ b/src/includes/configuration/session-tracking-interval/flutter.mdx @@ -0,0 +1,14 @@ +```dart +import 'package:flutter/widgets.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; + +Future main() async { + await SentryFlutter.init( + (options) => options.autoSessionTrackingIntervalMillis = 10000, // it's 30000 millis by default + () { + // Run your App + runApp(MyApp()); + }, + ); +} +``` diff --git a/src/includes/configure-scope/dart.mdx b/src/includes/configure-scope/dart.mdx new file mode 100644 index 0000000000000..ded5ae24e652b --- /dev/null +++ b/src/includes/configure-scope/dart.mdx @@ -0,0 +1,7 @@ +```dart +import 'package:sentry/sentry.dart'; + +Sentry.configureScope((scope) => scope + ..setTag('my-tag', 'my value') + ..user = User(id: '42', email: 'john.doe@example.com')); +``` diff --git a/src/includes/getting-started-config/dart.mdx b/src/includes/getting-started-config/dart.mdx new file mode 100644 index 0000000000000..e8e713df3822d --- /dev/null +++ b/src/includes/getting-started-config/dart.mdx @@ -0,0 +1,7 @@ +```dart +import 'package:sentry/sentry.dart'; + +Future main() async { + await Sentry.init((options) => options.dsn = '___PUBLIC_DSN___'); +} +``` diff --git a/src/includes/getting-started-config/flutter.mdx b/src/includes/getting-started-config/flutter.mdx new file mode 100644 index 0000000000000..844e3b3be159d --- /dev/null +++ b/src/includes/getting-started-config/flutter.mdx @@ -0,0 +1,16 @@ +```dart +import 'package:flutter/widgets.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; + +Future main() async { + await SentryFlutter.init( + (options) => options.dsn = '___PUBLIC_DSN___', + () { + // Run your App + runApp(MyApp()); + }, + ); + + // or define SENTRY_DSN via Dart environment variable (--dart-define) +} +``` diff --git a/src/includes/getting-started-install/dart.mdx b/src/includes/getting-started-install/dart.mdx new file mode 100644 index 0000000000000..81ad6aa660b69 --- /dev/null +++ b/src/includes/getting-started-install/dart.mdx @@ -0,0 +1,4 @@ +```yml {filename:pubspec.yaml} +dependencies: + sentry: ^4.0.0 +``` diff --git a/src/includes/getting-started-install/flutter.mdx b/src/includes/getting-started-install/flutter.mdx new file mode 100644 index 0000000000000..157cd904a88d9 --- /dev/null +++ b/src/includes/getting-started-install/flutter.mdx @@ -0,0 +1,4 @@ +```yml {filename:pubspec.yaml} +dependencies: + sentry_flutter: ^4.0.0 +``` diff --git a/src/includes/getting-started-primer/dart.mdx b/src/includes/getting-started-primer/dart.mdx new file mode 100644 index 0000000000000..0bd2f5f2d252b --- /dev/null +++ b/src/includes/getting-started-primer/dart.mdx @@ -0,0 +1,5 @@ + + +_Pure Dart SDK used by any Dart application like AngularDart, CLI and Server, it enables reporting messages and errors._ + + diff --git a/src/includes/getting-started-primer/flutter.mdx b/src/includes/getting-started-primer/flutter.mdx new file mode 100644 index 0000000000000..6f8bae740e9ea --- /dev/null +++ b/src/includes/getting-started-primer/flutter.mdx @@ -0,0 +1,7 @@ + + +_Sentry's Flutter SDK enables capturing sessions for Release Health, offline caching as well as reporting messages and errors._ + +_Sentry's Flutter SDK depends on the [Dart SDK](/platforms/dart/) and includes support to native crashes through Sentry's native SDKs (Android and iOS), It'll capture errors in the native layer, including Java, Kotlin, C and C++ code for `Android` and ObjC, Swift and C for `iOS`._ + + diff --git a/src/includes/getting-started-verify/dart.mdx b/src/includes/getting-started-verify/dart.mdx new file mode 100644 index 0000000000000..8fa5050949bc5 --- /dev/null +++ b/src/includes/getting-started-verify/dart.mdx @@ -0,0 +1,12 @@ +```dart +import 'package:sentry/sentry.dart'; + +try { + aMethodThatMightFail(); +} catch (exception, stackTrace) { + await Sentry.captureException( + exception, + stackTrace: stackTrace, + ); +} +``` diff --git a/src/includes/sensitive-data/set-tag/dart.mdx b/src/includes/sensitive-data/set-tag/dart.mdx new file mode 100644 index 0000000000000..a42e97256cd6c --- /dev/null +++ b/src/includes/sensitive-data/set-tag/dart.mdx @@ -0,0 +1,8 @@ +```dart +import 'package:sentry/sentry.dart'; + +Sentry.configureScope((scope) => scope.setTag( + 'birthday', + checksumOrHash('08/12/1990'), + )); +``` diff --git a/src/includes/sensitive-data/set-user/dart.mdx b/src/includes/sensitive-data/set-user/dart.mdx new file mode 100644 index 0000000000000..037fc4e96536e --- /dev/null +++ b/src/includes/sensitive-data/set-user/dart.mdx @@ -0,0 +1,8 @@ +```dart +import 'package:sentry/sentry.dart'; + +Sentry.configureScope((scope) => scope.user = User( + id: clientUser.id, + username: clientUser.username, + )); +``` diff --git a/src/includes/set-context/dart.mdx b/src/includes/set-context/dart.mdx new file mode 100644 index 0000000000000..612497e509bac --- /dev/null +++ b/src/includes/set-context/dart.mdx @@ -0,0 +1,9 @@ +```dart +import 'package:sentry/sentry.dart'; + +final person = { + 'name': 'Mighty Fighter', + 'age': '19', +}; +Sentry.configureScope((scope) => scope.setContexts('person', person)); +``` diff --git a/src/includes/set-context/flutter.mdx b/src/includes/set-context/flutter.mdx deleted file mode 100644 index 66e2fd91b7de7..0000000000000 --- a/src/includes/set-context/flutter.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```dart -import 'package:sentry/sentry.dart'; - -final sentry = SentryClient( - environmentAttributes: const Event( - extra: { - 'name': 'Mighty Fighter', - 'age': 19, - 'attack_type': 'melee', - } - ) -); -``` diff --git a/src/includes/set-environment/dart.mdx b/src/includes/set-environment/dart.mdx new file mode 100644 index 0000000000000..9f965d8f01909 --- /dev/null +++ b/src/includes/set-environment/dart.mdx @@ -0,0 +1,7 @@ +```dart +import 'package:sentry/sentry.dart'; + +Future main() async { + await Sentry.init((options) => options.environment = 'staging'); +} +``` diff --git a/src/includes/set-environment/flutter.mdx b/src/includes/set-environment/flutter.mdx index 043149be2a3cd..5b991012736fe 100644 --- a/src/includes/set-environment/flutter.mdx +++ b/src/includes/set-environment/flutter.mdx @@ -1,9 +1,17 @@ ```dart -import 'package:sentry/sentry.dart'; +import 'package:flutter/widgets.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; + +Future main() async { + await SentryFlutter.init( + (options) => options.environment = 'staging', + () { + // Run your App + runApp(MyApp()); + }, + ); + + // or define SENTRY_ENVIRONMENT via Dart environment variable (--dart-define) +} -final sentry = SentryClient( - environmentAttributes: const Event( - environment: 'production' - ) -); ``` diff --git a/src/includes/set-extra/dart.mdx b/src/includes/set-extra/dart.mdx new file mode 100644 index 0000000000000..a3dce1ae9517e --- /dev/null +++ b/src/includes/set-extra/dart.mdx @@ -0,0 +1,8 @@ +```dart +import 'package:sentry/sentry.dart'; + +Sentry.configureScope((scope) => scope.setExtra( + 'character.name', + 'Mighty Fighter', + )); +``` diff --git a/src/includes/set-extra/flutter.mdx b/src/includes/set-extra/flutter.mdx deleted file mode 100644 index 94bd12edbe19a..0000000000000 --- a/src/includes/set-extra/flutter.mdx +++ /dev/null @@ -1,9 +0,0 @@ -```dart -import 'package:sentry/sentry.dart'; - -final sentry = SentryClient( - environmentAttributes: const Event( - extra: { 'character.name': 'Mighty Fighter' } - ) -); -``` diff --git a/src/includes/set-fingerprint/basic/dart.mdx b/src/includes/set-fingerprint/basic/dart.mdx new file mode 100644 index 0000000000000..c8b55dc12d651 --- /dev/null +++ b/src/includes/set-fingerprint/basic/dart.mdx @@ -0,0 +1,14 @@ +```dart +import 'package:sentry/sentry.dart'; + +SentryEvent beforeSend(SentryEvent event, dynamic hint) { + if (event.exception is DatabaseException) { + event = event.copyWith(fingerprint: ['database-connection-error']); + } + return event; +} + +Future main() async { + await Sentry.init((options) => options.beforeSend = beforeSend); +} +``` diff --git a/src/includes/set-fingerprint/database-connection/dart.mdx b/src/includes/set-fingerprint/database-connection/dart.mdx new file mode 100644 index 0000000000000..c8b55dc12d651 --- /dev/null +++ b/src/includes/set-fingerprint/database-connection/dart.mdx @@ -0,0 +1,14 @@ +```dart +import 'package:sentry/sentry.dart'; + +SentryEvent beforeSend(SentryEvent event, dynamic hint) { + if (event.exception is DatabaseException) { + event = event.copyWith(fingerprint: ['database-connection-error']); + } + return event; +} + +Future main() async { + await Sentry.init((options) => options.beforeSend = beforeSend); +} +``` diff --git a/src/includes/set-fingerprint/rpc/dart.mdx b/src/includes/set-fingerprint/rpc/dart.mdx new file mode 100644 index 0000000000000..0860a64d66623 --- /dev/null +++ b/src/includes/set-fingerprint/rpc/dart.mdx @@ -0,0 +1,26 @@ +```dart +import 'package:sentry/sentry.dart'; + +class MyRpcException implements Exception { + final String function; + final int httpStatusCode; + + MyRpcException(this.function, this.httpStatusCode); +} + +SentryEvent beforeSend(SentryEvent event, dynamic hint) { + if (event.exception is MyRpcException) { + final exception = event.exception as MyRpcException; + event = event.copyWith(fingerprint: [ + '{{ default }}', + exception.function, + exception.httpStatusCode.toString(), + ]); + } + return event; +} + +Future main() async { + await Sentry.init((options) => options.beforeSend = beforeSend); +} +``` diff --git a/src/includes/set-fingerprint/static/dart.mdx b/src/includes/set-fingerprint/static/dart.mdx new file mode 100644 index 0000000000000..6de02829f9154 --- /dev/null +++ b/src/includes/set-fingerprint/static/dart.mdx @@ -0,0 +1,5 @@ +```dart +import 'package:sentry/sentry.dart'; + +Sentry.configureScope((scope) => scope.fingerprint = ['auth-error']); +``` diff --git a/src/includes/set-level/dart.mdx b/src/includes/set-level/dart.mdx new file mode 100644 index 0000000000000..8f9bd839be1c3 --- /dev/null +++ b/src/includes/set-level/dart.mdx @@ -0,0 +1,5 @@ +```dart +import 'package:sentry/sentry.dart'; + +Sentry.configureScope((scope) => scope.level = SentryLevel.warning); +``` diff --git a/src/includes/set-release/dart.mdx b/src/includes/set-release/dart.mdx new file mode 100644 index 0000000000000..f1071efac422a --- /dev/null +++ b/src/includes/set-release/dart.mdx @@ -0,0 +1,7 @@ +```dart +import 'package:sentry/sentry.dart'; + +Future main() async { + await Sentry.init((options) => options.release = 'my-project-name@2.3.12+12'); +} +``` diff --git a/src/includes/set-release/flutter.mdx b/src/includes/set-release/flutter.mdx index 81d8849e17adc..5928bedcacfe0 100644 --- a/src/includes/set-release/flutter.mdx +++ b/src/includes/set-release/flutter.mdx @@ -1,9 +1,17 @@ ```dart -import 'package:sentry/sentry.dart'; +import 'package:flutter/widgets.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; + +Future main() async { + await SentryFlutter.init( + (options) => options.release = 'my-project-name@2.3.12+12', // this is set automatically for Android and iOS (packageName@versionName+buildNumber) + () { + // Run your App + runApp(MyApp()); + }, + ); + + // or define SENTRY_RELEASE via Dart environment variable (--dart-define) +} -final sentry = SentryClient( - environmentAttributes: const Event( - release: 'my-project-name@2.3.12' - ) -); ``` diff --git a/src/includes/set-tag/dart.mdx b/src/includes/set-tag/dart.mdx new file mode 100644 index 0000000000000..1668e2dfc9c93 --- /dev/null +++ b/src/includes/set-tag/dart.mdx @@ -0,0 +1,5 @@ +```dart +import 'package:sentry/sentry.dart'; + +Sentry.configureScope((scope) => scope.setTag('page.locale', 'pt-BR')); +``` diff --git a/src/includes/set-user/dart.mdx b/src/includes/set-user/dart.mdx new file mode 100644 index 0000000000000..a9ddeda2f1a11 --- /dev/null +++ b/src/includes/set-user/dart.mdx @@ -0,0 +1,7 @@ +```dart +import 'package:sentry/sentry.dart'; + +Sentry.configureScope( + (scope) => scope.user = User(email: 'jane.doe@example.com'), +); +``` diff --git a/src/includes/unset-user/dart.mdx b/src/includes/unset-user/dart.mdx new file mode 100644 index 0000000000000..67556d06ddab4 --- /dev/null +++ b/src/includes/unset-user/dart.mdx @@ -0,0 +1,5 @@ +```dart +import 'package:sentry/sentry.dart'; + +Sentry.configureScope((scope) => scope.user = null); +``` diff --git a/src/platforms/common/configuration/draining.mdx b/src/platforms/common/configuration/draining.mdx index 5f462348a7e7c..a45e227481ae6 100644 --- a/src/platforms/common/configuration/draining.mdx +++ b/src/platforms/common/configuration/draining.mdx @@ -4,6 +4,7 @@ sidebar_order: 5 description: "Learn more about the default behavior of our SDK if the application shuts down unexpectedly." notSupported: - perl + - dart --- The default behavior of most SDKs is to send out events over the network diff --git a/src/platforms/common/configuration/options.mdx b/src/platforms/common/configuration/options.mdx index 21f7f0365bec1..6af2a7ec89f49 100644 --- a/src/platforms/common/configuration/options.mdx +++ b/src/platforms/common/configuration/options.mdx @@ -81,7 +81,7 @@ If possible, we recommended turning on this feature to send all such data by def - + This option can be used to supply a "server name." When provided, the name of the server is sent along and persisted in the event. For many integrations the server name actually corresponds to the device hostname, even in situations where the machine is not actually a server. Most SDKs will attempt to auto-discover this value. @@ -101,13 +101,13 @@ will be sent. This is a "contains" match to the entire file URL. As a result, if - + A list of string prefixes of module names that belong to the app. This option takes precedence over `in-app-exclude`. - + A list of string prefixes of module names that do not belong to the app, but rather to third-party packages. Modules considered not part of the app will be hidden from stack traces by default. diff --git a/src/platforms/common/data-management/sensitive-data/index.mdx b/src/platforms/common/data-management/sensitive-data/index.mdx index 925df7d0f1a34..631cb89e8bc63 100644 --- a/src/platforms/common/data-management/sensitive-data/index.mdx +++ b/src/platforms/common/data-management/sensitive-data/index.mdx @@ -17,7 +17,7 @@ There are two great examples for data scrubbing that every company should think ## Personally Identifiable Information (PII) - + Our newer SDKs do not purposefully send PII to stay on the safe side. This behavior is controlled by an option called [`send-default-pii`](../../configuration/options/#send-default-pii). diff --git a/src/platforms/common/enriching-events/user-feedback.mdx b/src/platforms/common/enriching-events/user-feedback.mdx index d922b2be41307..e1e45c53fe8b9 100644 --- a/src/platforms/common/enriching-events/user-feedback.mdx +++ b/src/platforms/common/enriching-events/user-feedback.mdx @@ -18,6 +18,8 @@ notSupported: - native.crashpad - native.minidumps - native.ue4 + - dart + - flutter --- When a user experiences an error, Sentry provides the ability to collect additional feedback. This type of feedback is useful when you may typically render a plain error page (the classic `500.html`). diff --git a/src/platforms/dart/config.yml b/src/platforms/dart/config.yml new file mode 100644 index 0000000000000..6c90f11e5db79 --- /dev/null +++ b/src/platforms/dart/config.yml @@ -0,0 +1,4 @@ +title: Dart +caseStyle: camelCase +supportLevel: production +sdk: sentry.dart diff --git a/src/platforms/dart/index.mdx b/src/platforms/dart/index.mdx new file mode 100644 index 0000000000000..81087f81af16b --- /dev/null +++ b/src/platforms/dart/index.mdx @@ -0,0 +1,35 @@ +--- +title: Dart +--- + + + + + +The Dart SDK `v4.0.0` is a Prelease and is under improvements and testing, the latest stable version is `v3.0.1` + + + + + +For Flutter apps, please refer to the [Flutter integration](/platforms/flutter) instead. + + + +Get the SDK from [pub.dev](https://pub.dev/packages/sentry) by adding the following to your `pubspec.yaml`: + + + +Import `Sentry` and initialize it: + + + +Capture a test exception: + + + +### Source code + +The Sentry Dart/Flutter SDK can be found on GitHub [`sentry-dart`](https://github.com/getsentry/sentry-dart/). + + diff --git a/src/platforms/dart/usage/advanced-usage.mdx b/src/platforms/dart/usage/advanced-usage.mdx new file mode 100644 index 0000000000000..4f397ff2ff205 --- /dev/null +++ b/src/platforms/dart/usage/advanced-usage.mdx @@ -0,0 +1,14 @@ +--- +title: Advanced Usage +sidebar_order: 2 +--- + +## Requirements + +- For the usage of the Dart SDK, the minimal required Dart SDK version is `2.8.0` and Flutter SDK version is `1.17.0` + +## Tips for catching errors + +- Use a `try/catch` block +- Use a `catchError` block for `Futures` +- Add an `ErrorListener` to your `Isolates` and call `Sentry.captureException` diff --git a/src/platforms/flutter/config.yml b/src/platforms/flutter/config.yml index 960e7644f9877..ae1eb343eb012 100644 --- a/src/platforms/flutter/config.yml +++ b/src/platforms/flutter/config.yml @@ -1,3 +1,9 @@ title: Flutter caseStyle: camelCase supportLevel: production +sdk: sentry.dart.flutter +fallbackPlatform: dart +categories: + - mobile + - browser + - server diff --git a/src/platforms/flutter/index.mdx b/src/platforms/flutter/index.mdx index b8d0d67af207e..5557707a0cf32 100644 --- a/src/platforms/flutter/index.mdx +++ b/src/platforms/flutter/index.mdx @@ -2,71 +2,33 @@ title: Flutter --- -Get the SDK from from [pub.dev](https://pub.dev/packages/sentry) by adding the following to your `pubspec.yaml`: + -```yml -dependencies: - sentry: ">=3.0.0 <4.0.0" -``` + -Import `SentryClient` and initialize it: +The Flutter SDK is a Prelease and is under improvements and testing, the latest stable version is the Dart SDK `v3.0.1` -```dart -import 'package:sentry/sentry.dart'; + -final sentry = SentryClient(dsn: "___PUBLIC_DSN___"); -``` +Get the SDK from [pub.dev](https://pub.dev/packages/sentry_flutter) by adding the following to your `pubspec.yaml`: -Run the whole app in a zone to capture all uncaught errors: + -```dart -import 'dart:async'; +Import `Sentry` and initialize it: -// Wrap your 'runApp(MyApp())' as follows: - -void main() async { - runZonedGuarded( - () => runApp(MyApp()), - (error, stackTrace) { - await sentry.captureException( - exception: error, - stackTrace: stackTrace, - ); - }, - ); -} -``` - -Catch Flutter specific errors by subscribing to `FlutterError.onError`: - -```dart -FlutterError.onError = (details, {bool forceReport = false}) { - sentry.captureException( - exception: details.exception, - stackTrace: details.stack, - ); -}; -``` + Capture a test exception: -```dart -// Throw an exception and capture it with the Sentry client: -try { - throw null; -} catch (error, stackTrace) { - await sentry.captureException( - exception: error, - stackTrace: stackTrace, - ); -} -``` + ### Resources -Flutter has extensive documentation, which includes a -[cookbook on how to integrate with Sentry](https://flutter.dev/docs/cookbook/maintenance/error-reporting). +The Flutter website has extensive documentation, including a +[cookbook on integrating with a Sentry version earlier than 4.0.0](https://flutter.dev/docs/cookbook/maintenance/error-reporting). ### Source code The Sentry Dart/Flutter SDK can be found on GitHub [`sentry-dart`](https://github.com/getsentry/sentry-dart/). + + diff --git a/src/platforms/flutter/usage/advanced-usage.mdx b/src/platforms/flutter/usage/advanced-usage.mdx new file mode 100644 index 0000000000000..4eb3f996b36a4 --- /dev/null +++ b/src/platforms/flutter/usage/advanced-usage.mdx @@ -0,0 +1,42 @@ +--- +title: Advanced Usage +sidebar_order: 2 +--- + +## Requirements + +For the usage of the Flutter SDK, the minimal required Dart SDK version is `2.8.0` and Flutter SDK version is `1.17.0` + +## Uploading Debug Symbols (Android and iOS) + +- [iOS dSYM files](/platforms/apple/dsym/) +- [Android NDK](/product/cli/dif/#uploading-files), You've to do it manually, Do not use the `uploadNativeSymbols` flag from the [Sentry Gradle Plugin](/platforms/android/proguard/), it's not supported yet. +- [Android Proguard/R8 mapping file](/platforms/android/proguard/) +- [Source maps for Flutter Web](/product/cli/releases/#managing-release-artifacts) + +## Known limitations + +- Flutter `split-debug-info` flag isn't supported yet, if this feature is enabled, Dart stack traces are not useful +- Flutter `obfuscate` flag isn't supported yet, if this feature is enabled, Dart stack traces are not useful + +## Tips for catching errors + +- Use a `try/catch` block +- Use a `catchError` block for `Futures` +- The SDK already runs your init `callback` on an error handler, e.g. using `runZonedGuarded`, are captured automatically +- Flutter-specific errors (such as layout failures), e.g. using `FlutterError.onError`, are captured automatically +- `Isolate` errors on the `current` Isolate which is the equivalent of a main/UI thread, e.g. using `Isolate.current.addErrorListener`, are captured automatically (Only for non-Web Apps). +- For your own `Isolates`, add an `ErrorListener` and call `Sentry.captureException` + +## Caveat + +Always prefer the `SentryFlutter.init(...)` instead of `Sentry.init(...)` as it adds the Flutter integrations on top of the Dart SDK. + +## Advanced Usage (Android and iOS) + +- [iOS Advanced Usage](/platforms/apple/usage/) +- [Android Advanced Usage](/platforms/android/usage/advanced-usage/) + +## Dart environment variables + +- You can configure the `SENTRY_DSN`, `SENTRY_RELEASE`, `SENTRY_DIST` and `SENTRY_ENVIRONMENT` via the Dart environment variables passing the `--dart-define` flag to the compiler. diff --git a/src/wizard/dart/index.md b/src/wizard/dart/index.md new file mode 100644 index 0000000000000..2c5cdc2cd27f7 --- /dev/null +++ b/src/wizard/dart/index.md @@ -0,0 +1,18 @@ +--- +name: Dart +doc_link: https://docs.sentry.io/platforms/dart/ +support_level: production +type: framework +--- + +Get the SDK from [pub.dev](https://pub.dev/packages/sentry) by adding the following to your `pubspec.yaml`: + + + +Import `Sentry` and initialize it: + + + +Capture a test exception: + + diff --git a/src/wizard/flutter/index.md b/src/wizard/flutter/index.md index 23c5bd43b8999..a031e6d144015 100644 --- a/src/wizard/flutter/index.md +++ b/src/wizard/flutter/index.md @@ -5,73 +5,14 @@ support_level: production type: framework --- -Get the SDK from from [pub.dev](https://pub.dev/packages/sentry) by adding the following to your `pubspec.yaml`: +Get the SDK from [pub.dev](https://pub.dev/packages/sentry_flutter) by adding the following to your `pubspec.yaml`: -```yml -dependencies: - sentry: ">=3.0.0 <4.0.0" -``` + -Import `SentryClient` and initialize it: +Import `Sentry` and initialize it: -```dart -import 'package:sentry/sentry.dart'; - -final sentry = SentryClient(dsn: "___PUBLIC_DSN___"); -``` - -Run the whole app in a zone to capture all uncaught errors: - -```dart -import 'dart:async'; - -// Wrap your 'runApp(MyApp())' as follows: - -void main() async { - runZonedGuarded( - () => runApp(MyApp()), - (error, stackTrace) { - await sentry.captureException( - exception: error, - stackTrace: stackTrace, - ); - }, - ); -} -``` - -Catch Flutter specific errors by subscribing to `FlutterError.onError`: - -```dart -FlutterError.onError = (details, {bool forceReport = false}) { - sentry.captureException( - exception: details.exception, - stackTrace: details.stack, - ); -}; -``` + Capture a test exception: -```dart -// Throw an exception and capture it with the Sentry client: -try { - throw null; -} catch (error, stackTrace) { - await sentry.captureException( - exception: error, - stackTrace: stackTrace, - ); -} -``` - -### Resources - -Flutter has extensive documentation, which includes a -[cookbook on how to integrate with Sentry](https://flutter.dev/docs/cookbook/maintenance/error-reporting). - -### Source code - -The Sentry SDK is part of the [Flutter organization on GitHub](https://github.com/flutter/sentry). -Sentry is working on improving the Flutter integration on top of the core Dart SDK -through [`sentry-flutter`](https://github.com/getsentry/sentry-flutter/). +