-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(sentry): to use newest sdk over deprecated raven client #476
Conversation
if (error instanceof Error === false && environment === 'development') { | ||
debugLogger.warn( | ||
'[SENTRY]: You called "sentry.reportError" with an argument that is not an instance of "Error". ' + | ||
export const reportErrorToSentry = (error, extraInfo, getIsEnabled) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need the factory function anymore as we test things a bit differently now (using the sentry-testkit).
export const reportErrorToSentry = (error, extraInfo, getIsEnabled) => { | ||
const environment = window.app.env || process.env.NODE_ENV; | ||
const isEnabled = getIsEnabled | ||
? getIsEnabled(environment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used in tests
if (typeof extraInfo.extra === 'object') { | ||
// See https://docs.sentry.io/platforms/javascript/react/ | ||
Object.keys(extraInfo.extra).forEach(key => { | ||
scope.setExtra(key, extraInfo.extra[key]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra info needs to be passed using the setExtra
function, as key-values, which is why we need to iterate through the properties.
scope.setExtra(key, extraInfo.extra[key]); | ||
}); | ||
} else { | ||
scope.setExtra('extra', extraInfo.extra); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case the extra
info is not an object, we pass it as a value under the key extra
32184f4
to
7953721
Compare
7953721
to
16e05c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Looks very cool to me. Thanks for improving this!
}).install(); | ||
}); | ||
Sentry.configureScope(scope => { | ||
scope.setTag('role', 'frontend'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one.
I had this on my list for a while. Basically it just uses the new JS client for sentry instead of the deprecated one.