Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/tracing/src/browser/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export function instrumentRoutingWithDefaults<T extends Transaction>(

let activeTransaction: T | undefined;
if (startTransactionOnPageLoad) {
activeTransaction = customStartTransaction({ name: global.location.pathname, op: 'pageload' });
activeTransaction = customStartTransaction({
name: global.location.pathname,
op: 'pageload',
metadata: { source: 'url' },
});
}

if (startTransactionOnLocationChange) {
Expand All @@ -46,7 +50,11 @@ export function instrumentRoutingWithDefaults<T extends Transaction>(
// If there's an open transaction on the scope, we need to finish it before creating an new one.
activeTransaction.finish();
}
activeTransaction = customStartTransaction({ name: global.location.pathname, op: 'navigation' });
activeTransaction = customStartTransaction({
name: global.location.pathname,
op: 'navigation',
metadata: { source: 'url' },
});
}
});
}
Expand Down
18 changes: 15 additions & 3 deletions packages/tracing/test/browser/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ describe('instrumentRoutingWithDefaults', () => {
it('starts a pageload transaction', () => {
instrumentRoutingWithDefaults(customStartTransaction);
expect(customStartTransaction).toHaveBeenCalledTimes(1);
expect(customStartTransaction).toHaveBeenLastCalledWith({ name: 'blank', op: 'pageload' });
expect(customStartTransaction).toHaveBeenLastCalledWith({
name: 'blank',
op: 'pageload',
metadata: { source: 'url' },
});
});

it('does not start a pageload transaction if startTransactionOnPageLoad is false', () => {
Expand All @@ -58,7 +62,11 @@ describe('instrumentRoutingWithDefaults', () => {

it('it is not created automatically', () => {
instrumentRoutingWithDefaults(customStartTransaction);
expect(customStartTransaction).not.toHaveBeenLastCalledWith({ name: 'blank', op: 'navigation' });
expect(customStartTransaction).not.toHaveBeenLastCalledWith({
name: 'blank',
op: 'navigation',
metadata: { source: 'url' },
});
});

it('is created on location change', () => {
Expand All @@ -67,7 +75,11 @@ describe('instrumentRoutingWithDefaults', () => {
expect(addInstrumentationHandlerType).toBe('history');

expect(customStartTransaction).toHaveBeenCalledTimes(2);
expect(customStartTransaction).toHaveBeenLastCalledWith({ name: 'blank', op: 'navigation' });
expect(customStartTransaction).toHaveBeenLastCalledWith({
name: 'blank',
op: 'navigation',
metadata: { source: 'url' },
});
});

it('is not created if startTransactionOnLocationChange is false', () => {
Expand Down