11import { captureException , getCurrentHub } from '@sentry/core' ;
22
33import {
4+ BUFFER_CHECKOUT_TIME ,
45 DEFAULT_FLUSH_MIN_DELAY ,
5- ERROR_CHECKOUT_TIME ,
66 MAX_SESSION_LIFE ,
77 REPLAY_SESSION_KEY ,
8- SESSION_IDLE_DURATION ,
8+ SESSION_IDLE_EXPIRE_DURATION ,
99 WINDOW ,
1010} from '../../src/constants' ;
1111import type { ReplayContainer } from '../../src/replay' ;
12+ import { clearSession } from '../../src/session/clearSession' ;
1213import { addEvent } from '../../src/util/addEvent' ;
1314import { PerformanceEntryResource } from '../fixtures/performanceEntry/resource' ;
1415import type { RecordMock } from '../index' ;
1516import { BASE_TIMESTAMP } from '../index' ;
1617import { resetSdkMock } from '../mocks/resetSdkMock' ;
1718import type { DomHandler } from '../types' ;
18- import { clearSession } from '../utils/clearSession' ;
1919import { useFakeTimers } from '../utils/use-fake-timers' ;
2020
2121useFakeTimers ( ) ;
@@ -242,15 +242,15 @@ describe('Integration | errorSampleRate', () => {
242242 } ) ;
243243 } ) ;
244244
245- it ( 'does not send a replay when triggering a full dom snapshot when document becomes visible after [SESSION_IDLE_DURATION ]ms' , async ( ) => {
245+ it ( 'does not send a replay when triggering a full dom snapshot when document becomes visible after [SESSION_IDLE_EXPIRE_DURATION ]ms' , async ( ) => {
246246 Object . defineProperty ( document , 'visibilityState' , {
247247 configurable : true ,
248248 get : function ( ) {
249249 return 'visible' ;
250250 } ,
251251 } ) ;
252252
253- jest . advanceTimersByTime ( SESSION_IDLE_DURATION + 1 ) ;
253+ jest . advanceTimersByTime ( SESSION_IDLE_EXPIRE_DURATION + 1 ) ;
254254
255255 document . dispatchEvent ( new Event ( 'visibilitychange' ) ) ;
256256
@@ -274,8 +274,8 @@ describe('Integration | errorSampleRate', () => {
274274
275275 expect ( replay ) . not . toHaveLastSentReplay ( ) ;
276276
277- // User comes back before `SESSION_IDLE_DURATION ` elapses
278- jest . advanceTimersByTime ( SESSION_IDLE_DURATION - 100 ) ;
277+ // User comes back before `SESSION_IDLE_EXPIRE_DURATION ` elapses
278+ jest . advanceTimersByTime ( SESSION_IDLE_EXPIRE_DURATION - 100 ) ;
279279 Object . defineProperty ( document , 'visibilityState' , {
280280 configurable : true ,
281281 get : function ( ) {
@@ -393,9 +393,9 @@ describe('Integration | errorSampleRate', () => {
393393 } ) ;
394394
395395 // Should behave the same as above test
396- it ( 'stops replay if user has been idle for more than SESSION_IDLE_DURATION and does not start a new session thereafter' , async ( ) => {
396+ it ( 'stops replay if user has been idle for more than SESSION_IDLE_EXPIRE_DURATION and does not start a new session thereafter' , async ( ) => {
397397 // Idle for 15 minutes
398- jest . advanceTimersByTime ( SESSION_IDLE_DURATION + 1 ) ;
398+ jest . advanceTimersByTime ( SESSION_IDLE_EXPIRE_DURATION + 1 ) ;
399399
400400 const TEST_EVENT = {
401401 data : { name : 'lost event' } ,
@@ -408,7 +408,7 @@ describe('Integration | errorSampleRate', () => {
408408 jest . runAllTimers ( ) ;
409409 await new Promise ( process . nextTick ) ;
410410
411- // We stop recording after SESSION_IDLE_DURATION of inactivity in error mode
411+ // We stop recording after SESSION_IDLE_EXPIRE_DURATION of inactivity in error mode
412412 expect ( replay ) . not . toHaveLastSentReplay ( ) ;
413413 expect ( replay . isEnabled ( ) ) . toBe ( false ) ;
414414 expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
@@ -458,7 +458,7 @@ describe('Integration | errorSampleRate', () => {
458458 } ) ;
459459
460460 it ( 'has correct timestamps when error occurs much later than initial pageload/checkout' , async ( ) => {
461- const ELAPSED = ERROR_CHECKOUT_TIME ;
461+ const ELAPSED = BUFFER_CHECKOUT_TIME ;
462462 const TEST_EVENT = { data : { } , timestamp : BASE_TIMESTAMP , type : 3 } ;
463463 mockRecord . _emitter ( TEST_EVENT ) ;
464464
@@ -538,7 +538,7 @@ describe('Integration | errorSampleRate', () => {
538538 expect ( replay ) . not . toHaveLastSentReplay ( ) ;
539539
540540 // Go idle
541- jest . advanceTimersByTime ( SESSION_IDLE_DURATION + 1 ) ;
541+ jest . advanceTimersByTime ( SESSION_IDLE_EXPIRE_DURATION + 1 ) ;
542542 await new Promise ( process . nextTick ) ;
543543
544544 mockRecord . _emitter ( TEST_EVENT ) ;
@@ -617,8 +617,8 @@ it('sends a replay after loading the session multiple times', async () => {
617617 replayOptions : {
618618 stickySession : true ,
619619 _experiments : {
620- delayFlushOnCheckout : DEFAULT_FLUSH_MIN_DELAY
621- }
620+ delayFlushOnCheckout : DEFAULT_FLUSH_MIN_DELAY ,
621+ } ,
622622 } ,
623623 autoStart : false ,
624624 } ) ;
0 commit comments