mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
add segmentation to user-registered
event (#6711)
* add segmentation to `user-registered` event GitOrigin-RevId: 9ba40c0a81aea488439758b992caeb7855c27f67
This commit is contained in:
parent
a3b01659a4
commit
1fb8f15005
2 changed files with 31 additions and 1 deletions
|
@ -7,6 +7,7 @@ const UserDeleter = require('./UserDeleter')
|
|||
const UserGetter = require('./UserGetter')
|
||||
const UserUpdater = require('./UserUpdater')
|
||||
const Analytics = require('../Analytics/AnalyticsManager')
|
||||
const SplitTestHandler = require('../SplitTests/SplitTestHandler')
|
||||
const UserOnboardingEmailManager = require('./UserOnboardingEmailManager')
|
||||
const UserPostRegistrationAnalyticsManager = require('./UserPostRegistrationAnalyticsManager')
|
||||
const OError = require('@overleaf/o-error')
|
||||
|
@ -35,6 +36,30 @@ async function _addAffiliation(user, affiliationOptions) {
|
|||
return user
|
||||
}
|
||||
|
||||
async function recordRegistrationEvent(user) {
|
||||
SplitTestHandler.promises
|
||||
.getAssignmentForUser(user._id, 'highlight-sso')
|
||||
.then(assignment => {
|
||||
const segmentation = {
|
||||
highlightSSO: assignment.variant === 'active',
|
||||
}
|
||||
if (user.thirdPartyIdentifiers && user.thirdPartyIdentifiers.length > 0) {
|
||||
segmentation.provider = user.thirdPartyIdentifiers[0].providerId
|
||||
}
|
||||
return Analytics.recordEventForUser(
|
||||
user._id,
|
||||
'user-registered',
|
||||
segmentation
|
||||
)
|
||||
})
|
||||
.catch(err =>
|
||||
logger.warn(
|
||||
{ err },
|
||||
'there was an error recording `user-registered` event'
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
async function createNewUser(attributes, options = {}) {
|
||||
let user = new User()
|
||||
|
||||
|
@ -84,7 +109,7 @@ async function createNewUser(attributes, options = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
await Analytics.recordEventForUser(user._id, 'user-registered')
|
||||
await recordRegistrationEvent(user)
|
||||
await Analytics.setUserPropertyForUser(user._id, 'created-at', new Date())
|
||||
await Analytics.setUserPropertyForUser(user._id, 'user-id', user._id)
|
||||
if (attributes.analyticsId) {
|
||||
|
|
|
@ -45,6 +45,11 @@ describe('UserCreator', function () {
|
|||
recordEventForUser: sinon.stub(),
|
||||
setUserPropertyForUser: sinon.stub(),
|
||||
}),
|
||||
'../SplitTests/SplitTestHandler': (this.SplitTestHandler = {
|
||||
promises: {
|
||||
getAssignmentForUser: sinon.stub().resolves({ variant: 'active' }),
|
||||
},
|
||||
}),
|
||||
'./UserOnboardingEmailManager': (this.UserOnboardingEmailManager = {
|
||||
scheduleOnboardingEmail: sinon.stub(),
|
||||
}),
|
||||
|
|
Loading…
Reference in a new issue