Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to access this file path in beforeSend event parameter? #5360

Unanswered
ffxsam asked this question in Q&A
Discussion options

How can I access this file path in the event parameter in beforeSend? My goal is to ignore all errors that have /node_modules/ in their path. denyUrls doesn't work, as URL is not the same as filename.

CleanShot 2022年07月04日 at 22 34 49

You must be logged in to vote

Replies: 1 comment 5 replies

Comment options

If you peek at the event JSON you can see the structure of the event and where that data is.
image

In this case, you might be able to get this value by accessing event.exception.values[0].stacktrace.frames. See https://develop.sentry.dev/sdk/event-payloads/types/ for more details.

One of the issue you might run into though is that if you are minifying your data, the file path may be unavailable (and only in sentry because of source maps).

You must be logged in to vote
5 replies
Comment options

Hey Abhi!

I did try logging that to Sentry to see what the value is:

event.exception.values[0].stacktrace.frames[0].filename

Looking at the event's raw JSON in the Sentry UI, I see this value should be ./node_modules/amazon-cognito-identity-js/es/Client.js. But in actuality, when I try to access this in my code, the value is https://myapp.com/js/chunk-vendors.01be0661.js.

In other words, in the beforeSend hook, stacktraces is actually raw_stacktraces, it seems. Let me know if any of this makes sense.

Comment options

Yes - totally makes sense, and that's the result you see in Sentry is after sourcemaps processing has been applied. https://myapp.com/js/chunk-vendors.01be0661.js is from the minified single file JS that is eventually mapped to ./node_modules/amazon-cognito-identity-js/es/Client.js by the source map.

If you're just looking to ignore the incoming errors - does Server Side inbound filters work for you? https://docs.sentry.io/product/data-management-settings/filtering/

You can try using https://docs.sentry.io/product/data-management-settings/scrubbing/advanced-datascrubbing/ to remove the stacktrace fields during ingestion - but otherwise I would recommend reaching out to Sentry support to get more help here.

Comment options

@AbhiPrasad My goal is to ignore all errors coming from third-party packages (filename contains /node_modules/).

Comment options

Ah yes - sorry for getting off track. It seems this will have to be done server-side, which we don't support at the moment. I can't see a way for us to do this on the client with the pre-sourcemapped errors.

I would reach out on https://github.com/getsentry/sentry/issues/new/choose and indicate this as a feature request!

Comment options

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /