Paulo Reis 10 лет назад
Родитель
Сommit
228de5332e

+ 6 - 0
services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee

@@ -19,6 +19,7 @@ describe "AuthenticationController", ->
 			"../../infrastructure/Metrics": @Metrics = { inc: sinon.stub() }
 			"../Security/LoginRateLimiter": @LoginRateLimiter = { processLoginRequest:sinon.stub(), recordSuccessfulLogin:sinon.stub() }
 			"../User/UserHandler": @UserHandler = {setupLoginData:sinon.stub()}
+			"../Analytics/AnalyticsManager": @AnalyticsManager = { recordEvent: sinon.stub() }
 			"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
 			"settings-sharelatex": {}
 			"../User/UserSessionsManager": @UserSessionsManager =
@@ -100,6 +101,11 @@ describe "AuthenticationController", ->
 					.calledWith(email: @email.toLowerCase(), user_id: @user._id.toString(), "successful log in")
 					.should.equal true
 
+			it "should track the login event", ->
+				@AnalyticsManager.recordEvent
+					.calledWith(@user._id, "user-logged-in")
+					.should.equal true
+
 
 		describe 'when the user is not authenticated', ->
 			beforeEach ->

+ 8 - 0
services/web/test/UnitTests/coffee/User/UserRegistrationHandlerTests.coffee

@@ -33,6 +33,7 @@ describe "UserRegistrationHandler", ->
 			"crypto": @crypto = {}
 			"../Email/EmailHandler": @EmailHandler
 			"../Security/OneTimeTokenHandler": @OneTimeTokenHandler
+			"../Analytics/AnalyticsManager": @AnalyticsManager = { recordEvent: sinon.stub() }
 			"settings-sharelatex": @settings = {siteUrl: "http://sl.example.com"}
 
 		@passingRequest = {email:"something@email.com", password:"123"}
@@ -132,6 +133,13 @@ describe "UserRegistrationHandler", ->
 					@NewsLetterManager.subscribe.calledWith(@user).should.equal true
 					done()
 
+			it "should track the registration event", (done)->
+				@handler.registerNewUser @passingRequest, (err)=>
+					@AnalyticsManager.recordEvent
+						.calledWith(@user._id, "user-registered")
+						.should.equal true
+					done()
+
 
 		it "should call the ReferalAllocator", (done)->
 			done()