mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
converted all analytics to use new google analytics, removing mixpanel
and heap. Not tracking subscriptions or cancelations yet.
This commit is contained in:
@@ -42,7 +42,6 @@ describe "EditorController", ->
|
||||
@VersioningApiHandler =
|
||||
enableVersioning : sinon.stub().callsArg(1)
|
||||
@client = new MockClient()
|
||||
@AnalyticsManager = {}
|
||||
|
||||
@settings =
|
||||
apis:{thirdPartyDataStore:{emptyProjectFlushDelayMiliseconds:0.5}}
|
||||
@@ -65,7 +64,6 @@ describe "EditorController", ->
|
||||
'../../handlers/ProjectHandler' : @ProjectHandler
|
||||
"../Versioning/AutomaticSnapshotManager" : @AutomaticSnapshotManager
|
||||
"../Versioning/VersioningApiHandler" : @VersioningApiHandler
|
||||
"../Analytics/AnalyticsManager" : @AnalyticsManager
|
||||
'../../models/Project' : Project: @Project
|
||||
"settings-sharelatex":@settings
|
||||
'../Dropbox/DropboxProjectLinker':@dropboxProjectLinker
|
||||
@@ -84,7 +82,6 @@ describe "EditorController", ->
|
||||
@ProjectGetter.getProjectWithoutDocLines = sinon.stub().callsArgWith(1, null, @project)
|
||||
@ProjectGetter.populateProjectWithUsers = sinon.stub().callsArgWith(1, null, @project)
|
||||
@AuthorizationManager.setPrivilegeLevelOnClient = sinon.stub()
|
||||
@AnalyticsManager.trackOpenEditor = sinon.stub()
|
||||
|
||||
describe "when authorized", ->
|
||||
beforeEach ->
|
||||
@@ -120,9 +117,6 @@ describe "EditorController", ->
|
||||
@VersioningApiHandler.enableVersioning.calledWith(@project)
|
||||
.should.equal true
|
||||
|
||||
it "should track the event", ->
|
||||
@AnalyticsManager.trackOpenEditor.calledWith(@user, @project).should.equal true
|
||||
|
||||
describe "when not authorized", ->
|
||||
beforeEach ->
|
||||
@AuthorizationManager.getPrivilegeLevelForProject =
|
||||
|
||||
@@ -9,7 +9,6 @@ describe 'Referal allocator', ->
|
||||
beforeEach ->
|
||||
@ReferalAllocator = SandboxedModule.require modulePath, requires:
|
||||
'../../models/User': User: @User = {}
|
||||
"../Analytics/AnalyticsManager": @AnalyticsManager = {}
|
||||
"../Subscription/SubscriptionLocator": @SubscriptionLocator = {}
|
||||
"settings-sharelatex": @Settings = {}
|
||||
'logger-sharelatex':
|
||||
@@ -27,7 +26,6 @@ describe 'Referal allocator', ->
|
||||
@referal_source = "bonus"
|
||||
@User.update = sinon.stub().callsArgWith 3, null
|
||||
@User.findOne = sinon.stub().callsArgWith 1, null, { _id: @user_id }
|
||||
@AnalyticsManager.trackReferral = sinon.stub()
|
||||
@ReferalAllocator.assignBonus = sinon.stub().callsArg 1
|
||||
@ReferalAllocator.allocate @referal_id, @new_user_id, @referal_source, @referal_medium, @callback
|
||||
|
||||
@@ -46,11 +44,6 @@ describe 'Referal allocator', ->
|
||||
.calledWith( referal_id: @referal_id )
|
||||
.should.equal true
|
||||
|
||||
it "should track the referral", ->
|
||||
@AnalyticsManager.trackReferral
|
||||
.calledWith({ _id: @user_id }, @referal_source, @referal_medium)
|
||||
.should.equal true
|
||||
|
||||
it "shoudl assign the user their bonus", ->
|
||||
@ReferalAllocator.assignBonus
|
||||
.calledWith(@user_id)
|
||||
@@ -64,7 +57,6 @@ describe 'Referal allocator', ->
|
||||
@referal_source = "public_share"
|
||||
@User.update = sinon.stub().callsArgWith 3, null
|
||||
@User.findOne = sinon.stub().callsArgWith 1, null, { _id: @user_id }
|
||||
@AnalyticsManager.trackReferral = sinon.stub()
|
||||
@ReferalAllocator.assignBonus = sinon.stub().callsArg 1
|
||||
@ReferalAllocator.allocate @referal_id, @new_user_id, @referal_source, @referal_medium, @callback
|
||||
|
||||
@@ -76,11 +68,6 @@ describe 'Referal allocator', ->
|
||||
.calledWith( referal_id: @referal_id )
|
||||
.should.equal true
|
||||
|
||||
it "should track the referral", ->
|
||||
@AnalyticsManager.trackReferral
|
||||
.calledWith({ _id: @user_id }, @referal_source, @referal_medium)
|
||||
.should.equal true
|
||||
|
||||
it "should not assign the user a bonus", ->
|
||||
@ReferalAllocator.assignBonus.called.should.equal false
|
||||
|
||||
|
||||
-8
@@ -9,14 +9,12 @@ describe "SubscriptionBackgroundTasks", ->
|
||||
@Settings = defaultPlanCode:
|
||||
collaborators: 13
|
||||
versioning: true
|
||||
@AnalyticsManager = {}
|
||||
@SubscriptionUpdater = {}
|
||||
|
||||
@SubscriptionBackgroundTasks = SandboxedModule.require modulePath, requires:
|
||||
"./SubscriptionLocator" : @SubscriptionLocator
|
||||
"./SubscriptionUpdater" : @SubscriptionUpdater
|
||||
"settings-sharelatex" : @Settings
|
||||
"../Analytics/AnalyticsManager" : @AnalyticsManager
|
||||
"logger-sharelatex" : log:->
|
||||
|
||||
describe 'downgradeExpiredFreeTrials', ->
|
||||
@@ -27,7 +25,6 @@ describe "SubscriptionBackgroundTasks", ->
|
||||
]
|
||||
@SubscriptionUpdater.downgradeFreeTrial = sinon.stub().callsArg(1)
|
||||
@SubscriptionLocator.expiredFreeTrials = sinon.stub().callsArgWith(0, null, @subscriptions)
|
||||
@AnalyticsManager.trackFreeTrialExpired = sinon.stub()
|
||||
@callback = sinon.stub()
|
||||
@SubscriptionBackgroundTasks.downgradeExpiredFreeTrials(@callback)
|
||||
|
||||
@@ -36,11 +33,6 @@ describe "SubscriptionBackgroundTasks", ->
|
||||
for subscription in @subscriptions
|
||||
@SubscriptionUpdater.downgradeFreeTrial.calledWith(subscription).should.equal true
|
||||
|
||||
it "should track each downgrade", ->
|
||||
@AnalyticsManager.trackFreeTrialExpired.callCount.should.equal @subscriptions.length
|
||||
for subscription in @subscriptions
|
||||
@AnalyticsManager.trackFreeTrialExpired.calledWith(subscription.admin_id).should.equal true
|
||||
|
||||
it "should return the subscriptions in the callback", ->
|
||||
@callback.called.should.equal true
|
||||
@callback.args[0][1].should.deep.equal @subscriptions
|
||||
|
||||
@@ -44,11 +44,6 @@ describe "Subscription Handler sanboxed", ->
|
||||
cancelSubscription: sinon.stub().callsArgWith(1)
|
||||
reactivateSubscription: sinon.stub().callsArgWith(1)
|
||||
|
||||
@AnalyticsManager =
|
||||
trackSubscriptionCancelled: sinon.stub()
|
||||
trackSubscriptionStarted: sinon.stub()
|
||||
trackFreeTrialStarted: sinon.stub()
|
||||
|
||||
@SubscriptionUpdater =
|
||||
syncSubscription: sinon.stub().callsArgWith(2)
|
||||
startFreeTrial: sinon.stub().callsArgWith(1)
|
||||
@@ -64,7 +59,6 @@ describe "Subscription Handler sanboxed", ->
|
||||
"settings-sharelatex": @Settings
|
||||
'../../models/User': User:@User
|
||||
'./SubscriptionUpdater': @SubscriptionUpdater
|
||||
'../Analytics/AnalyticsManager': @AnalyticsManager
|
||||
"logger-sharelatex":{log:->}
|
||||
'./LimitationsManager':@LimitationsManager
|
||||
"../Email/EmailHandler":@EmailHandler
|
||||
@@ -148,11 +142,6 @@ describe "Subscription Handler sanboxed", ->
|
||||
@RecurlyWrapper.cancelSubscription.called.should.equal true
|
||||
@RecurlyWrapper.cancelSubscription.calledWith(@subscription.recurlySubscription_id).should.equal true
|
||||
|
||||
it "should track the cancellation", ->
|
||||
@AnalyticsManager.trackSubscriptionCancelled
|
||||
.calledWith(@user)
|
||||
.should.equal true
|
||||
|
||||
it "should send a cancellation email", ->
|
||||
@EmailHandler.sendEmail.calledWith("canceledSubscription", {to:@user.email, first_name:@user.first_name}).should.equal true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user