From e03df3761e081541fabfaf0ac6fa5bd5a82fb7e3 Mon Sep 17 00:00:00 2001 From: Inozemtsev Denis Date: Tue, 13 Aug 2024 14:59:12 +0700 Subject: [PATCH] feat(browser): Allow sentry in safari extension background page (#13209) Add `safari-web-extension:` to the list of allowed extension protocols. This chage should allow sentry/browser to work in safari browser extensions. --- packages/browser/src/sdk.ts | 2 +- packages/browser/test/sdk.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/browser/src/sdk.ts b/packages/browser/src/sdk.ts index 04aa82b5f0e6..1a0296341341 100644 --- a/packages/browser/src/sdk.ts +++ b/packages/browser/src/sdk.ts @@ -93,7 +93,7 @@ function shouldShowBrowserExtensionError(): boolean { const runtimeId = extensionObject && extensionObject.runtime && extensionObject.runtime.id; const href = (WINDOW.location && WINDOW.location.href) || ''; - const extensionProtocols = ['chrome-extension:', 'moz-extension:', 'ms-browser-extension:']; + const extensionProtocols = ['chrome-extension:', 'moz-extension:', 'ms-browser-extension:', 'safari-web-extension:']; // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage const isDedicatedExtensionPage = diff --git a/packages/browser/test/sdk.test.ts b/packages/browser/test/sdk.test.ts index 618333532a09..d638862aba9d 100644 --- a/packages/browser/test/sdk.test.ts +++ b/packages/browser/test/sdk.test.ts @@ -199,7 +199,7 @@ describe('init', () => { consoleErrorSpy.mockRestore(); }); - it.each(['chrome-extension', 'moz-extension', 'ms-browser-extension'])( + it.each(['chrome-extension', 'moz-extension', 'ms-browser-extension', 'safari-web-extension'])( "doesn't log a browser extension error if executed inside an extension running in a dedicated page (%s)", extensionProtocol => { const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});