-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(js): Add beforeSendTransaction
option
#5814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fb6e838
e2838cf
db25742
00965a1
f04e5f3
88d2a2f
59105de
40a7bed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -324,7 +324,7 @@ The SDK sample rate is not dynamic; changing it requires re-deployment. Also, ke | |||||
|
||||||
## 7. SDK Filtering: beforeSend {#1-sdk-filtering-beforesend} | ||||||
|
||||||
All Sentry SDKs support the `beforeSend` callback method. Once implemented, the method is invoked when the SDK captures an event, right before sending it to your Sentry account. It receives the event object as a parameter, so you can use that to modify the event's data or drop it completely (by returning `null`) based on your custom logic and the data available on the event, like _tags_, _environment_, _release version_, _error attributes_, and so on. Learn more in [Filtering Events](/platform-redirect/?next=/configuration/filtering/). | ||||||
All Sentry SDKs support the `beforeSend` callback method. Once implemented, the method is invoked when the SDK captures an error event, right before sending it to your Sentry account. It receives the event object as a parameter, so you can use that to modify the event's data or drop it completely (by returning `null`) based on your custom logic and the data available on the event, like _tags_, _environment_, _release version_, _error attributes_, and so on. Note that only error and message events pass through `beforeSend`. Tansaction events have a separate method, `beforeSendTransaction`, though it is not yet supported in all SDKs. Learn more about both methods in [Filtering Events](/platform-redirect/?next=/configuration/filtering/). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need the two sentences starting at "Note" because this is already a page devoted to error events. It's a given that things on this page may not apply to transactions. That kind of caveat only needs to exist on the parent page.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree. The fact that transactions don't go through Also, this is 327 lines in, so if you got here by searching So I think it can't hurt to be extra clear on this point. |
||||||
|
||||||
## 8. SDK Configuration {#2-sdk-configuration} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -138,6 +138,10 @@ If you have a rogue client, Sentry supports blocking an IP from sending data. Na | |||||
|
||||||
If you discover a problematic release causing excessive noise, Sentry supports ignoring all events and attachments from that release. Navigate to **[Project] > Settings > Inbound Filters**, then add the release to the "Releases" field. | ||||||
|
||||||
## 3. SDK Configuration: Tracing Options {#2-sdk-configuration-tracing-options} | ||||||
## 3. SDK Filtering: beforeSendTransaction {#1-sdk-filtering-beforesendtransaction} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this heading alias from an ancient version of this doc?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have to assume so? IDK, I just went with it, because fixing it really should be a separate PR if we're going to do it. |
||||||
|
||||||
Some Sentry SDKs support the `beforeSendTransaction` callback method. Once implemented, the method is invoked when the SDK captures a transaction event, right before sending it to your Sentry account. It receives the transaction event object as a parameter, so you can use that to modify the event's data or drop it completely (by returning `null`) based on your custom logic and the data available on the event, like _tags_, _environment_, _release version_, _transaction name_, and so on. Note that only transaction events pass through `beforeSendTransaction`. Error and message events have a separate method, `beforeSend`, which is supported in all SDKs. Learn more about both methods in [Filtering Events](/platform-redirect/?next=/configuration/filtering/). | ||||||
lobsterkatie marked this conversation as resolved.
Show resolved
Hide resolved
lobsterkatie marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
## 4. SDK Configuration: Tracing Options {#2-sdk-configuration-tracing-options} | ||||||
|
||||||
When you configure your the SDK, you can control the number of transactions that are sent to Sentry by setting the [tracing options](/platform-redirect/?next=/configuration/options/%23tracing-options), including either setting a sample rate or providing a function for sampling. You can also set up [custom instrumentation](/platform-redirect/?next=/performance/instrumentation/custom-instrumentation/) for performance monitoring to capture certain types of transactions. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
```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; | ||
} | ||
return event; | ||
}, | ||
}); | ||
``` |
Uh oh!
There was an error while loading. Please reload this page.