Skip to content

Commit a7f6a86

Browse files
author
uzair-folio3
committed
copied optimizelyconfig from optimizely module to sharedType
1 parent 979dadb commit a7f6a86

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

packages/optimizely-sdk/lib/index.react_native.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ import {
2626

2727
import * as enums from './utils/enums';
2828
import { assign } from './utils/fns';
29-
import { Optimizely, configObj } from './optimizely';
29+
import Optimizely from './optimizely';
3030
import * as configValidator from './utils/config_validator';
3131
import defaultErrorHandler from './plugins/error_handler';
3232
import loggerPlugin from './plugins/logger/index.react_native';
3333
import defaultEventDispatcher from './plugins/event_dispatcher/index.browser';
3434
import eventProcessorConfigValidator from './utils/event_processor_config_validator';
35-
import * as projectConfig from './core/project_config';
36-
import { EventDispatcher, UserProfileService } from './shared_types';
35+
import { EventDispatcher, UserProfileService, OptimizelyConfig } from './shared_types';
3736

3837
const logger = getLogger();
3938
setLogHandler(loggerPlugin.createLogger());
@@ -100,7 +99,7 @@ const createInstance = function (config: Config): Optimizely | null {
10099
logger: logger,
101100
errorHandler: getErrorHandler(),
102101
}
103-
) as configObj;
102+
) as OptimizelyConfig;
104103

105104
if (!eventProcessorConfigValidator.validateEventBatchSize(config.eventBatchSize)) {
106105
logger.warn('Invalid eventBatchSize %s, defaulting to %s', config.eventBatchSize, DEFAULT_EVENT_BATCH_SIZE);

packages/optimizely-sdk/lib/optimizely/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const MODULE_NAME = 'OPTIMIZELY';
5353

5454
const DEFAULT_ONREADY_TIMEOUT = 30000;
5555

56-
export interface configObj {
56+
interface configObj {
5757
clientEngine: string;
5858
clientVersion?: string;
5959
errorHandler: ErrorHandler;
@@ -87,7 +87,7 @@ export interface configObj {
8787
* @param {Object} config.eventFlushInterval
8888
* @param {string} config.sdkKey
8989
*/
90-
export class Optimizely {
90+
export default class Optimizely {
9191
private isOptimizelyConfigValid: boolean;
9292
private disposeOnUpdate: (() => void ) | null;
9393
private readyPromise: Promise<{ success: boolean; reason?: string }>;

packages/optimizely-sdk/lib/shared_types.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ErrorHandler, LogHandler } from "@optimizely/js-sdk-logging";
2+
13
export type UserAttributes = {
24
// TODO[OASIS-6649]: Don't use any type
35
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -57,6 +59,26 @@ export interface OnReadyResult {
5759
reason?: string;
5860
}
5961

62+
export interface OptimizelyConfig {
63+
clientEngine: string;
64+
clientVersion?: string;
65+
errorHandler: ErrorHandler;
66+
eventDispatcher: EventDispatcher;
67+
isValidInstance: boolean;
68+
datafile?: string;
69+
// TODO[OASIS-6649]: Don't use object type
70+
// eslint-disable-next-line @typescript-eslint/ban-types
71+
jsonSchemaValidator?: object;
72+
sdkKey?: string;
73+
userProfileService?: UserProfileService | null;
74+
UNSTABLE_conditionEvaluators?: unknown;
75+
eventFlushInterval?: number;
76+
eventBatchSize?: number;
77+
datafileOptions?: DatafileOptions;
78+
eventMaxQueueSize?: number;
79+
logger: LogHandler;
80+
}
81+
6082
/**
6183
* Optimizely Config Entities
6284
*/

0 commit comments

Comments
 (0)