UNPKG

@embrace-io/web-sdk

Version:
108 lines 5.5 kB
import { ExtendedSpan } from "../../api-traces/api/TraceAPI/types.cjs"; import "../../index.cjs"; //#region src/api-sessions/manager/types.d.ts interface UserSessionManager { /** @deprecated Will be removed in a future version, use getUserSessionId(); returns null when no user session is active. */ getSessionId: () => string | null; /** @deprecated Will be removed in a future version, always returns null. Use getPreviousUserSessionId(). */ getPreviousSessionId: () => null; /** * @deprecated Will be removed in a future version, use * getUserSessionStartTime(); returns null when no user session is active, * otherwise milliseconds since the Unix epoch. */ getSessionStartTime: () => number | null; /** @deprecated Will be removed in a future version, use getSessionPartSpan(); returns null when no part is active. */ getSessionSpan: () => ExtendedSpan | null; /** * @deprecated Will be removed in a future version. No-op: starting a * session part is an internal consequence of foreground engagement * (visibility, focus, input) and is not exposed to callers. */ startSessionSpan: (options?: StartSessionOptions) => void; /** @deprecated Will be removed in a future version, use endUserSession(). */ endSessionSpan: () => void; /** * Adds a breadcrumb event to the active session part span. If no part is * active the breadcrumb is dropped. */ addBreadcrumb: (name: string) => void; /** * Stores a key/value property that travels with every session part within * the current user session. Properties added without `lifespan: 'permanent'` * survive across foreground/background transitions but are cleared when the * user session ends. They are persisted alongside the user-session state in * localStorage, so other tabs sharing the same user session pick them up * on their next part start. With `lifespan: 'permanent'` the property is * stored as its own localStorage entry and reapplied across user sessions * until removed via `removeProperty(key)`. * * When storage is unavailable, writes are rejected (both for `lifespan: * 'permanent'` and the default user-session scope), the in-memory state * is not updated, and the property will not appear on any session part * span. A warning is logged. * * Safe to call before any part is active. Properties are persisted * immediately and stamped on the session part span at end time. */ addProperty: (key: string, value: string, options?: PropertyOptions) => void; /** * Removes a property regardless of scope: clears it from the in-memory * maps (both user-session and permanent) and from localStorage. */ removeProperty: (key: string) => void; /** @deprecated Will be removed in a future version, always returns null. */ currentSessionAsReadableSpan: (reason: ReasonSessionEnded) => null; /** @deprecated Will be removed in a future version, the listener is never invoked and the returned unsubscribe is a no-op. */ addSessionStartedListener: (listener: () => void) => () => void; /** @deprecated Will be removed in a future version, the listener is never invoked and the returned unsubscribe is a no-op. */ addSessionEndedListener: (listener: () => void) => () => void; /** * Returns the active user session UUID, or `null` when no user session active */ getUserSessionId: () => string | null; getPreviousUserSessionId: () => string | null; getUserSessionStartTime: () => number | null; /** * Returns the active session part span, or `null` when no part is active. * * The SDK owns this span's lifecycle and can end it at any moment * (backgrounding, inactivity, max duration, user session end). Do not end * it yourself and do not hold long-lived references to it. * * Direct access to the span exists for backwards compatibility only and * will be removed entirely in a future version. */ getSessionPartSpan: () => ExtendedSpan | null; /** * Ends the current user session. The next foreground session part will * begin a new user session; there is no companion public start API, * starting is an internal consequence of the next foreground part. * * Subject to a 5-second cooldown. * * If no part is active when called, the user session is still ended and * the next foreground part begins a new one, but no part span can carry * `emb.user_session_termination_reason='manual'` (the attribute is only * stamped on a final part span). */ endUserSession: () => void; } /** @deprecated Will be removed in a future version */ type ReasonSessionEnded = 'unknown' | 'inactivity' | 'timer' | 'manual' | 'max_size_reached' | 'state_changed'; type PropertyOptions = { lifespan?: 'permanent'; }; /** @deprecated Will be removed in a future version */ type StartSessionOptions = { reason?: string; }; type SessionPartStartReason = 'init' | 'foreground' | 'web_activity' | 'web_soft_navigation' | 'user_session_rollover'; interface SessionPartStartedEvent { readonly reason: SessionPartStartReason; } type SessionPartEndReason = 'background' | 'web_foreground_inactivity' | 'web_soft_navigation' | 'user_session_ended'; type UserSessionEndReason = 'manual' | 'max_duration_reached' | 'inactivity'; //#endregion export { PropertyOptions, ReasonSessionEnded, SessionPartEndReason, SessionPartStartReason, SessionPartStartedEvent, StartSessionOptions, UserSessionEndReason, UserSessionManager }; //# sourceMappingURL=types.d.cts.map