@@ -3,11 +3,13 @@ import { EventType, record } from '@sentry-internal/rrweb';
33import {
44 SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ,
55 captureException ,
6+ getActiveSpan ,
67 getClient ,
78 getCurrentScope ,
9+ getRootSpan ,
810 spanToJSON ,
911} from '@sentry/core' ;
10- import type { ReplayRecordingMode , Transaction } from '@sentry/types' ;
12+ import type { ReplayRecordingMode , Span , Transaction } from '@sentry/types' ;
1113import { logger } from '@sentry/utils' ;
1214
1315import {
@@ -87,10 +89,10 @@ export class ReplayContainer implements ReplayContainerInterface {
8789 public recordingMode : ReplayRecordingMode ;
8890
8991 /**
90- * The current or last active transcation .
92+ * The current or last active span .
9193 * This is only available when performance is enabled.
9294 */
93- public lastTransaction ?: Transaction ;
95+ public lastActiveSpan ?: Span ;
9496
9597 /**
9698 * These are here so we can overwrite them in tests etc.
@@ -720,16 +722,16 @@ export class ReplayContainer implements ReplayContainerInterface {
720722 * This is only available if performance is enabled, and if an instrumented router is used.
721723 */
722724 public getCurrentRoute ( ) : string | undefined {
723- // eslint-disable-next-line deprecation/deprecation
724- const lastTransaction = this . lastTransaction || getCurrentScope ( ) . getTransaction ( ) ;
725+ const lastActiveSpan = this . lastActiveSpan || getActiveSpan ( ) ;
726+ const lastRootSpan = lastActiveSpan && getRootSpan ( lastActiveSpan ) ;
725727
726- const attributes = ( lastTransaction && spanToJSON ( lastTransaction ) . data ) || { } ;
728+ const attributes = ( lastRootSpan && spanToJSON ( lastRootSpan ) . data ) || { } ;
727729 const source = attributes [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] ;
728- if ( ! lastTransaction || ! source || ! [ 'route' , 'custom' ] . includes ( source ) ) {
730+ if ( ! lastRootSpan || ! source || ! [ 'route' , 'custom' ] . includes ( source ) ) {
729731 return undefined ;
730732 }
731733
732- return spanToJSON ( lastTransaction ) . description ;
734+ return spanToJSON ( lastRootSpan ) . description ;
733735 }
734736
735737 /**
0 commit comments