Solution skill
Sentry beforeSend: scrub PII without silently dropping everything
Complete solution
Shows how to fix sentry beforeSend: scrub PII without silently dropping everything. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
js Sentry.init({ dsn: "\_\_\_PUBLIC\_DSN\_\_\_", beforeSend(event) { if (event.user) { delete event.user.email; // keep the id, drop the address } return event; // ALWAYS return the event, or return null to drop deliberately }, }); The classic bug: a beforeSend that mutates the event but forgets to return it.
Steps
- ```js
Sentry.init({ dsn: "__PUBLICDSN___", beforeSend(event) { if (event.user) { delete event.user.email; // keep the id, drop the address } return event; // ALWAYS return the event, or return null to drop deliberately }, });
2. The classic bug: a `beforeSend` that mutates the event but forgets to return it. In JS that returns `undefined`, which the SDK treats as drop. Events vanish with no error. If volume craters after adding `beforeSend`, read the function first.
3. `sendDefaultPii` is replaced by `dataCollection`, with per-category switches:
```js
dataCollection: {
userInfo: false,
cookies: false,
httpBodies: [],
urlQueryParams: { deny: ["forwarded", "-ip"] },
}- Warning from the migration guide: the v11 default collects MORE than v10 did (user info, cookies, request/response bodies, genAI inputs/outputs). If you relied on the v10 restrictive default, set the baseline explicitly or you start shipping data you never approved.
When to use
You are seeing this: In JS that returns undefined, which the SDK treats as drop. Use this skill when you run into "Sentry beforeSend: scrub PII without silently dropping everything".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Researched against live Sentry docs 2026-09-26. The JS filtering page (docs.sentry.io/platforms/javascript/configuration/filtering/) documents beforeSend receiving the event and dropping it by returning null, the ignoreErrors/allowUrls/denyUrls options, and the thirdPartyErrorFilterIntegration (needs bundler applicationKey). The v10-to-v11 migration guide (docs.sentry.io/platforms/javascript/migration/v10-to-v11/) documents sendDefaultPii replaced by dataCollection with per-category defaults (v11 default collects more: userInfo, cookies, httpBodies, genAI inputs/outputs now on) and the built-in scrub that sends [Filtered] for values whose keys look like auth, token, secret, or password. The Python filtering page (docs.sentry.io/platforms/python/configuration/filtering/) covers before_send and the hint object.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_XIH54XXSl_LW90lBmQ8V7Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Sentry beforeSend: scrub PII without silently dropping everything <span>— Vectle</span></a>