Merge pull request #4639 from overleaf/ab-web-mono-analytics-id

Analytics ID support

GitOrigin-RevId: 820a6c0f4d19f046f6c791ce4dc64dbc80748924
This commit is contained in:
Alexandre Bourdin
2021-09-09 16:45:41 +02:00
committed by Copybot
parent 3af8fc63de
commit 44a8883b6d
36 changed files with 557 additions and 249 deletions

View File

@@ -12,7 +12,7 @@ describe('AnalyticsController', function () {
this.AnalyticsManager = {
updateEditingSession: sinon.stub(),
recordEvent: sinon.stub(),
recordEventForSession: sinon.stub(),
}
this.Features = {
@@ -42,6 +42,7 @@ describe('AnalyticsController', function () {
params: {
projectId: 'a project id',
},
session: {},
}
this.GeoIpLookup.getDetails = sinon
.stub()
@@ -78,35 +79,18 @@ describe('AnalyticsController', function () {
delete this.expectedData._csrf
})
it('should use the user_id', function (done) {
this.SessionManager.getLoggedInUserId.returns('1234')
it('should use the session', function (done) {
this.controller.recordEvent(this.req, this.res)
this.AnalyticsManager.recordEvent
.calledWith('1234', this.req.params.event, this.expectedData)
.should.equal(true)
done()
})
it('should use the session id', function (done) {
this.controller.recordEvent(this.req, this.res)
this.AnalyticsManager.recordEvent
.calledWith(
this.req.sessionID,
this.req.params.event,
this.expectedData
)
this.AnalyticsManager.recordEventForSession
.calledWith(this.req.session, this.req.params.event, this.expectedData)
.should.equal(true)
done()
})
it('should remove the CSRF token before sending to the manager', function (done) {
this.controller.recordEvent(this.req, this.res)
this.AnalyticsManager.recordEvent
.calledWith(
this.req.sessionID,
this.req.params.event,
this.expectedData
)
this.AnalyticsManager.recordEventForSession
.calledWith(this.req.session, this.req.params.event, this.expectedData)
.should.equal(true)
done()
})