Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createInstance: function(config) {
try {
var hasLogger = false;
config = config || {};
// TODO warn about setting per instance errorHandler / logger / logLevel
if (config.errorHandler) {
logging.setErrorHandler(config.errorHandler);
}
if (config.logger) {
// only set a logger in node if one is provided, by not setting we are noop-ing
hasLogger = true;
logging.setLogHandler(config.logger);
// respect the logger's shouldLog functionality
logging.setLogLevel(logging.LogLevel.NOTSET);
}
if (config.logLevel !== undefined) {
logging.setLogLevel(config.logLevel);
}
try {
configValidator.validate(config);
config.isValidInstance = true;
} catch (ex) {
if (hasLogger) {
logger.error(ex);
} else {
console.error(ex.message);
}
config.isValidInstance = false;
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var logging = require('@optimizely/js-sdk-logging');
var fns = require('./utils/fns');
var configValidator = require('./utils/config_validator');
var defaultErrorHandler = require('./plugins/error_handler');
var defaultEventDispatcher = require('./plugins/event_dispatcher/index.browser');
var enums = require('./utils/enums');
var loggerPlugin = require('./plugins/logger/index.react_native');
var Optimizely = require('./optimizely');
var eventProcessorConfigValidator = require('./utils/event_processor_config_validator');
var logger = logging.getLogger();
logging.setLogHandler(loggerPlugin.createLogger());
logging.setLogLevel(logging.LogLevel.INFO);
var DEFAULT_EVENT_BATCH_SIZE = 10;
var DEFAULT_EVENT_FLUSH_INTERVAL = 1000; // Unit is ms, default is 1s
/**
* Entry point into the Optimizely Javascript SDK for React Native
*/
module.exports = {
logging: loggerPlugin,
errorHandler: defaultErrorHandler,
eventDispatcher: defaultEventDispatcher,
enums: enums,
setLogger: logging.setLogHandler,
setLogLevel: logging.setLogLevel,
createInstance: function(config) {
try {
config = config || {};
// TODO warn about setting per instance errorHandler / logger / logLevel
if (config.errorHandler) {
logging.setErrorHandler(config.errorHandler);
}
if (config.logger) {
logging.setLogHandler(config.logger);
// respect the logger's shouldLog functionality
logging.setLogLevel(logging.LogLevel.NOTSET);
}
if (config.logLevel !== undefined) {
logging.setLogLevel(config.logLevel);
}
try {
configValidator.validate(config);
config.isValidInstance = true;
} catch (ex) {
logger.error(ex);
config.isValidInstance = false;
}
// Explicitly check for null or undefined
// prettier-ignore
if (config.skipJSONValidation == null) { // eslint-disable-line eqeqeq
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
var logging = require('@optimizely/js-sdk-logging');
var configValidator = require('./utils/config_validator');
var defaultErrorHandler = require('./plugins/error_handler');
var defaultEventDispatcher = require('./plugins/event_dispatcher/index.node');
var enums = require('./utils/enums');
var fns = require('./utils/fns');
var jsonSchemaValidator = require('./utils/json_schema_validator');
var loggerPlugin = require('./plugins/logger');
var Optimizely = require('./optimizely');
var eventProcessorConfigValidator = require('./utils/event_processor_config_validator');
var logger = logging.getLogger();
logging.setLogLevel(logging.LogLevel.ERROR);
var DEFAULT_EVENT_BATCH_SIZE = 10;
var DEFAULT_EVENT_FLUSH_INTERVAL = 30000; // Unit is ms, default is 30s
/**
* Entry point into the Optimizely Node testing SDK
*/
module.exports = {
logging: loggerPlugin,
errorHandler: defaultErrorHandler,
eventDispatcher: defaultEventDispatcher,
enums: enums,
setLogger: logging.setLogHandler,
setLogLevel: logging.setLogLevel,
createInstance: function(config) {
try {
config = config || {};
// TODO warn about setting per instance errorHandler / logger / logLevel
if (config.errorHandler) {
logging.setErrorHandler(config.errorHandler);
}
if (config.logger) {
logging.setLogHandler(config.logger);
// respect the logger's shouldLog functionality
logging.setLogLevel(logging.LogLevel.NOTSET);
}
if (config.logLevel !== undefined) {
logging.setLogLevel(config.logLevel);
}
try {
configValidator.validate(config);
config.isValidInstance = true;
} catch (ex) {
logger.error(ex);
config.isValidInstance = false;
}
// Explicitly check for null or undefined
// prettier-ignore
if (config.skipJSONValidation == null) { // eslint-disable-line eqeqeq
*/
require('promise-polyfill/dist/polyfill');
var logging = require('@optimizely/js-sdk-logging');
var fns = require('./utils/fns');
var configValidator = require('./utils/config_validator');
var defaultErrorHandler = require('./plugins/error_handler');
var defaultEventDispatcher = require('./plugins/event_dispatcher/index.browser');
var enums = require('./utils/enums');
var eventProcessor = require('@optimizely/js-sdk-event-processor');
var loggerPlugin = require('./plugins/logger');
var Optimizely = require('./optimizely');
var eventProcessorConfigValidator = require('./utils/event_processor_config_validator');
var logger = logging.getLogger();
logging.setLogHandler(loggerPlugin.createLogger());
logging.setLogLevel(logging.LogLevel.INFO);
var MODULE_NAME = 'INDEX_BROWSER';
var DEFAULT_EVENT_BATCH_SIZE = 10;
var DEFAULT_EVENT_FLUSH_INTERVAL = 1000; // Unit is ms, default is 1s
var hasRetriedEvents = false;
/**
* Entry point into the Optimizely Browser SDK
*/
module.exports = {
logging: loggerPlugin,
errorHandler: defaultErrorHandler,
eventDispatcher: defaultEventDispatcher,
enums: enums,
/**
* Copyright 2019, 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
*
* http://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.
*/
var LogLevel = require('@optimizely/js-sdk-logging').LogLevel;
var sprintf = require('@optimizely/js-sdk-utils').sprintf;
function getLogLevelName(level) {
switch(level) {
case LogLevel.INFO: return 'INFO';
case LogLevel.ERROR: return 'ERROR';
case LogLevel.WARNING: return 'WARNING';
case LogLevel.DEBUG: return 'DEBUG';
default: return 'NOTSET';
}
}
function ReactNativeLogger() {}
ReactNativeLogger.prototype.log = function(level, message) {
var formattedMessage = sprintf('[OPTIMIZELY] - %s %s %s', getLogLevelName(level), new Date().toISOString(), message);