From f2069c6208fa0c2caea0b133fd0a218e7c340597 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Sat, 8 Mar 2014 18:31:07 +0000 Subject: [PATCH] converted all analytics to use new google analytics, removing mixpanel and heap. Not tracking subscriptions or cancelations yet. --- .../Analytics/AnalyticsManager.coffee | 69 ------------------- .../Features/Editor/EditorController.coffee | 2 - .../Features/Referal/ReferalAllocator.coffee | 4 -- .../Subscription/LimitationsManager.coffee | 2 +- .../SubscriptionBackgroundTasks.coffee | 2 - .../Subscription/SubscriptionHandler.coffee | 3 - .../coffee/controllers/UserController.coffee | 1 - .../infrastructure/ExpressLocals.coffee | 3 - services/web/app/views/homepage/home.jade | 6 -- services/web/app/views/layout.jade | 48 +------------ services/web/app/views/project/editor.jade | 4 +- services/web/app/views/referal/bonus.jade | 11 ++- services/web/app/views/subscriptions/new.jade | 3 +- .../web/app/views/subscriptions/plans.jade | 3 +- services/web/app/views/user/register.jade | 5 -- .../web/config/settings.development.coffee | 4 -- services/web/public/coffee/ab_testing.coffee | 26 ------- .../coffee/analytics/AnalyticsManager.coffee | 6 +- .../web/public/coffee/editor/Document.coffee | 2 +- services/web/public/coffee/home.coffee | 3 - services/web/public/coffee/ide.coffee | 2 +- .../coffee/ide/ConnectionManager.coffee | 2 +- .../ProjectMembersManager.coffee | 8 +-- .../Editor/EditorControllerTests.coffee | 6 -- .../Referal/ReferalAllocatorTests.coffee | 13 ---- .../SubscriptionBackgroundTasksTests.coffee | 8 --- .../SubscriptionHandlerTests.coffee | 11 --- 27 files changed, 21 insertions(+), 236 deletions(-) delete mode 100644 services/web/app/coffee/Features/Analytics/AnalyticsManager.coffee delete mode 100644 services/web/public/coffee/ab_testing.coffee diff --git a/services/web/app/coffee/Features/Analytics/AnalyticsManager.coffee b/services/web/app/coffee/Features/Analytics/AnalyticsManager.coffee deleted file mode 100644 index 05438c15ba..0000000000 --- a/services/web/app/coffee/Features/Analytics/AnalyticsManager.coffee +++ /dev/null @@ -1,69 +0,0 @@ -Settings = require 'settings-sharelatex' -if Settings.analytics?.mixpanel? - Mixpanel = require("mixpanel").init(Settings.analytics.mixpanel.token) -else - Mixpanel = null -logger = require "logger-sharelatex" -async = require 'async' - -module.exports = AnalyticsManager = - - track: (user, event, properties, callback = (error)->) -> - properties.distinct_id = @getDistinctId user - properties.mp_name_tag = user.email if user.email? - logger.log user_id: properties.distinct_id, event: event, properties: properties, "tracking event" - Mixpanel?.track event, properties - callback() - - set: (user, properties, callback = (error)->) -> - properties["$first_name"] = user.first_name if user.first_name? - properties["$last_name"] = user.last_name if user.last_name? - properties["$email"] = user.email if user.email? - Mixpanel?.people.set @getDistinctId(user), properties - callback() - - increment: (user, property, amount, callback = (error)->) -> - Mixpanel?.people.increment @getDistinctId(user), property, amount - callback() - - # TODO: Remove this one month after the ability to start free trials was removed - trackFreeTrialExpired: (user, callback = (error)->) -> - async.series [ - (callback) => @track user, "free trial expired", {}, callback - (callback) => @set user, { free_trial_expired_at: new Date() }, callback - ], callback - - trackSubscriptionStarted: (user, plan_code, callback = (error)->) -> - async.series [ - (callback) => @track user, "subscribed", plan_code: plan_code, callback - (callback) => @set user, { plan_code: plan_code, subscribed_at: new Date() }, callback - ], callback - - trackSubscriptionCancelled: (user, callback = (error)->) -> - async.series [ - (callback) => @track user, "cancelled", callback - (callback) => @set user, { cancelled_at: new Date() }, callback - ], callback - - trackLogIn: (user, callback = (error)->) -> - async.series [ - (callback) => @track user, "logged in", {}, callback - (callback) => @set user, { last_logged_id: new Date() }, callback - ], callback - - trackOpenEditor: (user, project, callback = (error)->) -> - async.series [ - (callback) => @set user, { last_opened_editor: new Date() }, callback - (callback) => @increment user, "editor_opens", 1, callback - ], callback - - trackReferral: (user, referal_source, referal_medium, callback = (error) ->) -> - async.series [ - (callback) => - @track user, "Referred another user", { source: referal_source, medium: referal_medium }, callback - (callback) => - @track user, "Referred another user via #{referal_source}", { medium: referal_medium }, callback - ], callback - - getDistinctId: (user) -> user.id || user._id || user - diff --git a/services/web/app/coffee/Features/Editor/EditorController.coffee b/services/web/app/coffee/Features/Editor/EditorController.coffee index fb2818b914..fce0e68365 100644 --- a/services/web/app/coffee/Features/Editor/EditorController.coffee +++ b/services/web/app/coffee/Features/Editor/EditorController.coffee @@ -12,7 +12,6 @@ LimitationsManager = require("../Subscription/LimitationsManager") AuthorizationManager = require("../Security/AuthorizationManager") AutomaticSnapshotManager = require("../Versioning/AutomaticSnapshotManager") VersioningApiHandler = require("../Versioning/VersioningApiHandler") -AnalyticsManager = require("../Analytics/AnalyticsManager") EditorRealTimeController = require("./EditorRealTimeController") settings = require('settings-sharelatex') slReqIdHelper = require('soa-req-id') @@ -47,7 +46,6 @@ module.exports = EditorController = if error? or !canAccess callback new Error("Not authorized") else - AnalyticsManager.trackOpenEditor user, project client.join(project_id) client.set("project_id", project_id) client.set("owner_id", project.owner_ref._id) diff --git a/services/web/app/coffee/Features/Referal/ReferalAllocator.coffee b/services/web/app/coffee/Features/Referal/ReferalAllocator.coffee index 5010b08eed..e19735e3f6 100644 --- a/services/web/app/coffee/Features/Referal/ReferalAllocator.coffee +++ b/services/web/app/coffee/Features/Referal/ReferalAllocator.coffee @@ -1,6 +1,5 @@ logger = require('logger-sharelatex') User = require('../../models/User').User -AnalyticsManager = require("../Analytics/AnalyticsManager") SubscriptionLocator = require "../Subscription/SubscriptionLocator" Settings = require "settings-sharelatex" @@ -15,9 +14,6 @@ module.exports = ReferalAllocator = return callback(error) if error? return callback(new Error("user not found")) if !user? or !user._id? - # Can be backgrounded - AnalyticsManager.trackReferral user, referal_source, referal_medium - if referal_source == "bonus" User.update query, { $push: diff --git a/services/web/app/coffee/Features/Subscription/LimitationsManager.coffee b/services/web/app/coffee/Features/Subscription/LimitationsManager.coffee index 7f661a522e..24765128da 100644 --- a/services/web/app/coffee/Features/Subscription/LimitationsManager.coffee +++ b/services/web/app/coffee/Features/Subscription/LimitationsManager.coffee @@ -38,8 +38,8 @@ module.exports = userHasSubscription: (user, callback = (err, hasSubscription, subscription)->) -> logger.log user_id:user._id, "checking if user has subscription" SubscriptionLocator.getUsersSubscription user._id, (err, subscription)-> - logger.log user:user, subscription:subscription, "checking if user has subscription" hasValidSubscription = subscription? and subscription.recurlySubscription_id? and subscription?.state != "expired" + logger.log user:user, hasValidSubscription:hasValidSubscription, subscription:subscription, "checking if user has subscription" callback err, hasValidSubscription, subscription userHasFreeTrial: (user, callback = (err, hasFreeTrial, subscription)->) -> diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionBackgroundTasks.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionBackgroundTasks.coffee index 7085a30b1d..e82365846d 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionBackgroundTasks.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionBackgroundTasks.coffee @@ -2,7 +2,6 @@ async = require 'async' logger = require 'logger-sharelatex' SubscriptionUpdater = require("./SubscriptionUpdater") SubscriptionLocator = require("./SubscriptionLocator") -AnalyticsManager = require("../Analytics/AnalyticsManager") module.exports = SubscriptionBackgroundJobs = # TODO: Remove this one month after the ability to start free trials was removed @@ -15,7 +14,6 @@ module.exports = SubscriptionBackgroundJobs = do (subscription) => downgrades.push (cb) => logger.log subscription: subscription, "downgrading free trial" - AnalyticsManager.trackFreeTrialExpired subscription.admin_id SubscriptionUpdater.downgradeFreeTrial(subscription, cb) async.series downgrades, (error) -> callback(error, subscriptions) diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee index cdba20a0cc..3749ba89b6 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee @@ -2,7 +2,6 @@ RecurlyWrapper = require("./RecurlyWrapper") Settings = require "settings-sharelatex" User = require('../../models/User').User logger = require('logger-sharelatex') -AnalyticsManager = require '../Analytics/AnalyticsManager' SubscriptionUpdater = require("./SubscriptionUpdater") LimitationsManager = require('./LimitationsManager') EmailHandler = require("../Email/EmailHandler") @@ -15,7 +14,6 @@ module.exports = return callback(error) if error? SubscriptionUpdater.syncSubscription recurlySubscription, user._id, (error) -> return callback(error) if error? - AnalyticsManager.trackSubscriptionStarted user, recurlySubscription?.plan?.plan_code callback() updateSubscription: (user, plan_code, callback)-> @@ -33,7 +31,6 @@ module.exports = if hasSubscription RecurlyWrapper.cancelSubscription subscription.recurlySubscription_id, (error) -> return callback(error) if error? - AnalyticsManager.trackSubscriptionCancelled user emailOpts = to: user.email first_name: user.first_name diff --git a/services/web/app/coffee/controllers/UserController.coffee b/services/web/app/coffee/controllers/UserController.coffee index a4b139fec4..0dce803ac2 100644 --- a/services/web/app/coffee/controllers/UserController.coffee +++ b/services/web/app/coffee/controllers/UserController.coffee @@ -9,7 +9,6 @@ newsLetterManager = require('../managers/NewsletterManager') dropboxHandler = require('../Features/Dropbox/DropboxHandler') userRegistrationHandler = require('../Features/User/UserRegistrationHandler') metrics = require('../infrastructure/Metrics') -AnalyticsManager = require('../Features/Analytics/AnalyticsManager') ReferalAllocator = require('../Features/Referal/ReferalAllocator') AuthenticationManager = require("../Features/Authentication/AuthenticationManager") AuthenticationController = require("../Features/Authentication/AuthenticationController") diff --git a/services/web/app/coffee/infrastructure/ExpressLocals.coffee b/services/web/app/coffee/infrastructure/ExpressLocals.coffee index 654d74b711..714f99d800 100644 --- a/services/web/app/coffee/infrastructure/ExpressLocals.coffee +++ b/services/web/app/coffee/infrastructure/ExpressLocals.coffee @@ -95,7 +95,6 @@ module.exports = (app)-> app.use (req, res, next)-> if req.session.user? - res.locals.mixpanelId = req.session.user._id res.locals.user = email: req.session.user.email first_name: req.session.user.first_name @@ -106,9 +105,7 @@ module.exports = (app)-> if req.session.justLoggedIn res.locals.justLoggedIn = true delete req.session.justLoggedIn - res.locals.mixpanelToken = Settings.analytics?.mixpanel?.token res.locals.gaToken = Settings.analytics?.ga?.token - res.locals.heapToken = Settings.analytics?.heap?.token res.locals.tenderUrl = Settings.tenderUrl next() diff --git a/services/web/app/views/homepage/home.jade b/services/web/app/views/homepage/home.jade index 75e8b607d8..8b70d7b1b9 100644 --- a/services/web/app/views/homepage/home.jade +++ b/services/web/app/views/homepage/home.jade @@ -60,11 +60,5 @@ block content include ../general/social-footer include ../general/small-footer - .container - .row - .span12(style="text-align:right; margin-bottom:20px") - a(href="https://mixpanel.com/f/partner") - img(src="//cdn.mxpnl.com/site_media/images/partner/badge_light.png",alt="Mobile Analytics") - diff --git a/services/web/app/views/layout.jade b/services/web/app/views/layout.jade index cdeb589a24..50d595cd89 100644 --- a/services/web/app/views/layout.jade +++ b/services/web/app/views/layout.jade @@ -16,59 +16,13 @@ html(itemscope, itemtype='http://schema.org/Product') - if (typeof(gaToken) != "undefined") script(type='text/javascript') - var _gaq = _gaq || []; - _gaq.push(['_setAccount', '#{gaToken}']); - _gaq.push(['_trackPageview']); - - (function() { - var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; - var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); - })(); - - // this is the new google analytics https://developers.google.com/analytics/devguides/collection/analyticsjs/ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', '#{gaToken}', 'auto'); + ga('create', '#{gaToken}', 'sharelatex.com'); ga('send', 'pageview'); - - if (typeof(mixpanelToken) != "undefined") - script(type="text/javascript") - (function(c,a){window.mixpanel=a;var b,d,h,e;b=c.createElement("script"); - b.type="text/javascript";b.async=!0;b.src=("https:"===c.location.protocol?"https:":"http:")+ - '//cdn.mxpnl.com/libs/mixpanel-2.2.min.js';d=c.getElementsByTagName("script")[0]; - d.parentNode.insertBefore(b,d);a._i=[];a.init=function(b,c,f){function d(a,b){ - var c=b.split(".");2==c.length&&(a=a[c[0]],b=c[1]);a[b]=function(){a.push([b].concat( - Array.prototype.slice.call(arguments,0)))}}var g=a;"undefined"!==typeof f?g=a[f]=[]: - f="mixpanel";g.people=g.people||[];h=['disable','track','track_pageview','track_links', - 'track_forms','register','register_once','unregister','identify','alias','name_tag', - 'set_config','people.set','people.increment','people.track_charge','people.append']; - for(e=0;e - chooseOption = (testName, option1, option2, callback = (error, option) ->) -> - if Math.random() < 0.5 - option = option1 - else - option = option2 - - loaded = false - do initTest = -> - return if loaded - if mixpanel?.get_property? - attributes = {} - attributes[testName] = option - mixpanel?.register_once( attributes ) - mixpanel?.people.set( attributes ) - loaded = true - callback null, mixpanel?.get_property( testName ) - else - setTimeout(initTest, 300) - - fallback = () -> - return if loaded - loaded = true - callback null, option1 - setTimeout fallback, 1500 - diff --git a/services/web/public/coffee/analytics/AnalyticsManager.coffee b/services/web/public/coffee/analytics/AnalyticsManager.coffee index 8c88220327..9b2bc49702 100644 --- a/services/web/public/coffee/analytics/AnalyticsManager.coffee +++ b/services/web/public/coffee/analytics/AnalyticsManager.coffee @@ -5,12 +5,12 @@ define () -> @updateCount ||= 0 @updateCount++ if @updateCount == 100 - mixpanel?.track("Updated doc multiple times in one session", project_id: @ide.project.id) + ga('send', 'event', 'editor-interaction', 'multi-doc-update') @ide.pdfManager.on "compile:pdf", () => @compileCount ||= 0 @compileCount++ if @compileCount == 1 - mixpanel?.track("Compiled project at least once in one session", project_id: @ide.project.id) + ga('send', 'event', 'editor-interaction', 'single-compile') if @compileCount == 3 - mixpanel?.track("Compiled project multiple times in one session", project_id: @ide.project.id) + ga('send', 'event', 'editor-interaction', 'multi-compile') diff --git a/services/web/public/coffee/editor/Document.coffee b/services/web/public/coffee/editor/Document.coffee index 11b383fbc1..41cf1f7e11 100644 --- a/services/web/public/coffee/editor/Document.coffee +++ b/services/web/public/coffee/editor/Document.coffee @@ -144,7 +144,7 @@ define [ _onError: (error) -> console.error "ShareJS error", error - heap?.track "shareJsError", { error: (error.message or error), transport: ide.socket.socket.transport.name } + ga('send', 'event', 'error', "shareJsError", "#{error.message} - #{ide.socket.socket.transport.name}" ) @ide.socket.disconnect() @doc?.clearInflightAndPendingOps() @_cleanUp() diff --git a/services/web/public/coffee/home.coffee b/services/web/public/coffee/home.coffee index 2485ee5fa8..85ea435420 100644 --- a/services/web/public/coffee/home.coffee +++ b/services/web/public/coffee/home.coffee @@ -3,6 +3,3 @@ define [ "forms" ], ()-> $(document).ready ()-> - mixpanel?.track_links(".signup-now", "homepage.signup-now") - $('#registerButton').click -> - mixpanel?.track("homepage.register-now") diff --git a/services/web/public/coffee/ide.coffee b/services/web/public/coffee/ide.coffee index d15252d32c..c3d758c978 100644 --- a/services/web/public/coffee/ide.coffee +++ b/services/web/public/coffee/ide.coffee @@ -218,7 +218,7 @@ define [ return if @timeOut? @clearTimeout() @timeOut = setTimeout((=> - heap?.track "savingShown" + ga('send', 'event', 'editor-interaction', 'notification-shown', "saving") $("#savingProblems").show() ), 1000) diff --git a/services/web/public/coffee/ide/ConnectionManager.coffee b/services/web/public/coffee/ide/ConnectionManager.coffee index 15eb715db1..9556ec1d1c 100644 --- a/services/web/public/coffee/ide/ConnectionManager.coffee +++ b/services/web/public/coffee/ide/ConnectionManager.coffee @@ -15,7 +15,7 @@ define [ @connected = false @ide.trigger "disconnect" setTimeout(=> - mixpanel?.track("disconnected") + ga('send', 'event', 'editor-interaction', 'disconnect') , 2000) if !@forcedDisconnect diff --git a/services/web/public/coffee/project-members/ProjectMembersManager.coffee b/services/web/public/coffee/project-members/ProjectMembersManager.coffee index 032b9d1cbd..565d5dc7f3 100644 --- a/services/web/public/coffee/project-members/ProjectMembersManager.coffee +++ b/services/web/public/coffee/project-members/ProjectMembersManager.coffee @@ -274,7 +274,7 @@ define [ "caption=My LaTeX project (#{@ide.project.get("name")}) is available online on ShareLaTeX&" + "redirect_uri=#{window.sharelatex.siteUrl}&" + "display=popup" - mixpanel?.track("Project Shared", { method: "facebook" }) + ga('send', 'event', 'editor-interaction', 'project-shared', "facebook") window.open( url "" @@ -284,7 +284,7 @@ define [ postToTwitter: () -> @ensurePublic (error, success) => if success - mixpanel?.track("Project Shared", { method: "twitter" }) + ga('send', 'event', 'editor-interaction', 'project-shared', "twitter") window.open( "https://www.twitter.com/share/?text=Check out my online LaTeX Project: #{@ide.project.get("name")}&url=#{encodeURIComponent(@url("t"))}" "" @@ -294,7 +294,7 @@ define [ postToGoogle: () -> @ensurePublic (error, success) => if success - mixpanel?.track("Project Shared", { method: "google_plus" }) + ga('send', 'event', 'editor-interaction', 'project-shared', "google-plus") window.open( "https://plus.google.com/share?url=#{encodeURIComponent(@url("gp"))}" "" @@ -304,7 +304,7 @@ define [ shareUrl: () -> @ensurePublic (error, success) => if success - mixpanel?.track("Project Shared", { method: "url" }) + ga('send', 'event', 'editor-interaction', 'project-shared', "url") Modal.createModal el: $( "

You can share you project with your friends and colleagues via this URL:

" + diff --git a/services/web/test/UnitTests/coffee/Editor/EditorControllerTests.coffee b/services/web/test/UnitTests/coffee/Editor/EditorControllerTests.coffee index 36019bb2c3..3a0eb1120b 100644 --- a/services/web/test/UnitTests/coffee/Editor/EditorControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/Editor/EditorControllerTests.coffee @@ -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 = diff --git a/services/web/test/UnitTests/coffee/Referal/ReferalAllocatorTests.coffee b/services/web/test/UnitTests/coffee/Referal/ReferalAllocatorTests.coffee index 35cb913ae6..8ccc0019aa 100644 --- a/services/web/test/UnitTests/coffee/Referal/ReferalAllocatorTests.coffee +++ b/services/web/test/UnitTests/coffee/Referal/ReferalAllocatorTests.coffee @@ -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 diff --git a/services/web/test/UnitTests/coffee/Subscription/SubscriptionBackgroundTasksTests.coffee b/services/web/test/UnitTests/coffee/Subscription/SubscriptionBackgroundTasksTests.coffee index 273a0d9a55..7cfc981030 100644 --- a/services/web/test/UnitTests/coffee/Subscription/SubscriptionBackgroundTasksTests.coffee +++ b/services/web/test/UnitTests/coffee/Subscription/SubscriptionBackgroundTasksTests.coffee @@ -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 diff --git a/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee b/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee index e2e6bdbb44..c080612fd1 100644 --- a/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee @@ -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