Commit 607d0d44 authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

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

* fix: filter errors with OneKey in stack

* check stack
parent ff0209a7
...@@ -43,13 +43,20 @@ describe('filterKnownErrors', () => { ...@@ -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: ...@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment