File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -1110,14 +1110,21 @@ export class ReplayContainer implements ReplayContainerInterface {
11101110
11111111 // If session is too short, or too long (allow some wiggle room over maxSessionLife), do not send it
11121112 // This _should_ not happen, but it may happen if flush is triggered due to a page activity change or similar
1113- if ( duration < this . _options . minReplayDuration || duration > this . timeouts . maxSessionLife + 5_000 ) {
1113+ const tooShort = duration < this . _options . minReplayDuration ;
1114+ const tooLong = duration > this . timeouts . maxSessionLife + 5_000 ;
1115+ if ( tooShort || tooLong ) {
11141116 // eslint-disable-next-line no-console
11151117 const log = this . getOptions ( ) . _experiments . traceInternals ? console . warn : logger . warn ;
11161118 __DEBUG_BUILD__ &&
11171119 log (
1118- `[Replay] Session duration (${ Math . floor ( duration / 1000 ) } s) is too short or too long, not sending replay.` ,
1120+ `[Replay] Session duration (${ Math . floor ( duration / 1000 ) } s) is too ${
1121+ tooShort ? 'short' : 'long'
1122+ } , not sending replay.`,
11191123 ) ;
11201124
1125+ if ( tooShort ) {
1126+ this . _debouncedFlush ( ) ;
1127+ }
11211128 return ;
11221129 }
11231130
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