|
5 | 5 | TRACING_DEFAULTS,
|
6 | 6 | addTracingExtensions,
|
7 | 7 | getActiveTransaction,
|
8 |
| - spanIsSampled, |
9 |
| - spanToJSON, |
10 | 8 | startIdleTransaction,
|
11 | 9 | } from '@sentry/core';
|
12 | 10 | import type { EventProcessor, Integration, Transaction, TransactionContext, TransactionSource } from '@sentry/types';
|
@@ -310,23 +308,27 @@ export class BrowserTracing implements Integration {
|
310 | 308 |
|
311 | 309 | const isPageloadTransaction = context.op === 'pageload';
|
312 | 310 |
|
313 |
| - const sentryTrace = isPageloadTransaction ? getMetaContent('sentry-trace') : ''; |
314 |
| - const baggage = isPageloadTransaction ? getMetaContent('baggage') : ''; |
315 |
| - const { traceparentData, dynamicSamplingContext, propagationContext } = tracingContextFromHeaders( |
316 |
| - sentryTrace, |
317 |
| - baggage, |
318 |
| - ); |
319 |
| - |
320 |
| - const expandedContext: TransactionContext = { |
321 |
| - ...context, |
322 |
| - ...traceparentData, |
323 |
| - metadata: { |
324 |
| - // eslint-disable-next-line deprecation/deprecation |
325 |
| - ...context.metadata, |
326 |
| - dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext, |
327 |
| - }, |
328 |
| - trimEnd: true, |
329 |
| - }; |
| 311 | + let expandedContext: TransactionContext; |
| 312 | + if (isPageloadTransaction) { |
| 313 | + const sentryTrace = isPageloadTransaction ? getMetaContent('sentry-trace') : ''; |
| 314 | + const baggage = isPageloadTransaction ? getMetaContent('baggage') : undefined; |
| 315 | + const { traceparentData, dynamicSamplingContext } = tracingContextFromHeaders(sentryTrace, baggage); |
| 316 | + expandedContext = { |
| 317 | + ...context, |
| 318 | + ...traceparentData, |
| 319 | + metadata: { |
| 320 | + // eslint-disable-next-line deprecation/deprecation |
| 321 | + ...context.metadata, |
| 322 | + dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext, |
| 323 | + }, |
| 324 | + trimEnd: true, |
| 325 | + }; |
| 326 | + } else { |
| 327 | + expandedContext = { |
| 328 | + ...context, |
| 329 | + trimEnd: true, |
| 330 | + }; |
| 331 | + } |
330 | 332 |
|
331 | 333 | const modifiedContext = typeof beforeNavigate === 'function' ? beforeNavigate(expandedContext) : expandedContext;
|
332 | 334 |
|
@@ -384,24 +386,6 @@ export class BrowserTracing implements Integration {
|
384 | 386 | }
|
385 | 387 | }
|
386 | 388 |
|
387 |
| - // eslint-disable-next-line deprecation/deprecation |
388 |
| - const scope = hub.getScope(); |
389 |
| - |
390 |
| - // If it's a pageload and there is a meta tag set |
391 |
| - // use the traceparentData as the propagation context |
392 |
| - if (isPageloadTransaction && traceparentData) { |
393 |
| - scope.setPropagationContext(propagationContext); |
394 |
| - } else { |
395 |
| - // Navigation transactions should set a new propagation context based on the |
396 |
| - // created idle transaction. |
397 |
| - scope.setPropagationContext({ |
398 |
| - traceId: idleTransaction.spanContext().traceId, |
399 |
| - spanId: idleTransaction.spanContext().spanId, |
400 |
| - parentSpanId: spanToJSON(idleTransaction).parent_span_id, |
401 |
| - sampled: spanIsSampled(idleTransaction), |
402 |
| - }); |
403 |
| - } |
404 |
| - |
405 | 389 | idleTransaction.registerBeforeFinishCallback(transaction => {
|
406 | 390 | this._collectWebVitals();
|
407 | 391 | addPerformanceEntries(transaction);
|
|
0 commit comments