import { IExperimentAssignmentv5, EXPERIMENT_TYPE, IPayload, MARKED_DECISION_POINT_STATUS } from 'upgrade_types'; import { UpGradeClientInterfaces } from '../types'; import ApiService from '../ApiService/ApiService'; export default class Assignment { private apiService; private _site; private _target; private _conditionCode; private _payloadType; private _payloadValue; private _experimentType; private _assignedFactor; constructor({ site, target, assignedCondition, assignedFactor, experimentType }: IExperimentAssignmentv5, apiService: ApiService); getCondition(): string; getPayload(): IPayload | null; getExperimentType(): EXPERIMENT_TYPE; get factors(): string[]; getFactorLevel(factor: string): string; getFactorPayload(factor: string): IPayload | null; /** * Will record ("mark") that a user has "seen" an experiment condition per at the Assignment's decision point location (site + target). * * 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. * * @param status `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: * * ```ts * export enum MARKED_DECISION_POINT_STATUS { * CONDITION_APPLIED = 'condition applied', * CONDITION_FAILED_TO_APPLY = 'condition not applied', * NO_CONDITION_ASSIGNED = 'no condition assigned', * } * ``` * @param uniquifier A `uniquifier` unique string can be sent along to help tie a user's logged metrics to a specific marked condition. * This identifier will also need to be sent when calling `upgradeClient.log()` * This is required for 'within-subjects' experiments. * * @param clientError The client can also send along an additional `clientError` string to log context as to why a condition was not applied. * * @example * ```ts * import { MARKED_DECISION_POINT_STATUS } from 'upgrade_types'; * * const site = 'dashboard'; * const target = 'experimental button'; * const status: MARKED_DECISION_POINT_STATUS = MARKED_DECISION_POINT_STATUS.CONDITION_FAILED_TO_APPLY * const clientError = 'variant not recognized'; //optional * * ```ts * const assignment: Assignment[] = await upgradeClient.getDecisionPointAssignment(site, target); * const markResponse = await assignment.markDecisionPoint(MARKED_DECISION_POINT_STATUS.CONDITION_APPLIED); * ``` * * Note*: mark can also be called via `Client.markDecisionPoint()` without an Assignment object`: * ```ts * import { MARKED_DECISION_POINT_STATUS } from 'upgrade_types'; * * const site = 'dashboard'; * const target = 'experimental button'; * const condition = 'variant_x'; // send null if no condition / no experiment is running / error * const status: MARKED_DECISION_POINT_STATUS = MARKED_DECISION_POINT_STATUS.CONDITION_FAILED_TO_APPLY * const clientError = 'variant not recognized'; //optional * * const markResponse = await upgradeClient.markDecisionPoint(site, target, condition, MARKED_DECISION_POINT_STATUS.CONDITION_APPLIED); * ``` */ markDecisionPoint(status: MARKED_DECISION_POINT_STATUS, uniquifier?: string, clientError?: string): Promise; }