avo-amplitude-js
Advanced tools
Comparing version 1.0.0 to 1.1.0
35
index.js
@@ -25,2 +25,37 @@ var amplitude = require('amplitude-js'); | ||
function _logRevenue(productId, quantity, price, revenueType, eventProperties) { | ||
var revenue = new amplitude.Revenue().setQuantity(quantity).setPrice(price); | ||
if (productId !== null && productId !== undefined && productId.length !== 0) { | ||
revenue.setProductId(productId); | ||
} | ||
if ( | ||
revenueType !== null && | ||
revenueType !== undefined && | ||
revenueType.length !== 0 | ||
) { | ||
revenue.setRevenueType(revenueType); | ||
} | ||
if (eventProperties !== null && eventProperties !== undefined) { | ||
revenue.setEventProperties(eventProperties); | ||
} | ||
amplitude.logRevenueV2(revenue); | ||
} | ||
exports.logRevenueWithUserProperties = function logRevenueWithUserProperties( | ||
productId, | ||
quantity, | ||
price, | ||
revenueType, | ||
eventProperties, | ||
userProperties | ||
) { | ||
if (userProperties !== null && userProperties !== undefined) { | ||
amplitude.getInstance(apiKey).setUserProperties(userProperties); | ||
} | ||
_logRevenue(productId, quantity, price, revenueType, eventProperties); | ||
}; | ||
exports.logRevenue = _logRevenue; | ||
exports.setUserId = function setUserId(userId) { | ||
@@ -27,0 +62,0 @@ amplitude.getInstance(apiKey).setUserId(userId); |
{ | ||
"name": "avo-amplitude-js", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
2068
57