@optimizely/optimizely-sdk
Version:
JavaScript SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts
75 lines (74 loc) • 3.47 kB
TypeScript
/**
* Copyright 2023-2024, 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
*
* https://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.
*/
import { LoggerFacade } from '../logging/logger';
import { OdpIntegrationConfig } from './odp_config';
import { OdpEventManager } from './event_manager/odp_event_manager';
import { OdpSegmentManager } from './segment_manager/odp_segment_manager';
import { OptimizelySegmentOption } from './segment_manager/optimizely_segment_option';
import { OdpEvent } from './event_manager/odp_event';
import { BaseService, Service } from '../service';
import { UserAgentParser } from './ua_parser/user_agent_parser';
import { Platform } from '../platform_support';
export interface OdpManager extends Service {
updateConfig(odpIntegrationConfig: OdpIntegrationConfig): boolean;
fetchQualifiedSegments(userId: string, options?: Array<OptimizelySegmentOption>): Promise<string[] | null>;
identifyUser(userId: string, vuid?: string): void;
sendEvent(event: OdpEvent): void;
setClientInfo(clientEngine: string, clientVersion: string): void;
setVuid(vuid: string): void;
setLogger(logger: LoggerFacade): void;
flushImmediately(): Promise<unknown>;
}
export type OdpManagerConfig = {
segmentManager: OdpSegmentManager;
eventManager: OdpEventManager;
logger?: LoggerFacade;
userAgentParser?: UserAgentParser;
};
export declare const LOGGER_NAME = "OdpManager";
export declare class DefaultOdpManager extends BaseService implements OdpManager {
private configPromise;
private segmentManager;
private eventManager;
private odpIntegrationConfig?;
private vuid?;
private clientEngine;
private clientVersion;
private userAgentData?;
constructor(config: OdpManagerConfig);
setLogger(logger: LoggerFacade): void;
setClientInfo(clientEngine: string, clientVersion: string): void;
start(): void;
makeDisposable(): void;
private handleStartSuccess;
private handleStartFailure;
flushImmediately(): Promise<unknown>;
stop(): void;
updateConfig(odpIntegrationConfig: OdpIntegrationConfig): boolean;
/**
* Attempts to fetch and return a list of a user's qualified segments from the local segments cache.
* If no cached data exists for the target user, this fetches and caches data from the ODP server instead.
* @param {string} userId - Unique identifier of a target user.
* @param {Array<OptimizelySegmentOption>} options - An array of OptimizelySegmentOption used to ignore and/or reset the cache.
* @returns {Promise<string[] | null>} A promise holding either a list of qualified segments or null.
*/
fetchQualifiedSegments(userId: string, options?: Array<OptimizelySegmentOption>): Promise<string[] | null>;
identifyUser(userId: string, vuid?: string): void;
sendEvent(event: OdpEvent): void;
private augmentCommonData;
setVuid(vuid: string): void;
}
export declare const __platforms: Platform[];