Class

Context

Context(config, dependencies)

Provides visitor context
Constructor

# new Context(config, dependencies)

Parameters:
Name Type Description
config Config
dependencies Object
apiManager ApiManagerInterface
eventManager EventManagerInterface
experienceManager ExperienceManagerInterface
featureManager FeatureManagerInterface
dataManager DataManagerInterface
apiManager ApiManagerInterface
loggerManager LogManagerInterface
Implements:
  • ContextInterface

View Source src/context.ts, line 10

Classes

Context
Context

Methods

# getConfigEntity(key, entityType) → {Entity}

get Config Entity
Parameters:
Name Type Description
key string
entityType EntityType

View Source src/context.ts, line 483

Entity

# getConfigEntityById(id, entityType) → {Entity}

get Config Entity by string
Parameters:
Name Type Description
id string
entityType EntityType

View Source src/context.ts, line 491

Entity

# getVisitorData() → {StoreData}

Get visitor data

View Source src/context.ts, line 497

StoreData

# getVisitorProperties(attributesopt) → {Record.<string, any>}

Get visitor properties
Parameters:
Name Type Attributes Description
attributes Record.<string, any> <optional>
An object of key-value pairs that are used for audience targeting

View Source src/context.ts, line 349

Record.<string, any>

# releaseQueues(reasonopt) → {Promise.<any>}

Send pending API/DataStore queues to server
Parameters:
Name Type Attributes Description
reason string <optional>

View Source src/context.ts, line 504

Promise.<any>

# runCustomSegments(segmentKeys, attributesopt) → {RuleError}

Match Custom segments
Parameters:
Name Type Attributes Description
segmentKeys Array.<string> A list of segment keys
attributes SegmentsAttributes <optional>
An object that specifies attributes for the visitor
ruleData Record.<string, any> <optional>
An object of key-value pairs that are used for segments matching

View Source src/context.ts, line 467

RuleError

# runExperience(experienceKey, attributesopt) → {BucketedVariation|RuleError|BucketingError}

Get variation from specific experience
Parameters:
Name Type Attributes Description
experienceKey string An experience's key that should be activated
attributes BucketingAttributes <optional>
An object that specifies attributes for the visitor
locationProperties Record.<any, any> <optional>
An object of key-value pairs that are used for location matching
visitorProperties Record.<any, any> <optional>
An object of key-value pairs that are used for audience targeting
updateVisitorProperties boolean <optional>
Decide whether to update visitor properties upon bucketing
environment string <optional>
Overwrite the environment

View Source src/context.ts, line 395

BucketedVariation | RuleError | BucketingError

# runExperiences(attributesopt) → {Array.<(BucketedVariatio|RuleError|BucketingError)>}

Get variations across all experiences
Parameters:
Name Type Attributes Description
attributes BucketingAttributes <optional>
An object that specifies attributes for the visitor
locationProperties string <optional>
An object of key-value pairs that are used for location matching
visitorProperties Record.<any, any> <optional>
An object of key-value pairs that are used for audience targeting
updateVisitorProperties boolean <optional>
Decide whether to update visitor properties upon bucketing
environment string <optional>
Overwrite the environment

View Source src/context.ts, line 406

Array.<(BucketedVariatio|RuleError|BucketingError)>

# runFeature(key, attributesopt) → {BucketedFeature|RuleError|Array.<(BucketedFeature|RuleError)>}

Get feature and its status
Parameters:
Name Type Attributes Description
key string A feature key
attributes BucketingAttributes <optional>
An object that specifies attributes for the visitor
locationProperties string <optional>
An object of key-value pairs that are used for location matching
visitorProperties Record.<any, any> <optional>
An object of key-value pairs that are used for audience targeting
updateVisitorProperties boolean <optional>
Decide whether to update visitor properties upon bucketing
environment string <optional>
Overwrite the environment
typeCasting boolean <optional>
Control automatic type conversion to the variable's defined type. Does not do any JSON validation. Defaults to `true`
experienceKeys Array.<string> <optional>
Use only specific experiences

View Source src/context.ts, line 420

BucketedFeature | RuleError | Array.<(BucketedFeature|RuleError)>

# runFeatures(attributesopt) → {Array.<(BucketedFeature|RuleError)>}

Get features and their statuses
Parameters:
Name Type Attributes Description
attributes BucketingAttributes <optional>
An object that specifies attributes for the visitor
locationProperties string <optional>
An object of key-value pairs that are used for location matching
visitorProperties Record.<any, any> <optional>
An object of key-value pairs that are used for audience targeting
updateVisitorProperties boolean <optional>
Decide whether to update visitor properties upon bucketing
environment string <optional>
Overwrite the environment
typeCasting boolean <optional>
Control automatic type conversion to the variable's defined type. Does not do any JSON validation. Defaults to `true`

View Source src/context.ts, line 432

Array.<(BucketedFeature|RuleError)>

# setCustomSegments(segmentKeys, attributesopt) → {RuleError}

To be deprecated
Parameters:
Name Type Attributes Description
segmentKeys Array
attributes SegmentsAttributes <optional>

View Source src/context.ts, line 458

RuleError

# setDefaultSegments(segments) → {void}

Set default segments for reports
Parameters:
Name Type Description
segments VisitorSegments A segment key

View Source src/context.ts, line 450

void

# trackConversion(goalKey, attributesopt) → {RuleError}

Trigger Conversion
Parameters:
Name Type Attributes Description
goalKey string A goal key
attributes ConversionAttributes <optional>
An object that specifies attributes for the visitor
ruleData Record.<string, any> <optional>
An object of key-value pairs that are used for goal matching
conversionData Array.<GoalData> <optional>
An array of key-value pairs that are used for transaction data
conversionSetting Record.<ConversionSettingKey, (number|string|boolean)> An object of key-value pairs that are used for tracking settings

View Source src/context.ts, line 443

RuleError

# updateVisitorProperties(visitorId, visitorProperties) → {void}

Update visitor properties in memory
Parameters:
Name Type Description
visitorId string
visitorProperties Record.<string, any>

View Source src/context.ts, line 475

void