record when a subscription is canceled

This commit is contained in:
Henry Oswald 2016-10-10 15:29:54 +01:00
parent 92e3101d81
commit adc6b429e6
2 changed files with 8 additions and 0 deletions

View file

@ -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()

View file

@ -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)