diff --git a/services/web/app/src/Features/User/UserEmailsController.js b/services/web/app/src/Features/User/UserEmailsController.js index a53e5c07cd..297e0f86ca 100644 --- a/services/web/app/src/Features/User/UserEmailsController.js +++ b/services/web/app/src/Features/User/UserEmailsController.js @@ -295,7 +295,29 @@ const UserEmailsController = { 'failed to add audit log entry' ) } - res.sendStatus(200) + UserGetter.getUser( + userData.userId, + { email: 1 }, + function (error, user) { + if (error) { + logger.error( + { error, userId: userData.userId }, + 'failed to get user' + ) + } + const isPrimary = user?.email === userData.email + AnalyticsManager.recordEventForUser( + userData.userId, + 'email-verified', + { + provider: 'email', + verification_type: 'link', + isPrimary, + } + ) + res.sendStatus(200) + } + ) } ) } diff --git a/services/web/test/unit/src/User/UserEmailsControllerTests.js b/services/web/test/unit/src/User/UserEmailsControllerTests.js index bce081cd85..b16f91498a 100644 --- a/services/web/test/unit/src/User/UserEmailsControllerTests.js +++ b/services/web/test/unit/src/User/UserEmailsControllerTests.js @@ -21,6 +21,7 @@ describe('UserEmailsController', function () { } this.UserGetter = { + getUser: sinon.stub().yields(), getUserFullEmails: sinon.stub(), getUserByAnyEmail: sinon.stub(), promises: {