Session definition
Each project decides how visits are cut into sessions. The same rule runs in three places, so client and server agree on session ids:
Each project decides how visits are cut into sessions. The same rule runs in three places, so client and server agree on session ids:
the worker sessionizer (
crates/lc-session,services/lc-workersessionize stage), which owns the storedsession_idof every event;the SDKs (
packages/sdk-coreSessionManager), which rotate$session_idon the same rule;GET /v1/config, which serves the rule to the SDKs.
Settings
Key ( | Range | Default | Meaning |
|---|---|---|---|
| 1 to 1440 | 30 | Minutes without an event before the next event starts a new session. |
| 5 to 10080 | 1440 | Longest session; an active session is split when it reaches this age. Not shorter than the idle timeout. |
| up to 20 names | none | Events that always start a new session (for example |
A change in UTM campaign also starts a new session, as before.
Set them in Project settings -> Session definition, or through the API (admins only; present keys replace, absent keys are kept):
PUT /v1/projects/{project_id}/settings/sdk
{"session_idle_minutes": 15, "session_max_minutes": 240, "session_new_on_events": ["login"]}The worker picks the change up within a minute and the SDKs on their next config load. Stored sessions keep their boundaries; only new events follow the new rule.
SDKs
The browser SDK applies the project rule when it loads the remote config (autocapture, replay, heatmaps or consent.geo load it). Options passed in code win over the project rule:
lucida.init("lc_pk_...", { session: { idleMs: 10 * 60_000, newOnEvents: ["login"] } });Other SDKs built on @lucida-analytics/sdk-core call core.applyRemote(config) with the GET /v1/config response.
Verify
cargo test -p lc-sessionandcargo test -p lc-worker --test session_policygo test ./gateway -run TestConfigWithoutGeoRulesServesNoConsentDefaultpnpm --filter @lucida-analytics/sdk-core test remote-settings