Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 56 additions & 55 deletions docs/platforms/javascript/common/configuration/filtering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,56 +20,15 @@ You can use the <PlatformIdentifier name="ignore-errors" /> option to filter out

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

See <PlatformLink to="/configuration/options/#ignoreErrors">ignoreErrors</PlatformLink> for details.

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

You can configure a <PlatformIdentifier name="before-send" /> callback method to filter error events. 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 and, based on custom logic and the data available on the event, you can either modify the event’s data or drop it completely by returning `null`.
You can configure a <PlatformIdentifier name="before-send" /> callback method to filter error events. 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 and, based on custom logic and the data available on the event, you can either modify the event’s data or drop it completely by returning `null`. This hook is called for both error and message events.

<PlatformContent includePath="configuration/before-send/" />

Note also that breadcrumbs can be filtered, as discussed in [our Breadcrumbs documentation](/product/error-monitoring/breadcrumbs/).

#### Event Hints

The <PlatformIdentifier name="before-send" /> callback is passed both the `event` and a second argument, `hint`, that holds one or more hints.

Typically, a `hint` holds the original exception so that additional data can be extracted or grouping is affected. In this example, the fingerprint is forced to a common value if an exception of a certain type has been caught:

<PlatformContent includePath="configuration/before-send-hint" />

When the SDK creates an event or breadcrumb for transmission, that transmission is typically created from some sort of source object. For instance, an error event is typically created from a log record or exception instance. For better customization, SDKs send these objects to certain callbacks (<PlatformIdentifier name="before-send" />, <PlatformIdentifier name="before-breadcrumb" /> or the event processor system in the SDK).

### Using Hints

Hints are available in two places:

1. <PlatformIdentifier name="before-send" /> / <PlatformIdentifier name="before-breadcrumb" />
2. `eventProcessors`

Event and breadcrumb `hints` are objects containing various information used to put together an event or a breadcrumb. Typically `hints` hold the original exception so that additional data can be extracted or grouping can be affected.

For events, hints contain properties such as `event_id`, `originalException`, `syntheticException` (used internally to generate cleaner stack trace), and any other arbitrary `data` that you attach.

For breadcrumbs, the use of `hints` is implementation dependent. For XHR requests, the hint contains the xhr object itself; for user interactions the hint contains the DOM element and event name and so forth.

<PlatformContent includePath="configuration/before-send-fingerprint">

In this example, the fingerprint is forced to a common value if an exception of a certain type has been caught:

</PlatformContent>

#### Hints for Events

`originalException`

The original exception that caused the Sentry SDK to create the event. This is useful for changing how the Sentry SDK groups events or to extract additional information.

`syntheticException`

When a string or a non-error object is raised, Sentry creates a synthetic exception so you can get a basic stack trace. This exception is stored here for further data extraction.

#### Hints for Breadcrumbs

<PlatformContent includePath="configuration/breadcrumb-hints" />
See <PlatformLink to="/configuration/options/#beforeSend">beforeSend</PlatformLink> for details, and [Using Hints](#using-hints) for details on the `hint` object.

### Using `allowUrls` and `denyUrls`

Expand All @@ -83,6 +42,9 @@ Sentry.init({

You can also use `denyUrls` if you want to block errors created on specific URLs from being sent to Sentry.

- See <PlatformLink to="/configuration/options/#allowUrls">allowUrls</PlatformLink> details
- See <PlatformLink to="/configuration/options/#denyUrls">denyUrls</PlatformLink> details

### Using `thirdPartyErrorFilterIntegration`

_Available in browser-based SDKs from version 8.10.0_
Expand Down Expand Up @@ -156,28 +118,67 @@ You can use the <PlatformIdentifier name="ignore-transactions" /> option to filt

<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.
See <PlatformLink to="/configuration/options/#ignoreTransactions">ignoreTransactions</PlatformLink> for details.

In its simplest form, used just for filtering the transaction, it looks like this:

<PlatformContent includePath="performance/traces-sampler-as-filter" />

It also allows you to sample different transactions at different rates.
### Using <PlatformIdentifier name="traces-sampler" />

If the transaction currently being processed has a parent transaction (from an upstream service calling this service), the parent (upstream) sampling decision will always be included in the sampling context data, so that your <PlatformIdentifier name="traces-sampler" /> can choose whether and when to inherit that decision. In most cases, inheritance is the right choice, to avoid breaking distributed traces. A broken trace will not include all your services. See <PlatformLink to="/configuration/sampling/#inheritance">Inheriting the parent sampling decision</PlatformLink> to learn more.
You can also use the <PlatformLink to="/configuration/options/#tracesSampler">tracesSampler</PlatformLink> option to prevent certain transactions from being reported to Sentry.

Learn more about <PlatformLink to="/configuration/sampling/">configuring the sample rate</PlatformLink>.
See <PlatformLink to="/configuration/sampling/#setting-a-sampling-function">Sampling</PlatformLink> on information about how to use it.

### Using `beforeSendTransaction`

<PlatformContent includePath="configuration/before-send-transaction" />

See <PlatformLink to="/configuration/options/#beforeSendTransaction">beforeSendTransaction</PlatformLink> for details, and [Using Hints](#using-hints) for details on the `hint` object.

## Filtering Spans

Use the <PlatformIdentifier name="before-send-span" /> configuration option which allows you to provide a function to modify a span.
This function is called for the root span and all child spans. If you want to drop the root span, including its child spans, use [`beforeSendTransaction`](#using-beforesendtransaction) instead.
Please note that you cannot use `beforeSendSpan` to drop a span, you can only modify it and filter data on it.

<PlatformContent includePath="configuration/before-send-span" />

See <PlatformLink to="/configuration/options/#beforeSendSpan">beforeSendSpan</PlatformLink> for details.

## Filtering Breadcrumbs

You can filter breadcrumbs by using the `beforeBreadcrumb` configuration option:

<PlatformContent includePath="enriching-events/breadcrumbs/before-breadcrumb" />

See <PlatformLink to="/configuration/options/#beforeBreadcrumb">beforeBreadcrumb</PlatformLink> for details.

## Using Hints

Hints are available in two places:

1. <PlatformIdentifier name="before-send" /> / <PlatformIdentifier name="before-breadcrumb" />
2. Event processors added via `Sentry.addEventProcessor()`

Event and breadcrumb `hints` are objects containing various types of information used to put together an event or a breadcrumb. Typically `hints` hold the original exception so that additional data can be extracted or grouping can be affected.

For events, hints contain properties such as `event_id`, `originalException`, `syntheticException` (used internally to generate cleaner stack trace), and any other arbitrary `data` that you attach.

For breadcrumbs, the use of `hints` is implementation dependent. For XHR requests, the hint contains the xhr object itself; for user interactions the hint contains the DOM element and event name and so forth.

<PlatformContent includePath="configuration/before-send-fingerprint">

In this example, the fingerprint is forced to a common value if an exception of a certain type has been caught:

</PlatformContent>

### Hints for Events

`originalException`

The original exception that caused the Sentry SDK to create the event. This is useful for changing how the Sentry SDK groups events or to extract additional information.

`syntheticException`

When a string or a non-error object is raised, Sentry creates a synthetic exception so you can get a basic stack trace. This exception is stored here for further data extraction.

### Hints for Breadcrumbs

<PlatformContent includePath="configuration/breadcrumb-hints" />
7 changes: 2 additions & 5 deletions docs/platforms/javascript/common/configuration/releases.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ After configuring your SDK, you can install a repository integration or manually

Monitor the [health of releases](/product/releases/health/) by observing user adoption, usage of the application, percentage of [crashes](/product/releases/health/#crash), and [session data](/product/releases/health/#session). Release health will provide insight into the impact of crashes and bugs as it relates to user experience, and reveal trends with each new issue through the [Release Details](/product/releases/release-details/) graphs and filters.

<Alert>

Crash reporting and app hang detection are not available for watchOS.

</Alert>
Comment on lines -67 to -71
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up task. Remove this for ruby, powershell, rust, etc. where it doesn't make any sense...


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

Expand All @@ -77,3 +72,5 @@ In order to monitor release health, the SDK sends session data.
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.

<PlatformContent includePath="configuration/auto-session-tracking" />

See <PlatformLink to="/apis/#sessions">Session APIs</PlatformLink> for more information on how to manually capturing sessions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
By default, the JavaScript Browser SDKs are sending sessions.
We create a session for every page load. For single-page applications, we will create a new session for every navigation change (History API).

To disable sending sessions, disable the `BrowserSession` integration:
To disable the default sessions handling, disable the `BrowserSession` integration:

```javascript
Sentry.init({
Expand All @@ -22,7 +22,7 @@ Sentry.init({

By default, the Node.js-based SDKs are sending sessions.
Sessions are created for every incoming request.
To disable sending sessions, set `trackIncomingRequestsAsSessions: false` in the `httpIntegration`:
To disable the default sessions handling, set `trackIncomingRequestsAsSessions: false` in the `httpIntegration`:

```javascript
import * as Sentry from "@sentry/node";
Expand Down

This file was deleted.

18 changes: 0 additions & 18 deletions platform-includes/configuration/before-send-hint/javascript.mdx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
```javascript
Sentry.init({
dsn: "___PUBLIC_DSN___",

// Called for all spans
beforeSendSpan(span) {
// Modify the span here
if (span.description === "should be renamed") {
span.description = "renamed span";
span.data = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
```javascript
Sentry.init({
dsn: "___PUBLIC_DSN___",

// Called for transaction events
beforeSendTransaction(event) {
// Modify or drop the event here
if (event.transaction === "/unimportant/route") {
// Don't send the event to Sentry
return null;
Expand Down
7 changes: 0 additions & 7 deletions platform-includes/configuration/before-send/javascript.mdx
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
In JavaScript, you can use a function to modify the event or return a completely new one.
You can either return `null` or an event payload - no other return value (including `void`) is allowed.
If you return `null`, the event will be discarded.


```javascript
Sentry.init({
dsn: "___PUBLIC_DSN___",

// Called for message and error events
beforeSend(event) {
// Modify or drop the event here
if (event.user) {
// Don't send user's email address
delete event.user.email;
Expand Down