import HackleClient from "../core/HackleClient"; import HackleCore from "../core/HackleCore"; import { Decision, FeatureFlagDecision, HackleEvent, HackleRemoteConfig, Properties, User, VariationKey } from "../core/internal/model/model"; import { HackleExperiment, HackleInAppMessageListener, HackleInAppMessageView, HacklePage } from "../public/model"; import { HackleUserExplorerBase } from "../core/internal/user/UserExplorer"; import { PropertyOperations } from "./property/PropertyOperations"; import { UserManager } from "../core/internal/user/UserManager"; import { SessionManager } from "../core/internal/session/SessionManager"; import { PollingSynchronizer } from "../core/internal/sync/PollingSynchronizer"; import { Throttler } from "../core/internal/throttler/Throttler"; import { InAppMessageUi } from "./iam/ui/InAppMessageUi"; import { PIIEventManager } from "../core/internal/pii/PIIEventManager"; import { HackleSubscriptionOperations } from "./subscription/HackleSubscriptionOperations"; import { PageManager } from "../core/internal/page/PageManager"; import { OptOutManager } from "../core/internal/optout/OptOutManager"; export interface DevTools { manager: { userExplorer(userExplorer: HackleUserExplorerBase): void; close(): void; }; userExplorer?: HackleUserExplorerBase; } /** * @deprecated PageView is deprecated. use HacklePage instead. */ export interface PageView { /** * @deprecated user is deprecated and do nothing. * Use `setUserId()` or `setUser()` methods to identify users before calling trackPageView. */ user?: User; /** * @deprecated pathUrl is deprecated and do nothing. the path is automatically detected. */ pathUrl?: string; } export interface BrowserHackleClient extends HackleClient { /** * Returns current session ID * * @return {String} if session is unavailable, returns 0.ffffffff * @since 11.8.0 * */ getSessionId(): string; getUser(): User; setUser(user: User): Promise; setUserId(userId: string | number | undefined | null): Promise; setDeviceId(deviceId: string): Promise; setUserProperty(key: string, value: any): Promise; setUserProperties(properties: Properties): Promise; /** * Updates the user's properties. * * @param operations Property operations to update user properties. * */ updateUserProperties(operations: PropertyOperations): Promise; /** * Updates the user's push subscriptions. * * @param operations Push subscription operations to update user properties. * */ updatePushSubscriptions(operations: HackleSubscriptionOperations): Promise; /** * Updates the user's SMS subscriptions. * * @param operations SMS subscription operations to update user properties. * */ updateSmsSubscriptions(operations: HackleSubscriptionOperations): Promise; /** * Updates the user's Kakao subscriptions. * * @param operations Kakao subscription operations to update user properties. * */ updateKakaoSubscriptions(operations: HackleSubscriptionOperations): Promise; resetUser(): Promise; /** * Set user's phone number. Existing value will be replaced by new value if you call this method multiple times. * * @param phoneNumber String satisfying valid E.164 format is accepted. */ setPhoneNumber(phoneNumber: string): Promise; /** * Reset user's phone number to be an empty value. */ unsetPhoneNumber(): Promise; /** * 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 performed by the user. * * @param event the unique key of the event. MUST NOT be null. * @param user the identifier of user that performed the event. id MUST NOT be null. (e.g. { id: "userId"} ) */ track(event: HackleEvent | string, user?: User | string): void; /** * @deprecated trackPageView is deprecated and do nothing. * * Use the `setCurrentPage` method to track the page view. */ trackPageView(option?: PageView): void; /** * Tracking the page manually * This method always triggers page events regardless of whether the page has changed * * @param page */ setCurrentPage(page: HacklePage): void; /** * Return a instance of Hackle Remote Config. * * @param user the identifier of user. */ remoteConfig(user?: User | string): HackleRemoteConfig; /** * Show User Explorer. */ showUserExplorer(): void; /** * Hide User Explorer. */ hideUserExplorer(): void; /** * Fetch dashboard config data. */ fetch(): Promise; /** * Set InAppMessage listener. * * @param {HackleInAppMessageListener | null} listener The listener to be set. */ setInAppMessageListener(listener: HackleInAppMessageListener | null): void; /** * Get displayed InAppMessage view. * * @return {HackleInAppMessageView} if there is no displayed InAppMessage, return null. */ getDisplayedInAppMessageView(): HackleInAppMessageView | null; /** * Get opt-out tracking status. * * @return {boolean} opt out tracking status. */ isOptOutTracking(): boolean; /** * Set opt-out tracking status. * * @param {boolean} optOut opt out tracking status. */ setOptOutTracking(optOut: boolean): void; } export default class HackleClientImpl implements BrowserHackleClient { private readonly core; private readonly synchronizer; private readonly sessionManager; private readonly userManager; private readonly piiEventManager; private readonly fetchThrottler; private readonly pageManager; private readonly inAppMessageUi; private readonly optOutManager; private readonly devTools?; private readonly initialization; private initialized; constructor(core: HackleCore, synchronizer: PollingSynchronizer, sessionManager: SessionManager, userManager: UserManager, piiEventManager: PIIEventManager, fetchThrottler: Throttler, pageManager: PageManager, inAppMessageUi: InAppMessageUi, optOutManager: OptOutManager, devTools?: DevTools | undefined); private initialize; getSessionId(): string; getUser(): User; setUser(user: User): Promise; setUserId(userId: string | number | null | undefined): Promise; setDeviceId(deviceId: string): Promise; setUserProperty(key: string, value: any): Promise; setUserProperties(properties: Properties): Promise; updateUserProperties(operations: PropertyOperations): Promise; updatePushSubscriptions(operations: HackleSubscriptionOperations): Promise; updateSmsSubscriptions(operations: HackleSubscriptionOperations): Promise; updateKakaoSubscriptions(operations: HackleSubscriptionOperations): Promise; resetUser(): Promise; setPhoneNumber(phoneNumber: string): Promise; unsetPhoneNumber(): Promise; variation(experimentKey: number, user?: User | string, defaultVariation?: VariationKey): string; variationDetail(experimentKey: number, user?: User | string, defaultVariation?: VariationKey): Decision; isFeatureOn(featureKey: number, user?: User | string): boolean; featureFlagDetail(featureKey: number, user?: User | string): FeatureFlagDecision; track(event: HackleEvent | string, user?: User | string): void; trackPageView(option?: PageView): void; setCurrentPage(page: HacklePage): void; remoteConfig(user?: User): HackleRemoteConfig; onReady(block: () => void, timeout?: number): void; getExperiment(experimentKey: number): HackleExperiment | undefined; onInitialized(config?: { timeout?: number; }): Promise<{ success: boolean; }>; private _convertEvent; showUserExplorer(): void; hideUserExplorer(): void; fetch(): Promise; setInAppMessageListener(listener: HackleInAppMessageListener | null): void; getDisplayedInAppMessageView(): HackleInAppMessageView | null; isOptOutTracking(): boolean; setOptOutTracking(optOut: boolean): void; close(): void; }