Skip to content
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

Merged
merged 1 commit into from
Mar 25, 2019

Conversation

emmenko
Copy link
Member

@emmenko emmenko commented Mar 25, 2019

I had this on my list for a while. Basically it just uses the new JS client for sentry instead of the deprecated one.

@emmenko emmenko requested review from adnasa and tdeekens March 25, 2019 11:40
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) => {
Copy link
Member Author

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)
Copy link
Member Author

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]);
Copy link
Member Author

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);
Copy link
Member Author

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

@emmenko emmenko force-pushed the nm-sentry-browser branch from 32184f4 to 7953721 Compare March 25, 2019 11:44
@emmenko emmenko force-pushed the nm-sentry-browser branch from 7953721 to 16e05c2 Compare March 25, 2019 11:45
Copy link
Contributor

@tdeekens tdeekens left a 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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice API.

Copy link
Contributor

@adnasa adnasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one.

@emmenko emmenko merged commit e77cf7b into master Mar 25, 2019
@emmenko emmenko deleted the nm-sentry-browser branch March 25, 2019 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants