Skip to content

Commit f671ceb

Browse files
committed
More sentry filtering and ignore error from vero
1 parent 70fb97d commit f671ceb

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

packages/common/src/utils/analytics/sentry.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export async function initialize(dsn: string) {
2424
/extensions\//i,
2525
/^chrome:\/\//i,
2626
],
27-
whitelistUrls: [/https?:\/\/((uploads|www)\.)?codesandbox\.io/],
27+
// whitelistUrls: [/https?:\/\/((uploads|www)\.)?codesandbox\.io/],
2828
/**
2929
* Don't send messages from the sandbox, so don't send from eg.
3030
* new.codesandbox.io or new.csb.app
@@ -35,13 +35,14 @@ export async function initialize(dsn: string) {
3535
/.*\.csb\.app/,
3636
],
3737
beforeSend: (event, hint) => {
38-
const filename =
39-
event?.exception?.values?.[0]?.stacktrace?.frames?.[0]?.filename;
38+
const exception = event?.exception?.values?.[0];
39+
const exceptionFrame = exception?.stacktrace?.frames?.[0];
40+
const filename = exceptionFrame?.filename;
4041

4142
let errorMessage =
4243
typeof hint.originalException === 'string'
4344
? hint.originalException
44-
: hint.originalException.message;
45+
: hint.originalException?.message || exception.value;
4546

4647
if (typeof errorMessage !== 'string') {
4748
errorMessage = '';
@@ -78,7 +79,8 @@ export async function initialize(dsn: string) {
7879

7980
if (
8081
customError &&
81-
errorMessage.startsWith('Non-Error exception captured')
82+
errorMessage.startsWith('Non-Error exception captured') &&
83+
exception.mechanism.handled
8284
) {
8385
// This is an error coming from the sandbox, return with no error.
8486
return null;

packages/common/src/utils/analytics/vero.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ function loadScript() {
3232
const script = document.createElement('script');
3333
script.async = true;
3434
script.onload = resolve;
35-
script.onerror = reject;
35+
script.onerror = () => {
36+
reject(new Error('Could not load script'));
37+
};
3638
script.src = '//d3qxef4rp70elm.cloudfront.net/m.js';
3739
document.body.appendChild(script);
38-
}).then(() => {
39-
processArray();
40-
});
40+
})
41+
.then(() => {
42+
processArray();
43+
})
44+
.catch(() => {
45+
/* ignore */
46+
});
4147
}
4248

4349
let _hasSetAnonymousUserId = false;

0 commit comments

Comments
 (0)