Sentry-javascript: Include Fragment in Base URL

Created on 17 Nov 2018  路  5Comments  路  Source: getsentry/sentry-javascript

Package + Version

@sentry/browser 4.3.2

Version:

9.0.0

Description

Our application uses information after a # as part of unique URLs, so it is important this is included in the base url for errors logged. Is there a setting to turn this on?

Ex: mysite.com/#/display/12345

We need the entire above url to be the url of the error, as it represents the actual page the user was on.

Question

Most helpful comment

@pnewell in what place exactly? url tag in the Sentry UI, eg. here?

screenshot 2018-11-17 at 12 11 57

If so, there's no way in the SDK itself to set it automatically, but you can override both, request url and tag like so:

// preferably on every route change
Sentry.configureScope(scope => {
  scope.setTag('url', document.location.href)
});

And if you need to override request parameters as well

Sentry.init({
  dsn: '__YOUR_DSN__',
  beforeSend(event) {
    event.request = event.request || {};
    event.request.url = document.location.href;
    return event;
  }
});

All 5 comments

@pnewell in what place exactly? url tag in the Sentry UI, eg. here?

screenshot 2018-11-17 at 12 11 57

If so, there's no way in the SDK itself to set it automatically, but you can override both, request url and tag like so:

// preferably on every route change
Sentry.configureScope(scope => {
  scope.setTag('url', document.location.href)
});

And if you need to override request parameters as well

Sentry.init({
  dsn: '__YOUR_DSN__',
  beforeSend(event) {
    event.request = event.request || {};
    event.request.url = document.location.href;
    return event;
  }
});

Main question was answered. Feel free to reopen if still need any help. Cheers!

I tried the beforeSend code but my new Issues still only have the base url:

screen shot 2018-11-20 at 10 11 47 am

@pnewell can you provide a link to the event itself? (I will be able to see it as a Sentry employee, so full link is fine)

Closing due to inactivity

Was this page helpful?
0 / 5 - 0 ratings