File tree 2 files changed +16
-3
lines changed
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 {
1132
1132
1133
1133
// If session is too short, or too long (allow some wiggle room over maxSessionLife), do not send it
1134
1134
// 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 ) {
1136
1138
logInfo (
1137
- `[Replay] Session duration (${ Math . floor ( duration / 1000 ) } s) is too short or too long, not sending replay.` ,
1138
- this . _options . _experiments . traceInternals ,
1139
+ `[Replay] Session duration (${ Math . floor ( duration / 1000 ) } s) is too ${
1140
+ tooShort ? 'short' : 'long'
1141
+ } , not sending replay.`,
1139
1142
) ;
1143
+
1144
+ if ( tooShort ) {
1145
+ this . _debouncedFlush ( ) ;
1146
+ }
1140
1147
return ;
1141
1148
}
1142
1149
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