@@ -21,10 +21,8 @@ export function maybeRefreshSession(
21
21
} ,
22
22
sessionOptions : SessionOptions ,
23
23
) : Session {
24
- const isExpired = isSessionExpired ( session , timeouts ) ;
25
-
26
24
// If not expired, all good, just keep the session
27
- if ( ! isExpired ) {
25
+ if ( ! isSessionExpired ( session , timeouts ) ) {
28
26
return session ;
29
27
}
30
28
@@ -74,26 +72,5 @@ export function loadOrCreateSession(
74
72
return createSession ( sessionOptions ) ;
75
73
}
76
74
77
- // If a session exists, and it is not expired, just return it
78
- if ( ! isSessionExpired ( existingSession , timeouts ) ) {
79
- return existingSession ;
80
- }
81
-
82
- // If expired & we have a buffering session that should be refreshed, return it
83
- if ( existingSession . sampled === 'buffer' && existingSession . shouldRefresh ) {
84
- return existingSession ;
85
- }
86
-
87
- // If expired & we have a buffering session that should _not_ be refreshed, return a new unsampled session
88
- if ( existingSession . sampled === 'buffer' ) {
89
- logInfoNextTick ( '[Replay] Session should not be refreshed' , traceInternals ) ;
90
- return makeSession ( { sampled : false } ) ;
91
- }
92
-
93
- // Else, we have an expired session that should be refreshed & re-sampled
94
- logInfoNextTick ( '[Replay] Session has expired, creating new one...' , traceInternals ) ;
95
-
96
- const newSession = createSession ( sessionOptions , { previousSessionId : existingSession . id } ) ;
97
-
98
- return newSession ;
75
+ return maybeRefreshSession ( existingSession , { timeouts, traceInternals } , sessionOptions ) ;
99
76
}
0 commit comments