Commit 29db61ff authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

fix: filter error caused by missing meta tags (#6546)

* fix: filter error caused by missing meta tags

* fix
parent 8431ad91
...@@ -187,4 +187,20 @@ describe('beforeSend', () => { ...@@ -187,4 +187,20 @@ describe('beforeSend', () => {
const originalException = new DOMException('The user aborted a request.', 'AbortError') const originalException = new DOMException('The user aborted a request.', 'AbortError')
expect(beforeSend(ERROR, { originalException })).toBeNull() expect(beforeSend(ERROR, { originalException })).toBeNull()
}) })
describe('meta tags', () => {
it('filters apple-mobile-web-app-title errors', () => {
const originalException = new TypeError(
"null is not an object (evaluating 'document.querySelector('meta[name=\"apple-mobile-web-app-title\"]').content')"
)
expect(beforeSend(ERROR, { originalException })).toBeNull()
})
it('filters og:site_name errors', () => {
const originalException = new TypeError(
"null is not an object (evaluating 'document.querySelector('meta[name=\"og:site_name\"]').content')"
)
expect(beforeSend(ERROR, { originalException })).toBeNull()
})
})
}) })
...@@ -113,6 +113,13 @@ function shouldRejectError(error: EventHint['originalException']) { ...@@ -113,6 +113,13 @@ function shouldRejectError(error: EventHint['originalException']) {
return true return true
} }
// Filters out errors caused by checking for meta tags that may not exist.
if (
error.message.match(/null is not an object \(evaluating 'document\.querySelector\('meta\[[^\]]+\]'\)\.content'\)/)
) {
return true
}
// These are caused by user navigation away from the page before a request has finished. // These are caused by user navigation away from the page before a request has finished.
if (error instanceof DOMException && error.name === 'AbortError') return true if (error instanceof DOMException && error.name === 'AbortError') return true
} }
......
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