Filtering by error's origin file location

Main problem:
I’d like to filter out errors that do not origin in files from our cdn.

Up until recently I had sentry setup using raven-js. Im in the process of migrating to sentry-javascript (v5).
Raven’s errors were sent with transaction tag that contained file address at our cdn (or no transaction tag at all, but lets not worry about those now).
Errors sent by sentry-javascript do not have transaction tag straight out of bag. So I added Transaction integration but the values are now something entirely different (follow pattern module/function).

The question:
How to achieve filtering by error’s origin file location? Is transaction tag even a good aproach?

My plan B is to revert to raven-js and that would be sad.

I hope this is a good place to ask this. I feel like I just need a push in the right direction.

I’ll be thankfull for any tips.

Ill reply to myself for future reference. (Most of this is based on mailing support provided by Megan Heskett from Sentry support team).

How I got rid of errors from outside of my codebase:

  1. whitelist only my cdn url,
  2. filter out no-url errors with beforeSend option.

More into details.

  1. Whitelist only my cdn url.

First I’ve learned there’s a link to JSON with event data on every issue page. There’s multitude of informations. What I was looking for was Exception’s stacktrace. To be precise last frame of that stacktrace. If that frame had abs_path that was the address that was used at the process of whitelisting.

So I went through dozens of errors to make sure I can actually whitelist only my cdn. I’ve made sure that all types od errors that might originate on my website have abs_path set on last frame and that path is an url from my cdn.

I added changes to my code, shipped change to production and observed.

Sadly that wasn’t perfect solution. I’ve realised some errors don’t have proper abs_path set, sometimes there is no stacktracke, or even exception. I checked source code and found out, that whitelisting works only on errors/events with url that can be matched against whitelist. If not it goes to sentry ‘just in case’ (I pressume).

That takes us to the second part.

  1. filter out no-url errors with beforeSend option.

I’ve realised that I don’t really want to deal with broken errors without stacktaces that seems to originate in ads providers scripts, browser addons and so on. So I’ve added custom function that checks if event has stacktrace, and if that stacktrace has any value at last frame. Only gotcha here is that events dont have abs_path at this point so we should look for filename instead.

With that in place I’ve got rid of unwanted erros. It’s still work in progress so I might see some new errors that I don’t really want to deal with, but for now it seems to do a good job at keeping my Sentry clean of noise.

Additional info.

At some point I’ve added error generating tool just to be able to quickly check if every error type I can think of gets to Sentry.
I’ve also switch to development enviroment while on localhost just to get nice and easy access to errors I’ve caused.