@@ -207,14 +207,40 @@ describe('Integration | session', () => {
207207 await vi . advanceTimersByTimeAsync ( DEFAULT_FLUSH_MIN_DELAY ) ;
208208 await new Promise ( process . nextTick ) ;
209209
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 ;
211224
212225 expect ( replay ) . toHaveLastSentReplay ( {
213226 recordingPayloadHeader : { segment_id : 0 } ,
214227 recordingData : JSON . stringify ( [
215- { data : { isCheckout : true } , timestamp : newTimestamp , type : 2 } ,
228+ { data : { isCheckout : true } , timestamp : newTimestamp - DEFAULT_FLUSH_MIN_DELAY , type : 2 } ,
216229 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+ } ,
218244 ] ) ,
219245 } ) ;
220246
@@ -224,7 +250,7 @@ describe('Integration | session', () => {
224250 // `_context` should be reset when a new session is created
225251 expect ( replay . getContext ( ) ) . toEqual ( {
226252 initialUrl : 'http://dummy/' ,
227- initialTimestamp : newTimestamp ,
253+ initialTimestamp : newTimestamp - DEFAULT_FLUSH_MIN_DELAY ,
228254 urls : [ ] ,
229255 errorIds : new Set ( ) ,
230256 traceIds : new Set ( ) ,
0 commit comments