Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@segment/analytics.js-integration-amplitude

Package Overview
Dependencies
Maintainers
116
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@segment/analytics.js-integration-amplitude - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

24

lib/index.js

@@ -245,3 +245,7 @@ 'use strict';

type = value;
type === 'user_properties' ? (params[key] = query) : (props[key] = query);
if (type === 'user_properties') {
params[key] = query;
} else {
props[key] = query;
}
}, mapQueryParams);

@@ -275,2 +279,4 @@

var trackRevenuePerProduct = this.options.trackRevenuePerProduct;
var revenueType = track.proxy('properties.revenueType');
var revenue = track.revenue();

@@ -298,4 +304,12 @@ // Amplitude does not allow arrays of objects to as properties of events.

// Price could potentially be 0 so handle that edge case.
if (trackRevenuePerProduct && price != null && quantity)
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);

@@ -414,5 +428,5 @@ }.bind(this),

if (parts.length >= 3) {
var referring_domain = parts[2];
identify.setOnce('initial_referring_domain', referring_domain);
identify.set('referring_domain', referring_domain);
var referringDomain = parts[2];
identify.setOnce('initial_referring_domain', referringDomain);
identify.set('referring_domain', referringDomain);
}

@@ -419,0 +433,0 @@

{
"name": "@segment/analytics.js-integration-amplitude",
"description": "The Amplitude analytics.js integration.",
"version": "3.0.0",
"version": "3.0.1",
"keywords": [

@@ -53,3 +53,3 @@ "analytics.js",

},
"gitHead": "b410d4ccd7ccd2a65831a842af38ec33add895e1"
"gitHead": "98db2e118e9764cc61a88e17357e686c640d31a2"
}

@@ -677,2 +677,39 @@ 'use strict';

it('should send a custom revenueType if trackRevenuePerProduct is set', function() {
amplitude.options.useLogRevenueV2 = true;
amplitude.options.trackRevenuePerProduct = true;
var props = {
revenue: 20.0,
revenueType: 'I am custom',
products: [
{
quantity: 2,
price: 10.0,
productId: 'AMP1'
}
]
};
var setRevenue = sinon.spy(amplitude, 'setRevenue');
analytics.track('Completed Order', props);
var expected = {
price: 10.0,
productId: 'AMP1',
revenueType: 'I am custom',
quantity: 2,
eventProps: {
revenue: 20.0,
revenueType: 'I am custom',
quantity: 2,
price: 10.0,
productId: 'AMP1'
},
revenue: 20.0
};
analytics.assert(setRevenue.withArgs(expected).calledOnce);
});
it('should send a logRevenueV2 event for all items in products array if trackRevenuePerProduct is true', function() {

@@ -679,0 +716,0 @@ var spy = sinon.spy(window.amplitude.getInstance(), 'logRevenueV2');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc