import { Decision, FeatureFlagDecision, HackleEvent, HackleRemoteConfig, User } from "./internal/model/model"; import { PropertyOperations } from "../hackle/property/PropertyOperations"; import { HackleExperiment } from "../public/model"; export default interface HackleClient { /** * Determine the variation to expose to the user for experiment. * * This method return the {"A"} if: * - The experiment key is invalid * - The experiment has not started yet * - The user is not allocated to the experiment * - The determined variation has been dropped * * @param experimentKey the unique key of the experiment. * @param user the user to participate in the experiment. MUST NOT be null. * @param defaultVariation the default variation of the experiment. * * @return string the decided variation for the user, or the default variation. */ variation(experimentKey: number, user: User | string, defaultVariation?: string): string; /** * Determine the variation to expose to the user for experiment, and returns an object that * describes the way the variation was determined. * * @param experimentKey the unique key of the experiment. * @param user the user to participate in the experiment. MUST NOT be null. (e.g. { id: "userId"} ) * @param defaultVariation the default variation of the experiment. MUST NOT be null. * * @return {Decision} object */ variationDetail(experimentKey: number, user: User | string, defaultVariation?: string): Decision; /** * Determine whether the feature is turned on to the user. * * @param featureKey the unique key for the feature. * @param user the user requesting the feature. * * @return boolean True if the feature is on. False if the feature is off. * * @since 2.0.0 */ isFeatureOn(featureKey: number, user: User | string): boolean; /** * Determine whether the feature is turned on to the user, and returns an object that * describes the way the value was determined. * * @param featureKey the unique key for the feature. * @param user the identifier of user. * * @return {FeatureFlagDecision} * * @since 2.0.0 */ featureFlagDetail(featureKey: number, user: User | string): FeatureFlagDecision; /** * Records the event that occurred by the user. * * @param event the unique key of the event that occurred. MUST NOT be null. * @param user the user that occurred the event. MUST NOT be null. */ track(event: HackleEvent | string, user: User | string): void; /** * Returns a instance of Hackle Remote Config. * * @param user the identifier of user. */ remoteConfig(user: User | string): HackleRemoteConfig; /** * Updates the user's properties. * * @param operations Property operations to update user properties. * @param user the user whose properties will be updated * */ updateUserProperties(operations: PropertyOperations, user: User | string): void; getExperiment(experimentKey: number): HackleExperiment | undefined; /** * @deprecated use onInitialized instead. * @param block callback function. * @param timeout */ onReady(block: () => void, timeout?: number): void; onInitialized(config?: { timeout?: number; }): Promise<{ success: boolean; }>; close(): void; }