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;
};
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
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()
});
});
function createProductTrack(track, properties) {
properties.currency = properties.currency || track.currency();
return new Track({ properties: properties });
}
products.forEach(function(product) {
var track = new Track({ properties: product });
var productId =
track.proxy('properties.product_id') || track.productId() || track.id();
if (productId) {
contentIds.push(productId);
contents.push({
id: productId,
quantity: 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()
});
});
function createProductTrack(track, properties) {
var props = properties || {};
props.currency = properties.currency || track.currency();
return new Track({ properties: props });
}
each(products, function(product) {
var track = new Track({ properties: product });
skus.push(track.sku());
quantities.push(track.quantity());
prices.push(track.price());
});