|
8 | 8 | SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, |
9 | 9 | SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, |
10 | 10 | setHttpStatus, |
11 | | - spanToJSON, |
12 | 11 | startBrowserTracingNavigationSpan, |
13 | 12 | } from '@sentry/browser' |
14 | 13 | import type { Integration, Span, SpanAttributes, TransactionSource } from '@sentry/types' |
@@ -202,7 +201,6 @@ function browserTracingIntegration(router: Router): Integration { |
202 | 201 |
|
203 | 202 | router.beforeEach((to, from) => { |
204 | 203 | const attributes: SpanAttributes = { |
205 | | - [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.vue', |
206 | 204 | 'route.name': to.name as string, |
207 | 205 | 'route.path': to.path as string, |
208 | 206 | 'route.hash': to.hash as string, |
@@ -250,17 +248,14 @@ function browserTracingIntegration(router: Router): Integration { |
250 | 248 | if (instrumentPageLoad && isPageLoadNavigation) { |
251 | 249 | const activeRootSpan = getActiveRootSpan() |
252 | 250 | if (activeRootSpan) { |
253 | | - // Replace the name of the existing root span if it was not custom set |
254 | | - const existingAttributes = spanToJSON(activeRootSpan).data || {} |
255 | | - if (existingAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] !== 'custom') { |
256 | | - activeRootSpan.updateName(transactionName) |
257 | | - activeRootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, transactionSource) |
258 | | - } |
| 251 | + // Replace the name of the existing root span |
| 252 | + activeRootSpan.updateName(transactionName) |
259 | 253 |
|
260 | 254 | // Set router attributes on the existing pageload transaction |
261 | | - // This will override the origin and add params & query attributes |
| 255 | + // This will override the source and origin and add params & query attributes |
262 | 256 | activeRootSpan.setAttributes({ |
263 | 257 | ...attributes, |
| 258 | + [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: transactionSource, |
264 | 259 | [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.vue', |
265 | 260 | }) |
266 | 261 |
|
@@ -294,14 +289,5 @@ function browserTracingIntegration(router: Router): Integration { |
294 | 289 |
|
295 | 290 | function getActiveRootSpan(): Span | undefined { |
296 | 291 | const span = getActiveSpan() |
297 | | - const rootSpan = span && getRootSpan(span) |
298 | | - |
299 | | - if (!rootSpan) { |
300 | | - return undefined |
301 | | - } |
302 | | - |
303 | | - const op = spanToJSON(rootSpan).op |
304 | | - |
305 | | - // Only use this root span if it is a pageload or navigation span |
306 | | - return op === 'navigation' || op === 'pageload' ? rootSpan : undefined |
| 292 | + if (span) return getRootSpan(span) |
307 | 293 | } |
0 commit comments