@@ -338,7 +338,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
338338 } ;
339339
340340 let _collectWebVitals : undefined | ( ( ) => void ) ;
341- let lastClickTimestamp : number | undefined ;
341+ let lastInteractionTimestamp : number | undefined ;
342342
343343 /** Create routing idle transaction. */
344344 function _createRouteSpan ( client : Client , startSpanOptions : StartSpanOptions , makeActive = true ) : void {
@@ -446,7 +446,11 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
446446 }
447447
448448 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 } ) ;
450454 }
451455
452456 function maybeEndActiveSpan ( ) : void {
@@ -562,7 +566,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
562566 startingUrl = undefined ;
563567 const parsed = parseStringToURLObject ( to ) ;
564568 const activeSpan = getActiveIdleSpan ( client ) ;
565- const navigationIsRedirect = activeSpan && detectRedirects && isRedirect ( activeSpan , lastClickTimestamp ) ;
569+ const navigationIsRedirect = activeSpan && detectRedirects && isRedirect ( activeSpan , lastInteractionTimestamp ) ;
566570 startBrowserTracingNavigationSpan (
567571 client ,
568572 {
@@ -736,7 +740,7 @@ function setActiveIdleSpan(client: Client, span: Span | undefined): void {
736740// The max. time in seconds between two pageload/navigation spans that makes us consider the second one a redirect
737741const REDIRECT_THRESHOLD = 0.3 ;
738742
739- function isRedirect ( activeSpan : Span , lastClickTimestamp : number | undefined ) : boolean {
743+ function isRedirect ( activeSpan : Span , lastInteractionTimestamp : number | undefined ) : boolean {
740744 const spanData = spanToJSON ( activeSpan ) ;
741745
742746 const now = dateTimestampInSeconds ( ) ;
@@ -750,7 +754,7 @@ function isRedirect(activeSpan: Span, lastClickTimestamp: number | undefined): b
750754
751755 // A click happened in the last 300ms?
752756 // --> never consider this a redirect
753- if ( lastClickTimestamp && now - lastClickTimestamp <= REDIRECT_THRESHOLD ) {
757+ if ( lastInteractionTimestamp && now - lastInteractionTimestamp <= REDIRECT_THRESHOLD ) {
754758 return false ;
755759 }
756760
0 commit comments