Skip to content

Commit 1486ed2

Browse files
committed
s/startTransaction/customStartTransaction
1 parent 57423ee commit 1486ed2

File tree

7 files changed

+35
-35
lines changed

7 files changed

+35
-35
lines changed

packages/angular/src/tracing.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ let stashedStartTransactionOnLocationChange: boolean;
1414
* Creates routing instrumentation for Angular Router.
1515
*/
1616
export function routingInstrumentation(
17-
startTransaction: (context: TransactionContext) => Transaction | undefined,
17+
customStartTransaction: (context: TransactionContext) => Transaction | undefined,
1818
startTransactionOnPageLoad: boolean = true,
1919
startTransactionOnLocationChange: boolean = true,
2020
): void {
2121
instrumentationInitialized = true;
22-
stashedStartTransaction = startTransaction;
22+
stashedStartTransaction = customStartTransaction;
2323
stashedStartTransactionOnLocationChange = startTransactionOnLocationChange;
2424

2525
if (startTransactionOnPageLoad) {
26-
startTransaction({
26+
customStartTransaction({
2727
name: window.location.pathname,
2828
op: 'pageload',
2929
});

packages/ember/addon/instance-initializers/sentry-performance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,10 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
337337
sentryConfig['integrations'] = [
338338
...existingIntegrations,
339339
new tracing.Integrations.BrowserTracing({
340-
routingInstrumentation: (startTransaction, startTransactionOnPageLoad) => {
340+
routingInstrumentation: (customStartTransaction, startTransactionOnPageLoad) => {
341341
const routerMain = appInstance.lookup('router:main');
342342
const routerService = appInstance.lookup('service:router');
343-
_instrumentEmberRouter(routerService, routerMain, config, startTransaction, startTransactionOnPageLoad);
343+
_instrumentEmberRouter(routerService, routerMain, config, customStartTransaction, startTransactionOnPageLoad);
344344
},
345345
idleTimeout,
346346
}),

packages/react/src/reactrouter.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ function reactRouterInstrumentation(
8080
return pathname;
8181
}
8282

83-
return (startTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true): void => {
83+
return (customStartTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true): void => {
8484
if (startTransactionOnPageLoad && global && global.location) {
85-
activeTransaction = startTransaction({
85+
activeTransaction = customStartTransaction({
8686
name: getName(global.location.pathname),
8787
op: 'pageload',
8888
tags: {
@@ -101,7 +101,7 @@ function reactRouterInstrumentation(
101101
'routing.instrumentation': name,
102102
};
103103

104-
activeTransaction = startTransaction({
104+
activeTransaction = customStartTransaction({
105105
name: getName(location.pathname),
106106
op: 'navigation',
107107
tags,

packages/tracing/src/browser/browsertracing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export interface BrowserTracingOptions extends RequestInstrumentationOptions {
7777
* pageload and navigation transactions.
7878
*/
7979
routingInstrumentation<T extends Transaction>(
80-
startTransaction: (context: TransactionContext) => T | undefined,
80+
customStartTransaction: (context: TransactionContext) => T | undefined,
8181
startTransactionOnPageLoad?: boolean,
8282
startTransactionOnLocationChange?: boolean,
8383
): void;

packages/tracing/src/browser/router.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const global = getGlobalObject<Window>();
77
* Default function implementing pageload and navigation transactions
88
*/
99
export function defaultRoutingInstrumentation<T extends Transaction>(
10-
startTransaction: (context: TransactionContext) => T | undefined,
10+
customStartTransaction: (context: TransactionContext) => T | undefined,
1111
startTransactionOnPageLoad: boolean = true,
1212
startTransactionOnLocationChange: boolean = true,
1313
): void {
@@ -20,7 +20,7 @@ export function defaultRoutingInstrumentation<T extends Transaction>(
2020

2121
let activeTransaction: T | undefined;
2222
if (startTransactionOnPageLoad) {
23-
activeTransaction = startTransaction({ name: global.location.pathname, op: 'pageload' });
23+
activeTransaction = customStartTransaction({ name: global.location.pathname, op: 'pageload' });
2424
}
2525

2626
if (startTransactionOnLocationChange) {
@@ -47,7 +47,7 @@ export function defaultRoutingInstrumentation<T extends Transaction>(
4747
// If there's an open transaction on the scope, we need to finish it before creating an new one.
4848
activeTransaction.finish();
4949
}
50-
activeTransaction = startTransaction({ name: global.location.pathname, op: 'navigation' });
50+
activeTransaction = customStartTransaction({ name: global.location.pathname, op: 'navigation' });
5151
}
5252
},
5353
type: 'history',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ describe('BrowserTracing', () => {
9696
* so that we can show this functionality works independent of the default routing integration.
9797
*/
9898
describe('route transaction', () => {
99-
const customRoutingInstrumentation = (startTransaction: (obj: any) => void) => {
100-
startTransaction({ name: 'a/path', op: 'pageload' });
99+
const customRoutingInstrumentation = (customStartTransaction: (obj: any) => void) => {
100+
customStartTransaction({ name: 'a/path', op: 'pageload' });
101101
};
102102

103103
it('calls custom routing instrumenation', () => {

packages/tracing/test/browser/router.test.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jest.mock('@sentry/utils', () => {
1717

1818
describe('defaultRoutingInstrumentation', () => {
1919
const mockFinish = jest.fn();
20-
const startTransaction = jest.fn().mockReturnValue({ finish: mockFinish });
20+
const customStartTransaction = jest.fn().mockReturnValue({ finish: mockFinish });
2121
beforeEach(() => {
2222
const dom = new JSDOM();
2323
// @ts-ignore need to override global document
@@ -27,26 +27,26 @@ describe('defaultRoutingInstrumentation', () => {
2727
// @ts-ignore need to override global document
2828
global.location = dom.window.location;
2929

30-
startTransaction.mockClear();
30+
customStartTransaction.mockClear();
3131
mockFinish.mockClear();
3232
});
3333

3434
it('does not start transactions if global location is undefined', () => {
3535
// @ts-ignore need to override global document
3636
global.location = undefined;
37-
defaultRoutingInstrumentation(startTransaction);
38-
expect(startTransaction).toHaveBeenCalledTimes(0);
37+
defaultRoutingInstrumentation(customStartTransaction);
38+
expect(customStartTransaction).toHaveBeenCalledTimes(0);
3939
});
4040

4141
it('starts a pageload transaction', () => {
42-
defaultRoutingInstrumentation(startTransaction);
43-
expect(startTransaction).toHaveBeenCalledTimes(1);
44-
expect(startTransaction).toHaveBeenLastCalledWith({ name: 'blank', op: 'pageload' });
42+
defaultRoutingInstrumentation(customStartTransaction);
43+
expect(customStartTransaction).toHaveBeenCalledTimes(1);
44+
expect(customStartTransaction).toHaveBeenLastCalledWith({ name: 'blank', op: 'pageload' });
4545
});
4646

4747
it('does not start a pageload transaction if startTransactionOnPageLoad is false', () => {
48-
defaultRoutingInstrumentation(startTransaction, false);
49-
expect(startTransaction).toHaveBeenCalledTimes(0);
48+
defaultRoutingInstrumentation(customStartTransaction, false);
49+
expect(customStartTransaction).toHaveBeenCalledTimes(0);
5050
});
5151

5252
describe('navigation transaction', () => {
@@ -56,37 +56,37 @@ describe('defaultRoutingInstrumentation', () => {
5656
});
5757

5858
it('it is not created automatically', () => {
59-
defaultRoutingInstrumentation(startTransaction);
60-
expect(startTransaction).not.toHaveBeenLastCalledWith({ name: 'blank', op: 'navigation' });
59+
defaultRoutingInstrumentation(customStartTransaction);
60+
expect(customStartTransaction).not.toHaveBeenLastCalledWith({ name: 'blank', op: 'navigation' });
6161
});
6262

6363
it('is created on location change', () => {
64-
defaultRoutingInstrumentation(startTransaction);
64+
defaultRoutingInstrumentation(customStartTransaction);
6565
mockChangeHistory({ to: 'here', from: 'there' });
6666
expect(addInstrumentationHandlerType).toBe('history');
6767

68-
expect(startTransaction).toHaveBeenCalledTimes(2);
69-
expect(startTransaction).toHaveBeenLastCalledWith({ name: 'blank', op: 'navigation' });
68+
expect(customStartTransaction).toHaveBeenCalledTimes(2);
69+
expect(customStartTransaction).toHaveBeenLastCalledWith({ name: 'blank', op: 'navigation' });
7070
});
7171

7272
it('is not created if startTransactionOnLocationChange is false', () => {
73-
defaultRoutingInstrumentation(startTransaction, true, false);
73+
defaultRoutingInstrumentation(customStartTransaction, true, false);
7474
mockChangeHistory({ to: 'here', from: 'there' });
7575
expect(addInstrumentationHandlerType).toBe('');
7676

77-
expect(startTransaction).toHaveBeenCalledTimes(1);
77+
expect(customStartTransaction).toHaveBeenCalledTimes(1);
7878
});
7979

8080
it('finishes the last active transaction', () => {
81-
defaultRoutingInstrumentation(startTransaction);
81+
defaultRoutingInstrumentation(customStartTransaction);
8282

8383
expect(mockFinish).toHaveBeenCalledTimes(0);
8484
mockChangeHistory({ to: 'here', from: 'there' });
8585
expect(mockFinish).toHaveBeenCalledTimes(1);
8686
});
8787

8888
it('will finish active transaction multiple times', () => {
89-
defaultRoutingInstrumentation(startTransaction);
89+
defaultRoutingInstrumentation(customStartTransaction);
9090

9191
expect(mockFinish).toHaveBeenCalledTimes(0);
9292
mockChangeHistory({ to: 'here', from: 'there' });
@@ -98,12 +98,12 @@ describe('defaultRoutingInstrumentation', () => {
9898
});
9999

100100
it('not created if `from` is equal to `to`', () => {
101-
defaultRoutingInstrumentation(startTransaction);
101+
defaultRoutingInstrumentation(customStartTransaction);
102102
mockChangeHistory({ to: 'first/path', from: 'first/path' });
103103
expect(addInstrumentationHandlerType).toBe('history');
104104

105-
expect(startTransaction).toHaveBeenCalledTimes(1);
106-
expect(startTransaction).not.toHaveBeenLastCalledWith('navigation');
105+
expect(customStartTransaction).toHaveBeenCalledTimes(1);
106+
expect(customStartTransaction).not.toHaveBeenLastCalledWith('navigation');
107107
});
108108
});
109109
});

0 commit comments

Comments
 (0)