File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -1132,11 +1132,18 @@ export class ReplayContainer implements ReplayContainerInterface {
11321132
11331133    // If session is too short, or too long (allow some wiggle room over maxSessionLife), do not send it 
11341134    // This _should_ not happen, but it may happen if flush is triggered due to a page activity change or similar 
1135-     if  ( duration  <  this . _options . minReplayDuration  ||  duration  >  this . timeouts . maxSessionLife  +  5_000 )  { 
1135+     const  tooShort  =  duration  <  this . _options . minReplayDuration ; 
1136+     const  tooLong  =  duration  >  this . timeouts . maxSessionLife  +  5_000 ; 
1137+     if  ( tooShort  ||  tooLong )  { 
11361138      logInfo ( 
1137-         `[Replay] Session duration (${ Math . floor ( duration  /  1000 ) }  , 
1138-         this . _options . _experiments . traceInternals , 
1139+         `[Replay] Session duration (${ Math . floor ( duration  /  1000 ) } ${  
1140+           tooShort  ? 'short'  : 'long'  
1141+         }  , not sending replay.`, 
11391142      ) ; 
1143+ 
1144+       if  ( tooShort )  { 
1145+         this . _debouncedFlush ( ) ; 
1146+       } 
11401147      return ; 
11411148    } 
11421149
Original file line number Diff line number Diff line change @@ -280,6 +280,12 @@ describe('Integration | flush', () => {
280280
281281    expect ( mockFlush ) . toHaveBeenCalledTimes ( 1 ) ; 
282282    expect ( mockSendReplay ) . toHaveBeenCalledTimes ( 0 ) ; 
283+ 
284+     // it should re-schedule the flush, so once the min. duration is reached it should automatically send it 
285+     await  advanceTimers ( 100_000  -  DEFAULT_FLUSH_MIN_DELAY ) ; 
286+ 
287+     expect ( mockFlush ) . toHaveBeenCalledTimes ( 20 ) ; 
288+     expect ( mockSendReplay ) . toHaveBeenCalledTimes ( 1 ) ; 
283289  } ) ; 
284290
285291  it ( 'does not flush if session is too long' ,  async  ( )  =>  { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments