From 0355fc8e837819fc36d4870389669aee85e96c78 Mon Sep 17 00:00:00 2001 From: Raju Ahmed Date: Thu, 30 Jan 2025 21:11:50 +0600 Subject: [PATCH] [FSSDK-11101] cleanup OptiizelyOptions type --- lib/export_types.ts | 1 - lib/index.browser.ts | 4 ++-- lib/optimizely/index.ts | 22 +++++++++++++++++++++- lib/shared_types.ts | 26 -------------------------- 4 files changed, 23 insertions(+), 30 deletions(-) diff --git a/lib/export_types.ts b/lib/export_types.ts index a55f56f27..84bda50c7 100644 --- a/lib/export_types.ts +++ b/lib/export_types.ts @@ -33,7 +33,6 @@ export { Event, EventDispatcher, DatafileOptions, - OptimizelyOptions, UserProfileService, UserProfile, ListenerPayload, diff --git a/lib/index.browser.ts b/lib/index.browser.ts index 848524f48..bdb10fe42 100644 --- a/lib/index.browser.ts +++ b/lib/index.browser.ts @@ -18,7 +18,7 @@ import configValidator from './utils/config_validator'; import defaultEventDispatcher from './event_processor/event_dispatcher/default_dispatcher.browser'; import sendBeaconEventDispatcher from './event_processor/event_dispatcher/send_beacon_dispatcher.browser'; import * as enums from './utils/enums'; -import { OptimizelyDecideOption, Client, Config, OptimizelyOptions } from './shared_types'; +import { OptimizelyDecideOption, Client, Config } from './shared_types'; import Optimizely from './optimizely'; import { UserAgentParser } from './odp/ua_parser/user_agent_parser'; import { getUserAgentParser } from './odp/ua_parser/ua_parser.browser'; @@ -57,7 +57,7 @@ const createInstance = function(config: Config): Client | null { logger = config.logger ? extractLogger(config.logger) : undefined; const errorNotifier = config.errorNotifier ? extractErrorNotifier(config.errorNotifier) : undefined; - const optimizelyOptions: OptimizelyOptions = { + const optimizelyOptions = { ...config, clientEngine: clientEngine || enums.JAVASCRIPT_CLIENT_ENGINE, clientVersion: clientVersion || enums.CLIENT_VERSION, diff --git a/lib/optimizely/index.ts b/lib/optimizely/index.ts index 3747ba9a2..e7cb921de 100644 --- a/lib/optimizely/index.ts +++ b/lib/optimizely/index.ts @@ -31,7 +31,6 @@ import { Variation, FeatureFlag, FeatureVariable, - OptimizelyOptions, OptimizelyDecideOption, FeatureVariableValue, OptimizelyDecision, @@ -111,6 +110,27 @@ type StringInputs = Partial>; type DecisionReasons = (string | number)[]; +/** + * options required to create optimizely object + */ +export type OptimizelyOptions = { + projectConfigManager: ProjectConfigManager; + UNSTABLE_conditionEvaluators?: unknown; + clientEngine: string; + clientVersion?: string; + errorNotifier?: ErrorNotifier; + eventProcessor?: EventProcessor; + jsonSchemaValidator?: { + validate(jsonObject: unknown): boolean; + }; + logger?: LoggerFacade; + userProfileService?: UserProfileService | null; + defaultDecideOptions?: OptimizelyDecideOption[]; + odpManager?: OdpManager; + vuidManager?: VuidManager + disposable?: boolean; +} + export default class Optimizely implements Client { private disposeOnUpdate?: Fn; private readyPromise: Promise; diff --git a/lib/shared_types.ts b/lib/shared_types.ts index 725d84090..fe62e6471 100644 --- a/lib/shared_types.ts +++ b/lib/shared_types.ts @@ -248,32 +248,6 @@ export enum OptimizelyDecideOption { EXCLUDE_VARIABLES = 'EXCLUDE_VARIABLES', } -/** - * options required to create optimizely object - */ -export interface OptimizelyOptions { - projectConfigManager: ProjectConfigManager; - UNSTABLE_conditionEvaluators?: unknown; - clientEngine: string; - clientVersion?: string; - // TODO[OASIS-6649]: Don't use object type - // eslint-disable-next-line @typescript-eslint/ban-types - datafile?: string | object; - datafileManager?: DatafileManager; - errorNotifier?: ErrorNotifier; - eventProcessor?: EventProcessor; - jsonSchemaValidator?: { - validate(jsonObject: unknown): boolean; - }; - logger?: LoggerFacade; - sdkKey?: string; - userProfileService?: UserProfileService | null; - defaultDecideOptions?: OptimizelyDecideOption[]; - odpManager?: OdpManager; - vuidManager?: VuidManager - disposable?: boolean; -} - /** * Optimizely Config Entities */