Home > @uniformdev/context > Context

Context class

Signature:

Implements: ContextInstance

Constructors

Constructor

Modifiers

Description

(constructor)(options)

Constructs a new instance of the Context class

Properties

Property

Modifiers

Type

Description

events

readonly

{ on: { <Key extends keyof ContextEvents>): void; }; }

Subscribe to events

manifest

readonly

ManifestInstance

quirks

readonly

Readonly<Quirks>

Gets the current visitor's quirks values.

requireConsentForPersonalization

readonly

boolean | undefined

scores

readonly

Readonly<ScoreVector>

Gets the current visitor's dimension score vector.

storage

readonly

VisitorDataStore

Methods

Method

Modifiers

Description

forget(fromAllDevices)

Forgets the visitor's data and resets the Context to its initial state.

getCompositionMetadata()

Gets the current canvas data

getPersonalizeVariantControl(name, index)

getServerToClientTransitionState()

Computes server to client transition state.

Removes state from server-to-client if it came in initial state (cookies) to avoid double tracking on the client.

getTestVariantId(testName)

use test() instead

internal_processPersonalizationEvent(event)

internal_processTestEvent(event)

log(message)

Writes a message to the Context log sink. Used by Uniform internal SDK; not intended for public use.

personalize(options)

Executes a personalized placement with a given set of variants

processServerCommands({ serverCommands, commands, }, input)

setTestVariantId(testName, variantId)

use test() instead

test(options)

Executes an A/B test with a given set of variants, showing the visitor's assigned variant (or selecting one to assign, if none is set yet)

update(newData)

Updates the Context with new data of any sort, such as new URLs, cookies, quirks, and enrichments.

Only properties that are set in the data parameter will be updated, for example if passing url but not cookies, the last known state of cookies will be preserved.

Properties that do not result in a changed state, i.e. pushing the same URL or cookies as before, will NOT result in a recomputation of signal state.

updateCompositionMetadata(newData)

Updates the canvas data and emits a canvasDataUpdated event