Skip to content

Commit

Permalink
add ignoreErrors and ignoreTransactions for Dart (#10989)
Browse files Browse the repository at this point in the history
* add ignoreErrors and ignoreTransactions for Dart

* improved misleading code samples for ignoreErrors and ignoreTransactions

* removed unnecessary backslash from codesamples
  • Loading branch information
martinhaintz committed Aug 13, 2024
1 parent f6d39b8 commit 30dc4cb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/platforms/dart/configuration/filtering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ We also offer [Inbound Filters](/concepts/data-management/filtering/) to filter

Configure your SDK to filter error events by using the <PlatformIdentifier name="before-send" /> callback method and configuring, enabling, or disabling integrations.

### Using <PlatformIdentifier name="ignore-errors" />

You can use the <PlatformIdentifier name="ignore-errors" /> option to filter out errors that match a certain pattern. This option receives a list of strings and regular expressions to match against the error message. When using strings, partial matches will be filtered out. If you need to filter by exact match, use regex patterns instead.

<PlatformContent includePath="configuration/ignore-errors" />

### Using <PlatformIdentifier name="before-send" />

All Sentry SDKs support the <PlatformIdentifier name="before-send" /> callback method. Because it's called immediately before the event is sent to the server, this is your last chance to decide not to send data or to edit it. <PlatformIdentifier name="before-send" /> receives the event object as a parameter, which you can use to either modify the event’s data or drop it completely by returning `null`, based on custom logic and the data available on the event.
Expand Down Expand Up @@ -69,6 +75,12 @@ When a string or a non-error object is raised, Sentry creates a synthetic except

To prevent certain transactions from being reported to Sentry, use the <PlatformIdentifier name="traces-sampler" /> or <PlatformIdentifier name="before-send-transaction" /> configuration option, which allows you to provide a function to evaluate the current transaction and drop it if it's not one you want.

### Using <PlatformIdentifier name="ignore-transactions" />

You can use the <PlatformIdentifier name="ignore-transactions" /> option to filter out transactions that match a certain pattern. This option receives a list of strings and regular expressions to match against the transaction name. When using strings, partial matches will be filtered out. If you need to filter by exact match, use regex patterns instead.

<PlatformContent includePath="configuration/ignore-transactions" />

### Using <PlatformIdentifier name="traces-sampler" />

**Note:** The <PlatformIdentifier name="traces-sampler" /> and <PlatformIdentifier name="traces-sample-rate" /> config options are mutually exclusive. If you define a <PlatformIdentifier name="traces-sampler" /> to filter out certain transactions, you must also handle the case of non-filtered transactions by returning the rate at which you'd like them sampled.
Expand Down
10 changes: 10 additions & 0 deletions platform-includes/configuration/ignore-errors/dart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```dart
await SentryFlutter.init(
(options) {
options.dsn = '___PUBLIC_DSN___';
options.ignoreErrors = ["my-error", "^error-.*\$"];
...
},
appRunner: () => runApp(MyApp()),
);
```
10 changes: 10 additions & 0 deletions platform-includes/configuration/ignore-transactions/dart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```dart
await SentryFlutter.init(
(options) {
options.dsn = '___PUBLIC_DSN___';
options.ignoreTransactions = ["my-transaction", "^transaction-.*\$" ];
...
},
appRunner: () => runApp(MyApp()),
);
```

0 comments on commit 30dc4cb

Please sign in to comment.