Skip to content

Commit 70fb97d

Browse files
committed
Fix sentry filtering by adopting new format
1 parent f980d91 commit 70fb97d

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

.eslintrc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,7 @@
2727
"import/no-cycle": "warn",
2828
"react/prop-types": 0,
2929
"arrow-parens": 0,
30-
"prefer-destructuring": [
31-
"error",
32-
{
33-
"VariableDeclarator": {
34-
"array": false,
35-
"object": true
36-
},
37-
"AssignmentExpression": {
38-
"array": false,
39-
"object": false
40-
}
41-
}
42-
],
30+
"prefer-destructuring": 0,
4331
"no-async-promise-executor": "warn",
4432
"import/prefer-default-export": 0,
4533
"class-methods-use-this": 0,

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,22 @@ export async function initialize(dsn: string) {
3535
/.*\.csb\.app/,
3636
],
3737
beforeSend: (event, hint) => {
38-
if (event?.stacktrace?.frames && event.stacktrace.frames[0]) {
39-
const { filename } = event.stacktrace.frames[0];
38+
const filename =
39+
event?.exception?.values?.[0]?.stacktrace?.frames?.[0]?.filename;
4040

41+
let errorMessage =
42+
typeof hint.originalException === 'string'
43+
? hint.originalException
44+
: hint.originalException.message;
45+
46+
if (typeof errorMessage !== 'string') {
47+
errorMessage = '';
48+
}
49+
50+
if (filename) {
4151
if (
4252
filename.includes('typescript-worker') &&
43-
event.message &&
44-
event.message.includes('too much recursion')
53+
errorMessage.includes('too much recursion')
4554
) {
4655
// https://sentry.io/organizations/codesandbox/issues/1293123855/events/b01ee0feb7e3415a8bb81b6a9df19152/?project=155188&query=is%3Aunresolved&statsPeriod=14d
4756
return null;
@@ -69,17 +78,13 @@ export async function initialize(dsn: string) {
6978

7079
if (
7180
customError &&
72-
event.message &&
73-
event.message.startsWith('Non-Error exception captured')
81+
errorMessage.startsWith('Non-Error exception captured')
7482
) {
7583
// This is an error coming from the sandbox, return with no error.
7684
return null;
7785
}
7886

79-
if (
80-
event.message &&
81-
event.message.includes('Unexpected frame by generating stack.')
82-
) {
87+
if (errorMessage.includes('Unexpected frame by generating stack.')) {
8388
// A firefox error with error-polyfill, not critical. Referenced here: https://sentry.io/organizations/codesandbox/issues/1293236389/?project=155188&query=is%3Aunresolved
8489
return null;
8590
}

0 commit comments

Comments
 (0)