Skip to content

Commit 0b0cdb4

Browse files
mydeacoolguyzone
andauthored
feat(js): Update JS "Filtering" page (#13234)
--------- Co-authored-by: Alex Krawiec <[email protected]>
1 parent a70f7dd commit 0b0cdb4

File tree

8 files changed

+60
-109
lines changed

8 files changed

+60
-109
lines changed

docs/platforms/javascript/common/configuration/filtering.mdx

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -20,56 +20,15 @@ You can use the <PlatformIdentifier name="ignore-errors" /> option to filter out
2020

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

23+
See <PlatformLink to="/configuration/options/#ignoreErrors">ignoreErrors</PlatformLink> for details.
24+
2325
### Using <PlatformIdentifier name="before-send" />
2426

25-
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`.
27+
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.
2628

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

29-
Note also that breadcrumbs can be filtered, as discussed in [our Breadcrumbs documentation](/product/error-monitoring/breadcrumbs/).
30-
31-
#### Event Hints
32-
33-
The <PlatformIdentifier name="before-send" /> callback is passed both the `event` and a second argument, `hint`, that holds one or more hints.
34-
35-
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:
36-
37-
<PlatformContent includePath="configuration/before-send-hint" />
38-
39-
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).
40-
41-
### Using Hints
42-
43-
Hints are available in two places:
44-
45-
1. <PlatformIdentifier name="before-send" /> / <PlatformIdentifier name="before-breadcrumb" />
46-
2. `eventProcessors`
47-
48-
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.
49-
50-
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.
51-
52-
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.
53-
54-
<PlatformContent includePath="configuration/before-send-fingerprint">
55-
56-
In this example, the fingerprint is forced to a common value if an exception of a certain type has been caught:
57-
58-
</PlatformContent>
59-
60-
#### Hints for Events
61-
62-
`originalException`
63-
64-
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.
65-
66-
`syntheticException`
67-
68-
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.
69-
70-
#### Hints for Breadcrumbs
71-
72-
<PlatformContent includePath="configuration/breadcrumb-hints" />
31+
See <PlatformLink to="/configuration/options/#beforeSend">beforeSend</PlatformLink> for details, and [Using Hints](#using-hints) for details on the `hint` object.
7332

7433
### Using `allowUrls` and `denyUrls`
7534

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

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

45+
- See <PlatformLink to="/configuration/options/#allowUrls">allowUrls</PlatformLink> details
46+
- See <PlatformLink to="/configuration/options/#denyUrls">denyUrls</PlatformLink> details
47+
8648
### Using `thirdPartyErrorFilterIntegration`
8749

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

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

159-
### Using <PlatformIdentifier name="traces-sampler" />
160-
161-
**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.
121+
See <PlatformLink to="/configuration/options/#ignoreTransactions">ignoreTransactions</PlatformLink> for details.
162122

163-
In its simplest form, used just for filtering the transaction, it looks like this:
164-
165-
<PlatformContent includePath="performance/traces-sampler-as-filter" />
166-
167-
It also allows you to sample different transactions at different rates.
123+
### Using <PlatformIdentifier name="traces-sampler" />
168124

169-
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.
125+
You can also use the <PlatformLink to="/configuration/options/#tracesSampler">tracesSampler</PlatformLink> option to prevent certain transactions from being reported to Sentry.
170126

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

173129
### Using `beforeSendTransaction`
174130

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

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

179137
Use the <PlatformIdentifier name="before-send-span" /> configuration option which allows you to provide a function to modify a span.
180138
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.
181139
Please note that you cannot use `beforeSendSpan` to drop a span, you can only modify it and filter data on it.
182140

183141
<PlatformContent includePath="configuration/before-send-span" />
142+
143+
See <PlatformLink to="/configuration/options/#beforeSendSpan">beforeSendSpan</PlatformLink> for details.
144+
145+
## Filtering Breadcrumbs
146+
147+
You can filter breadcrumbs by using the `beforeBreadcrumb` configuration option:
148+
149+
<PlatformContent includePath="enriching-events/breadcrumbs/before-breadcrumb" />
150+
151+
See <PlatformLink to="/configuration/options/#beforeBreadcrumb">beforeBreadcrumb</PlatformLink> for details.
152+
153+
## Using Hints
154+
155+
Hints are available in two places:
156+
157+
1. <PlatformIdentifier name="before-send" /> / <PlatformIdentifier name="before-breadcrumb" />
158+
2. Event processors added via `Sentry.addEventProcessor()`
159+
160+
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.
161+
162+
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.
163+
164+
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.
165+
166+
<PlatformContent includePath="configuration/before-send-fingerprint">
167+
168+
In this example, the fingerprint is forced to a common value if an exception of a certain type has been caught:
169+
170+
</PlatformContent>
171+
172+
### Hints for Events
173+
174+
`originalException`
175+
176+
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.
177+
178+
`syntheticException`
179+
180+
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.
181+
182+
### Hints for Breadcrumbs
183+
184+
<PlatformContent includePath="configuration/breadcrumb-hints" />

docs/platforms/javascript/common/configuration/releases.mdx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ After configuring your SDK, you can install a repository integration or manually
6464

6565
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.
6666

67-
<Alert>
68-
69-
Crash reporting and app hang detection are not available for watchOS.
70-
71-
</Alert>
7267

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

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

7974
<PlatformContent includePath="configuration/auto-session-tracking" />
75+
76+
See <PlatformLink to="/apis/#sessions">Session APIs</PlatformLink> for more information on how to manually capturing sessions.

platform-includes/configuration/auto-session-tracking/javascript.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
By default, the JavaScript Browser SDKs are sending sessions.
44
We create a session for every page load. For single-page applications, we will create a new session for every navigation change (History API).
55

6-
To disable sending sessions, disable the `BrowserSession` integration:
6+
To disable the default sessions handling, disable the `BrowserSession` integration:
77

88
```javascript
99
Sentry.init({
@@ -22,7 +22,7 @@ Sentry.init({
2222

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

2727
```javascript
2828
import * as Sentry from "@sentry/node";

platform-includes/configuration/before-breadcrumb-hint/javascript.mdx

Lines changed: 0 additions & 16 deletions
This file was deleted.

platform-includes/configuration/before-send-hint/javascript.mdx

Lines changed: 0 additions & 18 deletions
This file was deleted.

platform-includes/configuration/before-send-span/javascript.mdx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
```javascript
22
Sentry.init({
33
dsn: "___PUBLIC_DSN___",
4-
5-
// Called for all spans
64
beforeSendSpan(span) {
7-
// Modify the span here
85
if (span.description === "should be renamed") {
96
span.description = "renamed span";
107
span.data = {

platform-includes/configuration/before-send-transaction/javascript.mdx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
```javascript
22
Sentry.init({
33
dsn: "___PUBLIC_DSN___",
4-
5-
// Called for transaction events
64
beforeSendTransaction(event) {
7-
// Modify or drop the event here
85
if (event.transaction === "/unimportant/route") {
96
// Don't send the event to Sentry
107
return null;

platform-includes/configuration/before-send/javascript.mdx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
In JavaScript, you can use a function to modify the event or return a completely new one.
2-
You can either return `null` or an event payload - no other return value (including `void`) is allowed.
3-
If you return `null`, the event will be discarded.
4-
51

62
```javascript
73
Sentry.init({
84
dsn: "___PUBLIC_DSN___",
9-
10-
// Called for message and error events
115
beforeSend(event) {
12-
// Modify or drop the event here
136
if (event.user) {
147
// Don't send user's email address
158
delete event.user.email;

0 commit comments

Comments
 (0)