Skip to content

Commit ba805b3

Browse files
committed
ref: Some improvements
1 parent 0ec5bf6 commit ba805b3

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

packages/replay/src/session/getSession.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)