1
1
import { captureException , getCurrentHub } from '@sentry/core' ;
2
2
3
3
import {
4
+ BUFFER_CHECKOUT_TIME ,
4
5
DEFAULT_FLUSH_MIN_DELAY ,
5
- ERROR_CHECKOUT_TIME ,
6
6
MAX_SESSION_LIFE ,
7
7
REPLAY_SESSION_KEY ,
8
- SESSION_IDLE_DURATION ,
8
+ SESSION_IDLE_EXPIRE_DURATION ,
9
9
WINDOW ,
10
10
} from '../../src/constants' ;
11
11
import type { ReplayContainer } from '../../src/replay' ;
12
+ import { clearSession } from '../../src/session/clearSession' ;
12
13
import { addEvent } from '../../src/util/addEvent' ;
13
14
import { PerformanceEntryResource } from '../fixtures/performanceEntry/resource' ;
14
15
import type { RecordMock } from '../index' ;
15
16
import { BASE_TIMESTAMP } from '../index' ;
16
17
import { resetSdkMock } from '../mocks/resetSdkMock' ;
17
18
import type { DomHandler } from '../types' ;
18
- import { clearSession } from '../utils/clearSession' ;
19
19
import { useFakeTimers } from '../utils/use-fake-timers' ;
20
20
21
21
useFakeTimers ( ) ;
@@ -242,15 +242,15 @@ describe('Integration | errorSampleRate', () => {
242
242
} ) ;
243
243
} ) ;
244
244
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 ( ) => {
246
246
Object . defineProperty ( document , 'visibilityState' , {
247
247
configurable : true ,
248
248
get : function ( ) {
249
249
return 'visible' ;
250
250
} ,
251
251
} ) ;
252
252
253
- jest . advanceTimersByTime ( SESSION_IDLE_DURATION + 1 ) ;
253
+ jest . advanceTimersByTime ( SESSION_IDLE_EXPIRE_DURATION + 1 ) ;
254
254
255
255
document . dispatchEvent ( new Event ( 'visibilitychange' ) ) ;
256
256
@@ -274,8 +274,8 @@ describe('Integration | errorSampleRate', () => {
274
274
275
275
expect ( replay ) . not . toHaveLastSentReplay ( ) ;
276
276
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 ) ;
279
279
Object . defineProperty ( document , 'visibilityState' , {
280
280
configurable : true ,
281
281
get : function ( ) {
@@ -393,9 +393,9 @@ describe('Integration | errorSampleRate', () => {
393
393
} ) ;
394
394
395
395
// 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 ( ) => {
397
397
// Idle for 15 minutes
398
- jest . advanceTimersByTime ( SESSION_IDLE_DURATION + 1 ) ;
398
+ jest . advanceTimersByTime ( SESSION_IDLE_EXPIRE_DURATION + 1 ) ;
399
399
400
400
const TEST_EVENT = {
401
401
data : { name : 'lost event' } ,
@@ -408,7 +408,7 @@ describe('Integration | errorSampleRate', () => {
408
408
jest . runAllTimers ( ) ;
409
409
await new Promise ( process . nextTick ) ;
410
410
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
412
412
expect ( replay ) . not . toHaveLastSentReplay ( ) ;
413
413
expect ( replay . isEnabled ( ) ) . toBe ( false ) ;
414
414
expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
@@ -458,7 +458,7 @@ describe('Integration | errorSampleRate', () => {
458
458
} ) ;
459
459
460
460
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 ;
462
462
const TEST_EVENT = { data : { } , timestamp : BASE_TIMESTAMP , type : 3 } ;
463
463
mockRecord . _emitter ( TEST_EVENT ) ;
464
464
@@ -538,7 +538,7 @@ describe('Integration | errorSampleRate', () => {
538
538
expect ( replay ) . not . toHaveLastSentReplay ( ) ;
539
539
540
540
// Go idle
541
- jest . advanceTimersByTime ( SESSION_IDLE_DURATION + 1 ) ;
541
+ jest . advanceTimersByTime ( SESSION_IDLE_EXPIRE_DURATION + 1 ) ;
542
542
await new Promise ( process . nextTick ) ;
543
543
544
544
mockRecord . _emitter ( TEST_EVENT ) ;
@@ -617,8 +617,8 @@ it('sends a replay after loading the session multiple times', async () => {
617
617
replayOptions : {
618
618
stickySession : true ,
619
619
_experiments : {
620
- delayFlushOnCheckout : DEFAULT_FLUSH_MIN_DELAY
621
- }
620
+ delayFlushOnCheckout : DEFAULT_FLUSH_MIN_DELAY ,
621
+ } ,
622
622
} ,
623
623
autoStart : false ,
624
624
} ) ;
0 commit comments