From 40566dba394fc093754eddd049969ab0de5b12fb Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 27 Aug 2024 13:35:42 +0200 Subject: [PATCH 1/9] add tests --- .../loader/noOnLoad/captureException/test.ts | 20 ++++++++++++ .../captureException/simpleError/test.ts | 32 +++++++++++++++---- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/captureException/test.ts b/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/captureException/test.ts index 09a10464c22e..43fcf3b985aa 100644 --- a/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/captureException/test.ts +++ b/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/captureException/test.ts @@ -1,4 +1,5 @@ import { expect } from '@playwright/test'; +import { SDK_VERSION } from '@sentry/browser'; import { sentryTest } from '../../../../utils/fixtures'; import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers'; @@ -11,3 +12,22 @@ sentryTest('captureException works', async ({ getLocalTestUrl, page }) => { expect(eventData.message).toBe('Test exception'); }); + +sentryTest('should capture a correct SDK metadata', async ({ getLocalTestUrl, page }) => { + const url = await getLocalTestUrl({ testDir: __dirname }); + const req = await waitForErrorRequestOnUrl(page, url); + + const eventData = envelopeRequestParser(req); + + expect(eventData.sdk).toMatchObject({ + name: 'sentry.javascript.browser', + version: SDK_VERSION, + integrations: expect.any(Object), + packages: [ + { + name: 'loader:@sentry/browser', + version: SDK_VERSION, + }, + ], + }); +}); diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureException/simpleError/test.ts b/dev-packages/browser-integration-tests/suites/public-api/captureException/simpleError/test.ts index 7e884c6eb6dc..956d2094861a 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/captureException/simpleError/test.ts +++ b/dev-packages/browser-integration-tests/suites/public-api/captureException/simpleError/test.ts @@ -1,13 +1,13 @@ import { expect } from '@playwright/test'; -import type { Event } from '@sentry/types'; +import { SDK_VERSION } from '@sentry/browser'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers'; -sentryTest('should capture a simple error with message', async ({ getLocalTestPath, page }) => { - const url = await getLocalTestPath({ testDir: __dirname }); - - const eventData = await getFirstSentryEnvelopeRequest(page, url); +sentryTest('should capture a simple error with message', async ({ getLocalTestUrl, page }) => { + const url = await getLocalTestUrl({ testDir: __dirname }); + const req = await waitForErrorRequestOnUrl(page, url); + const eventData = envelopeRequestParser(req); expect(eventData.exception?.values).toHaveLength(1); expect(eventData.exception?.values?.[0]).toMatchObject({ @@ -22,3 +22,23 @@ sentryTest('should capture a simple error with message', async ({ getLocalTestPa }, }); }); + +sentryTest('should capture a correct SDK metadata', async ({ getLocalTestUrl, page }) => { + const isCdn = (process.env.PW_BUNDLE || '').startsWith('bundle'); + + const url = await getLocalTestUrl({ testDir: __dirname }); + const req = await waitForErrorRequestOnUrl(page, url); + const eventData = envelopeRequestParser(req); + + expect(eventData.sdk).toEqual({ + name: 'sentry.javascript.browser', + version: SDK_VERSION, + integrations: expect.any(Object), + packages: [ + { + name: `${isCdn ? 'cdn' : 'npm'}:@sentry/browser`, + version: SDK_VERSION, + }, + ], + }); +}); From 22aeee87b0656f6571ee7aec38a1917bb395a445 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 27 Aug 2024 13:35:53 +0200 Subject: [PATCH 2/9] fix it --- dev-packages/rollup-utils/npmHelpers.mjs | 3 --- packages/utils/src/env.ts | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dev-packages/rollup-utils/npmHelpers.mjs b/dev-packages/rollup-utils/npmHelpers.mjs index 410d0847d928..1a855e5674b7 100644 --- a/dev-packages/rollup-utils/npmHelpers.mjs +++ b/dev-packages/rollup-utils/npmHelpers.mjs @@ -19,7 +19,6 @@ import { makeImportMetaUrlReplacePlugin, makeNodeResolvePlugin, makeRrwebBuildPlugin, - makeSetSDKSourcePlugin, makeSucrasePlugin, } from './plugins/index.mjs'; import { makePackageNodeEsm } from './plugins/make-esm-plugin.mjs'; @@ -45,7 +44,6 @@ export function makeBaseNPMConfig(options = {}) { const importMetaUrlReplacePlugin = makeImportMetaUrlReplacePlugin(); const cleanupPlugin = makeCleanupPlugin(); const extractPolyfillsPlugin = makeExtractPolyfillsPlugin(); - const setSdkSourcePlugin = makeSetSDKSourcePlugin('npm'); const rrwebBuildPlugin = makeRrwebBuildPlugin({ excludeShadowDom: undefined, excludeIframe: undefined, @@ -106,7 +104,6 @@ export function makeBaseNPMConfig(options = {}) { plugins: [ nodeResolvePlugin, - setSdkSourcePlugin, sucrasePlugin, debugBuildStatementReplacePlugin, importMetaUrlReplacePlugin, diff --git a/packages/utils/src/env.ts b/packages/utils/src/env.ts index 0a3308a88561..313f8c40ac24 100644 --- a/packages/utils/src/env.ts +++ b/packages/utils/src/env.ts @@ -15,6 +15,8 @@ declare const __SENTRY_BROWSER_BUNDLE__: boolean | undefined; +declare const __SENTRY_SDK_SOURCE__: SdkSource | undefined; + export type SdkSource = 'npm' | 'cdn' | 'loader'; /** @@ -30,6 +32,5 @@ export function isBrowserBundle(): boolean { * Get source of SDK. */ export function getSDKSource(): SdkSource { - // @ts-expect-error __SENTRY_SDK_SOURCE__ is injected by rollup during build process - return __SENTRY_SDK_SOURCE__; + return typeof __SENTRY_SDK_SOURCE__ !== 'undefined' ? __SENTRY_SDK_SOURCE__ : 'npm'; } From 7c184020f53366b904cae035776a29db790445cb Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 27 Aug 2024 16:04:52 +0200 Subject: [PATCH 3/9] ref: Do not use build-time constant for SDK source at all ?? --- dev-packages/rollup-utils/bundleHelpers.mjs | 9 ++++----- dev-packages/rollup-utils/plugins/bundlePlugins.mjs | 9 --------- packages/browser/src/client.ts | 4 ++-- packages/browser/test/index.test.ts | 12 ------------ packages/utils/src/env.ts | 9 --------- 5 files changed, 6 insertions(+), 37 deletions(-) diff --git a/dev-packages/rollup-utils/bundleHelpers.mjs b/dev-packages/rollup-utils/bundleHelpers.mjs index f80b0b7c2e50..013521f48809 100644 --- a/dev-packages/rollup-utils/bundleHelpers.mjs +++ b/dev-packages/rollup-utils/bundleHelpers.mjs @@ -15,7 +15,6 @@ import { makeLicensePlugin, makeNodeResolvePlugin, makeRrwebBuildPlugin, - makeSetSDKSourcePlugin, makeSucrasePlugin, makeTerserPlugin, } from './plugins/index.mjs'; @@ -51,6 +50,7 @@ export function makeBaseBundleConfig(options) { intro: () => { return 'exports = window.Sentry || {};'; }, + banner: 'window.SENTRY_SDK_SOURCE = window.SENTRY_SDK_SOURCE || "cdn";', }, context: 'window', plugins: [rrwebBuildPlugin, markAsBrowserBuildPlugin], @@ -168,7 +168,6 @@ export function makeBundleConfigVariants(baseConfig, options = {}) { const includeDebuggingPlugin = makeIsDebugBuildPlugin(true); const stripDebuggingPlugin = makeIsDebugBuildPlugin(false); const terserPlugin = makeTerserPlugin(); - const setSdkSourcePlugin = makeSetSDKSourcePlugin('cdn'); // The additional options to use for each variant we're going to create. const variantSpecificConfigMap = { @@ -176,21 +175,21 @@ export function makeBundleConfigVariants(baseConfig, options = {}) { output: { entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.js`, }, - plugins: [includeDebuggingPlugin, setSdkSourcePlugin], + plugins: [includeDebuggingPlugin], }, '.min.js': { output: { entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.min.js`, }, - plugins: [stripDebuggingPlugin, setSdkSourcePlugin, terserPlugin], + plugins: [stripDebuggingPlugin, terserPlugin], }, '.debug.min.js': { output: { entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.debug.min.js`, }, - plugins: [includeDebuggingPlugin, setSdkSourcePlugin, terserPlugin], + plugins: [includeDebuggingPlugin, terserPlugin], }, }; diff --git a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs index 2ce35d1e6168..cbe4acec4fb6 100644 --- a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs +++ b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs @@ -60,15 +60,6 @@ export function makeIsDebugBuildPlugin(includeDebugging) { }); } -export function makeSetSDKSourcePlugin(sdkSource) { - return replace({ - preventAssignment: false, - values: { - __SENTRY_SDK_SOURCE__: JSON.stringify(sdkSource), - }, - }); -} - /** * Create a plugin to set the value of the `__SENTRY_BROWSER_BUNDLE__` magic string. * diff --git a/packages/browser/src/client.ts b/packages/browser/src/client.ts index 177d787a438d..449afefa731c 100644 --- a/packages/browser/src/client.ts +++ b/packages/browser/src/client.ts @@ -12,7 +12,7 @@ import type { SeverityLevel, UserFeedback, } from '@sentry/types'; -import { getSDKSource, logger } from '@sentry/utils'; +import { logger } from '@sentry/utils'; import { DEBUG_BUILD } from './debug-build'; import { eventFromException, eventFromMessage } from './eventbuilder'; @@ -57,7 +57,7 @@ export class BrowserClient extends BaseClient { parentSpanIsAlwaysRootSpan: true, ...options, }; - const sdkSource = WINDOW.SENTRY_SDK_SOURCE || getSDKSource(); + const sdkSource = WINDOW.SENTRY_SDK_SOURCE || 'npm'; applySdkMetadata(opts, 'browser', ['browser'], sdkSource); super(opts); diff --git a/packages/browser/test/index.test.ts b/packages/browser/test/index.test.ts index eb2fb6104b11..74566cc11437 100644 --- a/packages/browser/test/index.test.ts +++ b/packages/browser/test/index.test.ts @@ -13,7 +13,6 @@ import { inboundFiltersIntegration, lastEventId, } from '@sentry/core'; -import * as utils from '@sentry/utils'; import { setCurrentClient } from '../src'; import { @@ -382,17 +381,6 @@ describe('SentryBrowser initialization', () => { delete global.SENTRY_SDK_SOURCE; }); - it('uses SDK source from global for package name', () => { - const spy = vi.spyOn(utils, 'getSDKSource').mockReturnValue('cdn'); - init({ dsn }); - - const sdkData = getClient()?.getOptions()._metadata?.sdk || {}; - - expect(sdkData.packages?.[0]?.name).toBe('cdn:@sentry/browser'); - expect(utils.getSDKSource).toBeCalledTimes(1); - spy.mockRestore(); - }); - it('should set SDK data when instantiating a client directly', () => { const options = getDefaultBrowserClientOptions({ dsn }); const client = new BrowserClient(options); diff --git a/packages/utils/src/env.ts b/packages/utils/src/env.ts index 313f8c40ac24..c8ad8cdf30b8 100644 --- a/packages/utils/src/env.ts +++ b/packages/utils/src/env.ts @@ -15,8 +15,6 @@ declare const __SENTRY_BROWSER_BUNDLE__: boolean | undefined; -declare const __SENTRY_SDK_SOURCE__: SdkSource | undefined; - export type SdkSource = 'npm' | 'cdn' | 'loader'; /** @@ -27,10 +25,3 @@ export type SdkSource = 'npm' | 'cdn' | 'loader'; export function isBrowserBundle(): boolean { return typeof __SENTRY_BROWSER_BUNDLE__ !== 'undefined' && !!__SENTRY_BROWSER_BUNDLE__; } - -/** - * Get source of SDK. - */ -export function getSDKSource(): SdkSource { - return typeof __SENTRY_SDK_SOURCE__ !== 'undefined' ? __SENTRY_SDK_SOURCE__ : 'npm'; -} From 25939a4ae9aa5c408a6ab02c79e3a892a761c513 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 27 Aug 2024 16:55:45 +0200 Subject: [PATCH 4/9] increase size limit --- .size-limit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.size-limit.js b/.size-limit.js index 2280b950c513..e75eeb422735 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -170,7 +170,7 @@ module.exports = [ path: createCDNPath('bundle.tracing.min.js'), gzip: false, brotli: false, - limit: '111 KB', + limit: '113 KB', }, { name: 'CDN Bundle (incl. Tracing, Replay) - uncompressed', From 310fc22a56cc9a465ccb1e0e1833b85fd3bb70c6 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 27 Aug 2024 16:57:22 +0200 Subject: [PATCH 5/9] Revert "ref: Do not use build-time constant for SDK source at all ??" This reverts commit 711e454ee6bdf0613eb0c30b99554777933b3383. --- dev-packages/rollup-utils/bundleHelpers.mjs | 9 +++++---- dev-packages/rollup-utils/plugins/bundlePlugins.mjs | 9 +++++++++ packages/browser/src/client.ts | 4 ++-- packages/browser/test/index.test.ts | 12 ++++++++++++ packages/utils/src/env.ts | 9 +++++++++ 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/dev-packages/rollup-utils/bundleHelpers.mjs b/dev-packages/rollup-utils/bundleHelpers.mjs index 013521f48809..f80b0b7c2e50 100644 --- a/dev-packages/rollup-utils/bundleHelpers.mjs +++ b/dev-packages/rollup-utils/bundleHelpers.mjs @@ -15,6 +15,7 @@ import { makeLicensePlugin, makeNodeResolvePlugin, makeRrwebBuildPlugin, + makeSetSDKSourcePlugin, makeSucrasePlugin, makeTerserPlugin, } from './plugins/index.mjs'; @@ -50,7 +51,6 @@ export function makeBaseBundleConfig(options) { intro: () => { return 'exports = window.Sentry || {};'; }, - banner: 'window.SENTRY_SDK_SOURCE = window.SENTRY_SDK_SOURCE || "cdn";', }, context: 'window', plugins: [rrwebBuildPlugin, markAsBrowserBuildPlugin], @@ -168,6 +168,7 @@ export function makeBundleConfigVariants(baseConfig, options = {}) { const includeDebuggingPlugin = makeIsDebugBuildPlugin(true); const stripDebuggingPlugin = makeIsDebugBuildPlugin(false); const terserPlugin = makeTerserPlugin(); + const setSdkSourcePlugin = makeSetSDKSourcePlugin('cdn'); // The additional options to use for each variant we're going to create. const variantSpecificConfigMap = { @@ -175,21 +176,21 @@ export function makeBundleConfigVariants(baseConfig, options = {}) { output: { entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.js`, }, - plugins: [includeDebuggingPlugin], + plugins: [includeDebuggingPlugin, setSdkSourcePlugin], }, '.min.js': { output: { entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.min.js`, }, - plugins: [stripDebuggingPlugin, terserPlugin], + plugins: [stripDebuggingPlugin, setSdkSourcePlugin, terserPlugin], }, '.debug.min.js': { output: { entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.debug.min.js`, }, - plugins: [includeDebuggingPlugin, terserPlugin], + plugins: [includeDebuggingPlugin, setSdkSourcePlugin, terserPlugin], }, }; diff --git a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs index cbe4acec4fb6..2ce35d1e6168 100644 --- a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs +++ b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs @@ -60,6 +60,15 @@ export function makeIsDebugBuildPlugin(includeDebugging) { }); } +export function makeSetSDKSourcePlugin(sdkSource) { + return replace({ + preventAssignment: false, + values: { + __SENTRY_SDK_SOURCE__: JSON.stringify(sdkSource), + }, + }); +} + /** * Create a plugin to set the value of the `__SENTRY_BROWSER_BUNDLE__` magic string. * diff --git a/packages/browser/src/client.ts b/packages/browser/src/client.ts index 449afefa731c..177d787a438d 100644 --- a/packages/browser/src/client.ts +++ b/packages/browser/src/client.ts @@ -12,7 +12,7 @@ import type { SeverityLevel, UserFeedback, } from '@sentry/types'; -import { logger } from '@sentry/utils'; +import { getSDKSource, logger } from '@sentry/utils'; import { DEBUG_BUILD } from './debug-build'; import { eventFromException, eventFromMessage } from './eventbuilder'; @@ -57,7 +57,7 @@ export class BrowserClient extends BaseClient { parentSpanIsAlwaysRootSpan: true, ...options, }; - const sdkSource = WINDOW.SENTRY_SDK_SOURCE || 'npm'; + const sdkSource = WINDOW.SENTRY_SDK_SOURCE || getSDKSource(); applySdkMetadata(opts, 'browser', ['browser'], sdkSource); super(opts); diff --git a/packages/browser/test/index.test.ts b/packages/browser/test/index.test.ts index 74566cc11437..eb2fb6104b11 100644 --- a/packages/browser/test/index.test.ts +++ b/packages/browser/test/index.test.ts @@ -13,6 +13,7 @@ import { inboundFiltersIntegration, lastEventId, } from '@sentry/core'; +import * as utils from '@sentry/utils'; import { setCurrentClient } from '../src'; import { @@ -381,6 +382,17 @@ describe('SentryBrowser initialization', () => { delete global.SENTRY_SDK_SOURCE; }); + it('uses SDK source from global for package name', () => { + const spy = vi.spyOn(utils, 'getSDKSource').mockReturnValue('cdn'); + init({ dsn }); + + const sdkData = getClient()?.getOptions()._metadata?.sdk || {}; + + expect(sdkData.packages?.[0]?.name).toBe('cdn:@sentry/browser'); + expect(utils.getSDKSource).toBeCalledTimes(1); + spy.mockRestore(); + }); + it('should set SDK data when instantiating a client directly', () => { const options = getDefaultBrowserClientOptions({ dsn }); const client = new BrowserClient(options); diff --git a/packages/utils/src/env.ts b/packages/utils/src/env.ts index c8ad8cdf30b8..313f8c40ac24 100644 --- a/packages/utils/src/env.ts +++ b/packages/utils/src/env.ts @@ -15,6 +15,8 @@ declare const __SENTRY_BROWSER_BUNDLE__: boolean | undefined; +declare const __SENTRY_SDK_SOURCE__: SdkSource | undefined; + export type SdkSource = 'npm' | 'cdn' | 'loader'; /** @@ -25,3 +27,10 @@ export type SdkSource = 'npm' | 'cdn' | 'loader'; export function isBrowserBundle(): boolean { return typeof __SENTRY_BROWSER_BUNDLE__ !== 'undefined' && !!__SENTRY_BROWSER_BUNDLE__; } + +/** + * Get source of SDK. + */ +export function getSDKSource(): SdkSource { + return typeof __SENTRY_SDK_SOURCE__ !== 'undefined' ? __SENTRY_SDK_SOURCE__ : 'npm'; +} From 59d5575597a2a4f141c0dfc34035b3b96a761b39 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 27 Aug 2024 17:24:51 +0200 Subject: [PATCH 6/9] reduce bundle size??! --- dev-packages/rollup-utils/plugins/bundlePlugins.mjs | 3 ++- packages/utils/src/env.ts | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs index 2ce35d1e6168..b59348fc06ac 100644 --- a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs +++ b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs @@ -63,8 +63,9 @@ export function makeIsDebugBuildPlugin(includeDebugging) { export function makeSetSDKSourcePlugin(sdkSource) { return replace({ preventAssignment: false, + delimiters: ['', ''], values: { - __SENTRY_SDK_SOURCE__: JSON.stringify(sdkSource), + "/* ref:__SENTRY_SDK_SOURCE__ */": `return ${JSON.stringify(sdkSource)};`, }, }); } diff --git a/packages/utils/src/env.ts b/packages/utils/src/env.ts index 313f8c40ac24..be304080a0cf 100644 --- a/packages/utils/src/env.ts +++ b/packages/utils/src/env.ts @@ -15,8 +15,6 @@ declare const __SENTRY_BROWSER_BUNDLE__: boolean | undefined; -declare const __SENTRY_SDK_SOURCE__: SdkSource | undefined; - export type SdkSource = 'npm' | 'cdn' | 'loader'; /** @@ -32,5 +30,6 @@ export function isBrowserBundle(): boolean { * Get source of SDK. */ export function getSDKSource(): SdkSource { - return typeof __SENTRY_SDK_SOURCE__ !== 'undefined' ? __SENTRY_SDK_SOURCE__ : 'npm'; + // This comment is used to identify this line in the CDN bundle build step and replace this with "return 'cdn';" + /* ref:__SENTRY_SDK_SOURCE__ */ return 'npm'; } From f2ba18fe6ec8e021195700f7e356815fa92685b1 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 28 Aug 2024 08:39:15 +0200 Subject: [PATCH 7/9] fix formatting --- dev-packages/rollup-utils/plugins/bundlePlugins.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs index b59348fc06ac..2919a42d4d97 100644 --- a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs +++ b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs @@ -65,7 +65,7 @@ export function makeSetSDKSourcePlugin(sdkSource) { preventAssignment: false, delimiters: ['', ''], values: { - "/* ref:__SENTRY_SDK_SOURCE__ */": `return ${JSON.stringify(sdkSource)};`, + '/* ref:__SENTRY_SDK_SOURCE__ */': `return ${JSON.stringify(sdkSource)};`, }, }); } From c9358317b01f8a78bd96e121b92a9eaa0a170fa9 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 28 Aug 2024 11:36:10 +0200 Subject: [PATCH 8/9] fix test typo --- .../loader-suites/loader/noOnLoad/captureException/test.ts | 2 +- .../suites/public-api/captureException/simpleError/test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/captureException/test.ts b/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/captureException/test.ts index 43fcf3b985aa..4404dac91364 100644 --- a/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/captureException/test.ts +++ b/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/captureException/test.ts @@ -13,7 +13,7 @@ sentryTest('captureException works', async ({ getLocalTestUrl, page }) => { expect(eventData.message).toBe('Test exception'); }); -sentryTest('should capture a correct SDK metadata', async ({ getLocalTestUrl, page }) => { +sentryTest('should capture correct SDK metadata', async ({ getLocalTestUrl, page }) => { const url = await getLocalTestUrl({ testDir: __dirname }); const req = await waitForErrorRequestOnUrl(page, url); diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureException/simpleError/test.ts b/dev-packages/browser-integration-tests/suites/public-api/captureException/simpleError/test.ts index 956d2094861a..85f001849748 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/captureException/simpleError/test.ts +++ b/dev-packages/browser-integration-tests/suites/public-api/captureException/simpleError/test.ts @@ -23,7 +23,7 @@ sentryTest('should capture a simple error with message', async ({ getLocalTestUr }); }); -sentryTest('should capture a correct SDK metadata', async ({ getLocalTestUrl, page }) => { +sentryTest('should capture correct SDK metadata', async ({ getLocalTestUrl, page }) => { const isCdn = (process.env.PW_BUNDLE || '').startsWith('bundle'); const url = await getLocalTestUrl({ testDir: __dirname }); From df2fd99705ba1ba5c17f41babfe268bb40f67e4b Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 28 Aug 2024 11:37:07 +0200 Subject: [PATCH 9/9] tweak comment --- dev-packages/rollup-utils/plugins/bundlePlugins.mjs | 2 +- packages/utils/src/env.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs index 2919a42d4d97..a3e25c232479 100644 --- a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs +++ b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs @@ -65,7 +65,7 @@ export function makeSetSDKSourcePlugin(sdkSource) { preventAssignment: false, delimiters: ['', ''], values: { - '/* ref:__SENTRY_SDK_SOURCE__ */': `return ${JSON.stringify(sdkSource)};`, + '/* __SENTRY_SDK_SOURCE__ */': `return ${JSON.stringify(sdkSource)};`, }, }); } diff --git a/packages/utils/src/env.ts b/packages/utils/src/env.ts index be304080a0cf..b85c91c55a8d 100644 --- a/packages/utils/src/env.ts +++ b/packages/utils/src/env.ts @@ -31,5 +31,5 @@ export function isBrowserBundle(): boolean { */ export function getSDKSource(): SdkSource { // This comment is used to identify this line in the CDN bundle build step and replace this with "return 'cdn';" - /* ref:__SENTRY_SDK_SOURCE__ */ return 'npm'; + /* __SENTRY_SDK_SOURCE__ */ return 'npm'; }