SdkSession
A fully-initialized SDK session with convenience methods for creating placement and entitlement controllers, updating user context, and accessing the underlying SDK instance.
This is the recommended entry point for headless (non-React) consumers.
Example
Section titled “Example”const session = await initRevTurbine({ tenantId: 'tenant_abc', apiKey: 'rt_live_xxx', endpoint: 'https://api.revturbine.io', user: { id: 'user_123', plan: { id: 'pro' } },});
// Get a placement by slot IDconst banner = session.placement({ surfaceSlot: { id: 'upsell_banner' } });const decision = await banner.load();
// Check an entitlement with auto-gateconst gate = session.entitlement({ handle: 'brand_kit', autoGate: true });await gate.check();
// Update user context (works in any runtime mode)session.identify('user_456', { plan: { id: 'enterprise' } });session.setUserContext({ personalization: { company: 'Acme' } });Properties
Section titled “Properties”
readonlysdk:RevTurbineCustomerSdk
The underlying SDK instance. Use for advanced/direct operations.
readonlytheme:RevTurbineTheme
Resolved theme.
Methods
Section titled “Methods”checkEntitlement()
Section titled “checkEntitlement()”checkEntitlement(
handle,context?):Promise<{ }>
One-shot entitlement check. For auto-gating or reactive updates, prefer entitlement which returns a full controller.
Parameters
Section titled “Parameters”handle
Section titled “handle”string
context?
Section titled “context?”RevTurbineEntitlementContext
Returns
Section titled “Returns”Promise<{ }>
entitlement()
Section titled “entitlement()”entitlement(
options):EntitlementGate
Create an EntitlementGate bound to this session’s SDK.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Example
Section titled “Example”const gate = session.entitlement({ handle: 'brand_kit', autoGate: true });await gate.check();if (gate.denied) { showGate(gate.gatedPlacement); }fetchUserContext()
Section titled “fetchUserContext()”fetchUserContext(
userId):Promise<UserTargetingContext>
Fetch full user context from the server (server runtime mode).
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<UserTargetingContext>
getPlacement()
Section titled “getPlacement()”getPlacement(
config):Promise<{ } |null>
Get a raw placement output by request config (slot, entitlement, plan, or chained).
Returns the full PlacementOutput or null.
Parameters
Section titled “Parameters”config
Section titled “config”RevTurbinePlacementRequestConfig
Returns
Section titled “Returns”Promise<{ } | null>
getPlacementBySlotId()
Section titled “getPlacementBySlotId()”getPlacementBySlotId(
slotId,options?):Promise<RevTurbinePlacementDecision|null>
One-shot: register a surface slot, fetch a decision, and return it.
For repeated use or interaction tracking, prefer placement which returns a full controller.
Parameters
Section titled “Parameters”slotId
Section titled “slotId”string
options?
Section titled “options?”Omit<PlacementControllerOptions, "placement" | "surfaceSlot">
Returns
Section titled “Returns”Promise<RevTurbinePlacementDecision | null>
getTrialStatus()
Section titled “getTrialStatus()”getTrialStatus():
Promise<{ }>
Get the current trial status.
Returns
Section titled “Returns”Promise<{ }>
getUsage()
Section titled “getUsage()”getUsage():
RevTurbineUsageSnapshot
Get a snapshot of current usage balances.
Returns
Section titled “Returns”getUserContext()
Section titled “getUserContext()”getUserContext():
object
Get the current resolved user context (includes tenant_id, user_id).
Returns
Section titled “Returns”object
identify()
Section titled “identify()”identify(
userId,contextOrTraits?):void
Identify a user and optionally set traits/context. Triggers segment re-evaluation and clears decision cache.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
contextOrTraits?
Section titled “contextOrTraits?”Returns
Section titled “Returns”void
placement()
Section titled “placement()”placement(
options):PlacementController
Create a PlacementController bound to this session’s SDK.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Example
Section titled “Example”const banner = session.placement({ surfaceSlot: { id: 'upsell_banner' } });await banner.load();if (banner.visible) { renderBanner(banner.content); }resetIdentity()
Section titled “resetIdentity()”resetIdentity():
void
Reset to anonymous user state.
Returns
Section titled “Returns”void
resetUserContext()
Section titled “resetUserContext()”resetUserContext():
void
Hard-reset the user context to a blank slate (no anonymous inference) — removes every user-context value plus usage balances and clears the decision cache, interaction state, and impression history. Mostly for demo / fixture flows. See RevTurbineCustomerSdk.resetUserContext.
Returns
Section titled “Returns”void
setUserContext()
Section titled “setUserContext()”setUserContext(
context):void
Merge fields into the current user context. Triggers segment re-evaluation.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”void
trackEvent()
Section titled “trackEvent()”trackEvent(
name,data?):Promise<void>
Track a custom event.
Parameters
Section titled “Parameters”string
Record<string, JsonValue>
Returns
Section titled “Returns”Promise<void>
updateUsage()
Section titled “updateUsage()”updateUsage(
balances):void
Update usage balances (e.g. after a meter event).
Parameters
Section titled “Parameters”balances
Section titled “balances”Returns
Section titled “Returns”void