mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #19348 from overleaf/tm-link-sharing-changes-events-fixes
Link sharing changes events fixes for collaborator sharing-updates prompt and project open event GitOrigin-RevId: 45449f0dd27e07de189a9c2620b0aa9a8849dc41
This commit is contained in:
parent
5871dafc02
commit
ab4a4df931
3 changed files with 16 additions and 5 deletions
|
@ -553,17 +553,18 @@ const _ProjectController = {
|
||||||
const ownerFeatures = await UserGetter.promises.getUserFeatures(
|
const ownerFeatures = await UserGetter.promises.getUserFeatures(
|
||||||
project.owner_ref
|
project.owner_ref
|
||||||
)
|
)
|
||||||
|
const planLimit = ownerFeatures?.collaborators || 0
|
||||||
|
const namedEditors = project.collaberator_refs?.length || 0
|
||||||
|
const exceedAtLimit = planLimit > -1 && namedEditors >= planLimit
|
||||||
const projectOpenedSegmentation = {
|
const projectOpenedSegmentation = {
|
||||||
projectId: project._id,
|
projectId: project._id,
|
||||||
// temporary link sharing segmentation:
|
// temporary link sharing segmentation:
|
||||||
linkSharingWarning: linkSharingChanges?.variant,
|
linkSharingWarning: linkSharingChanges?.variant,
|
||||||
namedEditors: project.collaberator_refs?.length || 0,
|
namedEditors,
|
||||||
tokenEditors: project.tokenAccessReadAndWrite_refs?.length || 0,
|
tokenEditors: project.tokenAccessReadAndWrite_refs?.length || 0,
|
||||||
planLimit: ownerFeatures?.collaborators || 0,
|
planLimit,
|
||||||
|
exceedAtLimit,
|
||||||
}
|
}
|
||||||
projectOpenedSegmentation.exceedAtLimit =
|
|
||||||
projectOpenedSegmentation.namedEditors >=
|
|
||||||
projectOpenedSegmentation.planLimit
|
|
||||||
AnalyticsManager.recordEventForUserInBackground(
|
AnalyticsManager.recordEventForUserInBackground(
|
||||||
userId,
|
userId,
|
||||||
'project-opened',
|
'project-opened',
|
||||||
|
|
|
@ -18,6 +18,7 @@ const EditorRealTimeController = require('../Editor/EditorRealTimeController')
|
||||||
const CollaboratorsGetter = require('../Collaborators/CollaboratorsGetter')
|
const CollaboratorsGetter = require('../Collaborators/CollaboratorsGetter')
|
||||||
const ProjectGetter = require('../Project/ProjectGetter')
|
const ProjectGetter = require('../Project/ProjectGetter')
|
||||||
const AsyncFormHelper = require('../Helpers/AsyncFormHelper')
|
const AsyncFormHelper = require('../Helpers/AsyncFormHelper')
|
||||||
|
const AnalyticsManager = require('../Analytics/AnalyticsManager')
|
||||||
|
|
||||||
const orderedPrivilegeLevels = [
|
const orderedPrivilegeLevels = [
|
||||||
PrivilegeLevels.NONE,
|
PrivilegeLevels.NONE,
|
||||||
|
@ -476,6 +477,10 @@ async function ensureUserCanUseSharingUpdatesConsentPage(req, res, next) {
|
||||||
|
|
||||||
async function sharingUpdatesConsent(req, res, next) {
|
async function sharingUpdatesConsent(req, res, next) {
|
||||||
const { Project_id: projectId } = req.params
|
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', {
|
res.render('project/token/sharing-updates', {
|
||||||
projectId,
|
projectId,
|
||||||
})
|
})
|
||||||
|
|
|
@ -100,6 +100,10 @@ describe('TokenAccessController', function () {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.AnalyticsManager = {
|
||||||
|
recordEventForSession: sinon.stub(),
|
||||||
|
}
|
||||||
|
|
||||||
this.TokenAccessController = SandboxedModule.require(MODULE_PATH, {
|
this.TokenAccessController = SandboxedModule.require(MODULE_PATH, {
|
||||||
requires: {
|
requires: {
|
||||||
'@overleaf/settings': this.Settings,
|
'@overleaf/settings': this.Settings,
|
||||||
|
@ -120,6 +124,7 @@ describe('TokenAccessController', function () {
|
||||||
'../Helpers/AsyncFormHelper': (this.AsyncFormHelper = {
|
'../Helpers/AsyncFormHelper': (this.AsyncFormHelper = {
|
||||||
redirect: sinon.stub(),
|
redirect: sinon.stub(),
|
||||||
}),
|
}),
|
||||||
|
'../Analytics/AnalyticsManager': this.AnalyticsManager,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue