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 {
1110
1110
1111
1111
// If session is too short, or too long (allow some wiggle room over maxSessionLife), do not send it
1112
1112
// 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 ) {
1114
1116
// eslint-disable-next-line no-console
1115
1117
const log = this . getOptions ( ) . _experiments . traceInternals ? console . warn : logger . warn ;
1116
1118
__DEBUG_BUILD__ &&
1117
1119
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.`,
1119
1123
) ;
1120
1124
1125
+ if ( tooShort ) {
1126
+ this . _debouncedFlush ( ) ;
1127
+ }
1121
1128
return ;
1122
1129
}
1123
1130
Original file line number Diff line number Diff line change @@ -280,6 +280,12 @@ describe('Integration | flush', () => {
280
280
281
281
expect ( mockFlush ) . toHaveBeenCalledTimes ( 1 ) ;
282
282
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 ) ;
283
289
} ) ;
284
290
285
291
it ( 'does not flush if session is too long' , async ( ) => {
You can’t perform that action at this time.
0 commit comments