@optimizely/optimizely-sdk
Version:
JavaScript SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts
43 lines (42 loc) • 3.26 kB
TypeScript
import { Audience, Condition, OptimizelyUserContext } from '../../shared_types';
import { LoggerFacade } from '../../logging/logger';
import { Platform } from '../../platform_support';
export declare class AudienceEvaluator {
private logger?;
private typeToEvaluatorMap;
/**
* Construct an instance of AudienceEvaluator with given options
* @param {Object=} UNSTABLE_conditionEvaluators A map of condition evaluators provided by the consumer. This enables matching
* condition types which are not supported natively by the SDK. Note that built in
* Optimizely evaluators cannot be overridden.
* @constructor
*/
constructor(UNSTABLE_conditionEvaluators: unknown, logger?: LoggerFacade);
/**
* Determine if the given user attributes satisfy the given audience conditions
* @param {Array<string|string[]} audienceConditions Audience conditions to match the user attributes against - can be an array
* of audience IDs, a nested array of conditions, or a single leaf condition.
* Examples: ["5", "6"], ["and", ["or", "1", "2"], "3"], "1"
* @param {[id: string]: Audience} audiencesById Object providing access to full audience objects for audience IDs
* contained in audienceConditions. Keys should be audience IDs, values
* should be full audience objects with conditions properties
* @param {OptimizelyUserContext} userAttributes User context which contains the attributes and segments which will be used in
* determining if audience conditions are met.
* @return {boolean} true if the user attributes match the given audience conditions, false
* otherwise
*/
evaluate(audienceConditions: Array<string | string[]>, audiencesById: {
[id: string]: Audience;
}, user: OptimizelyUserContext): boolean;
/**
* Wrapper around evaluator.evaluate that is passed to the conditionTreeEvaluator.
* Evaluates the condition provided given the user attributes if an evaluator has been defined for the condition type.
* @param {OptimizelyUserContext} user Optimizely user context containing attributes and segments
* @param {Condition} condition A single condition object to evaluate.
* @return {boolean|null} true if the condition is satisfied, null if a matcher is not found.
*/
evaluateConditionWithUserAttributes(user: OptimizelyUserContext, condition: Condition): boolean | null;
}
export default AudienceEvaluator;
export declare const createAudienceEvaluator: (UNSTABLE_conditionEvaluators: unknown, logger?: LoggerFacade) => AudienceEvaluator;
export declare const __platforms: Platform[];