mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #14380 from overleaf/jdt-history-onboarding-saves
save onboarding completion on user GitOrigin-RevId: bcb4d9d1909aa11e5cfcf283e04fe1057460bf7b
This commit is contained in:
parent
3d9e9f6aeb
commit
3bb7a7c7ba
5 changed files with 44 additions and 1 deletions
|
@ -437,7 +437,7 @@ const ProjectController = {
|
|||
)
|
||||
User.findById(
|
||||
userId,
|
||||
'email first_name last_name referal_id signUpDate featureSwitches features featuresEpoch refProviders alphaProgram betaProgram isAdmin ace labsProgram',
|
||||
'email first_name last_name referal_id signUpDate featureSwitches features featuresEpoch refProviders alphaProgram betaProgram isAdmin ace labsProgram completedTutorials',
|
||||
(err, user) => {
|
||||
// Handle case of deleted user
|
||||
if (user == null) {
|
||||
|
@ -877,6 +877,7 @@ const ProjectController = {
|
|||
alphaProgram: user.alphaProgram,
|
||||
betaProgram: user.betaProgram,
|
||||
labsProgram: user.labsProgram,
|
||||
completedTutorials: user.completedTutorials,
|
||||
isAdmin: hasAdminAccess(user),
|
||||
},
|
||||
userSettings: {
|
||||
|
|
21
services/web/app/src/Features/Tutorial/TutorialController.js
Normal file
21
services/web/app/src/Features/Tutorial/TutorialController.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
const SessionManager = require('../Authentication/SessionManager')
|
||||
const TutorialHandler = require('./TutorialHandler')
|
||||
const { expressify } = require('../../util/promises')
|
||||
|
||||
const VALID_KEYS = ['react-history-buttons-tutorial']
|
||||
|
||||
async function completeTutorial(req, res, next) {
|
||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||
const tutorialKey = req.params.tutorialKey
|
||||
|
||||
if (!VALID_KEYS.includes(tutorialKey)) {
|
||||
return res.sendStatus(400)
|
||||
}
|
||||
|
||||
await TutorialHandler.saveCompletion(userId, tutorialKey)
|
||||
res.sendStatus(204)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
completeTutorial: expressify(completeTutorial),
|
||||
}
|
13
services/web/app/src/Features/Tutorial/TutorialHandler.js
Normal file
13
services/web/app/src/Features/Tutorial/TutorialHandler.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
const UserUpdater = require('../User/UserUpdater')
|
||||
|
||||
async function saveCompletion(userId, tutorialKey) {
|
||||
const completionDate = new Date()
|
||||
|
||||
await UserUpdater.promises.updateUser(userId, {
|
||||
$set: {
|
||||
[`completedTutorials.${tutorialKey}`]: completionDate,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { saveCompletion }
|
|
@ -187,6 +187,7 @@ const UserSchema = new Schema(
|
|||
splitTests: Schema.Types.Mixed,
|
||||
analyticsId: { type: String },
|
||||
surveyResponses: Schema.Types.Mixed,
|
||||
completedTutorials: Schema.Types.Mixed,
|
||||
},
|
||||
{ minimize: false }
|
||||
)
|
||||
|
|
|
@ -21,6 +21,7 @@ const UserInfoController = require('./Features/User/UserInfoController')
|
|||
const UserController = require('./Features/User/UserController')
|
||||
const UserEmailsController = require('./Features/User/UserEmailsController')
|
||||
const UserPagesController = require('./Features/User/UserPagesController')
|
||||
const TutorialController = require('./Features/Tutorial/TutorialController')
|
||||
const DocumentController = require('./Features/Documents/DocumentController')
|
||||
const CompileManager = require('./Features/Compile/CompileManager')
|
||||
const CompileController = require('./Features/Compile/CompileController')
|
||||
|
@ -427,6 +428,12 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
|||
TpdsController.getQueues
|
||||
)
|
||||
|
||||
webRouter.post(
|
||||
'/tutorial/:tutorialKey/complete',
|
||||
AuthenticationController.requireLogin(),
|
||||
TutorialController.completeTutorial
|
||||
)
|
||||
|
||||
webRouter.get(
|
||||
'/user/projects',
|
||||
AuthenticationController.requireLogin(),
|
||||
|
|
Loading…
Reference in a new issue