diff --git a/.size-limit.js b/.size-limit.js index b775eaadb04f..9dafaed4545e 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -35,6 +35,31 @@ module.exports = [ return config; }, }, + { + name: '@sentry/browser - with treeshaking flags tracing without tracing', + path: 'packages/browser/build/npm/esm/prod/index.js', + import: createImport('init'), + gzip: true, + limit: '32 KB', + disablePlugins: ['@size-limit/esbuild'], + 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, + __SENTRY_TRACING__: false, + }), + ); + + config.optimization.minimize = true; + + return config; + }, + }, { name: '@sentry/browser (incl. Tracing)', path: 'packages/browser/build/npm/esm/prod/index.js', diff --git a/packages/browser/src/sdk.ts b/packages/browser/src/sdk.ts index 84f4940c8b41..4419b800591f 100644 --- a/packages/browser/src/sdk.ts +++ b/packages/browser/src/sdk.ts @@ -28,6 +28,8 @@ import { makeFetchTransport } from './transports/fetch'; import { normalizeStringifyValue } from './normalizeStringifyValue'; import { checkAndWarnIfIsEmbeddedBrowserExtension } from './utils/detectBrowserExtension'; +declare const __SENTRY_TRACING__: boolean; + /** Get the default integrations for the browser SDK. */ export function getDefaultIntegrations(_options: Options): Integration[] { /** @@ -120,6 +122,7 @@ export function init(options: BrowserOptions = {}): Client | undefined { }); if ( + (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) && options.traceLifecycle !== 'static' && !integrations.some(integration => integration.name === SPAN_STREAMING_INTEGRATION_NAME) ) { diff --git a/packages/core/src/server-runtime-client.ts b/packages/core/src/server-runtime-client.ts index e0426e558ed3..159c4aeb3b93 100644 --- a/packages/core/src/server-runtime-client.ts +++ b/packages/core/src/server-runtime-client.ts @@ -28,6 +28,8 @@ export interface ServerRuntimeClientOptions extends ClientOptions i.name === SPAN_STREAMING_INTEGRATION_NAME) ) {