@@ -207,14 +207,40 @@ describe('Integration | session', () => {
207
207
await vi . advanceTimersByTimeAsync ( DEFAULT_FLUSH_MIN_DELAY ) ;
208
208
await new Promise ( process . nextTick ) ;
209
209
210
- const newTimestamp = BASE_TIMESTAMP + ELAPSED ;
210
+
211
+ // The click actually does not trigger a flush because it never gets added to event buffer because
212
+ // the session is expired. We stop recording and re-sample the session expires.
213
+ expect ( replay ) . not . toHaveLastSentReplay ( ) ;
214
+
215
+ // This click will trigger a flush now that the session is active
216
+ // (sessionSampleRate=1 when resampling)
217
+ domHandler ( {
218
+ name : 'click' ,
219
+ event : new Event ( 'click' ) ,
220
+ } ) ;
221
+ await vi . advanceTimersByTimeAsync ( DEFAULT_FLUSH_MIN_DELAY ) ;
222
+ await new Promise ( process . nextTick ) ;
223
+ const newTimestamp = BASE_TIMESTAMP + ELAPSED + DEFAULT_FLUSH_MIN_DELAY ;
211
224
212
225
expect ( replay ) . toHaveLastSentReplay ( {
213
226
recordingPayloadHeader : { segment_id : 0 } ,
214
227
recordingData : JSON . stringify ( [
215
- { data : { isCheckout : true } , timestamp : newTimestamp , type : 2 } ,
228
+ { data : { isCheckout : true } , timestamp : newTimestamp - DEFAULT_FLUSH_MIN_DELAY , type : 2 } ,
216
229
optionsEvent ,
217
- // the click is lost, but that's OK
230
+ {
231
+ type : 5 ,
232
+ timestamp : newTimestamp ,
233
+ data : {
234
+ tag : 'breadcrumb' ,
235
+ payload : {
236
+ timestamp : newTimestamp / 1000 ,
237
+ type : 'default' ,
238
+ category : 'ui.click' ,
239
+ message : '<unknown>' ,
240
+ data : { } ,
241
+ } ,
242
+ } ,
243
+ } ,
218
244
] ) ,
219
245
} ) ;
220
246
@@ -224,7 +250,7 @@ describe('Integration | session', () => {
224
250
// `_context` should be reset when a new session is created
225
251
expect ( replay . getContext ( ) ) . toEqual ( {
226
252
initialUrl : 'http://dummy/' ,
227
- initialTimestamp : newTimestamp ,
253
+ initialTimestamp : newTimestamp - DEFAULT_FLUSH_MIN_DELAY ,
228
254
urls : [ ] ,
229
255
errorIds : new Set ( ) ,
230
256
traceIds : new Set ( ) ,
0 commit comments