Skip to content

Commit 945437a

Browse files
authored
ref(tracing): Reduce metrics bundle size (getsentry#5122)
1 parent d48711f commit 945437a

File tree

8 files changed

+656
-698
lines changed

8 files changed

+656
-698
lines changed

packages/tracing/src/browser/browsertracing.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { startIdleTransaction } from '../hubextensions';
77
import { DEFAULT_FINAL_TIMEOUT, DEFAULT_IDLE_TIMEOUT } from '../idletransaction';
88
import { extractTraceparentData } from '../utils';
99
import { registerBackgroundTabDetection } from './backgroundtab';
10-
import { MetricsInstrumentation } from './metrics';
10+
import { addPerformanceEntries, startTrackingWebVitals } from './metrics';
1111
import {
1212
defaultRequestInstrumentationOptions,
1313
instrumentOutgoingRequests,
@@ -126,8 +126,6 @@ export class BrowserTracing implements Integration {
126126

127127
private _getCurrentHub?: () => Hub;
128128

129-
private readonly _metrics: MetricsInstrumentation;
130-
131129
private readonly _emitOptionsWarning?: boolean;
132130

133131
public constructor(_options?: Partial<BrowserTracingOptions>) {
@@ -148,7 +146,7 @@ export class BrowserTracing implements Integration {
148146
};
149147

150148
const { _metricOptions } = this.options;
151-
this._metrics = new MetricsInstrumentation(_metricOptions && _metricOptions._reportAllChanges);
149+
startTrackingWebVitals(_metricOptions && _metricOptions._reportAllChanges);
152150
}
153151

154152
/**
@@ -235,7 +233,11 @@ export class BrowserTracing implements Integration {
235233
{ location }, // for use in the tracesSampler
236234
);
237235
idleTransaction.registerBeforeFinishCallback(transaction => {
238-
this._metrics.addPerformanceEntries(transaction);
236+
addPerformanceEntries(transaction);
237+
transaction.setTag(
238+
'sentry_reportAllChanges',
239+
Boolean(this.options._metricOptions && this.options._metricOptions._reportAllChanges),
240+
);
239241
});
240242

241243
return idleTransaction as Transaction;

0 commit comments

Comments
 (0)