@embrace-io/web-sdk
Version:
34 lines • 2.06 kB
TypeScript
import { NamespacedStorage } from "../../../utils/NamespacedStorage/NamespacedStorage.js";
import "../../../utils/index.js";
import { UserSessionState } from "../types.js";
import { DiagLogger } from "@opentelemetry/api";
//#region src/managers/EmbraceUserSessionManager/utils/state.d.ts
/**
* True when the stored state is no longer trustworthy: the device clock
* jumped backwards past the recorded start, the max-duration deadline has
* passed, or an inactivity deadline (set when the last part ended) has
* passed. Inactivity only applies between parts; the deadline is null
* while a part is active.
*/
declare const isUserSessionExpired: (state: UserSessionState, now: number) => boolean;
interface CreateUserSessionStateArgs {
now: number;
previousUserSessionId: string | null;
userSessionMaxDurationSeconds: number;
userSessionInactivityTimeoutSeconds: number;
userSessionForegroundInactivityTimeoutSeconds: number;
userSessionNumber: number;
}
declare const createUserSessionState: ({ now, previousUserSessionId, userSessionMaxDurationSeconds, userSessionInactivityTimeoutSeconds, userSessionForegroundInactivityTimeoutSeconds, userSessionNumber }: CreateUserSessionStateArgs) => UserSessionState;
declare const readUserSessionState: (storage: NamespacedStorage, diag: DiagLogger) => UserSessionState | null;
declare const readPermanentProperties: (storage: NamespacedStorage, diag: DiagLogger) => Record<string, string>;
/**
* Empty blobs are removed rather than written so storage stays tidy when
* the last property is cleared. Returns false on a failed write; callers
* gate cross-scope flips on this so a failed permanent write doesn't
* strip the previously-visible user-session-scoped value.
*/
declare const storePermanentProperties: (storage: NamespacedStorage, properties: Record<string, string>) => boolean;
//#endregion
export { CreateUserSessionStateArgs, createUserSessionState, isUserSessionExpired, readPermanentProperties, readUserSessionState, storePermanentProperties };
//# sourceMappingURL=state.d.ts.map