Skip to content

Commit

Permalink
fix global error fingerprint
Browse files Browse the repository at this point in the history
  • Loading branch information
alexayan committed Dec 13, 2018
1 parent 5974ae0 commit 5b67ebc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion browser/sentry-mina.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sentry-mina",
"description": "Sentry SDK for Mini-Program",
"version": "0.0.6",
"version": "0.0.7",
"main": "./dist/index.js",
"repository": "https://github.com/alexayan/sentry-mina.git",
"author": "alexayan",
Expand Down
2 changes: 1 addition & 1 deletion src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function supportLogManager() {
}

export function isWxUnhandledPromiseError(message) {
if (message && typeof message === 'string' && message.indexOf('Unhandled') >= -1) {
if (message && typeof message === 'string' && /^(Unhandled|Uncaught)/i.test(message)) {
return true;
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Breadcrumbs {
if (!('console' in global)) {
return;
}
let watchFunctions = ['debug', 'info', 'warn', 'error', 'log'];
let watchFunctions = ['info', 'warn', 'error', 'log'];
let filterFunctions = this.options.console ? watchFunctions : [];
if (isArray(this.options.console)) {
filterFunctions = this.options.console;
Expand Down Expand Up @@ -66,7 +66,7 @@ export class Breadcrumbs {
});
}

if (level === 'warn') {
if (level === 'warn' || level === 'error') {
if (isWxUnhandledPromiseError(args[0]) && isError(args[1])) {
captureException(args[1]);
}
Expand Down
19 changes: 10 additions & 9 deletions src/integrations/globalhandlers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCurrentHub, captureEvent, captureException } from '@sentry/core';
import { getCurrentHub, captureEvent, captureException, withScope } from '@sentry/core';
import { logger } from '@sentry/utils/logger';
import { eventFromStacktrace } from '../parsers';
import {
Expand Down Expand Up @@ -43,14 +43,15 @@ export class GlobalHandlers {

installGlobalErrorHandler() {
this.ctx.onError((msg) => {
const hint = {
level: 'error'
};
const fingerprint = globalErrorFingerprint(msg);
if (fingerprint) {
hint.fingerprint = fingerprint;
}
captureException(msg, hint);
withScope((scope) => {
const fingerprint = globalErrorFingerprint(msg);
if (fingerprint) {
scope.setFingerprint(fingerprint);
}
captureException(msg, {
level: 'error'
});
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const SDK_NAME = 'sentry.mina';
export const SDK_VERSION = '0.0.6';
export const SDK_VERSION = '0.0.7';

0 comments on commit 5b67ebc

Please sign in to comment.