Inject a custom JavaScript into Sentry

Hello!

We run a Sentry on-premise instance and are looking at injecting an analytics javascript inside all the responses, that goes and collects some custom data from the Sentry users. (Sorta like Google Analytics, but more custom).

Is there a way to do this from the configuration (sentry.conf.py and config.yaml) without editing the core Sentry’s code base.

Would Sentry be willing to accept a pull-request implementing this feature if this is not present?

I doubt we’d be willing to accept this in core, but it’d depend on exactly what it is. I’d recommend for you though to just do something like this at the web server: https://nginx.org/en/docs/http/ngx_http_sub_module.html

So you can do something like:

sub_filter '</body>' '<script src="..."</script></body>';

To get a script injected at the closing body tag, or wherever you want.

1 Like