From adc6b429e66307c7ac92711e6cfc824b264e26e5 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 10 Oct 2016 15:29:54 +0100 Subject: [PATCH] record when a subscription is canceled --- .../coffee/Features/Subscription/SubscriptionHandler.coffee | 3 +++ .../coffee/Subscription/SubscriptionHandlerTests.coffee | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee index 2396dca07b..ba95895dcd 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee @@ -7,6 +7,8 @@ SubscriptionUpdater = require("./SubscriptionUpdater") LimitationsManager = require('./LimitationsManager') EmailHandler = require("../Email/EmailHandler") Events = require "../../infrastructure/Events" +Analytics = require("../Analytics/AnalyticsManager") + module.exports = @@ -52,6 +54,7 @@ module.exports = setTimeout (-> EmailHandler.sendEmail "canceledSubscription", emailOpts ), ONE_HOUR_IN_MS Events.emit "cancelSubscription", user._id + Analytics.recordEvent user._id, "subscription-canceled" callback() else callback() diff --git a/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee b/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee index 7591aadebb..935ed6d025 100644 --- a/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee @@ -57,6 +57,10 @@ describe "Subscription Handler sanboxed", -> @EmailHandler = sendEmail:sinon.stub() + + @AnalyticsManager = + recordEvent:sinon.stub() + @SubscriptionHandler = SandboxedModule.require modulePath, requires: "./RecurlyWrapper": @RecurlyWrapper "settings-sharelatex": @Settings @@ -67,6 +71,7 @@ describe "Subscription Handler sanboxed", -> "../Email/EmailHandler":@EmailHandler "../Dropbox/DropboxHandler":@DropboxHandler "../../infrastructure/Events": @Events = {emit: sinon.stub()} + "../Analytics/AnalyticsManager": @AnalyticsManager @SubscriptionHandler.syncSubscriptionToUser = sinon.stub().callsArgWith(2)