fix: filter errors with OneKey in stack (#6477)

* fix: filter errors with OneKey in stack

* check stack
This commit is contained in:
Vignesh Mohankumar 2023-05-01 15:32:05 -04:00 committed by GitHub
parent ff0209a78f
commit 607d0d443e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

@ -43,13 +43,20 @@ describe('filterKnownErrors', () => {
describe('OneKey', () => { describe('OneKey', () => {
it('filter OneKey errors (macOS users)', () => { it('filter OneKey errors (macOS users)', () => {
const originalException = new Error() 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() expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
}) })
it('filter OneKey errors (Windows users)', () => { it('filter OneKey errors (Windows users)', () => {
const originalException = new Error() const originalException = new Error()
originalException.name = originalException.stack = `
'yd.<anonymous>(C:\\Users\\xyz\\AppData\\Local\\Programs\\OneKey\\resources\\static\\preload.js)' 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() expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
}) })
}) })

@ -89,7 +89,7 @@ export const filterKnownErrors: Required<ClientOptions>['beforeSend'] = (event:
* Errors coming from OneKey (a desktop wallet) can be ignored for now. * 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. * 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. * Content security policy 'unsafe-eval' errors can be filtered out because there are expected failures.