getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.97k stars 1.57k forks source link

Error events has error property of null #14155

Open reinaldoignatius opened 23 hours ago

reinaldoignatius commented 23 hours ago

Environment

SaaS (https://sentry.io/)

What are you trying to accomplish?

I have an SDK that captures error events into sentry by using the script below. window.addEventListener('error', (event) => { client.captureException(event); });

How are you getting stuck?

This works while testing locally, but when I access my SDK via script tag in an external application, the error property in the event is null and the error message becomes "Script Error." Tried the solution in this page https://sentry.io/answers/script-error/ but it still results in "Script Error." I've made sure my SDK has access-control-allow-origin: * header. And the script tag that loads the SDK has crossorigin='anonymous'

Where in the product are you?

Other

Link

No response

DSN

No response

Version

No response

getsantry[bot] commented 23 hours ago

Assigning to @getsentry/support for routing ⏲️

AbhiPrasad commented 9 hours ago

I have an SDK that captures error events into sentry by using the script below.

I would advise against this. We recommend explicitly capturing the errors caused by your SDK and not recording all application errors via window.addEventListener. This could interfere with your the site you are running on in weird ways (like if they are also running Sentry or another error monitoring service).

Instead I recommend following these docs (and explicitly capturing the errors that you think about): https://docs.sentry.io/platforms/javascript/best-practices/shared-environments/