Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
eventDispatcher = config.eventDispatcher;
}
config = fns.assignIn(
{
clientEngine: enums.JAVASCRIPT_CLIENT_ENGINE,
eventBatchSize: DEFAULT_EVENT_BATCH_SIZE,
eventFlushInterval: DEFAULT_EVENT_FLUSH_INTERVAL,
},
config,
{
eventDispatcher: eventDispatcher,
// always get the OptimizelyLogger facade from logging
logger: logger,
errorHandler: logging.getErrorHandler(),
}
);
if (!eventProcessorConfigValidator.validateEventBatchSize(config.eventBatchSize)) {
logger.warn('Invalid eventBatchSize %s, defaulting to %s', config.eventBatchSize, DEFAULT_EVENT_BATCH_SIZE);
config.eventBatchSize = DEFAULT_EVENT_BATCH_SIZE;
}
if (!eventProcessorConfigValidator.validateEventFlushInterval(config.eventFlushInterval)) {
logger.warn('Invalid eventFlushInterval %s, defaulting to %s', config.eventFlushInterval, DEFAULT_EVENT_FLUSH_INTERVAL);
config.eventFlushInterval = DEFAULT_EVENT_FLUSH_INTERVAL;
}
var optimizely = new Optimizely(config);
try {
if (typeof window.addEventListener === 'function') {
if (config.skipJSONValidation == null) { // eslint-disable-line eqeqeq
config.skipJSONValidation = true;
}
config = fns.assignIn(
{
clientEngine: enums.JAVASCRIPT_CLIENT_ENGINE,
eventBatchSize: DEFAULT_EVENT_BATCH_SIZE,
eventDispatcher: defaultEventDispatcher,
eventFlushInterval: DEFAULT_EVENT_FLUSH_INTERVAL,
},
config,
{
// always get the OptimizelyLogger facade from logging
logger: logger,
errorHandler: logging.getErrorHandler(),
}
);
if (!eventProcessorConfigValidator.validateEventBatchSize(config.eventBatchSize)) {
logger.warn('Invalid eventBatchSize %s, defaulting to %s', config.eventBatchSize, DEFAULT_EVENT_BATCH_SIZE);
config.eventBatchSize = DEFAULT_EVENT_BATCH_SIZE;
}
if (!eventProcessorConfigValidator.validateEventFlushInterval(config.eventFlushInterval)) {
logger.warn('Invalid eventFlushInterval %s, defaulting to %s', config.eventFlushInterval, DEFAULT_EVENT_FLUSH_INTERVAL);
config.eventFlushInterval = DEFAULT_EVENT_FLUSH_INTERVAL;
}
var optimizely = new Optimizely(config);
return optimizely;
} catch (e) {
}
config = fns.assign(
{
clientEngine: enums.NODE_CLIENT_ENGINE,
eventBatchSize: DEFAULT_EVENT_BATCH_SIZE,
eventDispatcher: defaultEventDispatcher,
eventFlushInterval: DEFAULT_EVENT_FLUSH_INTERVAL,
jsonSchemaValidator: jsonSchemaValidator,
skipJSONValidation: false,
},
config,
{
// always get the OptimizelyLogger facade from logging
logger: logger,
errorHandler: logging.getErrorHandler(),
}
);
if (!eventProcessorConfigValidator.validateEventBatchSize(config.eventBatchSize)) {
logger.warn('Invalid eventBatchSize %s, defaulting to %s', config.eventBatchSize, DEFAULT_EVENT_BATCH_SIZE);
config.eventBatchSize = DEFAULT_EVENT_BATCH_SIZE;
}
if (!eventProcessorConfigValidator.validateEventFlushInterval(config.eventFlushInterval)) {
logger.warn('Invalid eventFlushInterval %s, defaulting to %s', config.eventFlushInterval, DEFAULT_EVENT_FLUSH_INTERVAL);
config.eventFlushInterval = DEFAULT_EVENT_FLUSH_INTERVAL;
}
return new Optimizely(config);
} catch (e) {
logger.error(e);
return null;