Merge pull request #19814 from overleaf/tm-link-sharing-project-joined-event-for-treatment

Add project-joined event when adding as Editor via link sharing

GitOrigin-RevId: 40f538376b90a45877859be9e48a0b4c45c9641d
This commit is contained in:
Thomas 2024-08-06 16:56:20 +02:00 committed by Copybot
parent d2464abc7c
commit 2ee528a9d2
2 changed files with 18 additions and 0 deletions

View file

@ -340,6 +340,14 @@ async function grantTokenAccessReadAndWrite(req, res, next) {
req.ip,
{ privileges: 'readAndWrite' }
)
AnalyticsManager.recordEventForUserInBackground(
userId,
'project-joined',
{
mode: 'read-write',
projectId: project._id.toString(),
}
)
// Currently does not enforce the collaborator limit (warning phase)
await CollaboratorsHandler.promises.addUserIdToProject(
project._id,

View file

@ -108,6 +108,7 @@ describe('TokenAccessController', function () {
this.AnalyticsManager = {
recordEventForSession: sinon.stub(),
recordEventForUserInBackground: sinon.stub(),
}
this.UserGetter = {
@ -252,6 +253,15 @@ describe('TokenAccessController', function () {
)
})
it('records a project-joined event for the user', function () {
expect(
this.AnalyticsManager.recordEventForUserInBackground
).to.have.been.calledWith(this.user._id, 'project-joined', {
mode: 'read-write',
projectId: this.project._id.toString(),
})
})
it('emits a project membership changed event', function () {
expect(
this.EditorRealTimeController.emitToRoom