Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
} else {
var defaultPlan = events.__default || { enabled: true };
if (!defaultPlan.enabled) {
// Disabled events should always be sent to Segment.
planIntegrationOptions = { All: false, 'Segment.io': true };
}
}
// Add the initialize integrations so the server-side ones can be disabled too
defaults(
msg.integrations,
this._mergeInitializeAndPlanIntegrations(planIntegrationOptions)
);
this._invoke('track', new Track(msg));
this.emit('track', event, properties, options);
this._callback(fn);
return this;
};
// clone traits before we manipulate so we don't do anything uncouth, and take
// from `user` so that we carryover anonymous traits
user.identify(id, traits);
var msg = this.normalize({
options: options,
traits: user.traits(),
userId: user.id()
});
// Add the initialize integrations so the server-side ones can be disabled too
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
}
this._invoke('identify', new Identify(msg));
// emit
this.emit('identify', id, traits, options);
this._callback(fn);
return this;
};
options.context.page = overrides;
}
var msg = this.normalize({
properties: properties,
category: category,
options: options,
name: name
});
// Add the initialize integrations so the server-side ones can be disabled too
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
}
this._invoke('page', new Page(msg));
this.emit('page', category, name, properties, options);
this._callback(fn);
return this;
};
if (is.fn(from)) (fn = from), (options = null), (from = null);
if (is.object(from)) (options = from), (from = null);
/* eslint-enable no-unused-expressions, no-sequences */
var msg = this.normalize({
options: options,
previousId: from,
userId: to
});
// Add the initialize integrations so the server-side ones can be disabled too
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
}
this._invoke('alias', new Alias(msg));
this.emit('alias', to, from, options);
this._callback(fn);
return this;
};
// grab from group again to make sure we're taking from the source
group.identify(id, traits);
var msg = this.normalize({
options: options,
traits: group.traits(),
groupId: group.id()
});
// Add the initialize integrations so the server-side ones can be disabled too
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
}
this._invoke('group', new Group(msg));
this.emit('group', id, traits, options);
this._callback(fn);
return this;
};
var price = product.price;
var quantity = product.quantity;
clonedTrack.properties = product;
clonedTrack.event = 'Product Purchased';
// Price and quantity are both required by Amplitude:
// https://amplitude.zendesk.com/hc/en-us/articles/115001361248#tracking-revenue
// Price could potentially be 0 so handle that edge case.
if (trackRevenuePerProduct && price != null && quantity) {
// Add revenueType if exists, to be able to override.
if (revenueType) {
clonedTrack.properties.revenueType = revenueType;
}
if (revenue) {
clonedTrack.properties.revenue = revenue;
}
this.setRevenue(mapRevenueAttributes(new Track(clonedTrack)));
}
logEvent.call(this, new Track(clonedTrack), trackRevenuePerProduct);
}.bind(this),
products
HubSpot.prototype.identify = function(identify) {
// use newer version of Identify to have access to `companyName`
var newIdentify = new Identify({
traits: identify.traits(),
userId: identify.userId()
});
if (!newIdentify.email()) {
return;
}
var traits = newIdentify.traits({
firstName: 'firstname',
lastName: 'lastname'
});
traits = convertDates(traits);
traits = formatTraits(traits);
if (newIdentify.companyName() !== undefined) {
Totango.prototype.initialize = function(page) {
page = page || new Page({});
/* eslint-disable */
window.totango = {
go:function(){return -1;},
setAccountAttributes:function(){},
identify:function(){},
track:function(t,o,n,a){window.totango_tmp_stack.push({activity:t,module:o,org:n,user:a}); return -1;}};
/* eslint-enable */
window.totango_options = {
allow_empty_accounts: false,
service_id: this.options.serviceId,
disable_heartbeat: this.options.disableHeartbeat,
module: page.category()
};
each(products, function(product) {
var track = new Track({ properties: product });
push(
'_addItem',
orderId,
track.sku(),
track.name(),
track.category(),
track.price(),
track.quantity()
);
});
each(products, function(product) {
var track = new Track({ properties: product });
window.ga(self._trackerName + 'ec:addProduct', {
id: track.productId() || track.id() || track.sku(),
quantity: track.quantity()
});
});