Skip to content

Commit 6ebe2f9

Browse files
committed
Temporary move LogTierV1EventProcessorConfig to shared_types to avoid Travis lint failure
1 parent 1569d17 commit 6ebe2f9

File tree

3 files changed

+98
-89
lines changed

3 files changed

+98
-89
lines changed

packages/event-processor/src/eventProcessor.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// TODO change this to use Managed from js-sdk-models when available
1717
import { Managed } from './managed'
1818
import { ConversionEvent, ImpressionEvent } from './events'
19-
import { EventV1Request, EventDispatcher } from './eventDispatcher'
19+
import { EventV1Request } from './eventDispatcher'
2020
import { EventQueue, DefaultEventQueue, SingleEventQueue } from './eventQueue'
2121
import { getLogger } from '@optimizely/js-sdk-logging'
2222
import { NOTIFICATION_TYPES, NotificationCenter } from '@optimizely/js-sdk-utils'
@@ -34,14 +34,6 @@ export interface EventProcessor extends Managed {
3434
process(event: Partial<ProcessableEvent>): void
3535
}
3636

37-
export interface LogTierV1EventProcessorConfig {
38-
dispatcher: EventDispatcher;
39-
flushInterval?: number;
40-
batchSize?: number;
41-
notificationCenter?: NotificationCenter;
42-
maxQueueSize?: number;
43-
}
44-
4537
export function validateAndGetFlushInterval(flushInterval: number): number {
4638
if (flushInterval <= 0) {
4739
logger.warn(

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

Lines changed: 86 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@
1515
***************************************************************************/
1616
import { sprintf, objectValues } from '@optimizely/js-sdk-utils';
1717
import { LogHandler, ErrorHandler } from '@optimizely/js-sdk-logging';
18-
import { LogTierV1EventProcessorConfig } from '../../../event-processor/src';
1918
import * as eventProcessor from '@optimizely/js-sdk-event-processor';
2019
import { FeatureFlag, FeatureVariable } from '../core/project_config/entities';
2120
import { EventDispatcher } from '@optimizely/js-sdk-event-processor';
22-
import { UserAttributes, Variation, EventTags, OptimizelyConfig } from '../shared_types';
21+
import {
22+
UserAttributes,
23+
Variation,
24+
EventTags,
25+
OptimizelyConfig,
26+
LogTierV1EventProcessorConfig
27+
} from '../shared_types';
2328
import { createProjectConfigManager, ProjectConfigManager } from '../core/project_config/project_config_manager';
2429
import { createNotificationCenter, NotificationCenter } from '../core/notification_center';
2530
import { createDecisionService, DecisionService } from '../core/decision_service';
@@ -77,88 +82,87 @@ export default class Optimizely {
7782

7883
constructor(config: projectConfig.ProjectConfig) {
7984
let clientEngine = config.clientEngine;
80-
if (enums.VALID_CLIENT_ENGINES.indexOf(clientEngine) === -1) {
81-
config.logger.log(
82-
LOG_LEVEL.INFO,
83-
sprintf(LOG_MESSAGES.INVALID_CLIENT_ENGINE, MODULE_NAME, clientEngine)
84-
);
85-
clientEngine = enums.NODE_CLIENT_ENGINE;
86-
}
87-
88-
this.clientEngine = clientEngine;
89-
this.clientVersion = config.clientVersion || enums.NODE_CLIENT_VERSION;
90-
this.errorHandler = config.errorHandler;
91-
this.eventDispatcher = config.eventDispatcher;
92-
this.__isOptimizelyConfigValid = config.isValidInstance;
93-
this.logger = config.logger;
94-
95-
this.projectConfigManager = createProjectConfigManager({
96-
datafile: config.datafile,
97-
datafileOptions: config.datafileOptions,
98-
jsonSchemaValidator: config.jsonSchemaValidator,
99-
sdkKey: config.sdkKey,
100-
});
101-
102-
this.__disposeOnUpdate = this.projectConfigManager.onUpdate(
103-
function(this: Optimizely, configObj: projectConfig.ProjectConfig) {
104-
this.logger.log(
85+
if (enums.VALID_CLIENT_ENGINES.indexOf(clientEngine) === -1) {
86+
config.logger.log(
10587
LOG_LEVEL.INFO,
106-
sprintf(LOG_MESSAGES.UPDATED_OPTIMIZELY_CONFIG, MODULE_NAME, configObj.revision, configObj.projectId)
88+
sprintf(LOG_MESSAGES.INVALID_CLIENT_ENGINE, MODULE_NAME, clientEngine)
10789
);
108-
this.notificationCenter.sendNotifications(NOTIFICATION_TYPES.OPTIMIZELY_CONFIG_UPDATE);
109-
}.bind(this)
110-
);
90+
clientEngine = enums.NODE_CLIENT_ENGINE;
91+
}
11192

112-
const projectConfigManagerReadyPromise = this.projectConfigManager.onReady();
93+
this.clientEngine = clientEngine;
94+
this.clientVersion = config.clientVersion || enums.NODE_CLIENT_VERSION;
95+
this.errorHandler = config.errorHandler;
96+
this.eventDispatcher = config.eventDispatcher;
97+
this.__isOptimizelyConfigValid = config.isValidInstance;
98+
this.logger = config.logger;
99+
100+
this.projectConfigManager = createProjectConfigManager({
101+
datafile: config.datafile,
102+
datafileOptions: config.datafileOptions,
103+
jsonSchemaValidator: config.jsonSchemaValidator,
104+
sdkKey: config.sdkKey,
105+
});
113106

114-
let userProfileService = null;
115-
if (config.userProfileService) {
116-
try {
117-
if (userProfileServiceValidator.validate(config.userProfileService)) {
118-
userProfileService = config.userProfileService;
119-
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.VALID_USER_PROFILE_SERVICE, MODULE_NAME));
107+
this.__disposeOnUpdate = this.projectConfigManager.onUpdate(
108+
function(this: Optimizely, configObj: projectConfig.ProjectConfig) {
109+
this.logger.log(
110+
LOG_LEVEL.INFO,
111+
sprintf(LOG_MESSAGES.UPDATED_OPTIMIZELY_CONFIG, MODULE_NAME, configObj.revision, configObj.projectId)
112+
);
113+
this.notificationCenter.sendNotifications(NOTIFICATION_TYPES.OPTIMIZELY_CONFIG_UPDATE);
114+
}.bind(this)
115+
);
116+
117+
const projectConfigManagerReadyPromise = this.projectConfigManager.onReady();
118+
119+
let userProfileService = null;
120+
if (config.userProfileService) {
121+
try {
122+
if (userProfileServiceValidator.validate(config.userProfileService)) {
123+
userProfileService = config.userProfileService;
124+
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.VALID_USER_PROFILE_SERVICE, MODULE_NAME));
125+
}
126+
} catch (ex) {
127+
this.logger.log(LOG_LEVEL.WARNING, ex.message);
120128
}
121-
} catch (ex) {
122-
this.logger.log(LOG_LEVEL.WARNING, ex.message);
123129
}
124-
}
125130

126-
this.decisionService = createDecisionService({
127-
userProfileService: userProfileService,
128-
logger: this.logger,
129-
UNSTABLE_conditionEvaluators: config.UNSTABLE_conditionEvaluators,
130-
});
131-
132-
this.notificationCenter = createNotificationCenter({
133-
logger: this.logger,
134-
errorHandler: this.errorHandler,
135-
});
136-
137-
this.eventProcessor = new eventProcessor.LogTierV1EventProcessor({
138-
dispatcher: this.eventDispatcher,
139-
flushInterval: config.eventFlushInterval,
140-
batchSize: config.eventBatchSize,
141-
maxQueueSize: config.eventMaxQueueSize, // TODO: update event-processor to include maxQueueSize
142-
notificationCenter: this.notificationCenter,
143-
} as LogTierV1EventProcessorConfig);
144-
145-
146-
const eventProcessorStartedPromise = this.eventProcessor.start();
147-
148-
this.__readyPromise = Promise.all([projectConfigManagerReadyPromise, eventProcessorStartedPromise]).then(function(promiseResults) {
149-
// Only return status from project config promise because event processor promise does not return any status.
150-
return promiseResults[0];
151-
})
152-
153-
this.__readyTimeouts = {};
154-
this.__nextReadyTimeoutId = 0;
131+
this.decisionService = createDecisionService({
132+
userProfileService: userProfileService,
133+
logger: this.logger,
134+
UNSTABLE_conditionEvaluators: config.UNSTABLE_conditionEvaluators,
135+
});
136+
137+
this.notificationCenter = createNotificationCenter({
138+
logger: this.logger,
139+
errorHandler: this.errorHandler,
140+
});
141+
142+
this.eventProcessor = new eventProcessor.LogTierV1EventProcessor({
143+
dispatcher: this.eventDispatcher,
144+
flushInterval: config.eventFlushInterval,
145+
batchSize: config.eventBatchSize,
146+
maxQueueSize: config.eventMaxQueueSize, // TODO: update event-processor to include maxQueueSize
147+
notificationCenter: this.notificationCenter,
148+
} as LogTierV1EventProcessorConfig);
149+
150+
const eventProcessorStartedPromise = this.eventProcessor.start();
151+
152+
this.__readyPromise = Promise.all([projectConfigManagerReadyPromise, eventProcessorStartedPromise]).then(function(promiseResults) {
153+
// Only return status from project config promise because event processor promise does not return any status.
154+
return promiseResults[0];
155+
})
156+
157+
this.__readyTimeouts = {};
158+
this.__nextReadyTimeoutId = 0;
155159
}
156160

157161
/**
158162
* Returns a truthy value if this instance currently has a valid project config
159163
* object, and the initial configuration object that was passed into the
160164
* constructor was also valid.
161-
* @return {*}
165+
* @return {boolean}
162166
*/
163167
__isValidInstance(): boolean {
164168
return this.__isOptimizelyConfigValid && !!this.projectConfigManager.getConfig();
@@ -451,10 +455,11 @@ export default class Optimizely {
451455

452456
/**
453457
* Force a user into a variation for a given experiment.
454-
* @param {string} experimentKey
455-
* @param {string} userId
456-
* @param {string|null} variationKey user will be forced into. If null, then clear the existing experiment-to-variation mapping.
457-
* @return {boolean} A boolean value that indicates if the set completed successfully.
458+
* @param {string} experimentKey
459+
* @param {string} userId
460+
* @param {string|null} variationKey user will be forced into. If null,
461+
* then clear the existing experiment-to-variation mapping.
462+
* @return {boolean} A boolean value that indicates if the set completed successfully.
458463
*/
459464
setForcedVariation(experimentKey: string, userId: string, variationKey: string | null): boolean {
460465
if (!this.__validateInputs({ experiment_key: experimentKey, user_id: userId })) {
@@ -477,8 +482,8 @@ export default class Optimizely {
477482

478483
/**
479484
* Gets the forced variation for a given user and experiment.
480-
* @param {string} experimentKey
481-
* @param {string} userId
485+
* @param {string} experimentKey
486+
* @param {string} userId
482487
* @return {string|null} The forced variation key.
483488
*/
484489
getForcedVariation(experimentKey: string, userId: string): string | null {
@@ -505,7 +510,7 @@ export default class Optimizely {
505510
* @param {unknown} stringInputs Map of string keys and associated values
506511
* @param {unknown} userAttributes Optional parameter for user's attributes
507512
* @param {unknown} eventTags Optional parameter for event tags
508-
* @return {boolean} True if inputs are valid
513+
* @return {boolean} True if inputs are valid
509514
*
510515
*/
511516
__validateInputs(
@@ -720,8 +725,9 @@ export default class Optimizely {
720725
* being accessed
721726
* @param {string} userId ID for the user
722727
* @param {UserAttributes} attributes Optional user attributes
723-
* @return {unknown} Value of the variable cast to the appropriate
724-
* type, or null if the feature key is invalid or the variable key is invalid
728+
* @return {unknown} Value of the variable cast to the appropriate
729+
* type, or null if the feature key is invalid or
730+
* the variable key is invalid
725731
*/
726732

727733
getFeatureVariable(

packages/optimizely-sdk/lib/shared_types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,14 @@ export interface OptimizelyConfig {
120120
revision: string;
121121
getDatafile(): string;
122122
}
123+
124+
/**
125+
* Temprorary location LogTierV1EventProcessorConfig
126+
*/
127+
export interface LogTierV1EventProcessorConfig {
128+
dispatcher: import ('@optimizely/js-sdk-event-processor').EventDispatcher;
129+
flushInterval?: number;
130+
batchSize?: number;
131+
notificationCenter?: import('./core/notification_center').NotificationCenter;
132+
maxQueueSize?: number;
133+
}

0 commit comments

Comments
 (0)