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.
Extends
Section titled “Extends”Omit<UserContextInput,"custom"|"entitlements"|"usage"|"personalization"|"derived_computed_at"|"context_hash"|ServerAssignedUserContextKey>
Properties
Section titled “Properties”context_hash?
Section titled “context_hash?”
optionalcontext_hash?:string|null
Server-computed user-context hash (plan 74). Optional at the SDK input
boundary for the same reason as derived_computed_at.
custom?
Section titled “custom?”
optionalcustom?:SdkTraits
Customer-defined fields for segmentation and personalization.
derived_computed_at?
Section titled “derived_computed_at?”
optionalderived_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.
entitlements?
Section titled “entitlements?”
optionalentitlements?:Record<string,MirroredEntitlement>
App-supplied entitlement data, keyed by handle — a boolean or a grant
(status, allowed, limit, used, remaining, reason, all
optional; no entitlement_id or entitlement_handle needed). 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.
optionalid?:string
Authenticated user identifier — your stable internal user id.
Required at init (user: { id } on RevTurbineInitOptions.user):
the SDK has no anonymous mode, and a missing or blank id leaves it
disabled. This patch shape keeps id optional only because
setUserContext() merges partial updates; identity is (re)established
with identify().
personalization?
Section titled “personalization?”
optionalpersonalization?: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.
usage?
Section titled “usage?”
optionalusage?:Record<string, { }>
Usage entries derived from credits / usage_limit entitlements, keyed by handle.