Skip to content

RevTurbineUserContext

SDK-local user context state.

Extends the canonical UserContextInput with a local id field for user identification. The full persistence-ready UserContext (with tenant_id, user_id, timestamps) is built by the SDK via getUserContext().

custom is widened to Record<string, unknown> at the SDK boundary for customer convenience; values are narrowed to TraitValue when persisted via the API.

seat_type_handle is omitted on purpose (plan 279, D-36). A user’s seat type is assigned only server-side: by the tenant’s backend through a server-key user-context upsert, or by RevTurbine’s enrichment in hosted mode. The browser never writes it, so neither identify(), update(), setUserContext() nor the user init option accepts it. The browser receives the resolved seat_type / buyer_role as built-in dimensions delivered by GET /api/sdk/client-context instead. The server-computed activity_score / activity_score_computed_at are omitted on the same principle (BL-0352); the browser receives the derived activity_level dimension.

builtin_dimensions is omitted too (D-46, BL-0381): the browser never asserts a built-in dimension value. The SDK holds the values fetchClientContext delivers and stamps the reserved rt_<dimension> segment traits from them; read them back through getUserContext(). A plain-JS caller that passes any of these keys has them dropped and reported at runtime.

  • Omit<UserContextInput, "custom" | "entitlements" | "usage" | "personalization" | "derived_computed_at" | "context_hash" | ServerAssignedUserContextKey>

optional context_hash?: string | null

Server-computed user-context hash (plan 74). Optional at the SDK input boundary for the same reason as derived_computed_at.


optional custom?: SdkTraits

Customer-defined fields for segmentation and personalization.


optional derived_computed_at?: string | null

Server-computed derived-entitlement cache stamp (plan 74). Optional at the SDK input boundary — local mode does not compute it; the control plane populates and round-trips it, defaulting to null when absent.


optional entitlements?: Record<string, boolean | { }>

App-supplied entitlement data, keyed by handle — a boolean or a grant (status, limit, used). This is Entitlement Mirroring (D-61): it merges with the Playbook evaluation, and by default the app’s data wins. Browser-supplied data shapes the UI only; the server re-check on the same inputs stays authoritative for paid actions.


optional id?: string

Authenticated user identifier. When undefined, the SDK uses an anonymous ID.


optional personalization?: SdkTraits

Transient personalization token map.

Holds SDK-derived tokens (plan_name, usage_current, etc.) merged with app-provided tokens. Not persisted — rebuilt on each SDK session. Widened to accept unknown at the SDK boundary; narrowed to string | number when serialized.


optional usage?: Record<string, { }>

Usage entries derived from credits / usage_limit entitlements, keyed by handle.