Skip to content

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

Merged
merged 8 commits into from
Nov 30, 2022

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Nov 19, 2022

This adds the new beforeSendTransaction option to the docs, both on the options page and alongside beforeSend in many places in the text. Because you can't selectively turn certain phrases on and off for different platforms, I tried to indicate where I could that it's not universally supported. (Right now, I believe JS is in fact the only platform to support it, though I expect that to change in the near future.) It also does a tiny bit of wordsmithing of the text around the additions, courtesy of @lizokm and @imatwawana.

Note that the one spot where updates haven't been done in this PR is the text of the Filtering page, as it's being worked on separately in #5804. Once the changes there are done, #5838 will add beforeSendTransaction.

@vercel
Copy link

vercel bot commented Nov 19, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
sentry-docs ✅ Ready (Inspect) Visit Preview Nov 22, 2022 at 6:10PM (UTC)

@lobsterkatie lobsterkatie force-pushed the kmclb-add-beforeSendTransaction-to-JS-options branch from b14744f to 40a7bed Compare November 22, 2022 17:54
@lobsterkatie lobsterkatie marked this pull request as ready for review November 22, 2022 17:55
Copy link
Contributor

@imatwawana imatwawana left a comment

Choose a reason for hiding this comment

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

I've made some overall wording tweaks and left a couple questions.

@@ -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/).
Copy link
Contributor

Choose a reason for hiding this comment

The 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
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/).
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. Learn more in [Filtering Events](/platform-redirect/?next=/configuration/filtering/).

Copy link
Member Author

Choose a reason for hiding this comment

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

I disagree. The fact that transactions don't go through beforeSend is a perennial source of confusion for users, which is fair given that a) it's not called beforeSendError, and b) we have a bad habit of using "event" to sometimes mean "error event" and sometimes mean "error or transaction event," a holdover from the days when there were no transaction events, so it's easy to mess up which things apply only to errors and which things apply to all events.

Also, this is 327 lines in, so if you got here by searching beforeSend, or a following a link, you easily might not realize what page you're on, especially since the lefthand sidebar doesn't automatically scroll to show the highlighted section. Check out the screenshot below, where there's only the faintest indication that what we're looking at is specific to error events:

image

So I think it can't hurt to be extra clear on this point.

@@ -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}
Copy link
Contributor

Choose a reason for hiding this comment

The 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
## 3. SDK Filtering: beforeSendTransaction {#1-sdk-filtering-beforesendtransaction}
## 3. SDK Filtering: beforeSendTransaction {#1-sdk-filtering-beforesendtransaction}

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

@imatwawana imatwawana removed the request for review from lizokm November 22, 2022 20:40
Copy link
Contributor

@lizokm lizokm left a comment

Choose a reason for hiding this comment

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

Woot! Looking good.

@lobsterkatie
Copy link
Member Author

lobsterkatie commented Nov 30, 2022

Thanks for the suggestions, @imatwawana and @lizokm! I took most of them, and @imatwawana, I tried to answer your questions above. In order to unblock folks working on beforeSendTransaction in other SDKs, I'm going to merge this, but if we need to come back to anything in a future PR, we totally can. (UPDATE: Which I'm already doing, because I didn't actually push the last set of changes based on your edits. 🤦🏻‍♀️)

P.S. Just for the record (since it came up again in this PR), in hopes of preventing us from going back and forth every time I use the phrase "Note that xxxx" (which I'll admit I perhaps do too frequently):

No disrespect intended, but you can't note-comma-that. It's just not grammatical. Either "note" is an interjection (akin to "look" or "see" in the phrases "look, here's the thing" or "see, that's the problem"), in which case it gets a comma, or it's a prepositional verb (akin to "look" or "see" in the phrases "look at the sky" or "see that you do"), in which case it doesn't. But if it's an interjection, you have to be able to get rid of it and still have a full sentence after you've done so. Removing "Note," from, "Note, that xyz is true" just leaves you with "that xyz is true," which clearly isn't a fully-formed sentence. So we can argue the stylistic merits of "Note, xyz is true" vs. "Note that xyz is true" (I gravitate towards the latter, but am open to switching to the former if you think it fits the overall docs style better), but the hybrid doesn't work.

(Other than that, though, I really do appreciate the help tightening up my prose. My brain thinks in many layers of parentheses, and I try to keep it out of my writing, but I know I don't always succeed. So keep 'em coming!)

@lobsterkatie lobsterkatie merged commit 8f422ac into master Nov 30, 2022
@lobsterkatie lobsterkatie deleted the kmclb-add-beforeSendTransaction-to-JS-options branch November 30, 2022 05:41
lobsterkatie added a commit that referenced this pull request Nov 30, 2022
When making fixes suggested by code reviewers, it helps to actually push them before merging the PR[1].

[1] #5814
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants