mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Add platform, change itemName to itemKey
This commit is contained in:
@@ -820,7 +820,7 @@ api.wrap = (user, main=true) ->
|
||||
|
||||
analyticsData = {
|
||||
uuid: user._id,
|
||||
itemName: key,
|
||||
itemKey: key,
|
||||
acquireMethod: 'Gold',
|
||||
goldCost: convRate,
|
||||
category: 'behavior'
|
||||
@@ -847,7 +847,7 @@ api.wrap = (user, main=true) ->
|
||||
|
||||
analyticsData = {
|
||||
uuid: user._id,
|
||||
itemName: key,
|
||||
itemKey: key,
|
||||
itemType: 'Market',
|
||||
acquireMethod: 'Gems',
|
||||
gemCost: item.value,
|
||||
@@ -977,7 +977,7 @@ api.wrap = (user, main=true) ->
|
||||
|
||||
analyticsData = {
|
||||
uuid: user._id,
|
||||
itemName: key,
|
||||
itemKey: key,
|
||||
acquireMethod: 'Gold',
|
||||
goldCost: item.value,
|
||||
category: 'behavior'
|
||||
@@ -996,7 +996,7 @@ api.wrap = (user, main=true) ->
|
||||
user.items.gear.owned[i.key]=true
|
||||
analyticsData = {
|
||||
uuid: user._id,
|
||||
itemName: i.key,
|
||||
itemKey: i.key,
|
||||
itemType: 'Subscriber Gear',
|
||||
acquireMethod: 'Hourglass',
|
||||
category: 'behavior'
|
||||
@@ -1076,7 +1076,7 @@ api.wrap = (user, main=true) ->
|
||||
|
||||
analyticsData = {
|
||||
uuid: user._id,
|
||||
itemName: path,
|
||||
itemKey: path,
|
||||
itemType: 'customization',
|
||||
acquireMethod: 'Gems',
|
||||
gemCost: (cost/.25),
|
||||
@@ -1170,7 +1170,7 @@ api.wrap = (user, main=true) ->
|
||||
|
||||
analyticsData = {
|
||||
uuid: user._id,
|
||||
itemName: item,
|
||||
itemKey: item,
|
||||
itemType: 'Subscriber Gear',
|
||||
acquireMethod: 'Subscriber',
|
||||
category: 'behavior'
|
||||
@@ -1628,7 +1628,7 @@ api.wrap = (user, main=true) ->
|
||||
|
||||
analyticsData = {
|
||||
uuid: user._id,
|
||||
itemName: 'quest drop: ' + k,
|
||||
itemKey: 'quest drop: ' + k,
|
||||
acquireMethod: 'Drop',
|
||||
category: 'behavior'
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ describe('analytics', function() {
|
||||
expect(amplitudeTrack).to.be.calledWith({
|
||||
event_type: 'Cron',
|
||||
user_id: 'unique-user-id',
|
||||
platform: 'server',
|
||||
event_properties: {
|
||||
category: 'behavior',
|
||||
resting: true,
|
||||
@@ -111,6 +112,7 @@ describe('analytics', function() {
|
||||
expect(amplitudeTrack).to.be.calledWith({
|
||||
event_type: 'Cron',
|
||||
user_id: 'unique-user-id',
|
||||
platform: 'server',
|
||||
event_properties: {
|
||||
category: 'behavior',
|
||||
resting: true,
|
||||
@@ -159,7 +161,7 @@ describe('analytics', function() {
|
||||
it('if gemCost property is provided, use as label (overrides goldCost)', function() {
|
||||
var data = _.cloneDeep(analyticsData);
|
||||
data.goldCost = 10;
|
||||
data.itemName = 50;
|
||||
data.itemKey = 50;
|
||||
|
||||
initializedAnalytics.track(event_type, data);
|
||||
|
||||
@@ -171,11 +173,11 @@ describe('analytics', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('if itemName property is provided, use as label (overrides gem/goldCost)', function() {
|
||||
it('if itemKey property is provided, use as label (overrides gem/goldCost)', function() {
|
||||
var data = _.cloneDeep(analyticsData);
|
||||
data.goldCost = 5;
|
||||
data.gemCost = 50;
|
||||
data.itemName = 'some item';
|
||||
data.itemKey = 'some item';
|
||||
|
||||
initializedAnalytics.track(event_type, data);
|
||||
|
||||
@@ -187,10 +189,10 @@ describe('analytics', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('if gaLabel property is provided, use as label (overrides itemName)', function() {
|
||||
it('if gaLabel property is provided, use as label (overrides itemKey)', function() {
|
||||
var data = _.cloneDeep(analyticsData);
|
||||
data.value = 'some value';
|
||||
data.itemName = 'some item';
|
||||
data.itemKey = 'some item';
|
||||
data.gaLabel = 'some label';
|
||||
|
||||
initializedAnalytics.track(event_type, data);
|
||||
@@ -239,6 +241,7 @@ describe('analytics', function() {
|
||||
expect(amplitudeTrack).to.be.calledWith({
|
||||
event_type: 'purchase',
|
||||
user_id: 'user-id',
|
||||
platform: 'server',
|
||||
event_properties: {
|
||||
paymentMethod: 'PayPal',
|
||||
sku: 'paypal-checkout',
|
||||
|
||||
@@ -39,7 +39,7 @@ function _sendDataToGoogle(eventType, data) {
|
||||
|
||||
function _generateLabelForGoogleAnalytics(data) {
|
||||
var label = 'Label Not Specified';
|
||||
var POSSIBLE_LABELS = ['gaLabel', 'itemName', 'gemCost', 'goldCost'];
|
||||
var POSSIBLE_LABELS = ['gaLabel', 'itemKey', 'gemCost', 'goldCost'];
|
||||
|
||||
_(POSSIBLE_LABELS).each(function(key) {
|
||||
if(data[key]) {
|
||||
@@ -70,6 +70,7 @@ function _formatDataForAmplitude(data) {
|
||||
|
||||
var ampData = {
|
||||
user_id: data.uuid,
|
||||
platform: 'server',
|
||||
event_properties: event_properties
|
||||
}
|
||||
|
||||
@@ -109,7 +110,7 @@ function _sendPurchaseDataToGoogle(data) {
|
||||
var price = data.purchaseValue;
|
||||
var qty = data.quantity;
|
||||
var sku = data.sku;
|
||||
var itemName = data.itemPurchased;
|
||||
var itemKey = data.itemPurchased;
|
||||
var variation = type;
|
||||
if(data.gift) variation += ' - Gift';
|
||||
|
||||
@@ -117,7 +118,7 @@ function _sendPurchaseDataToGoogle(data) {
|
||||
.send();
|
||||
|
||||
ga.transaction(data.uuid, price)
|
||||
.item(price, qty, sku, itemName, variation)
|
||||
.item(price, qty, sku, itemKey, variation)
|
||||
.send();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user