From 4c51b7ac9d7cca891a64225adba9e7e163c1e6eb Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 19 Dec 2025 15:23:10 +0100 Subject: [PATCH 1/3] ref(core): Extract and reuse `getFinalScopeData` helper --- packages/core/src/index.ts | 2 +- packages/core/src/logs/internal.ts | 21 +------ packages/core/src/metrics/internal.ts | 22 ++------ packages/core/src/utils/prepareEvent.ts | 2 +- ...{applyScopeDataToEvent.ts => scopeData.ts} | 17 +++++- packages/core/test/lib/scope.test.ts | 2 +- ...eDataToEvent.test.ts => scopeData.test.ts} | 56 ++++++++++++++++++- 7 files changed, 79 insertions(+), 43 deletions(-) rename packages/core/src/utils/{applyScopeDataToEvent.ts => scopeData.ts} (91%) rename packages/core/test/lib/utils/{applyScopeDataToEvent.test.ts => scopeData.test.ts} (86%) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index e18ea294f182..d142f8764b1e 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -61,7 +61,7 @@ export { _INTERNAL_shouldSkipAiProviderWrapping, _INTERNAL_clearAiProviderSkips, } from './utils/ai/providerSkip'; -export { applyScopeDataToEvent, mergeScopeData } from './utils/applyScopeDataToEvent'; +export { applyScopeDataToEvent, mergeScopeData } from './utils/scopeData'; export { prepareEvent } from './utils/prepareEvent'; export type { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent'; export { createCheckInEnvelope } from './checkin'; diff --git a/packages/core/src/logs/internal.ts b/packages/core/src/logs/internal.ts index a39aa75d7074..d0915e17b670 100644 --- a/packages/core/src/logs/internal.ts +++ b/packages/core/src/logs/internal.ts @@ -1,14 +1,13 @@ import { serializeAttributes } from '../attributes'; import { getGlobalSingleton } from '../carrier'; import type { Client } from '../client'; -import { getClient, getCurrentScope, getGlobalScope, getIsolationScope } from '../currentScopes'; +import { getClient, getCurrentScope } from '../currentScopes'; import { DEBUG_BUILD } from '../debug-build'; -import type { Scope, ScopeData } from '../scope'; import type { Integration } from '../types-hoist/integration'; import type { Log, SerializedLog } from '../types-hoist/log'; -import { mergeScopeData } from '../utils/applyScopeDataToEvent'; import { consoleSandbox, debug } from '../utils/debug-logger'; import { isParameterizedString } from '../utils/is'; +import { getFinalScopeData } from '../utils/scopeData'; import { _getSpanForScope } from '../utils/spanOnScope'; import { timestampInSeconds } from '../utils/time'; import { _getTraceInfoFromScope } from '../utils/trace-info'; @@ -98,7 +97,7 @@ export function _INTERNAL_captureLog( const { user: { id, email, username }, attributes: scopeAttributes = {}, - } = getMergedScopeData(currentScope); + } = getFinalScopeData(currentScope); setLogAttribute(processedLogAttributes, 'user.id', id, false); setLogAttribute(processedLogAttributes, 'user.email', email, false); @@ -212,20 +211,6 @@ export function _INTERNAL_getLogBuffer(client: Client): Array | u return _getBufferMap().get(client); } -/** - * Get the scope data for the current scope after merging with the - * global scope and isolation scope. - * - * @param currentScope - The current scope. - * @returns The scope data. - */ -function getMergedScopeData(currentScope: Scope): ScopeData { - const scopeData = getGlobalScope().getScopeData(); - mergeScopeData(scopeData, getIsolationScope().getScopeData()); - mergeScopeData(scopeData, currentScope.getScopeData()); - return scopeData; -} - function _getBufferMap(): WeakMap> { // The reference to the Client <> LogBuffer map is stored on the carrier to ensure it's always the same return getGlobalSingleton('clientToLogBufferMap', () => new WeakMap>()); diff --git a/packages/core/src/metrics/internal.ts b/packages/core/src/metrics/internal.ts index 7ac1372d1285..9512c5648398 100644 --- a/packages/core/src/metrics/internal.ts +++ b/packages/core/src/metrics/internal.ts @@ -1,12 +1,12 @@ import { getGlobalSingleton } from '../carrier'; import type { Client } from '../client'; -import { getClient, getCurrentScope, getGlobalScope, getIsolationScope } from '../currentScopes'; +import { getClient, getCurrentScope } from '../currentScopes'; import { DEBUG_BUILD } from '../debug-build'; -import type { Scope, ScopeData } from '../scope'; +import type { Scope } from '../scope'; import type { Integration } from '../types-hoist/integration'; import type { Metric, SerializedMetric, SerializedMetricAttributeValue } from '../types-hoist/metric'; -import { mergeScopeData } from '../utils/applyScopeDataToEvent'; import { debug } from '../utils/debug-logger'; +import { getFinalScopeData } from '../utils/scopeData'; import { _getSpanForScope } from '../utils/spanOnScope'; import { timestampInSeconds } from '../utils/time'; import { _getTraceInfoFromScope } from '../utils/trace-info'; @@ -130,7 +130,7 @@ function _enrichMetricAttributes(beforeMetric: Metric, client: Client, currentSc // Add user attributes const { user: { id, email, username }, - } = getMergedScopeData(currentScope); + } = getFinalScopeData(currentScope); setMetricAttribute(processedMetricAttributes, 'user.id', id, false); setMetricAttribute(processedMetricAttributes, 'user.email', email, false); setMetricAttribute(processedMetricAttributes, 'user.name', username, false); @@ -288,20 +288,6 @@ export function _INTERNAL_getMetricBuffer(client: Client): Array> { // The reference to the Client <> MetricBuffer map is stored on the carrier to ensure it's always the same return getGlobalSingleton('clientToMetricBufferMap', () => new WeakMap>()); diff --git a/packages/core/src/utils/prepareEvent.ts b/packages/core/src/utils/prepareEvent.ts index fd1cb62440f4..d57f09c4158b 100644 --- a/packages/core/src/utils/prepareEvent.ts +++ b/packages/core/src/utils/prepareEvent.ts @@ -7,7 +7,7 @@ import { Scope } from '../scope'; import type { Event, EventHint } from '../types-hoist/event'; import type { ClientOptions } from '../types-hoist/options'; import type { StackParser } from '../types-hoist/stacktrace'; -import { applyScopeDataToEvent, mergeScopeData } from './applyScopeDataToEvent'; +import { applyScopeDataToEvent, mergeScopeData } from './scopeData'; import { getFilenameToDebugIdMap } from './debug-ids'; import { addExceptionMechanism, uuid4 } from './misc'; import { normalize } from './normalize'; diff --git a/packages/core/src/utils/applyScopeDataToEvent.ts b/packages/core/src/utils/scopeData.ts similarity index 91% rename from packages/core/src/utils/applyScopeDataToEvent.ts rename to packages/core/src/utils/scopeData.ts index 3770c41977dc..9da76812831c 100644 --- a/packages/core/src/utils/applyScopeDataToEvent.ts +++ b/packages/core/src/utils/scopeData.ts @@ -1,4 +1,5 @@ -import type { ScopeData } from '../scope'; +import { getGlobalScope, getIsolationScope } from '../currentScopes'; +import type { Scope, ScopeData } from '../scope'; import { getDynamicSamplingContextFromSpan } from '../tracing/dynamicSamplingContext'; import type { Breadcrumb } from '../types-hoist/breadcrumb'; import type { Event } from '../types-hoist/event'; @@ -113,6 +114,20 @@ export function mergeArray( event[prop] = merged.length ? merged : undefined; } +/** + * Get the scope data for the current scope after merging with the + * global scope and isolation scope. + * + * @param currentScope - The current scope. + * @returns The scope data. + */ +export function getFinalScopeData(currentScope: Scope): ScopeData { + const scopeData = getGlobalScope().getScopeData(); + mergeScopeData(scopeData, getIsolationScope().getScopeData()); + mergeScopeData(scopeData, currentScope.getScopeData()); + return scopeData; +} + function applyDataToEvent(event: Event, data: ScopeData): void { const { extra, tags, user, contexts, level, transactionName } = data; diff --git a/packages/core/test/lib/scope.test.ts b/packages/core/test/lib/scope.test.ts index 339a57828e5b..f1e5c58550be 100644 --- a/packages/core/test/lib/scope.test.ts +++ b/packages/core/test/lib/scope.test.ts @@ -10,7 +10,7 @@ import { import { Scope } from '../../src/scope'; import type { Breadcrumb } from '../../src/types-hoist/breadcrumb'; import type { Event } from '../../src/types-hoist/event'; -import { applyScopeDataToEvent } from '../../src/utils/applyScopeDataToEvent'; +import { applyScopeDataToEvent } from '../../src/utils/scopeData'; import { getDefaultTestClientOptions, TestClient } from '../mocks/client'; import { clearGlobalScope } from '../testutils'; diff --git a/packages/core/test/lib/utils/applyScopeDataToEvent.test.ts b/packages/core/test/lib/utils/scopeData.test.ts similarity index 86% rename from packages/core/test/lib/utils/applyScopeDataToEvent.test.ts rename to packages/core/test/lib/utils/scopeData.test.ts index a23404eaf70f..37bb7d9d44a0 100644 --- a/packages/core/test/lib/utils/applyScopeDataToEvent.test.ts +++ b/packages/core/test/lib/utils/scopeData.test.ts @@ -1,16 +1,18 @@ -import { describe, expect, it } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; import type { ScopeData } from '../../../src'; -import { startInactiveSpan } from '../../../src'; +import { Scope, startInactiveSpan } from '../../../src'; +import * as currentScopes from '../../../src/currentScopes'; import type { Attachment } from '../../../src/types-hoist/attachment'; import type { Breadcrumb } from '../../../src/types-hoist/breadcrumb'; import type { Event, EventType } from '../../../src/types-hoist/event'; import type { EventProcessor } from '../../../src/types-hoist/eventprocessor'; import { applyScopeDataToEvent, + getFinalScopeData, mergeAndOverwriteScopeData, mergeArray, mergeScopeData, -} from '../../../src/utils/applyScopeDataToEvent'; +} from '../../../src/utils/scopeData'; describe('mergeArray', () => { it.each([ @@ -353,3 +355,51 @@ describe('applyScopeDataToEvent', () => { }, ); }); + +describe('getFinalScopeData', () => { + const globalScope = new Scope(); + const isolationScope = new Scope(); + const currentScope = new Scope(); + + it('returns the combined scope data with correct precedence', () => { + globalScope.setTag('foo', 'bar'); + globalScope.setTag('dogs', 'boring'); + globalScope.setTag('global', 'global'); + + isolationScope.setTag('dogs', 'great'); + isolationScope.setTag('foo', 'nope'); + isolationScope.setTag('isolation', 'isolation'); + + currentScope.setTag('foo', 'baz'); + currentScope.setTag('current', 'current'); + + vi.spyOn(currentScopes, 'getGlobalScope').mockReturnValue(globalScope); + vi.spyOn(currentScopes, 'getIsolationScope').mockReturnValue(isolationScope); + + expect(getFinalScopeData(currentScope)).toEqual({ + attachments: [], + attributes: {}, + breadcrumbs: [], + contexts: {}, + eventProcessors: [], + extra: {}, + fingerprint: [], + level: undefined, + propagationContext: { + sampleRand: expect.any(Number), + traceId: expect.any(String), + }, + sdkProcessingMetadata: {}, + span: undefined, + tags: { + current: 'current', + global: 'global', + isolation: 'isolation', + foo: 'baz', + dogs: 'great', + }, + transactionName: undefined, + user: {}, + }); + }); +}); From 13113065d8bd87146cba6baa672b792b288916f3 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 19 Dec 2025 16:20:00 +0100 Subject: [PATCH 2/3] reuse it in other places --- .size-limit.js | 546 +++++++++--------- packages/core/src/index.ts | 2 +- packages/core/src/logs/internal.ts | 6 +- packages/core/src/metrics/internal.ts | 6 +- packages/core/src/utils/prepareEvent.ts | 15 +- packages/core/src/utils/scopeData.ts | 8 +- .../core/test/lib/utils/scopeData.test.ts | 7 +- .../node-core/src/integrations/anr/index.ts | 7 +- 8 files changed, 291 insertions(+), 306 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index 24772d8380f5..05d56ea9603c 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -3,122 +3,122 @@ const nodePrefixedBuiltinModules = builtinModules.map(m => `node:${m}`); module.exports = [ // Browser SDK (ESM) - { - name: '@sentry/browser', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init'), - gzip: true, - limit: '25 KB', - }, - { - name: '@sentry/browser - with treeshaking flags', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init'), - gzip: true, - limit: '24.1 KB', - modifyWebpackConfig: function (config) { - const webpack = require('webpack'); + // { + // name: '@sentry/browser', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init'), + // gzip: true, + // limit: '25 KB', + // }, + // { + // name: '@sentry/browser - with treeshaking flags', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init'), + // gzip: true, + // limit: '24.1 KB', + // modifyWebpackConfig: function (config) { + // const webpack = require('webpack'); - config.plugins.push( - new webpack.DefinePlugin({ - __SENTRY_DEBUG__: false, - __RRWEB_EXCLUDE_SHADOW_DOM__: true, - __RRWEB_EXCLUDE_IFRAME__: true, - __SENTRY_EXCLUDE_REPLAY_WORKER__: true, - }), - ); + // config.plugins.push( + // new webpack.DefinePlugin({ + // __SENTRY_DEBUG__: false, + // __RRWEB_EXCLUDE_SHADOW_DOM__: true, + // __RRWEB_EXCLUDE_IFRAME__: true, + // __SENTRY_EXCLUDE_REPLAY_WORKER__: true, + // }), + // ); - config.optimization.minimize = true; + // config.optimization.minimize = true; - return config; - }, - }, - { - name: '@sentry/browser (incl. Tracing)', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init', 'browserTracingIntegration'), - gzip: true, - limit: '42 KB', - }, - { - name: '@sentry/browser (incl. Tracing, Profiling)', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init', 'browserTracingIntegration', 'browserProfilingIntegration'), - gzip: true, - limit: '48 KB', - }, - { - name: '@sentry/browser (incl. Tracing, Replay)', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init', 'browserTracingIntegration', 'replayIntegration'), - gzip: true, - limit: '82 KB', - }, - { - name: '@sentry/browser (incl. Tracing, Replay) - with treeshaking flags', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init', 'browserTracingIntegration', 'replayIntegration'), - gzip: true, - limit: '75 KB', - modifyWebpackConfig: function (config) { - const webpack = require('webpack'); + // return config; + // }, + // }, + // { + // name: '@sentry/browser (incl. Tracing)', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init', 'browserTracingIntegration'), + // gzip: true, + // limit: '42 KB', + // }, + // { + // name: '@sentry/browser (incl. Tracing, Profiling)', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init', 'browserTracingIntegration', 'browserProfilingIntegration'), + // gzip: true, + // limit: '48 KB', + // }, + // { + // name: '@sentry/browser (incl. Tracing, Replay)', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init', 'browserTracingIntegration', 'replayIntegration'), + // gzip: true, + // limit: '82 KB', + // }, + // { + // name: '@sentry/browser (incl. Tracing, Replay) - with treeshaking flags', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init', 'browserTracingIntegration', 'replayIntegration'), + // gzip: true, + // limit: '75 KB', + // modifyWebpackConfig: function (config) { + // const webpack = require('webpack'); - config.plugins.push( - new webpack.DefinePlugin({ - __SENTRY_DEBUG__: false, - __RRWEB_EXCLUDE_SHADOW_DOM__: true, - __RRWEB_EXCLUDE_IFRAME__: true, - __SENTRY_EXCLUDE_REPLAY_WORKER__: true, - }), - ); + // config.plugins.push( + // new webpack.DefinePlugin({ + // __SENTRY_DEBUG__: false, + // __RRWEB_EXCLUDE_SHADOW_DOM__: true, + // __RRWEB_EXCLUDE_IFRAME__: true, + // __SENTRY_EXCLUDE_REPLAY_WORKER__: true, + // }), + // ); - config.optimization.minimize = true; + // config.optimization.minimize = true; - return config; - }, - }, - { - name: '@sentry/browser (incl. Tracing, Replay with Canvas)', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'replayCanvasIntegration'), - gzip: true, - limit: '85 KB', - }, - { - name: '@sentry/browser (incl. Tracing, Replay, Feedback)', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'feedbackIntegration'), - gzip: true, - limit: '98 KB', - }, - { - name: '@sentry/browser (incl. Feedback)', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init', 'feedbackIntegration'), - gzip: true, - limit: '42 KB', - }, - { - name: '@sentry/browser (incl. sendFeedback)', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init', 'sendFeedback'), - gzip: true, - limit: '30 KB', - }, - { - name: '@sentry/browser (incl. FeedbackAsync)', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init', 'feedbackAsyncIntegration'), - gzip: true, - limit: '35 KB', - }, - { - name: '@sentry/browser (incl. Metrics)', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init', 'metrics'), - gzip: true, - limit: '27 KB', - }, + // return config; + // }, + // }, + // { + // name: '@sentry/browser (incl. Tracing, Replay with Canvas)', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'replayCanvasIntegration'), + // gzip: true, + // limit: '85 KB', + // }, + // { + // name: '@sentry/browser (incl. Tracing, Replay, Feedback)', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'feedbackIntegration'), + // gzip: true, + // limit: '98 KB', + // }, + // { + // name: '@sentry/browser (incl. Feedback)', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init', 'feedbackIntegration'), + // gzip: true, + // limit: '42 KB', + // }, + // { + // name: '@sentry/browser (incl. sendFeedback)', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init', 'sendFeedback'), + // gzip: true, + // limit: '30 KB', + // }, + // { + // name: '@sentry/browser (incl. FeedbackAsync)', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init', 'feedbackAsyncIntegration'), + // gzip: true, + // limit: '35 KB', + // }, + // { + // name: '@sentry/browser (incl. Metrics)', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init', 'metrics'), + // gzip: true, + // limit: '27 KB', + // }, { name: '@sentry/browser (incl. Logs)', path: 'packages/browser/build/npm/esm/prod/index.js', @@ -126,173 +126,173 @@ module.exports = [ gzip: true, limit: '27 KB', }, - { - name: '@sentry/browser (incl. Metrics & Logs)', - path: 'packages/browser/build/npm/esm/prod/index.js', - import: createImport('init', 'metrics', 'logger'), - gzip: true, - limit: '28 KB', - }, + // { + // name: '@sentry/browser (incl. Metrics & Logs)', + // path: 'packages/browser/build/npm/esm/prod/index.js', + // import: createImport('init', 'metrics', 'logger'), + // gzip: true, + // limit: '28 KB', + // }, // React SDK (ESM) - { - name: '@sentry/react', - path: 'packages/react/build/esm/index.js', - import: createImport('init', 'ErrorBoundary'), - ignore: ['react/jsx-runtime'], - gzip: true, - limit: '27 KB', - }, - { - name: '@sentry/react (incl. Tracing)', - path: 'packages/react/build/esm/index.js', - import: createImport('init', 'ErrorBoundary', 'reactRouterV6BrowserTracingIntegration'), - ignore: ['react/jsx-runtime'], - gzip: true, - limit: '44 KB', - }, - // Vue SDK (ESM) - { - name: '@sentry/vue', - path: 'packages/vue/build/esm/index.js', - import: createImport('init'), - gzip: true, - limit: '30 KB', - }, - { - name: '@sentry/vue (incl. Tracing)', - path: 'packages/vue/build/esm/index.js', - import: createImport('init', 'browserTracingIntegration'), - gzip: true, - limit: '44 KB', - }, - // Svelte SDK (ESM) - { - name: '@sentry/svelte', - path: 'packages/svelte/build/esm/index.js', - import: createImport('init'), - gzip: true, - limit: '25 KB', - }, - // Browser CDN bundles - { - name: 'CDN Bundle', - path: createCDNPath('bundle.min.js'), - gzip: true, - limit: '27.5 KB', - }, - { - name: 'CDN Bundle (incl. Tracing)', - path: createCDNPath('bundle.tracing.min.js'), - gzip: true, - limit: '42.5 KB', - }, - { - name: 'CDN Bundle (incl. Tracing, Replay)', - path: createCDNPath('bundle.tracing.replay.min.js'), - gzip: true, - limit: '80 KB', - }, - { - name: 'CDN Bundle (incl. Tracing, Replay, Feedback)', - path: createCDNPath('bundle.tracing.replay.feedback.min.js'), - gzip: true, - limit: '86 KB', - }, - // browser CDN bundles (non-gzipped) - { - name: 'CDN Bundle - uncompressed', - path: createCDNPath('bundle.min.js'), - gzip: false, - brotli: false, - limit: '82 KB', - }, - { - name: 'CDN Bundle (incl. Tracing) - uncompressed', - path: createCDNPath('bundle.tracing.min.js'), - gzip: false, - brotli: false, - limit: '127 KB', - }, - { - name: 'CDN Bundle (incl. Tracing, Replay) - uncompressed', - path: createCDNPath('bundle.tracing.replay.min.js'), - gzip: false, - brotli: false, - limit: '245 KB', - }, - { - name: 'CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed', - path: createCDNPath('bundle.tracing.replay.feedback.min.js'), - gzip: false, - brotli: false, - limit: '264 KB', - }, - // Next.js SDK (ESM) - { - name: '@sentry/nextjs (client)', - path: 'packages/nextjs/build/esm/client/index.js', - import: createImport('init'), - ignore: ['next/router', 'next/constants'], - gzip: true, - limit: '46.5 KB', - }, - // SvelteKit SDK (ESM) - { - name: '@sentry/sveltekit (client)', - path: 'packages/sveltekit/build/esm/client/index.js', - import: createImport('init'), - ignore: ['$app/stores'], - gzip: true, - limit: '42 KB', - }, - // Node-Core SDK (ESM) - { - name: '@sentry/node-core', - path: 'packages/node-core/build/esm/index.js', - import: createImport('init'), - ignore: [...builtinModules, ...nodePrefixedBuiltinModules], - gzip: true, - limit: '52 KB', - }, - // Node SDK (ESM) - { - name: '@sentry/node', - path: 'packages/node/build/esm/index.js', - import: createImport('init'), - ignore: [...builtinModules, ...nodePrefixedBuiltinModules], - gzip: true, - limit: '162 KB', - }, - { - name: '@sentry/node - without tracing', - path: 'packages/node/build/esm/index.js', - import: createImport('initWithoutDefaultIntegrations', 'getDefaultIntegrationsWithoutPerformance'), - gzip: true, - limit: '95 KB', - ignore: [...builtinModules, ...nodePrefixedBuiltinModules], - modifyWebpackConfig: function (config) { - const webpack = require('webpack'); + // { + // name: '@sentry/react', + // path: 'packages/react/build/esm/index.js', + // import: createImport('init', 'ErrorBoundary'), + // ignore: ['react/jsx-runtime'], + // gzip: true, + // limit: '27 KB', + // }, + // { + // name: '@sentry/react (incl. Tracing)', + // path: 'packages/react/build/esm/index.js', + // import: createImport('init', 'ErrorBoundary', 'reactRouterV6BrowserTracingIntegration'), + // ignore: ['react/jsx-runtime'], + // gzip: true, + // limit: '44 KB', + // }, + // // Vue SDK (ESM) + // { + // name: '@sentry/vue', + // path: 'packages/vue/build/esm/index.js', + // import: createImport('init'), + // gzip: true, + // limit: '30 KB', + // }, + // { + // name: '@sentry/vue (incl. Tracing)', + // path: 'packages/vue/build/esm/index.js', + // import: createImport('init', 'browserTracingIntegration'), + // gzip: true, + // limit: '44 KB', + // }, + // // Svelte SDK (ESM) + // { + // name: '@sentry/svelte', + // path: 'packages/svelte/build/esm/index.js', + // import: createImport('init'), + // gzip: true, + // limit: '25 KB', + // }, + // // Browser CDN bundles + // { + // name: 'CDN Bundle', + // path: createCDNPath('bundle.min.js'), + // gzip: true, + // limit: '27.5 KB', + // }, + // { + // name: 'CDN Bundle (incl. Tracing)', + // path: createCDNPath('bundle.tracing.min.js'), + // gzip: true, + // limit: '42.5 KB', + // }, + // { + // name: 'CDN Bundle (incl. Tracing, Replay)', + // path: createCDNPath('bundle.tracing.replay.min.js'), + // gzip: true, + // limit: '80 KB', + // }, + // { + // name: 'CDN Bundle (incl. Tracing, Replay, Feedback)', + // path: createCDNPath('bundle.tracing.replay.feedback.min.js'), + // gzip: true, + // limit: '86 KB', + // }, + // // browser CDN bundles (non-gzipped) + // { + // name: 'CDN Bundle - uncompressed', + // path: createCDNPath('bundle.min.js'), + // gzip: false, + // brotli: false, + // limit: '82 KB', + // }, + // { + // name: 'CDN Bundle (incl. Tracing) - uncompressed', + // path: createCDNPath('bundle.tracing.min.js'), + // gzip: false, + // brotli: false, + // limit: '127 KB', + // }, + // { + // name: 'CDN Bundle (incl. Tracing, Replay) - uncompressed', + // path: createCDNPath('bundle.tracing.replay.min.js'), + // gzip: false, + // brotli: false, + // limit: '245 KB', + // }, + // { + // name: 'CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed', + // path: createCDNPath('bundle.tracing.replay.feedback.min.js'), + // gzip: false, + // brotli: false, + // limit: '264 KB', + // }, + // // Next.js SDK (ESM) + // { + // name: '@sentry/nextjs (client)', + // path: 'packages/nextjs/build/esm/client/index.js', + // import: createImport('init'), + // ignore: ['next/router', 'next/constants'], + // gzip: true, + // limit: '46.5 KB', + // }, + // // SvelteKit SDK (ESM) + // { + // name: '@sentry/sveltekit (client)', + // path: 'packages/sveltekit/build/esm/client/index.js', + // import: createImport('init'), + // ignore: ['$app/stores'], + // gzip: true, + // limit: '42 KB', + // }, + // // Node-Core SDK (ESM) + // { + // name: '@sentry/node-core', + // path: 'packages/node-core/build/esm/index.js', + // import: createImport('init'), + // ignore: [...builtinModules, ...nodePrefixedBuiltinModules], + // gzip: true, + // limit: '52 KB', + // }, + // // Node SDK (ESM) + // { + // name: '@sentry/node', + // path: 'packages/node/build/esm/index.js', + // import: createImport('init'), + // ignore: [...builtinModules, ...nodePrefixedBuiltinModules], + // gzip: true, + // limit: '162 KB', + // }, + // { + // name: '@sentry/node - without tracing', + // path: 'packages/node/build/esm/index.js', + // import: createImport('initWithoutDefaultIntegrations', 'getDefaultIntegrationsWithoutPerformance'), + // gzip: true, + // limit: '95 KB', + // ignore: [...builtinModules, ...nodePrefixedBuiltinModules], + // modifyWebpackConfig: function (config) { + // const webpack = require('webpack'); - config.plugins.push( - new webpack.DefinePlugin({ - __SENTRY_TRACING__: false, - }), - ); + // config.plugins.push( + // new webpack.DefinePlugin({ + // __SENTRY_TRACING__: false, + // }), + // ); - config.optimization.minimize = true; + // config.optimization.minimize = true; - return config; - }, - }, - // AWS SDK (ESM) - { - name: '@sentry/aws-serverless', - path: 'packages/aws-serverless/build/npm/esm/index.js', - import: createImport('init'), - ignore: [...builtinModules, ...nodePrefixedBuiltinModules], - gzip: true, - limit: '111 KB', - }, + // return config; + // }, + // }, + // // AWS SDK (ESM) + // { + // name: '@sentry/aws-serverless', + // path: 'packages/aws-serverless/build/npm/esm/index.js', + // import: createImport('init'), + // ignore: [...builtinModules, ...nodePrefixedBuiltinModules], + // gzip: true, + // limit: '111 KB', + // }, ]; function createImport(...args) { diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index d142f8764b1e..c4884edf939b 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -61,7 +61,7 @@ export { _INTERNAL_shouldSkipAiProviderWrapping, _INTERNAL_clearAiProviderSkips, } from './utils/ai/providerSkip'; -export { applyScopeDataToEvent, mergeScopeData } from './utils/scopeData'; +export { applyScopeDataToEvent, mergeScopeData, getCombinedScopeData } from './utils/scopeData'; export { prepareEvent } from './utils/prepareEvent'; export type { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent'; export { createCheckInEnvelope } from './checkin'; diff --git a/packages/core/src/logs/internal.ts b/packages/core/src/logs/internal.ts index d0915e17b670..3408b01a5f96 100644 --- a/packages/core/src/logs/internal.ts +++ b/packages/core/src/logs/internal.ts @@ -1,13 +1,13 @@ import { serializeAttributes } from '../attributes'; import { getGlobalSingleton } from '../carrier'; import type { Client } from '../client'; -import { getClient, getCurrentScope } from '../currentScopes'; +import { getClient, getCurrentScope, getIsolationScope } from '../currentScopes'; import { DEBUG_BUILD } from '../debug-build'; import type { Integration } from '../types-hoist/integration'; import type { Log, SerializedLog } from '../types-hoist/log'; import { consoleSandbox, debug } from '../utils/debug-logger'; import { isParameterizedString } from '../utils/is'; -import { getFinalScopeData } from '../utils/scopeData'; +import { getCombinedScopeData } from '../utils/scopeData'; import { _getSpanForScope } from '../utils/spanOnScope'; import { timestampInSeconds } from '../utils/time'; import { _getTraceInfoFromScope } from '../utils/trace-info'; @@ -97,7 +97,7 @@ export function _INTERNAL_captureLog( const { user: { id, email, username }, attributes: scopeAttributes = {}, - } = getFinalScopeData(currentScope); + } = getCombinedScopeData(getIsolationScope(), currentScope); setLogAttribute(processedLogAttributes, 'user.id', id, false); setLogAttribute(processedLogAttributes, 'user.email', email, false); diff --git a/packages/core/src/metrics/internal.ts b/packages/core/src/metrics/internal.ts index 9512c5648398..db98c476fff7 100644 --- a/packages/core/src/metrics/internal.ts +++ b/packages/core/src/metrics/internal.ts @@ -1,12 +1,12 @@ import { getGlobalSingleton } from '../carrier'; import type { Client } from '../client'; -import { getClient, getCurrentScope } from '../currentScopes'; +import { getClient, getCurrentScope, getIsolationScope } from '../currentScopes'; import { DEBUG_BUILD } from '../debug-build'; import type { Scope } from '../scope'; import type { Integration } from '../types-hoist/integration'; import type { Metric, SerializedMetric, SerializedMetricAttributeValue } from '../types-hoist/metric'; import { debug } from '../utils/debug-logger'; -import { getFinalScopeData } from '../utils/scopeData'; +import { getCombinedScopeData } from '../utils/scopeData'; import { _getSpanForScope } from '../utils/spanOnScope'; import { timestampInSeconds } from '../utils/time'; import { _getTraceInfoFromScope } from '../utils/trace-info'; @@ -130,7 +130,7 @@ function _enrichMetricAttributes(beforeMetric: Metric, client: Client, currentSc // Add user attributes const { user: { id, email, username }, - } = getFinalScopeData(currentScope); + } = getCombinedScopeData(getIsolationScope(), currentScope); setMetricAttribute(processedMetricAttributes, 'user.id', id, false); setMetricAttribute(processedMetricAttributes, 'user.email', email, false); setMetricAttribute(processedMetricAttributes, 'user.name', username, false); diff --git a/packages/core/src/utils/prepareEvent.ts b/packages/core/src/utils/prepareEvent.ts index d57f09c4158b..3a127d332686 100644 --- a/packages/core/src/utils/prepareEvent.ts +++ b/packages/core/src/utils/prepareEvent.ts @@ -1,16 +1,15 @@ import type { Client } from '../client'; import { DEFAULT_ENVIRONMENT } from '../constants'; -import { getGlobalScope } from '../currentScopes'; import { notifyEventProcessors } from '../eventProcessors'; import type { CaptureContext, ScopeContext } from '../scope'; import { Scope } from '../scope'; import type { Event, EventHint } from '../types-hoist/event'; import type { ClientOptions } from '../types-hoist/options'; import type { StackParser } from '../types-hoist/stacktrace'; -import { applyScopeDataToEvent, mergeScopeData } from './scopeData'; import { getFilenameToDebugIdMap } from './debug-ids'; import { addExceptionMechanism, uuid4 } from './misc'; import { normalize } from './normalize'; +import { applyScopeDataToEvent, getCombinedScopeData } from './scopeData'; import { truncate } from './string'; import { dateTimestampInSeconds } from './time'; @@ -79,17 +78,7 @@ export function prepareEvent( // This should be the last thing called, since we want that // {@link Scope.addEventProcessor} gets the finished prepared event. // Merge scope data together - const data = getGlobalScope().getScopeData(); - - if (isolationScope) { - const isolationData = isolationScope.getScopeData(); - mergeScopeData(data, isolationData); - } - - if (finalScope) { - const finalScopeData = finalScope.getScopeData(); - mergeScopeData(data, finalScopeData); - } + const data = getCombinedScopeData(isolationScope, finalScope); const attachments = [...(hint.attachments || []), ...data.attachments]; if (attachments.length) { diff --git a/packages/core/src/utils/scopeData.ts b/packages/core/src/utils/scopeData.ts index 9da76812831c..6d8f68c747b5 100644 --- a/packages/core/src/utils/scopeData.ts +++ b/packages/core/src/utils/scopeData.ts @@ -1,4 +1,4 @@ -import { getGlobalScope, getIsolationScope } from '../currentScopes'; +import { getGlobalScope } from '../currentScopes'; import type { Scope, ScopeData } from '../scope'; import { getDynamicSamplingContextFromSpan } from '../tracing/dynamicSamplingContext'; import type { Breadcrumb } from '../types-hoist/breadcrumb'; @@ -121,10 +121,10 @@ export function mergeArray( * @param currentScope - The current scope. * @returns The scope data. */ -export function getFinalScopeData(currentScope: Scope): ScopeData { +export function getCombinedScopeData(isolationScope: Scope | undefined, currentScope: Scope | undefined): ScopeData { const scopeData = getGlobalScope().getScopeData(); - mergeScopeData(scopeData, getIsolationScope().getScopeData()); - mergeScopeData(scopeData, currentScope.getScopeData()); + isolationScope && mergeScopeData(scopeData, isolationScope.getScopeData()); + currentScope && mergeScopeData(scopeData, currentScope.getScopeData()); return scopeData; } diff --git a/packages/core/test/lib/utils/scopeData.test.ts b/packages/core/test/lib/utils/scopeData.test.ts index 37bb7d9d44a0..50af1179a4c4 100644 --- a/packages/core/test/lib/utils/scopeData.test.ts +++ b/packages/core/test/lib/utils/scopeData.test.ts @@ -8,7 +8,7 @@ import type { Event, EventType } from '../../../src/types-hoist/event'; import type { EventProcessor } from '../../../src/types-hoist/eventprocessor'; import { applyScopeDataToEvent, - getFinalScopeData, + getCombinedScopeData, mergeAndOverwriteScopeData, mergeArray, mergeScopeData, @@ -356,7 +356,7 @@ describe('applyScopeDataToEvent', () => { ); }); -describe('getFinalScopeData', () => { +describe('getCombinedScopeData', () => { const globalScope = new Scope(); const isolationScope = new Scope(); const currentScope = new Scope(); @@ -374,9 +374,8 @@ describe('getFinalScopeData', () => { currentScope.setTag('current', 'current'); vi.spyOn(currentScopes, 'getGlobalScope').mockReturnValue(globalScope); - vi.spyOn(currentScopes, 'getIsolationScope').mockReturnValue(isolationScope); - expect(getFinalScopeData(currentScope)).toEqual({ + expect(getCombinedScopeData(isolationScope, currentScope)).toEqual({ attachments: [], attributes: {}, breadcrumbs: [], diff --git a/packages/node-core/src/integrations/anr/index.ts b/packages/node-core/src/integrations/anr/index.ts index e33c92a1eb3b..e2207f9379c7 100644 --- a/packages/node-core/src/integrations/anr/index.ts +++ b/packages/node-core/src/integrations/anr/index.ts @@ -5,12 +5,11 @@ import { debug, defineIntegration, getClient, + getCombinedScopeData, getCurrentScope, getFilenameToDebugIdMap, - getGlobalScope, getIsolationScope, GLOBAL_OBJ, - mergeScopeData, } from '@sentry/core'; import { NODE_VERSION } from '../../nodeVersion'; import type { NodeClient } from '../../sdk/client'; @@ -35,9 +34,7 @@ function globalWithScopeFetchFn(): typeof GLOBAL_OBJ & { __SENTRY_GET_SCOPES__?: /** Fetches merged scope data */ function getScopeData(): ScopeData { - const scope = getGlobalScope().getScopeData(); - mergeScopeData(scope, getIsolationScope().getScopeData()); - mergeScopeData(scope, getCurrentScope().getScopeData()); + const scope = getCombinedScopeData(getIsolationScope(), getCurrentScope()); // We remove attachments because they likely won't serialize well as json scope.attachments = []; From 1e4ad6f1049999380d14327aeaf7973740fdfd63 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 19 Dec 2025 16:45:22 +0100 Subject: [PATCH 3/3] whoops --- .size-limit.js | 546 ++++++++++++++++++++++++------------------------- 1 file changed, 273 insertions(+), 273 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index 05d56ea9603c..24772d8380f5 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -3,122 +3,122 @@ const nodePrefixedBuiltinModules = builtinModules.map(m => `node:${m}`); module.exports = [ // Browser SDK (ESM) - // { - // name: '@sentry/browser', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init'), - // gzip: true, - // limit: '25 KB', - // }, - // { - // name: '@sentry/browser - with treeshaking flags', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init'), - // gzip: true, - // limit: '24.1 KB', - // modifyWebpackConfig: function (config) { - // const webpack = require('webpack'); + { + name: '@sentry/browser', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init'), + gzip: true, + limit: '25 KB', + }, + { + name: '@sentry/browser - with treeshaking flags', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init'), + gzip: true, + limit: '24.1 KB', + modifyWebpackConfig: function (config) { + const webpack = require('webpack'); - // config.plugins.push( - // new webpack.DefinePlugin({ - // __SENTRY_DEBUG__: false, - // __RRWEB_EXCLUDE_SHADOW_DOM__: true, - // __RRWEB_EXCLUDE_IFRAME__: true, - // __SENTRY_EXCLUDE_REPLAY_WORKER__: true, - // }), - // ); + config.plugins.push( + new webpack.DefinePlugin({ + __SENTRY_DEBUG__: false, + __RRWEB_EXCLUDE_SHADOW_DOM__: true, + __RRWEB_EXCLUDE_IFRAME__: true, + __SENTRY_EXCLUDE_REPLAY_WORKER__: true, + }), + ); - // config.optimization.minimize = true; + config.optimization.minimize = true; - // return config; - // }, - // }, - // { - // name: '@sentry/browser (incl. Tracing)', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init', 'browserTracingIntegration'), - // gzip: true, - // limit: '42 KB', - // }, - // { - // name: '@sentry/browser (incl. Tracing, Profiling)', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init', 'browserTracingIntegration', 'browserProfilingIntegration'), - // gzip: true, - // limit: '48 KB', - // }, - // { - // name: '@sentry/browser (incl. Tracing, Replay)', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init', 'browserTracingIntegration', 'replayIntegration'), - // gzip: true, - // limit: '82 KB', - // }, - // { - // name: '@sentry/browser (incl. Tracing, Replay) - with treeshaking flags', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init', 'browserTracingIntegration', 'replayIntegration'), - // gzip: true, - // limit: '75 KB', - // modifyWebpackConfig: function (config) { - // const webpack = require('webpack'); + return config; + }, + }, + { + name: '@sentry/browser (incl. Tracing)', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init', 'browserTracingIntegration'), + gzip: true, + limit: '42 KB', + }, + { + name: '@sentry/browser (incl. Tracing, Profiling)', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init', 'browserTracingIntegration', 'browserProfilingIntegration'), + gzip: true, + limit: '48 KB', + }, + { + name: '@sentry/browser (incl. Tracing, Replay)', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init', 'browserTracingIntegration', 'replayIntegration'), + gzip: true, + limit: '82 KB', + }, + { + name: '@sentry/browser (incl. Tracing, Replay) - with treeshaking flags', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init', 'browserTracingIntegration', 'replayIntegration'), + gzip: true, + limit: '75 KB', + modifyWebpackConfig: function (config) { + const webpack = require('webpack'); - // config.plugins.push( - // new webpack.DefinePlugin({ - // __SENTRY_DEBUG__: false, - // __RRWEB_EXCLUDE_SHADOW_DOM__: true, - // __RRWEB_EXCLUDE_IFRAME__: true, - // __SENTRY_EXCLUDE_REPLAY_WORKER__: true, - // }), - // ); + config.plugins.push( + new webpack.DefinePlugin({ + __SENTRY_DEBUG__: false, + __RRWEB_EXCLUDE_SHADOW_DOM__: true, + __RRWEB_EXCLUDE_IFRAME__: true, + __SENTRY_EXCLUDE_REPLAY_WORKER__: true, + }), + ); - // config.optimization.minimize = true; + config.optimization.minimize = true; - // return config; - // }, - // }, - // { - // name: '@sentry/browser (incl. Tracing, Replay with Canvas)', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'replayCanvasIntegration'), - // gzip: true, - // limit: '85 KB', - // }, - // { - // name: '@sentry/browser (incl. Tracing, Replay, Feedback)', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'feedbackIntegration'), - // gzip: true, - // limit: '98 KB', - // }, - // { - // name: '@sentry/browser (incl. Feedback)', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init', 'feedbackIntegration'), - // gzip: true, - // limit: '42 KB', - // }, - // { - // name: '@sentry/browser (incl. sendFeedback)', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init', 'sendFeedback'), - // gzip: true, - // limit: '30 KB', - // }, - // { - // name: '@sentry/browser (incl. FeedbackAsync)', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init', 'feedbackAsyncIntegration'), - // gzip: true, - // limit: '35 KB', - // }, - // { - // name: '@sentry/browser (incl. Metrics)', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init', 'metrics'), - // gzip: true, - // limit: '27 KB', - // }, + return config; + }, + }, + { + name: '@sentry/browser (incl. Tracing, Replay with Canvas)', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'replayCanvasIntegration'), + gzip: true, + limit: '85 KB', + }, + { + name: '@sentry/browser (incl. Tracing, Replay, Feedback)', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'feedbackIntegration'), + gzip: true, + limit: '98 KB', + }, + { + name: '@sentry/browser (incl. Feedback)', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init', 'feedbackIntegration'), + gzip: true, + limit: '42 KB', + }, + { + name: '@sentry/browser (incl. sendFeedback)', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init', 'sendFeedback'), + gzip: true, + limit: '30 KB', + }, + { + name: '@sentry/browser (incl. FeedbackAsync)', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init', 'feedbackAsyncIntegration'), + gzip: true, + limit: '35 KB', + }, + { + name: '@sentry/browser (incl. Metrics)', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init', 'metrics'), + gzip: true, + limit: '27 KB', + }, { name: '@sentry/browser (incl. Logs)', path: 'packages/browser/build/npm/esm/prod/index.js', @@ -126,173 +126,173 @@ module.exports = [ gzip: true, limit: '27 KB', }, - // { - // name: '@sentry/browser (incl. Metrics & Logs)', - // path: 'packages/browser/build/npm/esm/prod/index.js', - // import: createImport('init', 'metrics', 'logger'), - // gzip: true, - // limit: '28 KB', - // }, + { + name: '@sentry/browser (incl. Metrics & Logs)', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init', 'metrics', 'logger'), + gzip: true, + limit: '28 KB', + }, // React SDK (ESM) - // { - // name: '@sentry/react', - // path: 'packages/react/build/esm/index.js', - // import: createImport('init', 'ErrorBoundary'), - // ignore: ['react/jsx-runtime'], - // gzip: true, - // limit: '27 KB', - // }, - // { - // name: '@sentry/react (incl. Tracing)', - // path: 'packages/react/build/esm/index.js', - // import: createImport('init', 'ErrorBoundary', 'reactRouterV6BrowserTracingIntegration'), - // ignore: ['react/jsx-runtime'], - // gzip: true, - // limit: '44 KB', - // }, - // // Vue SDK (ESM) - // { - // name: '@sentry/vue', - // path: 'packages/vue/build/esm/index.js', - // import: createImport('init'), - // gzip: true, - // limit: '30 KB', - // }, - // { - // name: '@sentry/vue (incl. Tracing)', - // path: 'packages/vue/build/esm/index.js', - // import: createImport('init', 'browserTracingIntegration'), - // gzip: true, - // limit: '44 KB', - // }, - // // Svelte SDK (ESM) - // { - // name: '@sentry/svelte', - // path: 'packages/svelte/build/esm/index.js', - // import: createImport('init'), - // gzip: true, - // limit: '25 KB', - // }, - // // Browser CDN bundles - // { - // name: 'CDN Bundle', - // path: createCDNPath('bundle.min.js'), - // gzip: true, - // limit: '27.5 KB', - // }, - // { - // name: 'CDN Bundle (incl. Tracing)', - // path: createCDNPath('bundle.tracing.min.js'), - // gzip: true, - // limit: '42.5 KB', - // }, - // { - // name: 'CDN Bundle (incl. Tracing, Replay)', - // path: createCDNPath('bundle.tracing.replay.min.js'), - // gzip: true, - // limit: '80 KB', - // }, - // { - // name: 'CDN Bundle (incl. Tracing, Replay, Feedback)', - // path: createCDNPath('bundle.tracing.replay.feedback.min.js'), - // gzip: true, - // limit: '86 KB', - // }, - // // browser CDN bundles (non-gzipped) - // { - // name: 'CDN Bundle - uncompressed', - // path: createCDNPath('bundle.min.js'), - // gzip: false, - // brotli: false, - // limit: '82 KB', - // }, - // { - // name: 'CDN Bundle (incl. Tracing) - uncompressed', - // path: createCDNPath('bundle.tracing.min.js'), - // gzip: false, - // brotli: false, - // limit: '127 KB', - // }, - // { - // name: 'CDN Bundle (incl. Tracing, Replay) - uncompressed', - // path: createCDNPath('bundle.tracing.replay.min.js'), - // gzip: false, - // brotli: false, - // limit: '245 KB', - // }, - // { - // name: 'CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed', - // path: createCDNPath('bundle.tracing.replay.feedback.min.js'), - // gzip: false, - // brotli: false, - // limit: '264 KB', - // }, - // // Next.js SDK (ESM) - // { - // name: '@sentry/nextjs (client)', - // path: 'packages/nextjs/build/esm/client/index.js', - // import: createImport('init'), - // ignore: ['next/router', 'next/constants'], - // gzip: true, - // limit: '46.5 KB', - // }, - // // SvelteKit SDK (ESM) - // { - // name: '@sentry/sveltekit (client)', - // path: 'packages/sveltekit/build/esm/client/index.js', - // import: createImport('init'), - // ignore: ['$app/stores'], - // gzip: true, - // limit: '42 KB', - // }, - // // Node-Core SDK (ESM) - // { - // name: '@sentry/node-core', - // path: 'packages/node-core/build/esm/index.js', - // import: createImport('init'), - // ignore: [...builtinModules, ...nodePrefixedBuiltinModules], - // gzip: true, - // limit: '52 KB', - // }, - // // Node SDK (ESM) - // { - // name: '@sentry/node', - // path: 'packages/node/build/esm/index.js', - // import: createImport('init'), - // ignore: [...builtinModules, ...nodePrefixedBuiltinModules], - // gzip: true, - // limit: '162 KB', - // }, - // { - // name: '@sentry/node - without tracing', - // path: 'packages/node/build/esm/index.js', - // import: createImport('initWithoutDefaultIntegrations', 'getDefaultIntegrationsWithoutPerformance'), - // gzip: true, - // limit: '95 KB', - // ignore: [...builtinModules, ...nodePrefixedBuiltinModules], - // modifyWebpackConfig: function (config) { - // const webpack = require('webpack'); + { + name: '@sentry/react', + path: 'packages/react/build/esm/index.js', + import: createImport('init', 'ErrorBoundary'), + ignore: ['react/jsx-runtime'], + gzip: true, + limit: '27 KB', + }, + { + name: '@sentry/react (incl. Tracing)', + path: 'packages/react/build/esm/index.js', + import: createImport('init', 'ErrorBoundary', 'reactRouterV6BrowserTracingIntegration'), + ignore: ['react/jsx-runtime'], + gzip: true, + limit: '44 KB', + }, + // Vue SDK (ESM) + { + name: '@sentry/vue', + path: 'packages/vue/build/esm/index.js', + import: createImport('init'), + gzip: true, + limit: '30 KB', + }, + { + name: '@sentry/vue (incl. Tracing)', + path: 'packages/vue/build/esm/index.js', + import: createImport('init', 'browserTracingIntegration'), + gzip: true, + limit: '44 KB', + }, + // Svelte SDK (ESM) + { + name: '@sentry/svelte', + path: 'packages/svelte/build/esm/index.js', + import: createImport('init'), + gzip: true, + limit: '25 KB', + }, + // Browser CDN bundles + { + name: 'CDN Bundle', + path: createCDNPath('bundle.min.js'), + gzip: true, + limit: '27.5 KB', + }, + { + name: 'CDN Bundle (incl. Tracing)', + path: createCDNPath('bundle.tracing.min.js'), + gzip: true, + limit: '42.5 KB', + }, + { + name: 'CDN Bundle (incl. Tracing, Replay)', + path: createCDNPath('bundle.tracing.replay.min.js'), + gzip: true, + limit: '80 KB', + }, + { + name: 'CDN Bundle (incl. Tracing, Replay, Feedback)', + path: createCDNPath('bundle.tracing.replay.feedback.min.js'), + gzip: true, + limit: '86 KB', + }, + // browser CDN bundles (non-gzipped) + { + name: 'CDN Bundle - uncompressed', + path: createCDNPath('bundle.min.js'), + gzip: false, + brotli: false, + limit: '82 KB', + }, + { + name: 'CDN Bundle (incl. Tracing) - uncompressed', + path: createCDNPath('bundle.tracing.min.js'), + gzip: false, + brotli: false, + limit: '127 KB', + }, + { + name: 'CDN Bundle (incl. Tracing, Replay) - uncompressed', + path: createCDNPath('bundle.tracing.replay.min.js'), + gzip: false, + brotli: false, + limit: '245 KB', + }, + { + name: 'CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed', + path: createCDNPath('bundle.tracing.replay.feedback.min.js'), + gzip: false, + brotli: false, + limit: '264 KB', + }, + // Next.js SDK (ESM) + { + name: '@sentry/nextjs (client)', + path: 'packages/nextjs/build/esm/client/index.js', + import: createImport('init'), + ignore: ['next/router', 'next/constants'], + gzip: true, + limit: '46.5 KB', + }, + // SvelteKit SDK (ESM) + { + name: '@sentry/sveltekit (client)', + path: 'packages/sveltekit/build/esm/client/index.js', + import: createImport('init'), + ignore: ['$app/stores'], + gzip: true, + limit: '42 KB', + }, + // Node-Core SDK (ESM) + { + name: '@sentry/node-core', + path: 'packages/node-core/build/esm/index.js', + import: createImport('init'), + ignore: [...builtinModules, ...nodePrefixedBuiltinModules], + gzip: true, + limit: '52 KB', + }, + // Node SDK (ESM) + { + name: '@sentry/node', + path: 'packages/node/build/esm/index.js', + import: createImport('init'), + ignore: [...builtinModules, ...nodePrefixedBuiltinModules], + gzip: true, + limit: '162 KB', + }, + { + name: '@sentry/node - without tracing', + path: 'packages/node/build/esm/index.js', + import: createImport('initWithoutDefaultIntegrations', 'getDefaultIntegrationsWithoutPerformance'), + gzip: true, + limit: '95 KB', + ignore: [...builtinModules, ...nodePrefixedBuiltinModules], + modifyWebpackConfig: function (config) { + const webpack = require('webpack'); - // config.plugins.push( - // new webpack.DefinePlugin({ - // __SENTRY_TRACING__: false, - // }), - // ); + config.plugins.push( + new webpack.DefinePlugin({ + __SENTRY_TRACING__: false, + }), + ); - // config.optimization.minimize = true; + config.optimization.minimize = true; - // return config; - // }, - // }, - // // AWS SDK (ESM) - // { - // name: '@sentry/aws-serverless', - // path: 'packages/aws-serverless/build/npm/esm/index.js', - // import: createImport('init'), - // ignore: [...builtinModules, ...nodePrefixedBuiltinModules], - // gzip: true, - // limit: '111 KB', - // }, + return config; + }, + }, + // AWS SDK (ESM) + { + name: '@sentry/aws-serverless', + path: 'packages/aws-serverless/build/npm/esm/index.js', + import: createImport('init'), + ignore: [...builtinModules, ...nodePrefixedBuiltinModules], + gzip: true, + limit: '111 KB', + }, ]; function createImport(...args) {