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:

Embed
Preview of the card
<a href="https://lucidace.com/help/session-definition"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/8752fb02-f1ba-41b0-9cea-69b739d875b7/social-card.svg?v=3e7ae33eec8b" alt="Session definition" width="600" height="315"></a>

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-worker sessionize stage), which owns the stored session_id of every event;

  • the SDKs (packages/sdk-core SessionManager), which rotate $session_id on the same rule;

  • GET /v1/config, which serves the rule to the SDKs.

Settings

Key (settings.sdk)

Range

Default

Meaning

session_idle_minutes

1 to 1440

30

Minutes without an event before the next event starts a new session.

session_max_minutes

5 to 10080

1440

Longest session; an active session is split when it reaches this age. Not shorter than the idle timeout.

session_new_on_events

up to 20 names

none

Events that always start a new session (for example login or app_opened).

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-session and cargo test -p lc-worker --test session_policy

  • go test ./gateway -run TestConfigWithoutGeoRulesServesNoConsentDefault

  • pnpm --filter @lucida-analytics/sdk-core test remote-settings

Updated