mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Track unsubscription
This commit is contained in:
@@ -167,9 +167,11 @@ describe('analytics', function() {
|
|||||||
analytics.__set__('ga.transaction', googleTransaction);
|
analytics.__set__('ga.transaction', googleTransaction);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls amplitude.track', function() {
|
context('Amplitude', function() {
|
||||||
|
|
||||||
initializedAnalytics.trackPurchase(purchaseData);
|
it('calls amplitude.track', function() {
|
||||||
|
var data = _.cloneDeep(purchaseData);
|
||||||
|
initializedAnalytics.trackPurchase(data);
|
||||||
|
|
||||||
expect(amplitudeTrack).to.be.calledOnce;
|
expect(amplitudeTrack).to.be.calledOnce;
|
||||||
expect(amplitudeTrack).to.be.calledWith({
|
expect(amplitudeTrack).to.be.calledWith({
|
||||||
@@ -186,10 +188,13 @@ describe('analytics', function() {
|
|||||||
revenue: 8
|
revenue: 8
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
context('Google Analytics', function() {
|
||||||
|
|
||||||
it('calls ga.event', function() {
|
it('calls ga.event', function() {
|
||||||
|
var data = _.cloneDeep(purchaseData);
|
||||||
initializedAnalytics.trackPurchase(purchaseData);
|
initializedAnalytics.trackPurchase(data);
|
||||||
|
|
||||||
expect(googleEvent).to.be.calledOnce;
|
expect(googleEvent).to.be.calledOnce;
|
||||||
expect(googleEvent).to.be.calledWith(
|
expect(googleEvent).to.be.calledWith(
|
||||||
@@ -201,8 +206,8 @@ describe('analytics', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('calls ga.transaction', function() {
|
it('calls ga.transaction', function() {
|
||||||
|
var data = _.cloneDeep(purchaseData);
|
||||||
initializedAnalytics.trackPurchase(purchaseData);
|
initializedAnalytics.trackPurchase(data);
|
||||||
|
|
||||||
expect(googleTransaction).to.be.calledOnce;
|
expect(googleTransaction).to.be.calledOnce;
|
||||||
expect(googleTransaction).to.be.calledWith(
|
expect(googleTransaction).to.be.calledWith(
|
||||||
@@ -221,10 +226,9 @@ describe('analytics', function() {
|
|||||||
|
|
||||||
it('appends gift to variation of ga.transaction.item if gift is true', function() {
|
it('appends gift to variation of ga.transaction.item if gift is true', function() {
|
||||||
|
|
||||||
var purchaseDataWithGift = _.clone(purchaseData);
|
var data = _.cloneDeep(purchaseData);
|
||||||
purchaseDataWithGift.gift = true;
|
data.gift = true;
|
||||||
|
initializedAnalytics.trackPurchase(data);
|
||||||
initializedAnalytics.trackPurchase(purchaseDataWithGift);
|
|
||||||
|
|
||||||
expect(googleItem).to.be.calledOnce;
|
expect(googleItem).to.be.calledOnce;
|
||||||
expect(googleItem).to.be.calledWith(
|
expect(googleItem).to.be.calledWith(
|
||||||
@@ -236,4 +240,5 @@ describe('analytics', function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -127,7 +127,13 @@ exports.cancelSubscription = function(data, cb) {
|
|||||||
|
|
||||||
data.user.save(cb);
|
data.user.save(cb);
|
||||||
utils.txnEmail(data.user, 'cancel-subscription');
|
utils.txnEmail(data.user, 'cancel-subscription');
|
||||||
utils.ga.event('commerce', 'unsubscribe', data.paymentMethod).send();
|
var analyticsData = {
|
||||||
|
uuid: data.user._id,
|
||||||
|
gaCategory: 'commerce',
|
||||||
|
gaLabel: data.paymentMethod,
|
||||||
|
paymentMethod: data.paymentMethod
|
||||||
|
}
|
||||||
|
utils.analytics.track('unsubscribe', analyticsData);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.buyGems = function(data, cb) {
|
exports.buyGems = function(data, cb) {
|
||||||
|
|||||||
Reference in New Issue
Block a user