Skip to content

Commit fae9e68

Browse files
committed
Make sure option is set correctly
1 parent ef452d6 commit fae9e68

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

packages/tracing/src/browser/browsertracing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class BrowserTracing implements Integration {
149149
tracingOrigins,
150150
};
151151

152-
this._metrics = new MetricsInstrumentation({ ...this.options._metricOptions, ...DEFAULT_METRICS_INSTR_OPTIONS });
152+
this._metrics = new MetricsInstrumentation({ ...DEFAULT_METRICS_INSTR_OPTIONS, ...this.options._metricOptions });
153153
}
154154

155155
/**

packages/tracing/test/browser/browsertracing.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
getHeaderContext,
1212
getMetaContent,
1313
} from '../../src/browser/browsertracing';
14+
import { DEFAULT_METRICS_INSTR_OPTIONS, MetricsInstrumentation } from '../../src/browser/metrics';
1415
import { defaultRequestInstrumentationOptions } from '../../src/browser/request';
1516
import { instrumentRoutingWithDefaults } from '../../src/browser/router';
1617
import * as hubExtensions from '../../src/hubextensions';
@@ -32,6 +33,8 @@ jest.mock('@sentry/utils', () => {
3233
};
3334
});
3435

36+
jest.mock('../../src/browser/metrics');
37+
3538
const { logger } = jest.requireActual('@sentry/utils');
3639
const warnSpy = jest.spyOn(logger, 'warn');
3740

@@ -493,4 +496,31 @@ describe('BrowserTracing', () => {
493496
);
494497
});
495498
});
499+
500+
describe('metrics', () => {
501+
beforeEach(() => {
502+
// @ts-ignore mock clear
503+
MetricsInstrumentation.mockClear();
504+
});
505+
506+
it('creates metrics instrumentation', () => {
507+
createBrowserTracing(true, {});
508+
509+
expect(MetricsInstrumentation).toHaveBeenCalledTimes(1);
510+
expect(MetricsInstrumentation).toHaveBeenLastCalledWith(DEFAULT_METRICS_INSTR_OPTIONS);
511+
});
512+
513+
it('creates metrics instrumentation with custom options', () => {
514+
createBrowserTracing(true, {
515+
_metricOptions: {
516+
_reportAllChanges: true,
517+
},
518+
});
519+
520+
expect(MetricsInstrumentation).toHaveBeenCalledTimes(1);
521+
expect(MetricsInstrumentation).toHaveBeenLastCalledWith({
522+
_reportAllChanges: true,
523+
});
524+
});
525+
});
496526
});

0 commit comments

Comments
 (0)