Class: UpgradeClient
UpgradeClient.UpgradeClient
UpGradeClient is the main class for interacting with the UpGrade API.
Example
General UpGrade types can also be accessed as named exports:
SDK-Specific types can be accessed also:
Table of contents
Constructors
constructor
Methods
getAllExperimentConditions
getDecisionPointAssignment
init
log
logCaliper
markExperimentPoint
setAltUserIds
setGroupMembership
setWorkingGroup
Constructors
constructor
• new UpgradeClient(userId
, hostUrl
, context
, options?
)
When constructing UpgradeClient, the user id, api host url, and "context" identifier are required. These will be attached to various API calls for this instance of the client.
Example
Parameters
userId
string
hostUrl
string
context
string
options?
Object
options.clientSessionId?
string
options.token?
string
Defined in
Methods
getAllExperimentConditions
▸ getAllExperimentConditions(): Promise
<IExperimentAssignmentv5
[]>
Will return all the experiment conditions for the user. Internally this uses the context
and userId
to query conditions for all eligible decision points at enrolling experiments for this user.
Example
Returns
Promise
<IExperimentAssignmentv5
[]>
Defined in
getDecisionPointAssignment
▸ getDecisionPointAssignment(site
, target?
): Promise
<Assignment
>
Given a site and optional target, return the condition assignment at this decision point NOTE: If getAllExperimentConditions() has not been called, this will call it first. NOTE ALSO: If getAllExperimentConditions() has been called, this will return the cached result and not make a network call.
Example
Parameters
site
string
target?
string
Returns
Promise
<Assignment
>
Defined in
init
▸ init(group?
, workingGroup?
): Promise
<IUser
>
This will initialize user and metadata for the user. It will return the user object with id, group, and working group. NOTE: A user must be initialized at least once before calling any other methods. Else, you will see "Experiment user not defined" errors when other SDK methods are called.
Example
Parameters
group?
Record
<string
, string
[]>
workingGroup?
Record
<string
, string
>
Returns
Promise
<IUser
>
Defined in
log
▸ log(value
, sendAsAnalytics?
): Promise
<ILog
[]>
Will report user outcome metrics to Upgrade. Please see https://upgrade-platform.gitbook.io/docs/developer-guide/reference/metrics for more information.
Example
Parameters
value
ILogInput
[]
undefined
sendAsAnalytics
boolean
false
Returns
Promise
<ILog
[]>
Defined in
logCaliper
▸ logCaliper(value
, sendAsAnalytics?
): Promise
<ILog
[]>
Will report Caliper user outcome metrics to Upgrade, same as log() but with Caliper envelope.
Example
Parameters
value
CaliperEnvelope
undefined
sendAsAnalytics
boolean
false
Returns
Promise
<ILog
[]>
Defined in
markExperimentPoint
▸ markExperimentPoint(site
, condition?
, status
, target?
, uniquifier?
,clientError?
): Promise
<IMarkExperimentPoint
>
Will record ("mark") that a user has "seen" a decision point.
Marking the decision point will record the user's condition assignment and the time of the decision point, regardless of whether the user is enrolled in an experiment.
status
signifies a client application's note on what it did in the code with condition assignment that Upgrade provided. Status can be one of the following:
The client can also send along an additional clientError
string to log context as to why a condition was not applied.
Example
Parameters
site
string
undefined
condition
string
null
status
MARKED_DECISION_POINT_STATUS
undefined
target?
string
undefined
uniquifier?
string
undefined
clientError?
string
undefined
Returns
Promise
<IMarkExperimentPoint
>
Defined in
setAltUserIds
▸ setAltUserIds(altUserIds
): Promise
<IExperimentUserAliases
[]>
Will set an array of alternate user ids for the user.
Example
Parameters
altUserIds
string
[]
Returns
Promise
<IExperimentUserAliases
[]>
Defined in
setGroupMembership
▸ setGroupMembership(group
): Promise
<IUser
>
Will set the group membership(s) for the user and return the user object with updated working group.
Example
Parameters
group
Record
<string
, string
[]>
Returns
Promise
<IUser
>
Defined in
setWorkingGroup
▸ setWorkingGroup(workingGroup
): Promise
<IUser
>
Will set the working group(s) for the user and return the user object with updated working group.
Example
Parameters
workingGroup
Record
<string
, string
>
Returns
Promise
<IUser
>
Defined in
Last updated