Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
data.DEVICE_TYPE = userAgent.DEVICE_TYPE;
data.BROWSER_TYPE = userAgent.BROWSER_TYPE;
data.BROWSER_VERSION = userAgent.BROWSER_VERSION;
data.SIMULATED = userAgent.SIMULATED;
if (!this.enabled) {
log(`Skipping event send (no config for current environment): key= ${key} data=`, data);
continue;
}
//for now just send it straight to amplitude - they do their own batching
// DO THIS BEFORE KEEN PROPERTY
if(this.amplitudeBlacklist.indexOf(key) === -1)
{
// Only send to amplitude if it's not in the blacklist.
this._amplitudeClient.logEvent(key, merge({}, data));
}
// Duplicate events over to Facebook pixel if they are on the PIXEL whitelist
const sendToPixel = this.pixelEnabled && (!this.pixelWhitelist || this.pixelWhitelist.indexOf(key) >= 0);
if (sendToPixel) {
pixel.trackCustom(key, merge({}, data));
}
const sendToKeen = (!this.keenWhitelist || this.keenWhitelist.indexOf(key) >= 0);
if (sendToKeen) {
data.keen = this.keenAddons;
data.userProperties = merge({}, this.userProperties);
// special nested ab tests for Keen
if (GC.app && GC.app.abTests) {
GC.app.abTests.applyKeenData(data);
setScalingMode (scalingMode, opts) {
this._scalingMode = scalingMode;
switch (scalingMode) {
case SCALING.FIXED:
opts = merge(opts, {
width: device.width,
height: device.height
});
break;
case SCALING.RESIZE:
opts = merge(opts, { resizeCanvas: true });
// fall through:
case SCALING.MANUAL:
break;
}
this._scalingOpts = opts;
this.onResize();
setTimeout(bind(this, 'onResize'), 1000);
}
if(this.amplitudeBlacklist.indexOf(key) === -1)
{
// Only send to amplitude if it's not in the blacklist.
this._amplitudeClient.logEvent(key, merge({}, data));
}
// Duplicate events over to Facebook pixel if they are on the PIXEL whitelist
const sendToPixel = this.pixelEnabled && (!this.pixelWhitelist || this.pixelWhitelist.indexOf(key) >= 0);
if (sendToPixel) {
pixel.trackCustom(key, merge({}, data));
}
const sendToKeen = (!this.keenWhitelist || this.keenWhitelist.indexOf(key) >= 0);
if (sendToKeen) {
data.keen = this.keenAddons;
data.userProperties = merge({}, this.userProperties);
// special nested ab tests for Keen
if (GC.app && GC.app.abTests) {
GC.app.abTests.applyKeenData(data);
}
if (!batch[key]) {
batch[key] = [];
}
batch[key].push(data);
}
}
if (Object.keys(batch).length > 0) {
keen.sendEventBatch(batch);
}
log(`Skipping event send (no config for current environment): key= ${key} data=`, data);
continue;
}
//for now just send it straight to amplitude - they do their own batching
// DO THIS BEFORE KEEN PROPERTY
if(this.amplitudeBlacklist.indexOf(key) === -1)
{
// Only send to amplitude if it's not in the blacklist.
this._amplitudeClient.logEvent(key, merge({}, data));
}
// Duplicate events over to Facebook pixel if they are on the PIXEL whitelist
const sendToPixel = this.pixelEnabled && (!this.pixelWhitelist || this.pixelWhitelist.indexOf(key) >= 0);
if (sendToPixel) {
pixel.trackCustom(key, merge({}, data));
}
const sendToKeen = (!this.keenWhitelist || this.keenWhitelist.indexOf(key) >= 0);
if (sendToKeen) {
data.keen = this.keenAddons;
data.userProperties = merge({}, this.userProperties);
// special nested ab tests for Keen
if (GC.app && GC.app.abTests) {
GC.app.abTests.applyKeenData(data);
}
if (!batch[key]) {
batch[key] = [];
}
batch[key].push(data);
initialize(params) {
this.isInitialized = true;
this.sessionID = this.createGuid();
this.userID = params.userID;
var isDev = userAgent.SIMULATED || process.env.NODE_ENV === 'development';
this.enabled = !userAgent.SIMULATED && (params.dev || !isDev);
params = isDev && params.dev ? merge(params.dev, params.prod) : params.prod;
if (params.pixel && params.pixel.enabled) {
this.pixelEnabled = params.pixel.enabled && pixel.enabled;
this.pixelWhitelist = params.pixel.whitelist || [];
}
this.keenWhitelist = params.keen.whitelist || [];
this.amplitudeBlacklist = params.amplitude.blacklist || [];
if (params.amplitude.key) {
this._initAmplitude(params.amplitude.key);
}
keen.init(params.keen.projectID, params.keen.writeKey);
this.keenAddons = {
pushError (name, error, event) {
event = event || {};
error = error || {};
logger.error('Sending ERROR:', name, error, event);
this.pushEvent(name, merge({
errorCode: error.code || 'No Code',
errorMessage: error.message || 'No Message',
errorStack: error.stack || 'No Stack'
}, event));
}
updateOpts (opts) {
this._opts = merge(opts, this._opts);
if (this._keyListener) {
this._keyListener.setEnabled(this._opts.keyListenerEnabled);
}
if (this._opts.scaleUI) {
if (Array.isArray(this._opts.scaleUI)) {
if (this._opts.scaleUI.length != 2) {
throw new Error('Illegal value for engine option scaleUI: ' +
this._opts.scaleUI);
}
this.scaleUI(this._opts.scaleUI[0], this._opts.scaleUI[1]);
} else {
this.scaleUI(576, 1024);
}
}
constructor (opts) {
super(merge(opts, defaults));
}
_forceLoad () {