diff --git a/packages/core/src/tracing/transaction.ts b/packages/core/src/tracing/transaction.ts index eba498b7e654..8fe01e5afcce 100644 --- a/packages/core/src/tracing/transaction.ts +++ b/packages/core/src/tracing/transaction.ts @@ -10,6 +10,7 @@ import type { TransactionMetadata, } from '@sentry/types'; import { dropUndefinedKeys, logger } from '@sentry/utils'; +import { Replay } from '@sentry/replay'; import { DEFAULT_ENVIRONMENT } from '../constants'; import type { Hub } from '../hub'; @@ -241,6 +242,7 @@ export class Transaction extends SpanClass implements TransactionInterface { * @experimental */ public getDynamicSamplingContext(): Readonly> { + console.log('dsc'); if (this._frozenDynamicSamplingContext) { return this._frozenDynamicSamplingContext; } @@ -261,6 +263,12 @@ export class Transaction extends SpanClass implements TransactionInterface { const source = this.metadata.source; + const replay = client.getIntegration(Replay); + let replay_id; + if (replay) { + replay_id = replay.getCurrentReplayId(); + } + // We don't want to have a transaction name in the DSC if the source is "url" because URLs might contain PII const transaction = source && source !== 'url' ? this.name : undefined; @@ -272,6 +280,7 @@ export class Transaction extends SpanClass implements TransactionInterface { public_key, trace_id: this.traceId, sample_rate, + replay_id, }); // Uncomment if we want to make DSC immutable diff --git a/packages/replay/src/integration.ts b/packages/replay/src/integration.ts index c08eb0431cac..eb4704a57fda 100644 --- a/packages/replay/src/integration.ts +++ b/packages/replay/src/integration.ts @@ -226,6 +226,14 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`, return this._replay.flushImmediate(); } + /** returns the current replayId if there is an existing session */ + public getCurrentReplayId(): string | undefined { + if (!this._replay || !this._replay.session) { + return; + } + return this._replay.session.id; + } + /** Setup the integration. */ private _setup(): void { // Client is not available in constructor, so we need to wait until setupOnce diff --git a/packages/tracing/src/browser/request.ts b/packages/tracing/src/browser/request.ts index e1e1c9aaf7fb..24772e0ef6f8 100644 --- a/packages/tracing/src/browser/request.ts +++ b/packages/tracing/src/browser/request.ts @@ -160,6 +160,7 @@ export function fetchCallback( shouldAttachHeaders: (url: string) => boolean, spans: Record, ): void { + console.log(2); if (!hasTracingEnabled() || !(handlerData.fetchData && shouldCreateSpan(handlerData.fetchData.url))) { return; } @@ -294,6 +295,7 @@ export function xhrCallback( shouldAttachHeaders: (url: string) => boolean, spans: Record, ): void { + console.log(1); if ( !hasTracingEnabled() || (handlerData.xhr && handlerData.xhr.__sentry_own_request__) ||