(options: { dsn?: string; appVersion: string; sdkVersion?: string })
| 9 | const URL_REDACT = '[URL]'; |
| 10 | |
| 11 | export function initSentry(options: { dsn?: string; appVersion: string; sdkVersion?: string }) { |
| 12 | const dsn = options.dsn; |
| 13 | if (!dsn?.trim()) { |
| 14 | return; |
| 15 | } |
| 16 | |
| 17 | sentryEnabled = true; |
| 18 | |
| 19 | Sentry.init({ |
| 20 | dsn: dsn.trim(), |
| 21 | release: `${options.appVersion} (sdk: ${options.sdkVersion ?? 'unknown'})`, |
| 22 | includeServerName: false, |
| 23 | sendDefaultPii: false, |
| 24 | beforeSend(event) { |
| 25 | return scrubErrorEventForLocalPii(event); |
| 26 | }, |
| 27 | // Do not send console outputs to Sentry to avoid sending PII. |
| 28 | integrations: (defaults) => { |
| 29 | return defaults.filter((integration) => integration.name !== 'Console'); |
| 30 | }, |
| 31 | }); |
| 32 | } |
| 33 | |
| 34 | export function disableSentry() { |
| 35 | sentryEnabled = false; |
no test coverage detected