Skip to main content

[JavaScript] Why isn't denyUrls filtering app:// frames?

Issue

I added app://* or app:// to denyUrls, but events whose stack frames show app:// in Sentry are still sent.

Applies To

  • All SaaS Customers and Self-Hosted Users

  • JavaScript SDK and React Native SDK

  • Next.js SDK

  • denyUrls and RewriteFrames

  • Filtering

Resolution

denyUrls does not see app://. React Native and Next.js rewrite stack filenames to app:// after denyUrls runs. Match the original filename instead, or inspect frames in beforeSend.

denyUrls only checks the top stack frame's file URL. String entries are substring matches, not globs, so 'app://*' does not match app:///file.js.

If you are using denyUrls:

Put the original path in denyUrls, not the rewritten app:// prefix. For example, a Next.js chunk that appears as app:///_next/static/chunks/foo.js was originally a https://…/_next/static/chunks/foo.js URL:

Sentry.init({
  denyUrls: [/_next\/static\/chunks\/foo/],
});

On React Native, match the pre-rewrite path (for example a file:// path or a module path), not app:///index.android.bundle.

If you need to filter on rewritten app:// filenames:

Use beforeSend. Event processors, including RewriteFrames, run first, so beforeSend sees app:// filenames. Return null to drop the event.

Sentry.init({
  beforeSend(event) {
    const frames = event.exception?.values?.[0]?.stacktrace?.frames;
    if (!frames) {
      return event;
    }
    const top = frames[frames.length - 1];
    if (top?.filename && /unwanted-module/.test(top.filename)) {
      return null;
    }
    return event;
  },
});

Do not deny every app:// frame. RewriteFrames applies that prefix to your own app code.

If matching frames are not at the top of the stack, denyUrls will not drop the event. See How do I filter events based on the entire stack trace?.

Did this answer your question?