Skip to content

docs(js): Update "Scrubbing Data" guide for span streaming, logs and metrics#18013

Open
Lms24 wants to merge 2 commits into
masterfrom
lms/ref-js-scrubbing-data
Open

docs(js): Update "Scrubbing Data" guide for span streaming, logs and metrics#18013
Lms24 wants to merge 2 commits into
masterfrom
lms/ref-js-scrubbing-data

Conversation

@Lms24
Copy link
Copy Markdown
Member

@Lms24 Lms24 commented Jun 3, 2026

DESCRIBE YOUR PR

This PR updates the "Scrubbing Data" section in two regards:

  1. Adds beforeSendSpan as a hook to scrub span data and adds a note that for stream mode, beforeSendTransaction is no longer invoked
  2. Adds beforeSendMetric and beforeSendLog APIs which can be used to scrub metrics and logs respectively.

⚠️ #17834 must be merged first. The 404 lint job currently fails because of the missing links only introduced with this PR.

Note: I also decided to remove the PlatformIdentifier components since this page is already JS-specific. No need to worry about case-ing.

h/t @s1gr1d for flagging this page

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline: Mid June
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

LEGAL BOILERPLATE

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

EXTRA RESOURCES

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sentry-docs Ready Ready Preview, Comment Jun 3, 2026 9:59am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
develop-docs Ignored Ignored Preview Jun 3, 2026 9:59am

Request Review

Comment on lines +51 to +55
If you're using <PlatformLink to="/tracing/new-spans/">Span Stream Mode</PlatformLink>, `beforeSendTransaction` has no effect. Instead, use `beforeSendSpan` with the `withStreamedSpan` helper to modify streamed spans directly.

</Alert>

We recommend using these hooks in the SDKs to **scrub any data before it is sent**, to ensure that sensitive data never leaves the local environment.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The documentation contains a broken link to /tracing/new-spans/ and mentions an undocumented helper API withStreamedSpan.
Severity: LOW

Suggested Fix

Remove the <PlatformLink> to the non-existent page and the mention of the withStreamedSpan helper. Alternatively, create the corresponding documentation page and add the necessary details for the feature.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
docs/platforms/javascript/common/data-management/sensitive-data/index.mdx#L51-L55

Potential issue: The documentation file contains a `<PlatformLink>` that points to the
path `/tracing/new-spans/`. This link is broken and will result in a 404 error for
users, as the target page does not exist within the documentation repository. The same
section also refers to a helper API named `withStreamedSpan` and a feature called "Span
Stream Mode" without providing any documentation, examples, or cross-references, making
the guidance incomplete and unactionable for developers trying to use the feature.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

correct. The link and the API are only introduced in #17834. This PR won't be merged before that.

@Lms24 Lms24 self-assigned this Jun 3, 2026
Comment thread docs/platforms/javascript/common/data-management/sensitive-data/index.mdx Outdated
Copy link
Copy Markdown
Collaborator

@inventarSarah inventarSarah left a comment

Choose a reason for hiding this comment

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

Thank you 🙌!


<Alert>

If you're using <PlatformLink to="/tracing/new-spans/">Span Stream Mode</PlatformLink>, `beforeSendTransaction` has no effect. Instead, use `beforeSendSpan` with the `withStreamedSpan` helper to modify streamed spans directly.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
If you're using <PlatformLink to="/tracing/new-spans/">Span Stream Mode</PlatformLink>, `beforeSendTransaction` has no effect. Instead, use `beforeSendSpan` with the `withStreamedSpan` helper to modify streamed spans directly.
If you're using <PlatformLink to="/tracing/new-spans/">stream mode</PlatformLink>, `beforeSendTransaction` has no effect. Instead, use `beforeSendSpan` with the `withStreamedSpan` helper to modify streamed spans directly.

SDKs provide a <PlatformIdentifier name="before-send" /> hook, which is invoked before an error or message event is sent and can be used to modify event data to remove sensitive information. Some SDKs also provide a <PlatformIdentifier name="before-send-transaction" /> hook which does the same thing for transactions. We recommend using <PlatformIdentifier name="before-send" /> and <PlatformIdentifier name="before-send-transaction" /> in the SDKs to **scrub any data before it is sent**, to ensure that sensitive data never leaves the local environment.
SDKs provide various `beforeSend*` hooks, which are invoked before an errors, messages, spans, logs or metrics are sent and can be used to modify event data to remove sensitive information. The following hooks are available:

- `beforeSend` applies to error and message events
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it would be handy to link these to the respective documentation -- wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants