@sentry/browser 9.21.0 → 9.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,37 +68,6 @@ function dropTopLevelUndefinedKeys(obj) {
68
68
  return mutatetedObj;
69
69
  }
70
70
 
71
- function shouldShowBrowserExtensionError() {
72
- const windowWithMaybeExtension =
73
- typeof helpers.WINDOW.window !== 'undefined' && (helpers.WINDOW );
74
- if (!windowWithMaybeExtension) {
75
- // No need to show the error if we're not in a browser window environment (e.g. service workers)
76
- return false;
77
- }
78
-
79
- const extensionKey = windowWithMaybeExtension.chrome ? 'chrome' : 'browser';
80
- const extensionObject = windowWithMaybeExtension[extensionKey];
81
-
82
- const runtimeId = extensionObject?.runtime?.id;
83
- const href = core.getLocationHref() || '';
84
-
85
- const extensionProtocols = ['chrome-extension:', 'moz-extension:', 'ms-browser-extension:', 'safari-web-extension:'];
86
-
87
- // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage
88
- const isDedicatedExtensionPage =
89
- !!runtimeId && helpers.WINDOW === helpers.WINDOW.top && extensionProtocols.some(protocol => href.startsWith(`${protocol}//`));
90
-
91
- // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine
92
- // see: https://github.com/getsentry/sentry-javascript/issues/12668
93
- const isNWjs = typeof windowWithMaybeExtension.nw !== 'undefined';
94
-
95
- return !!runtimeId && !isDedicatedExtensionPage && !isNWjs;
96
- }
97
-
98
- /**
99
- * A magic string that build tooling can leverage in order to inject a release value into the SDK.
100
- */
101
-
102
71
  /**
103
72
  * The Sentry Browser SDK Client.
104
73
  *
@@ -146,25 +115,11 @@ function shouldShowBrowserExtensionError() {
146
115
  * @see {@link BrowserOptions} for documentation on configuration options.
147
116
  */
148
117
  function init(browserOptions = {}) {
149
- const options = applyDefaultOptions(browserOptions);
150
-
151
- if (!options.skipBrowserExtensionCheck && shouldShowBrowserExtensionError()) {
152
- if (debugBuild.DEBUG_BUILD) {
153
- core.consoleSandbox(() => {
154
- // eslint-disable-next-line no-console
155
- console.error(
156
- '[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
157
- );
158
- });
159
- }
118
+ if (!browserOptions.skipBrowserExtensionCheck && _checkForBrowserExtension()) {
160
119
  return;
161
120
  }
162
121
 
163
- if (debugBuild.DEBUG_BUILD && !core.supportsFetch()) {
164
- core.logger.warn(
165
- 'No Fetch API detected. The Sentry SDK requires a Fetch API compatible environment to send events. Please add a Fetch API polyfill.',
166
- );
167
- }
122
+ const options = applyDefaultOptions(browserOptions);
168
123
  const clientOptions = {
169
124
  ...options,
170
125
  stackParser: core.stackParserFromStackParserOptions(options.stackParser || stackParsers.defaultStackParser),
@@ -191,6 +146,51 @@ function onLoad(callback) {
191
146
  callback();
192
147
  }
193
148
 
149
+ function _isEmbeddedBrowserExtension() {
150
+ if (typeof helpers.WINDOW.window === 'undefined') {
151
+ // No need to show the error if we're not in a browser window environment (e.g. service workers)
152
+ return false;
153
+ }
154
+
155
+ const _window = helpers.WINDOW ;
156
+
157
+ // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine
158
+ // see: https://github.com/getsentry/sentry-javascript/issues/12668
159
+ if (_window.nw) {
160
+ return false;
161
+ }
162
+
163
+ const extensionObject = _window['chrome'] || _window['browser'];
164
+
165
+ if (!extensionObject?.runtime?.id) {
166
+ return false;
167
+ }
168
+
169
+ const href = core.getLocationHref();
170
+ const extensionProtocols = ['chrome-extension', 'moz-extension', 'ms-browser-extension', 'safari-web-extension'];
171
+
172
+ // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage
173
+ const isDedicatedExtensionPage =
174
+ helpers.WINDOW === helpers.WINDOW.top && extensionProtocols.some(protocol => href.startsWith(`${protocol}://`));
175
+
176
+ return !isDedicatedExtensionPage;
177
+ }
178
+
179
+ function _checkForBrowserExtension() {
180
+ if (_isEmbeddedBrowserExtension()) {
181
+ if (debugBuild.DEBUG_BUILD) {
182
+ core.consoleSandbox(() => {
183
+ // eslint-disable-next-line no-console
184
+ console.error(
185
+ '[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
186
+ );
187
+ });
188
+ }
189
+
190
+ return true;
191
+ }
192
+ }
193
+
194
194
  exports.applyDefaultOptions = applyDefaultOptions;
195
195
  exports.forceLoad = forceLoad;
196
196
  exports.getDefaultIntegrations = getDefaultIntegrations;
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../../src/sdk.ts"],"sourcesContent":["import type { Client, Integration, Options } from '@sentry/core';\nimport {\n consoleSandbox,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n getLocationHref,\n inboundFiltersIntegration,\n initAndBind,\n logger,\n stackParserFromStackParserOptions,\n supportsFetch,\n} from '@sentry/core';\nimport type { BrowserClientOptions, BrowserOptions } from './client';\nimport { BrowserClient } from './client';\nimport { DEBUG_BUILD } from './debug-build';\nimport { WINDOW } from './helpers';\nimport { breadcrumbsIntegration } from './integrations/breadcrumbs';\nimport { browserApiErrorsIntegration } from './integrations/browserapierrors';\nimport { browserSessionIntegration } from './integrations/browsersession';\nimport { globalHandlersIntegration } from './integrations/globalhandlers';\nimport { httpContextIntegration } from './integrations/httpcontext';\nimport { linkedErrorsIntegration } from './integrations/linkederrors';\nimport { defaultStackParser } from './stack-parsers';\nimport { makeFetchTransport } from './transports/fetch';\n\n/** Get the default integrations for the browser SDK. */\nexport function getDefaultIntegrations(_options: Options): Integration[] {\n /**\n * Note: Please make sure this stays in sync with Angular SDK, which re-exports\n * `getDefaultIntegrations` but with an adjusted set of integrations.\n */\n return [\n // TODO(v10): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n browserApiErrorsIntegration(),\n breadcrumbsIntegration(),\n globalHandlersIntegration(),\n linkedErrorsIntegration(),\n dedupeIntegration(),\n httpContextIntegration(),\n browserSessionIntegration(),\n ];\n}\n\n/** Exported only for tests. */\nexport function applyDefaultOptions(optionsArg: BrowserOptions = {}): BrowserOptions {\n const defaultOptions: BrowserOptions = {\n defaultIntegrations: getDefaultIntegrations(optionsArg),\n release:\n typeof __SENTRY_RELEASE__ === 'string' // This allows build tooling to find-and-replace __SENTRY_RELEASE__ to inject a release value\n ? __SENTRY_RELEASE__\n : WINDOW.SENTRY_RELEASE?.id, // This supports the variable that sentry-webpack-plugin injects\n sendClientReports: true,\n };\n\n return {\n ...defaultOptions,\n ...dropTopLevelUndefinedKeys(optionsArg),\n };\n}\n\n/**\n * In contrast to the regular `dropUndefinedKeys` method,\n * this one does not deep-drop keys, but only on the top level.\n */\nfunction dropTopLevelUndefinedKeys<T extends object>(obj: T): Partial<T> {\n const mutatetedObj: Partial<T> = {};\n\n for (const k of Object.getOwnPropertyNames(obj)) {\n const key = k as keyof T;\n if (obj[key] !== undefined) {\n mutatetedObj[key] = obj[key];\n }\n }\n\n return mutatetedObj;\n}\n\ntype ExtensionProperties = {\n chrome?: Runtime;\n browser?: Runtime;\n nw?: unknown;\n};\ntype Runtime = {\n runtime?: {\n id?: string;\n };\n};\n\nfunction shouldShowBrowserExtensionError(): boolean {\n const windowWithMaybeExtension =\n typeof WINDOW.window !== 'undefined' && (WINDOW as typeof WINDOW & ExtensionProperties);\n if (!windowWithMaybeExtension) {\n // No need to show the error if we're not in a browser window environment (e.g. service workers)\n return false;\n }\n\n const extensionKey = windowWithMaybeExtension.chrome ? 'chrome' : 'browser';\n const extensionObject = windowWithMaybeExtension[extensionKey];\n\n const runtimeId = extensionObject?.runtime?.id;\n const href = getLocationHref() || '';\n\n const extensionProtocols = ['chrome-extension:', 'moz-extension:', 'ms-browser-extension:', 'safari-web-extension:'];\n\n // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage\n const isDedicatedExtensionPage =\n !!runtimeId && WINDOW === WINDOW.top && extensionProtocols.some(protocol => href.startsWith(`${protocol}//`));\n\n // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine\n // see: https://github.com/getsentry/sentry-javascript/issues/12668\n const isNWjs = typeof windowWithMaybeExtension.nw !== 'undefined';\n\n return !!runtimeId && !isDedicatedExtensionPage && !isNWjs;\n}\n\n/**\n * A magic string that build tooling can leverage in order to inject a release value into the SDK.\n */\ndeclare const __SENTRY_RELEASE__: string | undefined;\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nexport function init(browserOptions: BrowserOptions = {}): Client | undefined {\n const options = applyDefaultOptions(browserOptions);\n\n if (!options.skipBrowserExtensionCheck && shouldShowBrowserExtensionError()) {\n if (DEBUG_BUILD) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.error(\n '[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',\n );\n });\n }\n return;\n }\n\n if (DEBUG_BUILD && !supportsFetch()) {\n logger.warn(\n 'No Fetch API detected. The Sentry SDK requires a Fetch API compatible environment to send events. Please add a Fetch API polyfill.',\n );\n }\n const clientOptions: BrowserClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeFetchTransport,\n };\n\n return initAndBind(BrowserClient, clientOptions);\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function forceLoad(): void {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function onLoad(callback: () => void): void {\n callback();\n}\n"],"names":["inboundFiltersIntegration","functionToStringIntegration","browserApiErrorsIntegration","breadcrumbsIntegration","globalHandlersIntegration","linkedErrorsIntegration","dedupeIntegration","httpContextIntegration","browserSessionIntegration","WINDOW","getLocationHref","DEBUG_BUILD","consoleSandbox","supportsFetch","logger","stackParserFromStackParserOptions","defaultStackParser","getIntegrationsToSetup","makeFetchTransport","initAndBind","BrowserClient"],"mappings":";;;;;;;;;;;;;;;AA0BA;AACO,SAAS,sBAAsB,CAAC,QAAQ,EAA0B;AACzE;AACA;AACA;AACA;AACA,EAAE,OAAO;AACT;AACA;AACA,IAAIA,8BAAyB,EAAE;AAC/B,IAAIC,gCAA2B,EAAE;AACjC,IAAIC,4CAA2B,EAAE;AACjC,IAAIC,kCAAsB,EAAE;AAC5B,IAAIC,wCAAyB,EAAE;AAC/B,IAAIC,oCAAuB,EAAE;AAC7B,IAAIC,sBAAiB,EAAE;AACvB,IAAIC,kCAAsB,EAAE;AAC5B,IAAIC,wCAAyB,EAAE;AAC/B,GAAG;AACH;;AAEA;AACO,SAAS,mBAAmB,CAAC,UAAU,GAAmB,EAAE,EAAkB;AACrF,EAAE,MAAM,cAAc,GAAmB;AACzC,IAAI,mBAAmB,EAAE,sBAAsB,CAAW,CAAC;AAC3D,IAAI,OAAO;AACX,MAAM,OAAO,uBAAuB,QAAA;AACpC,UAAU;AACV,UAAUC,cAAM,CAAC,cAAc,EAAE,EAAE;AACnC,IAAI,iBAAiB,EAAE,IAAI;AAC3B,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,GAAG,cAAc;AACrB,IAAI,GAAG,yBAAyB,CAAC,UAAU,CAAC;AAC5C,GAAG;AACH;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version":3,"file":"sdk.js","sources":["../../../src/sdk.ts"],"sourcesContent":["import type { Client, Integration, Options } from '@sentry/core';\nimport {\n consoleSandbox,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n getLocationHref,\n inboundFiltersIntegration,\n initAndBind,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { BrowserClientOptions, BrowserOptions } from './client';\nimport { BrowserClient } from './client';\nimport { DEBUG_BUILD } from './debug-build';\nimport { WINDOW } from './helpers';\nimport { breadcrumbsIntegration } from './integrations/breadcrumbs';\nimport { browserApiErrorsIntegration } from './integrations/browserapierrors';\nimport { browserSessionIntegration } from './integrations/browsersession';\nimport { globalHandlersIntegration } from './integrations/globalhandlers';\nimport { httpContextIntegration } from './integrations/httpcontext';\nimport { linkedErrorsIntegration } from './integrations/linkederrors';\nimport { defaultStackParser } from './stack-parsers';\nimport { makeFetchTransport } from './transports/fetch';\n\ntype ExtensionProperties = {\n chrome?: Runtime;\n browser?: Runtime;\n nw?: unknown;\n};\ntype Runtime = {\n runtime?: {\n id?: string;\n };\n};\n\n/**\n * A magic string that build tooling can leverage in order to inject a release value into the SDK.\n */\ndeclare const __SENTRY_RELEASE__: string | undefined;\n\n/** Get the default integrations for the browser SDK. */\nexport function getDefaultIntegrations(_options: Options): Integration[] {\n /**\n * Note: Please make sure this stays in sync with Angular SDK, which re-exports\n * `getDefaultIntegrations` but with an adjusted set of integrations.\n */\n return [\n // TODO(v10): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n browserApiErrorsIntegration(),\n breadcrumbsIntegration(),\n globalHandlersIntegration(),\n linkedErrorsIntegration(),\n dedupeIntegration(),\n httpContextIntegration(),\n browserSessionIntegration(),\n ];\n}\n\n/** Exported only for tests. */\nexport function applyDefaultOptions(optionsArg: BrowserOptions = {}): BrowserOptions {\n const defaultOptions: BrowserOptions = {\n defaultIntegrations: getDefaultIntegrations(optionsArg),\n release:\n typeof __SENTRY_RELEASE__ === 'string' // This allows build tooling to find-and-replace __SENTRY_RELEASE__ to inject a release value\n ? __SENTRY_RELEASE__\n : WINDOW.SENTRY_RELEASE?.id, // This supports the variable that sentry-webpack-plugin injects\n sendClientReports: true,\n };\n\n return {\n ...defaultOptions,\n ...dropTopLevelUndefinedKeys(optionsArg),\n };\n}\n\n/**\n * In contrast to the regular `dropUndefinedKeys` method,\n * this one does not deep-drop keys, but only on the top level.\n */\nfunction dropTopLevelUndefinedKeys<T extends object>(obj: T): Partial<T> {\n const mutatetedObj: Partial<T> = {};\n\n for (const k of Object.getOwnPropertyNames(obj)) {\n const key = k as keyof T;\n if (obj[key] !== undefined) {\n mutatetedObj[key] = obj[key];\n }\n }\n\n return mutatetedObj;\n}\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nexport function init(browserOptions: BrowserOptions = {}): Client | undefined {\n if (!browserOptions.skipBrowserExtensionCheck && _checkForBrowserExtension()) {\n return;\n }\n\n const options = applyDefaultOptions(browserOptions);\n const clientOptions: BrowserClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeFetchTransport,\n };\n\n return initAndBind(BrowserClient, clientOptions);\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function forceLoad(): void {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function onLoad(callback: () => void): void {\n callback();\n}\n\nfunction _isEmbeddedBrowserExtension(): boolean {\n if (typeof WINDOW.window === 'undefined') {\n // No need to show the error if we're not in a browser window environment (e.g. service workers)\n return false;\n }\n\n const _window = WINDOW as typeof WINDOW & ExtensionProperties;\n\n // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine\n // see: https://github.com/getsentry/sentry-javascript/issues/12668\n if (_window.nw) {\n return false;\n }\n\n const extensionObject = _window['chrome'] || _window['browser'];\n\n if (!extensionObject?.runtime?.id) {\n return false;\n }\n\n const href = getLocationHref();\n const extensionProtocols = ['chrome-extension', 'moz-extension', 'ms-browser-extension', 'safari-web-extension'];\n\n // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage\n const isDedicatedExtensionPage =\n WINDOW === WINDOW.top && extensionProtocols.some(protocol => href.startsWith(`${protocol}://`));\n\n return !isDedicatedExtensionPage;\n}\n\nfunction _checkForBrowserExtension(): true | void {\n if (_isEmbeddedBrowserExtension()) {\n if (DEBUG_BUILD) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.error(\n '[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',\n );\n });\n }\n\n return true;\n }\n}\n"],"names":["inboundFiltersIntegration","functionToStringIntegration","browserApiErrorsIntegration","breadcrumbsIntegration","globalHandlersIntegration","linkedErrorsIntegration","dedupeIntegration","httpContextIntegration","browserSessionIntegration","WINDOW","stackParserFromStackParserOptions","defaultStackParser","getIntegrationsToSetup","makeFetchTransport","initAndBind","BrowserClient","getLocationHref","DEBUG_BUILD","consoleSandbox"],"mappings":";;;;;;;;;;;;;;;AAwCA;AACO,SAAS,sBAAsB,CAAC,QAA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AAChC,EAAE,MAAM,kBAAmB,GAAE,CAAC,kBAAkB,EAAE,eAAe,EAAE,sBAAsB,EAAE,sBAAsB,CAAC;;AAElH;AACA,EAAE,MAAM,wBAAyB;AACjC,IAAIP,mBAAWA,cAAM,CAAC,GAAA,IAAO,kBAAkB,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,CAAC,CAAC,EAAA,QAAA,CAAA,GAAA,CAAA,CAAA,CAAA;;AAEA,EAAA,OAAA,CAAA,wBAAA;AACA;;AAEA,SAAA,yBAAA,GAAA;AACA,EAAA,IAAA,2BAAA,EAAA,EAAA;AACA,IAAA,IAAAQ,sBAAA,EAAA;AACA,MAAAC,mBAAA,CAAA,MAAA;AACA;AACA,QAAA,OAAA,CAAA,KAAA;AACA,UAAA,mJAAA;AACA,SAAA;AACA,OAAA,CAAA;AACA;;AAEA,IAAA,OAAA,IAAA;AACA;AACA;;;;;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"9.21.0","sideEffects":false}
1
+ {"type":"module","version":"9.22.0","sideEffects":false}
@@ -1,4 +1,4 @@
1
- import { inboundFiltersIntegration, functionToStringIntegration, dedupeIntegration, consoleSandbox, supportsFetch, logger, getIntegrationsToSetup, stackParserFromStackParserOptions, initAndBind, getLocationHref } from '@sentry/core';
1
+ import { inboundFiltersIntegration, functionToStringIntegration, dedupeIntegration, getIntegrationsToSetup, stackParserFromStackParserOptions, initAndBind, consoleSandbox, getLocationHref } from '@sentry/core';
2
2
  import { BrowserClient } from './client.js';
3
3
  import { DEBUG_BUILD } from './debug-build.js';
4
4
  import { WINDOW } from './helpers.js';
@@ -66,37 +66,6 @@ function dropTopLevelUndefinedKeys(obj) {
66
66
  return mutatetedObj;
67
67
  }
68
68
 
69
- function shouldShowBrowserExtensionError() {
70
- const windowWithMaybeExtension =
71
- typeof WINDOW.window !== 'undefined' && (WINDOW );
72
- if (!windowWithMaybeExtension) {
73
- // No need to show the error if we're not in a browser window environment (e.g. service workers)
74
- return false;
75
- }
76
-
77
- const extensionKey = windowWithMaybeExtension.chrome ? 'chrome' : 'browser';
78
- const extensionObject = windowWithMaybeExtension[extensionKey];
79
-
80
- const runtimeId = extensionObject?.runtime?.id;
81
- const href = getLocationHref() || '';
82
-
83
- const extensionProtocols = ['chrome-extension:', 'moz-extension:', 'ms-browser-extension:', 'safari-web-extension:'];
84
-
85
- // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage
86
- const isDedicatedExtensionPage =
87
- !!runtimeId && WINDOW === WINDOW.top && extensionProtocols.some(protocol => href.startsWith(`${protocol}//`));
88
-
89
- // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine
90
- // see: https://github.com/getsentry/sentry-javascript/issues/12668
91
- const isNWjs = typeof windowWithMaybeExtension.nw !== 'undefined';
92
-
93
- return !!runtimeId && !isDedicatedExtensionPage && !isNWjs;
94
- }
95
-
96
- /**
97
- * A magic string that build tooling can leverage in order to inject a release value into the SDK.
98
- */
99
-
100
69
  /**
101
70
  * The Sentry Browser SDK Client.
102
71
  *
@@ -144,25 +113,11 @@ function shouldShowBrowserExtensionError() {
144
113
  * @see {@link BrowserOptions} for documentation on configuration options.
145
114
  */
146
115
  function init(browserOptions = {}) {
147
- const options = applyDefaultOptions(browserOptions);
148
-
149
- if (!options.skipBrowserExtensionCheck && shouldShowBrowserExtensionError()) {
150
- if (DEBUG_BUILD) {
151
- consoleSandbox(() => {
152
- // eslint-disable-next-line no-console
153
- console.error(
154
- '[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
155
- );
156
- });
157
- }
116
+ if (!browserOptions.skipBrowserExtensionCheck && _checkForBrowserExtension()) {
158
117
  return;
159
118
  }
160
119
 
161
- if (DEBUG_BUILD && !supportsFetch()) {
162
- logger.warn(
163
- 'No Fetch API detected. The Sentry SDK requires a Fetch API compatible environment to send events. Please add a Fetch API polyfill.',
164
- );
165
- }
120
+ const options = applyDefaultOptions(browserOptions);
166
121
  const clientOptions = {
167
122
  ...options,
168
123
  stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),
@@ -189,5 +144,50 @@ function onLoad(callback) {
189
144
  callback();
190
145
  }
191
146
 
147
+ function _isEmbeddedBrowserExtension() {
148
+ if (typeof WINDOW.window === 'undefined') {
149
+ // No need to show the error if we're not in a browser window environment (e.g. service workers)
150
+ return false;
151
+ }
152
+
153
+ const _window = WINDOW ;
154
+
155
+ // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine
156
+ // see: https://github.com/getsentry/sentry-javascript/issues/12668
157
+ if (_window.nw) {
158
+ return false;
159
+ }
160
+
161
+ const extensionObject = _window['chrome'] || _window['browser'];
162
+
163
+ if (!extensionObject?.runtime?.id) {
164
+ return false;
165
+ }
166
+
167
+ const href = getLocationHref();
168
+ const extensionProtocols = ['chrome-extension', 'moz-extension', 'ms-browser-extension', 'safari-web-extension'];
169
+
170
+ // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage
171
+ const isDedicatedExtensionPage =
172
+ WINDOW === WINDOW.top && extensionProtocols.some(protocol => href.startsWith(`${protocol}://`));
173
+
174
+ return !isDedicatedExtensionPage;
175
+ }
176
+
177
+ function _checkForBrowserExtension() {
178
+ if (_isEmbeddedBrowserExtension()) {
179
+ if (DEBUG_BUILD) {
180
+ consoleSandbox(() => {
181
+ // eslint-disable-next-line no-console
182
+ console.error(
183
+ '[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
184
+ );
185
+ });
186
+ }
187
+
188
+ return true;
189
+ }
190
+ }
191
+
192
192
  export { applyDefaultOptions, forceLoad, getDefaultIntegrations, init, onLoad };
193
193
  //# sourceMappingURL=sdk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../../src/sdk.ts"],"sourcesContent":["import type { Client, Integration, Options } from '@sentry/core';\nimport {\n consoleSandbox,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n getLocationHref,\n inboundFiltersIntegration,\n initAndBind,\n logger,\n stackParserFromStackParserOptions,\n supportsFetch,\n} from '@sentry/core';\nimport type { BrowserClientOptions, BrowserOptions } from './client';\nimport { BrowserClient } from './client';\nimport { DEBUG_BUILD } from './debug-build';\nimport { WINDOW } from './helpers';\nimport { breadcrumbsIntegration } from './integrations/breadcrumbs';\nimport { browserApiErrorsIntegration } from './integrations/browserapierrors';\nimport { browserSessionIntegration } from './integrations/browsersession';\nimport { globalHandlersIntegration } from './integrations/globalhandlers';\nimport { httpContextIntegration } from './integrations/httpcontext';\nimport { linkedErrorsIntegration } from './integrations/linkederrors';\nimport { defaultStackParser } from './stack-parsers';\nimport { makeFetchTransport } from './transports/fetch';\n\n/** Get the default integrations for the browser SDK. */\nexport function getDefaultIntegrations(_options: Options): Integration[] {\n /**\n * Note: Please make sure this stays in sync with Angular SDK, which re-exports\n * `getDefaultIntegrations` but with an adjusted set of integrations.\n */\n return [\n // TODO(v10): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n browserApiErrorsIntegration(),\n breadcrumbsIntegration(),\n globalHandlersIntegration(),\n linkedErrorsIntegration(),\n dedupeIntegration(),\n httpContextIntegration(),\n browserSessionIntegration(),\n ];\n}\n\n/** Exported only for tests. */\nexport function applyDefaultOptions(optionsArg: BrowserOptions = {}): BrowserOptions {\n const defaultOptions: BrowserOptions = {\n defaultIntegrations: getDefaultIntegrations(optionsArg),\n release:\n typeof __SENTRY_RELEASE__ === 'string' // This allows build tooling to find-and-replace __SENTRY_RELEASE__ to inject a release value\n ? __SENTRY_RELEASE__\n : WINDOW.SENTRY_RELEASE?.id, // This supports the variable that sentry-webpack-plugin injects\n sendClientReports: true,\n };\n\n return {\n ...defaultOptions,\n ...dropTopLevelUndefinedKeys(optionsArg),\n };\n}\n\n/**\n * In contrast to the regular `dropUndefinedKeys` method,\n * this one does not deep-drop keys, but only on the top level.\n */\nfunction dropTopLevelUndefinedKeys<T extends object>(obj: T): Partial<T> {\n const mutatetedObj: Partial<T> = {};\n\n for (const k of Object.getOwnPropertyNames(obj)) {\n const key = k as keyof T;\n if (obj[key] !== undefined) {\n mutatetedObj[key] = obj[key];\n }\n }\n\n return mutatetedObj;\n}\n\ntype ExtensionProperties = {\n chrome?: Runtime;\n browser?: Runtime;\n nw?: unknown;\n};\ntype Runtime = {\n runtime?: {\n id?: string;\n };\n};\n\nfunction shouldShowBrowserExtensionError(): boolean {\n const windowWithMaybeExtension =\n typeof WINDOW.window !== 'undefined' && (WINDOW as typeof WINDOW & ExtensionProperties);\n if (!windowWithMaybeExtension) {\n // No need to show the error if we're not in a browser window environment (e.g. service workers)\n return false;\n }\n\n const extensionKey = windowWithMaybeExtension.chrome ? 'chrome' : 'browser';\n const extensionObject = windowWithMaybeExtension[extensionKey];\n\n const runtimeId = extensionObject?.runtime?.id;\n const href = getLocationHref() || '';\n\n const extensionProtocols = ['chrome-extension:', 'moz-extension:', 'ms-browser-extension:', 'safari-web-extension:'];\n\n // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage\n const isDedicatedExtensionPage =\n !!runtimeId && WINDOW === WINDOW.top && extensionProtocols.some(protocol => href.startsWith(`${protocol}//`));\n\n // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine\n // see: https://github.com/getsentry/sentry-javascript/issues/12668\n const isNWjs = typeof windowWithMaybeExtension.nw !== 'undefined';\n\n return !!runtimeId && !isDedicatedExtensionPage && !isNWjs;\n}\n\n/**\n * A magic string that build tooling can leverage in order to inject a release value into the SDK.\n */\ndeclare const __SENTRY_RELEASE__: string | undefined;\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nexport function init(browserOptions: BrowserOptions = {}): Client | undefined {\n const options = applyDefaultOptions(browserOptions);\n\n if (!options.skipBrowserExtensionCheck && shouldShowBrowserExtensionError()) {\n if (DEBUG_BUILD) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.error(\n '[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',\n );\n });\n }\n return;\n }\n\n if (DEBUG_BUILD && !supportsFetch()) {\n logger.warn(\n 'No Fetch API detected. The Sentry SDK requires a Fetch API compatible environment to send events. Please add a Fetch API polyfill.',\n );\n }\n const clientOptions: BrowserClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeFetchTransport,\n };\n\n return initAndBind(BrowserClient, clientOptions);\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function forceLoad(): void {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function onLoad(callback: () => void): void {\n callback();\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AA0BA;AACO,SAAS,sBAAsB,CAAC,QAAQ,EAA0B;AACzE;AACA;AACA;AACA;AACA,EAAE,OAAO;AACT;AACA;AACA,IAAI,yBAAyB,EAAE;AAC/B,IAAI,2BAA2B,EAAE;AACjC,IAAI,2BAA2B,EAAE;AACjC,IAAI,sBAAsB,EAAE;AAC5B,IAAI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AA,CAAA,IAAA;AACA,MAAA,oIAAA;AACA,KAAA;AACA;AACA,EAAA,MAAA,aAAA,GAAA;AACA,IAAA,GAAA,OAAA;AACA,IAAA,WAAA,EAAA,iCAAA,CAAA,OAAA,CAAA,WAAA,IAAA,kBAAA,CAAA;AACA,IAAA,YAAA,EAAA,sBAAA,CAAA,OAAA,CAAA;AACA,IAAA,SAAA,EAAA,OAAA,CAAA,SAAA,IAAA,kBAAA;AACA,GAAA;;AAEA,EAAA,OAAA,WAAA,CAAA,aAAA,EAAA,aAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAA,SAAA,GAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAA,MAAA,CAAA,QAAA,EAAA;AACA,EAAA,QAAA,EAAA;AACA;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../../src/sdk.ts"],"sourcesContent":["import type { Client, Integration, Options } from '@sentry/core';\nimport {\n consoleSandbox,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n getLocationHref,\n inboundFiltersIntegration,\n initAndBind,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { BrowserClientOptions, BrowserOptions } from './client';\nimport { BrowserClient } from './client';\nimport { DEBUG_BUILD } from './debug-build';\nimport { WINDOW } from './helpers';\nimport { breadcrumbsIntegration } from './integrations/breadcrumbs';\nimport { browserApiErrorsIntegration } from './integrations/browserapierrors';\nimport { browserSessionIntegration } from './integrations/browsersession';\nimport { globalHandlersIntegration } from './integrations/globalhandlers';\nimport { httpContextIntegration } from './integrations/httpcontext';\nimport { linkedErrorsIntegration } from './integrations/linkederrors';\nimport { defaultStackParser } from './stack-parsers';\nimport { makeFetchTransport } from './transports/fetch';\n\ntype ExtensionProperties = {\n chrome?: Runtime;\n browser?: Runtime;\n nw?: unknown;\n};\ntype Runtime = {\n runtime?: {\n id?: string;\n };\n};\n\n/**\n * A magic string that build tooling can leverage in order to inject a release value into the SDK.\n */\ndeclare const __SENTRY_RELEASE__: string | undefined;\n\n/** Get the default integrations for the browser SDK. */\nexport function getDefaultIntegrations(_options: Options): Integration[] {\n /**\n * Note: Please make sure this stays in sync with Angular SDK, which re-exports\n * `getDefaultIntegrations` but with an adjusted set of integrations.\n */\n return [\n // TODO(v10): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n browserApiErrorsIntegration(),\n breadcrumbsIntegration(),\n globalHandlersIntegration(),\n linkedErrorsIntegration(),\n dedupeIntegration(),\n httpContextIntegration(),\n browserSessionIntegration(),\n ];\n}\n\n/** Exported only for tests. */\nexport function applyDefaultOptions(optionsArg: BrowserOptions = {}): BrowserOptions {\n const defaultOptions: BrowserOptions = {\n defaultIntegrations: getDefaultIntegrations(optionsArg),\n release:\n typeof __SENTRY_RELEASE__ === 'string' // This allows build tooling to find-and-replace __SENTRY_RELEASE__ to inject a release value\n ? __SENTRY_RELEASE__\n : WINDOW.SENTRY_RELEASE?.id, // This supports the variable that sentry-webpack-plugin injects\n sendClientReports: true,\n };\n\n return {\n ...defaultOptions,\n ...dropTopLevelUndefinedKeys(optionsArg),\n };\n}\n\n/**\n * In contrast to the regular `dropUndefinedKeys` method,\n * this one does not deep-drop keys, but only on the top level.\n */\nfunction dropTopLevelUndefinedKeys<T extends object>(obj: T): Partial<T> {\n const mutatetedObj: Partial<T> = {};\n\n for (const k of Object.getOwnPropertyNames(obj)) {\n const key = k as keyof T;\n if (obj[key] !== undefined) {\n mutatetedObj[key] = obj[key];\n }\n }\n\n return mutatetedObj;\n}\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nexport function init(browserOptions: BrowserOptions = {}): Client | undefined {\n if (!browserOptions.skipBrowserExtensionCheck && _checkForBrowserExtension()) {\n return;\n }\n\n const options = applyDefaultOptions(browserOptions);\n const clientOptions: BrowserClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeFetchTransport,\n };\n\n return initAndBind(BrowserClient, clientOptions);\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function forceLoad(): void {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function onLoad(callback: () => void): void {\n callback();\n}\n\nfunction _isEmbeddedBrowserExtension(): boolean {\n if (typeof WINDOW.window === 'undefined') {\n // No need to show the error if we're not in a browser window environment (e.g. service workers)\n return false;\n }\n\n const _window = WINDOW as typeof WINDOW & ExtensionProperties;\n\n // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine\n // see: https://github.com/getsentry/sentry-javascript/issues/12668\n if (_window.nw) {\n return false;\n }\n\n const extensionObject = _window['chrome'] || _window['browser'];\n\n if (!extensionObject?.runtime?.id) {\n return false;\n }\n\n const href = getLocationHref();\n const extensionProtocols = ['chrome-extension', 'moz-extension', 'ms-browser-extension', 'safari-web-extension'];\n\n // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage\n const isDedicatedExtensionPage =\n WINDOW === WINDOW.top && extensionProtocols.some(protocol => href.startsWith(`${protocol}://`));\n\n return !isDedicatedExtensionPage;\n}\n\nfunction _checkForBrowserExtension(): true | void {\n if (_isEmbeddedBrowserExtension()) {\n if (DEBUG_BUILD) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.error(\n '[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',\n );\n });\n }\n\n return true;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwCA;AACO,SAAS,sBAAsB,CAAC,QAAQ,EAA0B;AACzE;AACA;AACA;AACA;AACA,EAAE,OAAO;AACT;AACA;AACA,IAAI,yBAAyB,EAAE;AAC/B,IAAI,2BAA2B,EAAE;AACjC,IAAI,2BAA2B,EAAE;AACjC,IAAI,sBAAsB,EAAE;AAC5B,IAAI,yBAAyB,EAAE;AAC/B,IAAI,uBAAuB,EAAE;AAC7B,IAAI,iBAAiB,EAAE;AACvB,IAAI,sBAAsB,EAAE;AAC5B,IAAI,yBAAyB,EAAE;AAC/B,GAAG;AACH;;AAEA;AACO,SAAS,mBAAmB,CAAC,UAAU,GAAmB,EAAE,EAAkB;AACrF,EAAE,MAAM,cAAc,GAAmB;AACzC,IAAI,mBAAmB,EAAE,sBAAsB,CAAW,CAAC;AAC3D,IAAI,OAAO;AACX,MAAM,OAAO,uBAAuB,QAAA;AACpC,UAAU;AACV,UAAU,MAAM,CAAC,cAAc,EAAE,EAAE;AACnC,IAAI,iBAAiB,EAAE,IAAI;AAC3B,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,GAAG,cAAc;AACrB,IAAI,GAAG,yBAAyB,CAAC,UAAU,CAAC;AAC5C,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA,SAAS,yBAAyB,CAAmB,GAAG,EAAiB;AACzE,EAAE,MAAM,YAAY,GAAe,EAAE;;AAErC,EAAE,KAAK,MAAM,CAAE,IAAG,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE;AACnD,IAAI,MAAM,GAAI,GAAE,CAAE;AAClB,IAAI,IAAI,GAAG,CAAC,GA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;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAgB,IAAI,CAAC,cAAc,GAAE,cAAmB,GAAG,MAAM,GAAG,SAAS,CA4B5E;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAEhC;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAEjD"}
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAWjE,OAAO,KAAK,EAAwB,cAAc,EAAE,MAAM,UAAU,CAAC;AA6BrE,wDAAwD;AACxD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,OAAO,GAAG,WAAW,EAAE,CAkBvE;AAED,+BAA+B;AAC/B,wBAAgB,mBAAmB,CAAC,UAAU,GAAE,cAAmB,GAAG,cAAc,CAcnF;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAgB,IAAI,CAAC,cAAc,GAAE,cAAmB,GAAG,MAAM,GAAG,SAAS,CAc5E;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAEhC;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAEjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/browser",
3
- "version": "9.21.0",
3
+ "version": "9.22.0",
4
4
  "description": "Official Sentry SDK for browsers",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
@@ -39,14 +39,14 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@sentry-internal/browser-utils": "9.21.0",
43
- "@sentry-internal/feedback": "9.21.0",
44
- "@sentry-internal/replay": "9.21.0",
45
- "@sentry-internal/replay-canvas": "9.21.0",
46
- "@sentry/core": "9.21.0"
42
+ "@sentry-internal/browser-utils": "9.22.0",
43
+ "@sentry-internal/feedback": "9.22.0",
44
+ "@sentry-internal/replay": "9.22.0",
45
+ "@sentry-internal/replay-canvas": "9.22.0",
46
+ "@sentry/core": "9.22.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@sentry-internal/integration-shims": "9.21.0",
49
+ "@sentry-internal/integration-shims": "9.22.0",
50
50
  "fake-indexeddb": "^4.0.1"
51
51
  },
52
52
  "scripts": {