@optimizely/optimizely-sdk
Version:
JavaScript SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts
66 lines (65 loc) • 2.7 kB
TypeScript
/**
* Copyright 2022-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 { ODP_USER_KEY } from '../constant';
import { RequestHandler } from '../../utils/http_request_handler/http';
import { Platform } from '../../platform_support';
/**
* Manager for communicating with the Optimizely Data Platform GraphQL endpoint
*/
export interface OdpSegmentApiManager {
fetchSegments(apiKey: string, apiHost: string, userKey: string, userValue: string, segmentsToCheck: string[]): Promise<string[] | null>;
setLogger(logger: LoggerFacade): void;
}
export declare const LOGGER_NAME = "OdpSegmentApiManager";
export declare class DefaultOdpSegmentApiManager implements OdpSegmentApiManager {
private logger?;
private requestHandler;
constructor(requestHandler: RequestHandler, logger?: LoggerFacade);
setLogger(logger: LoggerFacade): void;
/**
* Retrieves the audience segments from ODP
* @param apiKey ODP public key
* @param apiHost Host of ODP endpoint
* @param userKey 'vuid' or 'fs_user_id key'
* @param userValue Associated value to query for the user key
* @param segmentsToCheck Audience segments to check for experiment inclusion
*/
fetchSegments(apiKey: string, apiHost: string, userKey: ODP_USER_KEY, userValue: string, segmentsToCheck: string[]): Promise<string[] | null>;
/**
* Converts the query parameters to a GraphQL JSON payload
* @returns GraphQL JSON string
*/
private toGraphQLJson;
/**
* Handler for querying the ODP GraphQL endpoint
* @param apiKey ODP API key
* @param endpoint Fully-qualified GraphQL endpoint URL
* @param userKey 'vuid' or 'fs_user_id'
* @param userValue userKey's value
* @param query GraphQL formatted query string
* @returns JSON response string from ODP or null
*/
private querySegments;
/**
* Parses JSON response
* @param jsonResponse JSON response from ODP
* @private
* @returns Response Strongly-typed ODP Response object
*/
private parseSegmentsResponseJson;
}
export declare const __platforms: Platform[];