[web] avoid UserAnalyticsIdCache (#33121)

* [web] always provide an analyticsId when registering new users

* [web] add recordEventForMongoUser and use it during login

* [web] use recordEventForMongoUser/recordEventForSession where possible

* [web] use session cache for analyticsId when refreshing features

* [web] add setUserPropertyForMongoUser and use it where possible

* [web] use setUserPropertyForSessionInBackground where possible

* [web] use mongo user for analyticsId when setting utm user properties

* [web] admin-panel: user updated user when sending events

* [web] enforce labsProgram being populated on user object

Co-authored-by: Andrew Rumble <andrew.rumble@overleaf.com>

* [web] revert FeaturesUpdater.refreshFeatures change

* [web] labs: move session maintenance into handler

* [web] analyticsMiddleware: ensure that all users have labsProgram field

* [web] migrate a few more events to recordEventForSession

* [migrations] mark back-fill of db.users.analyticsId as required

* [web] setUserPropertyForSessionInBackground: throw early

---------

Co-authored-by: Andrew Rumble <andrew.rumble@overleaf.com>
GitOrigin-RevId: 19c26bc36abd8c11f0a8f458d25abfb7cbda0bb7
This commit is contained in:
Jakob Ackermann
2026-06-17 08:08:32 +00:00
committed by Copybot
co-authored by Andrew Rumble
parent 7035a2e025
commit 6323fddbd8
37 changed files with 320 additions and 184 deletions
@@ -120,6 +120,7 @@ describe('ProjectUploadController', function () {
)
ctx.AnalyticsManager = {
recordEventForSession: sinon.stub(),
recordEventForUserInBackground: sinon.stub(),
}
vi.doMock(
@@ -545,8 +546,8 @@ describe('ProjectUploadController', function () {
it('should record a successful convert-format analytics event', function (ctx) {
sinon.assert.calledWith(
ctx.AnalyticsManager.recordEventForUserInBackground,
ctx.user_id,
ctx.AnalyticsManager.recordEventForSession,
ctx.req.session,
'convert-format',
{
sourceFormat: 'docx',
@@ -615,8 +616,8 @@ describe('ProjectUploadController', function () {
it('should record a successful convert-format analytics event', function (ctx) {
sinon.assert.calledWith(
ctx.AnalyticsManager.recordEventForUserInBackground,
ctx.user_id,
ctx.AnalyticsManager.recordEventForSession,
ctx.req.session,
'convert-format',
{
sourceFormat: 'markdown',
@@ -687,8 +688,8 @@ describe('ProjectUploadController', function () {
it('should record a failed convert-format analytics event', function (ctx) {
sinon.assert.calledWith(
ctx.AnalyticsManager.recordEventForUserInBackground,
ctx.user_id,
ctx.AnalyticsManager.recordEventForSession,
ctx.req.session,
'convert-format',
{
sourceFormat: 'docx',