mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #7829 from overleaf/ab-refresh-features-script-update
[web / script] Handle analytics and dropbox unlinking in refresh_features script GitOrigin-RevId: 9d0524aeab5dcf810e28c3de4f61ab7f3913f872
This commit is contained in:
parent
477c2a3ecd
commit
16f3dc3abc
2 changed files with 44 additions and 9 deletions
|
@ -96,12 +96,11 @@ async function computeFeatures(userId) {
|
|||
bonusFeatures,
|
||||
featuresOverrides,
|
||||
])
|
||||
const features = _.reduce(
|
||||
return _.reduce(
|
||||
featureSets,
|
||||
FeaturesHelper.mergeFeatures,
|
||||
Settings.defaultFeatures
|
||||
)
|
||||
return features
|
||||
}
|
||||
|
||||
async function _getIndividualFeatures(userId) {
|
||||
|
@ -131,12 +130,7 @@ async function _getFeaturesOverrides(user) {
|
|||
activeFeaturesOverrides.push(featuresOverride.features)
|
||||
}
|
||||
}
|
||||
const features = _.reduce(
|
||||
activeFeaturesOverrides,
|
||||
FeaturesHelper.mergeFeatures,
|
||||
{}
|
||||
)
|
||||
return features
|
||||
return _.reduce(activeFeaturesOverrides, FeaturesHelper.mergeFeatures, {})
|
||||
}
|
||||
|
||||
async function _getV1Features(user) {
|
||||
|
|
|
@ -5,6 +5,10 @@ const async = require('async')
|
|||
const FeaturesUpdater = require('../app/src/Features/Subscription/FeaturesUpdater')
|
||||
const FeaturesHelper = require('../app/src/Features/Subscription/FeaturesHelper')
|
||||
const UserFeaturesUpdater = require('../app/src/Features/Subscription/UserFeaturesUpdater')
|
||||
const AnalyticsManager = require('../app/src/Features/Analytics/AnalyticsManager')
|
||||
const DropboxHandler = require('../modules/dropbox/app/src/DropboxHandler')
|
||||
const { OError } = require('../app/src/Features/Errors/Errors')
|
||||
const logger = require('@overleaf/logger')
|
||||
|
||||
const ScriptLogger = {
|
||||
checkedUsersCount: 0,
|
||||
|
@ -76,7 +80,44 @@ const checkAndUpdateUser = (user, callback) =>
|
|||
return callback()
|
||||
}
|
||||
|
||||
UserFeaturesUpdater.overrideFeatures(user._id, freshFeatures, callback)
|
||||
const matchedFeatureSet = FeaturesHelper.getMatchedFeatureSet(freshFeatures)
|
||||
AnalyticsManager.setUserPropertyForUser(
|
||||
user._id,
|
||||
'feature-set',
|
||||
matchedFeatureSet
|
||||
)
|
||||
|
||||
UserFeaturesUpdater.overrideFeatures(
|
||||
user._id,
|
||||
freshFeatures,
|
||||
(error, featuresChanged) => {
|
||||
if (error) {
|
||||
return callback(error)
|
||||
}
|
||||
if (
|
||||
mismatchReasons.dropbox !== undefined &&
|
||||
freshFeatures.dropbox === false
|
||||
) {
|
||||
DropboxHandler.unlinkAccount(
|
||||
user._id,
|
||||
{ sendEmail: false },
|
||||
error => {
|
||||
if (error) {
|
||||
return callback(
|
||||
OError.tag(error, 'error unlinking dropbox', {
|
||||
userId: user._id,
|
||||
})
|
||||
)
|
||||
}
|
||||
logger.log({ userId: user._id }, 'Unlinked dropbox')
|
||||
callback(null, featuresChanged)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
callback(null, featuresChanged)
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
const checkAndUpdateUsers = (users, callback) =>
|
||||
|
|
Loading…
Reference in a new issue