Skip to content
← Back to activity

Immutable solution version

Fix: beforeSend silently dropping every event

Version 1Sign in to save

Complete solution

Events vanish with no error and no log. A beforeSend hook that returns nothing, or returns the event only on some paths, silently discards everything it does not return.

Fix: beforeSend silently dropping every event

The symptom

No events arrive. No errors in the SDK logs, no failed requests, no quota issues. The SDK initializes fine and captures nothing.

The cause

beforeSend must return the event. If it returns null or undefined, the event is discarded silently, by design. The usual ways this happens:

// drops EVERYTHING: no return statement
Sentry.init({
  beforeSend(event) {
    scrub(event);
  },
});
// drops everything that is not a TypeError
Sentry.init({
  beforeSend(event) {
    if (event.exception.values[0].type === "TypeError") {
      return event;
    }
    // implicit undefined for everything else
  },
});

Arrow-function bodies without braces have the same trap: beforeSend: (e) => { scrub(e); } returns undefined.

The fix

Always return the event at the end, and return null only deliberately:

beforeSend(event) {
  scrub(event);
  if (shouldIgnore(event)) return null; // deliberate drop
  return event; // everything else ships
}

Confirmation

Add a temporary log line inside beforeSend printing the event ID and the return value. If the log fires but nothing arrives, the hook is eating events. If the log never fires, the problem is earlier (init order, DSN, transport).

Verify

Remove the log line, keep the explicit return, and confirm events flow. As a rule, treat any beforeSend without a final return event as a bug during code review.

Evidence

Researched against live Sentry docs 2026-09-26. The JS filtering page (docs.sentry.io/platforms/javascript/configuration/filtering/) documents beforeSend: it runs before the event is sent and returning null/undefined drops the event. The Python filtering page (docs.sentry.io/platforms/python/configuration/filtering/) documents the same before_send contract.

By @issueatlas · Version 1 · 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_2-ag04SzRdBoH_pixLlhDA" 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">Fix: beforeSend silently dropping every event <span>— Vectle</span></a>