-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(flutter): Use sentry flutter init in samples (#11858)
- Loading branch information
Showing
42 changed files
with
351 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,5 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Future<void> main() async { | ||
await Sentry.init( | ||
(options) { | ||
options.dsn = '___PUBLIC_DSN___'; | ||
options.allowUrls = ["^https://sentry.com.*\$", "my-custom-domain"]; | ||
}, | ||
appRunner: initApp, // Init your App. | ||
); | ||
} | ||
```dart {2} | ||
await Sentry.init((options) { | ||
options.allowUrls = ["^https://sentry.com.*\$", "my-custom-domain"]; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
```dart {2} | ||
await SentryFlutter.init((options) { | ||
options.allowUrls = ["^https://sentry.com.*\$", "my-custom-domain"]; | ||
}); | ||
``` |
16 changes: 6 additions & 10 deletions
16
platform-includes/configuration/before-breadcrumb-hint/dart.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Breadcrumb? beforeBreadcrumb(Breadcrumb? breadcrumb, Hint hint) { | ||
return hint is MyHint ? null : crumb; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeBreadcrumb = beforeBreadcrumb); | ||
} | ||
```dart {3} | ||
await Sentry.init((options) { | ||
options.beforeBreadcrumb = (breadcrumb, hint) { | ||
return hint is MyHint ? null : crumb; | ||
}; | ||
}); | ||
``` |
7 changes: 7 additions & 0 deletions
7
platform-includes/configuration/before-breadcrumb-hint/flutter.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```dart {3} | ||
await SentryFlutter.init((options) { | ||
options.beforeBreadcrumb = (breadcrumb, hint) { | ||
return hint is MyHint ? null : crumb; | ||
}; | ||
}); | ||
``` |
22 changes: 9 additions & 13 deletions
22
platform-includes/configuration/before-send-fingerprint/dart.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
FutureOr<SentryEvent?> beforeSend(SentryEvent event, Hint hint) async { | ||
if (event.throwable is DatabaseException) { | ||
event = event.copyWith(fingerprint: ['database-connection-error']); | ||
} | ||
return event; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeSend = beforeSend); | ||
} | ||
```dart {3-6} | ||
await Sentry.init((options) { | ||
options.beforeSend = (event, hint) { | ||
if (event.throwable is DatabaseException) { | ||
event = event.copyWith(fingerprint: ['database-connection-error']); | ||
} | ||
return event; | ||
}; | ||
}); | ||
``` |
10 changes: 10 additions & 0 deletions
10
platform-includes/configuration/before-send-fingerprint/flutter.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
```dart {3-6} | ||
await SentryFlutter.init((options) { | ||
options.beforeSend = (event, hint) { | ||
if (event.throwable is DatabaseException) { | ||
event = event.copyWith(fingerprint: ['database-connection-error']); | ||
} | ||
return event; | ||
}; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
FutureOr<SentryEvent?> beforeSend(SentryEvent event, Hint hint) async { | ||
return hint is MyHint ? null : event; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeSend = beforeSend); | ||
} | ||
```dart {3} | ||
await Sentry.init((options) { | ||
options.beforeSend = (event, hint) { | ||
return hint is MyHint ? null : event; | ||
}; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```dart {3} | ||
await SentryFlutter.init((options) { | ||
options.beforeSend = (event, hint) { | ||
return hint is MyHint ? null : event; | ||
}; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
FutureOr<SentryEvent?> beforeSend(SentryEvent event, Hint hint) async { | ||
// Modify the event here: | ||
event = event.copyWith(serverName: null); // Don't send server names. | ||
return event; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeSend = beforeSend); | ||
} | ||
```dart {3} | ||
await Sentry.init((options) { | ||
options.beforeSend = (event, hint) { | ||
return event.copyWith(serverName: null); // Don't send server names. | ||
}; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```dart {3} | ||
await SentryFlutter.init((options) { | ||
options.beforeSend = (event, hint) { | ||
return event.copyWith(serverName: null); // Don't send server names. | ||
}; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,5 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Future<void> main() async { | ||
await Sentry.init( | ||
(options) { | ||
options.dsn = '___PUBLIC_DSN___'; | ||
options.denyUrls = ["^.*ends-with-this\$", "denied-url"]; | ||
}, | ||
appRunner: initApp, // Init your App. | ||
); | ||
} | ||
```dart {2} | ||
await Sentry.init((options) { | ||
options.denyUrls = ["^.*ends-with-this\$", "denied-url"]; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
```dart {2} | ||
await SentryFlutter.init((options) { | ||
options.denyUrls = ["^.*ends-with-this\$", "denied-url"]; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
```dart | ||
await SentryFlutter.init( | ||
(options) { | ||
options.dsn = '___PUBLIC_DSN___'; | ||
options.ignoreErrors = ["my-error", "^error-.*\$"]; | ||
... | ||
}, | ||
appRunner: () => runApp(MyApp()), | ||
); | ||
```dart {2} | ||
await Sentry.init((options) { | ||
options.ignoreErrors = ["my-error", "^error-.*\$"]; | ||
}); | ||
``` |
13 changes: 4 additions & 9 deletions
13
platform-includes/configuration/ignore-transactions/dart.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
```dart | ||
await SentryFlutter.init( | ||
(options) { | ||
options.dsn = '___PUBLIC_DSN___'; | ||
options.ignoreTransactions = ["my-transaction", "^transaction-.*\$" ]; | ||
... | ||
}, | ||
appRunner: () => runApp(MyApp()), | ||
); | ||
```dart {2} | ||
await Sentry.init((options) { | ||
options.ignoreTransactions = ["my-transaction", "^transaction-.*\$" ]; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Future<void> main() async { | ||
```dart {3} | ||
await Sentry.init((options) { | ||
// Capture only 25% of events | ||
await Sentry.init((options) => options.sampleRate = 0.25); | ||
} | ||
options.sampleRate = 0.25; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
```dart {3} | ||
await SentryFlutter.init((options) { | ||
// Capture only 25% of events | ||
options.sampleRate = 0.25; | ||
}); | ||
``` |
17 changes: 4 additions & 13 deletions
17
platform-includes/enriching-events/attach-viewhierarchy/flutter.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,5 @@ | ||
```dart | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
Future<void> main() async { | ||
await SentryFlutter.init( | ||
(options) { | ||
options.dsn = '___PUBLIC_DSN___'; | ||
options.attachViewHierarchy = true; | ||
}, | ||
appRunner: () => runApp(MyApp()), | ||
); | ||
} | ||
```dart {2} | ||
await SentryFlutter.init((options) { | ||
options.attachViewHierarchy = true; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 6 additions & 10 deletions
16
platform-includes/enriching-events/breadcrumbs/before-breadcrumb/dart.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Breadcrumb? beforeBreadcrumb(Breadcrumb? breadcrumb, Hint hint) { | ||
return 'a.spammy.Logger' == breadcrumb.category ? null : breadcrumb; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeBreadcrumb = beforeBreadcrumb); | ||
} | ||
```dart {3} | ||
await Sentry.init((options) { | ||
options.beforeBreadcrumb = (breadcrumb, hint) { | ||
return 'a.spammy.Logger' == breadcrumb.category ? null : breadcrumb; | ||
}; | ||
}); | ||
``` |
7 changes: 7 additions & 0 deletions
7
platform-includes/enriching-events/breadcrumbs/before-breadcrumb/flutter.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```dart {3} | ||
await SentryFlutter.init((options) { | ||
options.beforeBreadcrumb = (breadcrumb, hint) { | ||
return 'a.spammy.Logger' == breadcrumb.category ? null : breadcrumb; | ||
}; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 10 additions & 18 deletions
28
platform-includes/performance/configure-sample-rate/flutter.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
```dart {diff} | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
SentryFlutter.init((options) { | ||
+ // To set a uniform sample rate | ||
+ options.tracesSampleRate = 1.0; | ||
SentryFlutter.init( | ||
(options) => { | ||
options.dsn = '___PUBLIC_DSN___'; | ||
+ // To set a uniform sample rate | ||
+ options.tracesSampleRate = 1.0; | ||
+ // OR if you prefer, determine traces sample rate | ||
+ // based on the sampling context | ||
+ options.tracesSampler = (samplingContext) { | ||
+ // return a number between 0 and 1 or null (to fallback | ||
+ // to configured value) | ||
+ }; | ||
}, | ||
appRunner: () => runApp(MyApp()), | ||
); | ||
+ // OR if you prefer, determine traces sample rate | ||
+ // based on the sampling context | ||
+ options.tracesSampler = (samplingContext) { | ||
+ // return a number between 0 and 1 or null (to fallback | ||
+ // to configured value) | ||
+ }; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Sentry.init((options) => { | ||
options.tracesSampleRate = 0.2, | ||
}); | ||
```dart {2} | ||
await Sentry.init((options) { | ||
options.tracesSampleRate = 0.2; | ||
}); | ||
``` |
14 changes: 4 additions & 10 deletions
14
platform-includes/performance/traces-sample-rate/flutter.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
```dart | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
SentryFlutter.init( | ||
(options) => { | ||
options.tracesSampleRate = 0.2; | ||
}, | ||
appRunner: () => runApp(MyApp()), | ||
); | ||
```dart {2} | ||
await SentryFlutter.init((options) => { | ||
options.tracesSampleRate = 0.2; | ||
}); | ||
``` |
Oops, something went wrong.