@@ -350,7 +350,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
350
350
} ;
351
351
352
352
let _collectWebVitals : undefined | ( ( ) => void ) ;
353
- let lastClickTimestamp : number | undefined ;
353
+ let lastInteractionTimestamp : number | undefined ;
354
354
355
355
/** Create routing idle transaction. */
356
356
function _createRouteSpan ( client : Client , startSpanOptions : StartSpanOptions , makeActive = true ) : void {
@@ -466,7 +466,11 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
466
466
}
467
467
468
468
if ( detectRedirects && optionalWindowDocument ) {
469
- addEventListener ( 'click' , ( ) => ( lastClickTimestamp = timestampInSeconds ( ) ) , { capture : true , passive : true } ) ;
469
+ const clickHandler = ( ) : void => {
470
+ lastInteractionTimestamp = timestampInSeconds ( ) ;
471
+ } ;
472
+ addEventListener ( 'click' , ( ) => clickHandler , { capture : true , passive : true } ) ;
473
+ addEventListener ( 'keypress' , ( ) => clickHandler , { capture : true , passive : true } ) ;
470
474
}
471
475
472
476
function maybeEndActiveSpan ( ) : void {
@@ -582,7 +586,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
582
586
startingUrl = undefined ;
583
587
const parsed = parseStringToURLObject ( to ) ;
584
588
const activeSpan = getActiveIdleSpan ( client ) ;
585
- const navigationIsRedirect = activeSpan && detectRedirects && isRedirect ( activeSpan , lastClickTimestamp ) ;
589
+ const navigationIsRedirect = activeSpan && detectRedirects && isRedirect ( activeSpan , lastInteractionTimestamp ) ;
586
590
startBrowserTracingNavigationSpan (
587
591
client ,
588
592
{
@@ -756,7 +760,7 @@ function setActiveIdleSpan(client: Client, span: Span | undefined): void {
756
760
// The max. time in seconds between two pageload/navigation spans that makes us consider the second one a redirect
757
761
const REDIRECT_THRESHOLD = 0.3 ;
758
762
759
- function isRedirect ( activeSpan : Span , lastClickTimestamp : number | undefined ) : boolean {
763
+ function isRedirect ( activeSpan : Span , lastInteractionTimestamp : number | undefined ) : boolean {
760
764
const spanData = spanToJSON ( activeSpan ) ;
761
765
762
766
const now = dateTimestampInSeconds ( ) ;
@@ -770,7 +774,7 @@ function isRedirect(activeSpan: Span, lastClickTimestamp: number | undefined): b
770
774
771
775
// A click happened in the last 300ms?
772
776
// --> never consider this a redirect
773
- if ( lastClickTimestamp && now - lastClickTimestamp <= REDIRECT_THRESHOLD ) {
777
+ if ( lastInteractionTimestamp && now - lastInteractionTimestamp <= REDIRECT_THRESHOLD ) {
774
778
return false ;
775
779
}
776
780
0 commit comments