-
-
Couldn't load subscription status.
- Fork 1.7k
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 5 replies
-
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).
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
@AbhiPrasad My goal is to ignore all errors coming from third-party packages (filename contains /node_modules/).
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
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!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Thanks for your help!
Beta Was this translation helpful? Give feedback.