UNPKG

@optimizely/optimizely-sdk

Version:

JavaScript SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts

49 lines (48 loc) 2.51 kB
/** * Copyright 2022-2025, 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 { Cache } from '../../utils/cache/cache'; import { OdpSegmentApiManager } from './odp_segment_api_manager'; import { OdpIntegrationConfig } from '../odp_config'; import { OptimizelySegmentOption } from './optimizely_segment_option'; import { ODP_USER_KEY } from '../constant'; import { LoggerFacade } from '../../logging/logger'; import { Platform } from '../../platform_support'; export interface OdpSegmentManager { fetchQualifiedSegments(userKey: ODP_USER_KEY, userValue: string, options?: Array<OptimizelySegmentOption>): Promise<string[] | null>; updateConfig(config: OdpIntegrationConfig): void; setLogger(logger: LoggerFacade): void; } export declare const LOGGER_NAME = "OdpSegmentManager"; export declare class DefaultOdpSegmentManager implements OdpSegmentManager { private odpIntegrationConfig?; private segmentsCache; private odpSegmentApiManager; private logger?; constructor(segmentsCache: Cache<string[]>, odpSegmentApiManager: OdpSegmentApiManager, logger?: LoggerFacade); setLogger(logger: LoggerFacade): void; /** * 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 userKey Key used for identifying the id type. * @param userValue The id value itself. * @param options An array of OptimizelySegmentOption used to ignore and/or reset the cache. * @returns Qualified segments for the user from the cache or the ODP server if the cache is empty. */ fetchQualifiedSegments(userKey: ODP_USER_KEY, userValue: string, options?: Array<OptimizelySegmentOption>): Promise<string[] | null>; makeCacheKey(userKey: string, userValue: string): string; updateConfig(config: OdpIntegrationConfig): void; } export declare const __platforms: Platform[];