@@ -21,10 +21,8 @@ export function maybeRefreshSession(
2121 } ,
2222 sessionOptions : SessionOptions ,
2323) : Session {
24- const isExpired = isSessionExpired ( session , timeouts ) ;
25-
2624 // If not expired, all good, just keep the session
27- if ( ! isExpired ) {
25+ if ( ! isSessionExpired ( session , timeouts ) ) {
2826 return session ;
2927 }
3028
@@ -74,26 +72,5 @@ export function loadOrCreateSession(
7472 return createSession ( sessionOptions ) ;
7573 }
7674
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 ) ;
9976}
0 commit comments