mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-06 08:51:21 +00:00
Merge pull request #296 from sharelatex/pr-track-signup-and-login
Track signup and login
This commit is contained in:
commit
d6a2bc9d71
4 changed files with 18 additions and 0 deletions
|
@ -10,6 +10,7 @@ Settings = require "settings-sharelatex"
|
|||
basicAuth = require('basic-auth-connect')
|
||||
UserHandler = require("../User/UserHandler")
|
||||
UserSessionsManager = require("../User/UserSessionsManager")
|
||||
Analytics = require "../Analytics/AnalyticsManager"
|
||||
|
||||
module.exports = AuthenticationController =
|
||||
login: (req, res, next = (error) ->) ->
|
||||
|
@ -37,6 +38,7 @@ module.exports = AuthenticationController =
|
|||
return next(error) if error?
|
||||
req.session.justLoggedIn = true
|
||||
logger.log email: email, user_id: user._id.toString(), "successful log in"
|
||||
Analytics.recordEvent user._id, "user-logged-in"
|
||||
res.json redir: redir
|
||||
else
|
||||
AuthenticationController._recordFailedLogin()
|
||||
|
|
|
@ -8,6 +8,7 @@ logger = require("logger-sharelatex")
|
|||
crypto = require("crypto")
|
||||
EmailHandler = require("../Email/EmailHandler")
|
||||
OneTimeTokenHandler = require "../Security/OneTimeTokenHandler"
|
||||
Analytics = require "../Analytics/AnalyticsManager"
|
||||
settings = require "settings-sharelatex"
|
||||
|
||||
module.exports = UserRegistrationHandler =
|
||||
|
@ -62,6 +63,7 @@ module.exports = UserRegistrationHandler =
|
|||
cb() #this can be slow, just fire it off
|
||||
], (err)->
|
||||
logger.log user: user, "registered"
|
||||
Analytics.recordEvent user._id, "user-registered"
|
||||
callback(err, user)
|
||||
|
||||
registerNewUserAndSendActivationEmail: (email, callback = (error, user, setNewPasswordUrl) ->) ->
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue