@@ -338,7 +338,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
338
338
} ;
339
339
340
340
let _collectWebVitals : undefined | ( ( ) => void ) ;
341
- let lastClickTimestamp : number | undefined ;
341
+ let lastInteractionTimestamp : number | undefined ;
342
342
343
343
/** Create routing idle transaction. */
344
344
function _createRouteSpan ( client : Client , startSpanOptions : StartSpanOptions , makeActive = true ) : void {
@@ -446,7 +446,11 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
446
446
}
447
447
448
448
if ( detectRedirects && optionalWindowDocument ) {
449
- addEventListener ( 'click' , ( ) => ( lastClickTimestamp = timestampInSeconds ( ) ) , { capture : true , passive : true } ) ;
449
+ const clickHandler = ( ) : void => {
450
+ lastInteractionTimestamp = timestampInSeconds ( ) ;
451
+ } ;
452
+ addEventListener ( 'click' , ( ) => clickHandler , { capture : true , passive : true } ) ;
453
+ addEventListener ( 'keypress' , ( ) => clickHandler , { capture : true , passive : true } ) ;
450
454
}
451
455
452
456
function maybeEndActiveSpan ( ) : void {
@@ -562,7 +566,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
562
566
startingUrl = undefined ;
563
567
const parsed = parseStringToURLObject ( to ) ;
564
568
const activeSpan = getActiveIdleSpan ( client ) ;
565
- const navigationIsRedirect = activeSpan && detectRedirects && isRedirect ( activeSpan , lastClickTimestamp ) ;
569
+ const navigationIsRedirect = activeSpan && detectRedirects && isRedirect ( activeSpan , lastInteractionTimestamp ) ;
566
570
startBrowserTracingNavigationSpan (
567
571
client ,
568
572
{
@@ -736,7 +740,7 @@ function setActiveIdleSpan(client: Client, span: Span | undefined): void {
736
740
// The max. time in seconds between two pageload/navigation spans that makes us consider the second one a redirect
737
741
const REDIRECT_THRESHOLD = 0.3 ;
738
742
739
- function isRedirect ( activeSpan : Span , lastClickTimestamp : number | undefined ) : boolean {
743
+ function isRedirect ( activeSpan : Span , lastInteractionTimestamp : number | undefined ) : boolean {
740
744
const spanData = spanToJSON ( activeSpan ) ;
741
745
742
746
const now = dateTimestampInSeconds ( ) ;
@@ -750,7 +754,7 @@ function isRedirect(activeSpan: Span, lastClickTimestamp: number | undefined): b
750
754
751
755
// A click happened in the last 300ms?
752
756
// --> never consider this a redirect
753
- if ( lastClickTimestamp && now - lastClickTimestamp <= REDIRECT_THRESHOLD ) {
757
+ if ( lastInteractionTimestamp && now - lastInteractionTimestamp <= REDIRECT_THRESHOLD ) {
754
758
return false ;
755
759
}
756
760
0 commit comments