diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index 49876778a0..50c48cb48c 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -553,17 +553,18 @@ const _ProjectController = { const ownerFeatures = await UserGetter.promises.getUserFeatures( project.owner_ref ) + const planLimit = ownerFeatures?.collaborators || 0 + const namedEditors = project.collaberator_refs?.length || 0 + const exceedAtLimit = planLimit > -1 && namedEditors >= planLimit const projectOpenedSegmentation = { projectId: project._id, // temporary link sharing segmentation: linkSharingWarning: linkSharingChanges?.variant, - namedEditors: project.collaberator_refs?.length || 0, + namedEditors, tokenEditors: project.tokenAccessReadAndWrite_refs?.length || 0, - planLimit: ownerFeatures?.collaborators || 0, + planLimit, + exceedAtLimit, } - projectOpenedSegmentation.exceedAtLimit = - projectOpenedSegmentation.namedEditors >= - projectOpenedSegmentation.planLimit AnalyticsManager.recordEventForUserInBackground( userId, 'project-opened', diff --git a/services/web/app/src/Features/TokenAccess/TokenAccessController.js b/services/web/app/src/Features/TokenAccess/TokenAccessController.js index f9914b6c2a..a78d13beb3 100644 --- a/services/web/app/src/Features/TokenAccess/TokenAccessController.js +++ b/services/web/app/src/Features/TokenAccess/TokenAccessController.js @@ -18,6 +18,7 @@ const EditorRealTimeController = require('../Editor/EditorRealTimeController') const CollaboratorsGetter = require('../Collaborators/CollaboratorsGetter') const ProjectGetter = require('../Project/ProjectGetter') const AsyncFormHelper = require('../Helpers/AsyncFormHelper') +const AnalyticsManager = require('../Analytics/AnalyticsManager') const orderedPrivilegeLevels = [ PrivilegeLevels.NONE, @@ -476,6 +477,10 @@ async function ensureUserCanUseSharingUpdatesConsentPage(req, res, next) { async function sharingUpdatesConsent(req, res, next) { const { Project_id: projectId } = req.params + AnalyticsManager.recordEventForSession(req.session, 'notification-prompt', { + page: req.path, + name: 'link-sharing-collaborator', + }) res.render('project/token/sharing-updates', { projectId, }) diff --git a/services/web/test/unit/src/TokenAccess/TokenAccessControllerTests.js b/services/web/test/unit/src/TokenAccess/TokenAccessControllerTests.js index e23c9085c5..12cd17477a 100644 --- a/services/web/test/unit/src/TokenAccess/TokenAccessControllerTests.js +++ b/services/web/test/unit/src/TokenAccess/TokenAccessControllerTests.js @@ -100,6 +100,10 @@ describe('TokenAccessController', function () { }, } + this.AnalyticsManager = { + recordEventForSession: sinon.stub(), + } + this.TokenAccessController = SandboxedModule.require(MODULE_PATH, { requires: { '@overleaf/settings': this.Settings, @@ -120,6 +124,7 @@ describe('TokenAccessController', function () { '../Helpers/AsyncFormHelper': (this.AsyncFormHelper = { redirect: sinon.stub(), }), + '../Analytics/AnalyticsManager': this.AnalyticsManager, }, }) })