Skip to content

Commit 09721ce

Browse files
committed
feat(browser): Do not include metrics in base CDN bundle
Metrics are only included when performance is included, reducing the base bundle size. We always expose a shim so there is no API breakage, it just does nothing.
1 parent b188e61 commit 09721ce

16 files changed

+74
-22
lines changed

packages/browser/src/exports.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ export {
6868
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
6969
} from '@sentry/core';
7070

71-
export * from './metrics';
72-
7371
export { WINDOW } from './helpers';
7472
export { BrowserClient } from './client';
7573
export { makeFetchTransport } from './transports/fetch';

packages/browser/src/index.bundle.feedback.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { browserTracingIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
1+
import { browserTracingIntegrationShim, metricsShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
22
import { feedbackAsyncIntegration } from './feedbackAsync';
33

44
export * from './index.bundle.base';
@@ -10,6 +10,7 @@ export {
1010
feedbackAsyncIntegration as feedbackAsyncIntegration,
1111
feedbackAsyncIntegration as feedbackIntegration,
1212
replayIntegrationShim as replayIntegration,
13+
metricsShim as metrics,
1314
};
1415

1516
export { captureFeedback } from '@sentry/core';

packages/browser/src/index.bundle.replay.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { browserTracingIntegrationShim, feedbackIntegrationShim } from '@sentry-internal/integration-shims';
1+
import {
2+
browserTracingIntegrationShim,
3+
feedbackIntegrationShim,
4+
metricsShim,
5+
} from '@sentry-internal/integration-shims';
26

37
export * from './index.bundle.base';
48

@@ -8,4 +12,5 @@ export {
812
browserTracingIntegrationShim as browserTracingIntegration,
913
feedbackIntegrationShim as feedbackAsyncIntegration,
1014
feedbackIntegrationShim as feedbackIntegration,
15+
metricsShim as metrics,
1116
};

packages/browser/src/index.bundle.tracing.replay.feedback.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ registerSpanErrorInstrumentation();
44

55
export * from './index.bundle.base';
66

7+
export * from './metrics';
8+
79
export {
810
getActiveSpan,
911
getRootSpan,

packages/browser/src/index.bundle.tracing.replay.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ registerSpanErrorInstrumentation();
44

55
export * from './index.bundle.base';
66

7+
export * from './metrics';
8+
79
export {
810
getActiveSpan,
911
getRootSpan,

packages/browser/src/index.bundle.tracing.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ registerSpanErrorInstrumentation();
55

66
export * from './index.bundle.base';
77

8+
export * from './metrics';
9+
810
export {
911
getActiveSpan,
1012
getRootSpan,

packages/browser/src/index.bundle.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
browserTracingIntegrationShim,
33
feedbackIntegrationShim,
4+
metricsShim,
45
replayIntegrationShim,
56
} from '@sentry-internal/integration-shims';
67

@@ -11,4 +12,5 @@ export {
1112
feedbackIntegrationShim as feedbackAsyncIntegration,
1213
feedbackIntegrationShim as feedbackIntegration,
1314
replayIntegrationShim as replayIntegration,
15+
metricsShim as metrics,
1416
};

packages/browser/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export {
3939
sendFeedback,
4040
} from '@sentry-internal/feedback';
4141

42+
export * from './metrics';
43+
4244
export {
4345
defaultRequestInstrumentationOptions,
4446
instrumentOutgoingRequests,

packages/browser/src/metrics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { MetricData } from '@sentry/core';
21
import { BrowserMetricsAggregator, metrics as metricsCore } from '@sentry/core';
2+
import type { MetricData, Metrics } from '@sentry/types';
33

44
/**
55
* Adds a value to a counter metric
@@ -37,7 +37,7 @@ function gauge(name: string, value: number, data?: MetricData): void {
3737
metricsCore.gauge(BrowserMetricsAggregator, name, value, data);
3838
}
3939

40-
export const metrics = {
40+
export const metrics: Metrics = {
4141
increment,
4242
distribution,
4343
set,

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export { rewriteFramesIntegration } from './integrations/rewriteframes';
9797
export { sessionTimingIntegration } from './integrations/sessiontiming';
9898
export { zodErrorsIntegration } from './integrations/zoderrors';
9999
export { metrics } from './metrics/exports';
100-
export type { MetricData } from './metrics/exports';
100+
export type { MetricData } from '@sentry/types';
101101
export { metricsDefault } from './metrics/exports-default';
102102
export { BrowserMetricsAggregator } from './metrics/browser-aggregator';
103103
export { getMetricSummaryJsonForSpan } from './metrics/metric-summary';

0 commit comments

Comments
 (0)