@optimizely/optimizely-sdk
Version:
JavaScript SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts
68 lines (67 loc) • 4.04 kB
TypeScript
/**
* Copyright 2016, 2019-2022, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Bucketer API for determining the variation id from the specified parameters
*/
import { LoggerFacade } from '../../logging/logger';
import { DecisionResponse, BucketerParams, TrafficAllocation, Group } from '../../shared_types';
import { Platform } from '../../platform_support';
export declare const USER_NOT_IN_ANY_EXPERIMENT = "User %s is not in any experiment of group %s.";
export declare const USER_NOT_BUCKETED_INTO_EXPERIMENT_IN_GROUP = "User %s is not in experiment %s of group %s.";
export declare const USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP = "User %s is in experiment %s of group %s.";
export declare const USER_ASSIGNED_TO_EXPERIMENT_BUCKET = "Assigned bucket %s to user with bucketing ID %s.";
export declare const INVALID_VARIATION_ID = "Bucketed into an invalid variation ID. Returning null.";
/**
* Determines ID of variation to be shown for the given input params
* @param {Object} bucketerParams
* @param {string} bucketerParams.experimentId
* @param {string} bucketerParams.experimentKey
* @param {string} bucketerParams.userId
* @param {Object[]} bucketerParams.trafficAllocationConfig
* @param {Array} bucketerParams.experimentKeyMap
* @param {Object} bucketerParams.groupIdMap
* @param {Object} bucketerParams.variationIdMap
* @param {string} bucketerParams.varationIdMap[].key
* @param {Object} bucketerParams.logger
* @param {string} bucketerParams.bucketingId
* @return {Object} DecisionResponse DecisionResponse containing variation ID that user has been bucketed into,
* null if user is not bucketed into any experiment and the decide reasons.
*/
export declare const bucket: (bucketerParams: BucketerParams) => DecisionResponse<string | null>;
/**
* Returns bucketed experiment ID to compare against experiment user is being called into
* @param {Group} group Group that experiment is in
* @param {string} bucketingId Bucketing ID
* @param {string} userId ID of user to be bucketed into experiment
* @param {LoggerFacade} logger Logger implementation
* @return {string|null} ID of experiment if user is bucketed into experiment within the group, null otherwise
*/
export declare const bucketUserIntoExperiment: (group: Group, bucketingId: string, userId: string, logger?: LoggerFacade) => string | null;
/**
* Returns entity ID associated with bucket value
* @param {number} bucketValue
* @param {TrafficAllocation[]} trafficAllocationConfig
* @param {number} trafficAllocationConfig[].endOfRange
* @param {string} trafficAllocationConfig[].entityId
* @return {string|null} Entity ID for bucketing if bucket value is within traffic allocation boundaries, null otherwise
*/
export declare const _findBucket: (bucketValue: number, trafficAllocationConfig: TrafficAllocation[]) => string | null;
declare const _default: {
bucket: (bucketerParams: BucketerParams) => DecisionResponse<string | null>;
bucketUserIntoExperiment: (group: Group, bucketingId: string, userId: string, logger?: LoggerFacade | undefined) => string | null;
};
export default _default;
export declare const __platforms: Platform[];