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

fix: filter errors with OneKey in stack #6477

Merged
merged 2 commits into from
May 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/tracing/errors.test.ts
Original file line number Diff line number Diff line change
@@ -43,13 +43,20 @@ describe('filterKnownErrors', () => {
describe('OneKey', () => {
it('filter OneKey errors (macOS users)', () => {
const originalException = new Error()
originalException.name = 'xd.<anonymous>(/Applications/OneKey.app/Contents/Resources/static/preload.js)'
originalException.stack = `
SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse(<anonymous>)
at _d._handleAccountChange(/Applications/OneKey.app/Contents/Resources/static/preload.js:2:1634067)
`
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
it('filter OneKey errors (Windows users)', () => {
const originalException = new Error()
originalException.name =
'yd.<anonymous>(C:\\Users\\xyz\\AppData\\Local\\Programs\\OneKey\\resources\\static\\preload.js)'
originalException.stack = `
SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse(<anonymous>)
vd._handleAccountChange(C:\\Users\\example\\AppData\\Local\\Programs\\OneKey\\resources\\static\\preload.js:2:1626130
`
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
})
2 changes: 1 addition & 1 deletion src/tracing/errors.ts
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ export const filterKnownErrors: Required<ClientOptions>['beforeSend'] = (event:
* Errors coming from OneKey (a desktop wallet) can be ignored for now.
* These errors are either application-specific, or they will be thrown separately outside of OneKey.
*/
if (error.name.match(/OneKey/i)) return null
if (error.stack?.match(/OneKey/i)) return null

/*
* Content security policy 'unsafe-eval' errors can be filtered out because there are expected failures.