Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ test('sends a pageload transaction with a route name as transaction name if avai
'sentry.source': 'custom',
'sentry.origin': 'auto.pageload.vue',
'sentry.op': 'pageload',
'navigation.route.id': 'AboutView',
'url.path': '/about',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/about$/),
},
Expand Down
11 changes: 10 additions & 1 deletion packages/vue/src/router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { captureException, getAbsoluteUrl } from '@sentry/browser';
import { PARAMS_KEY_BASE, URL_PATH_PARAMETER_KEY_BASE, URL_TEMPLATE } from '@sentry/conventions/attributes';
import {
NAVIGATION_ROUTE_ID,
PARAMS_KEY_BASE,
URL_PATH_PARAMETER_KEY_BASE,
URL_TEMPLATE,
} from '@sentry/conventions/attributes';
import type { Span, SpanAttributes, StartSpanOptions, TransactionSource } from '@sentry/core';
import {
getActiveSpan,
Expand Down Expand Up @@ -101,6 +106,10 @@ export function instrumentVueRouter(
attributes[URL_TEMPLATE] = spanName;
}

if (to.name) {
attributes[NAVIGATION_ROUTE_ID] = to.name.toString();
}

getCurrentScope().setTransactionName(spanName);

// Update the existing page load span with parametrized route information
Expand Down
6 changes: 5 additions & 1 deletion packages/vue/test/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as SentryBrowser from '@sentry/browser';
import type { Span, SpanAttributes } from '@sentry/core';
import * as SentryCore from '@sentry/core';
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
import { URL_TEMPLATE } from '@sentry/conventions/attributes';
import { NAVIGATION_ROUTE_ID, URL_TEMPLATE } from '@sentry/conventions/attributes';
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { Route } from '../src/router';
import { instrumentVueRouter } from '../src/router';
Expand Down Expand Up @@ -465,5 +465,9 @@ function getAttributesForRoute(route: Route, urlTemplate?: string): SpanAttribut
attributes[URL_TEMPLATE] = urlTemplate;
}

if (route.name) {
attributes[NAVIGATION_ROUTE_ID] = route.name.toString();
}

return attributes;
}
Loading