Skip to content

Commit cdefc4c

Browse files
authored
Merge pull request #42 from topcoder-platform/feat/override-onboarding-checklist
feat/override onboarding checklist
2 parents 161b85b + d1dfc9a commit cdefc4c

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

config/default.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,8 @@ module.exports = {
4646
MEMBERS_API_URL: process.env.MEMBERS_API_URL || 'https://api.topcoder-dev.com/v5/members',
4747

4848
// List of registration sources that can skip the onboarding wizard
49-
SKIP_ONBOARDING_REG_SOURCES: process.env.SKIP_ONBOARDING_REG_SOURCES || ['taasApp', 'gigs', 'selfService', 'challenges']
49+
SKIP_ONBOARDING_REG_SOURCES: process.env.SKIP_ONBOARDING_REG_SOURCES || ['taasApp', 'gigs', 'selfService'],
50+
// List of registration sources that should carry over original registration url (retUrl); users registering
51+
// through these sources will be taken to retUrl at the end of the onboarding process
52+
FORWARD_TO_RET_URL_REG_SOURCES: process.env.FORWARD_TO_RET_URL_REG_SOURCES || ['challenges']
5053
}

src/common/helper.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,16 @@ async function getOnboardingChecklist (handle, token) {
136136
}
137137

138138
/**
139-
* update trait onboarding_checklist to indicate to consumers that showing the user
140-
* identified by handle is not required
139+
* update trait onboarding_checklist to indicate to consumers if onboarding wizard
140+
* can be skipped or if onboarding wizard should take the user to the original url
141+
* the user signed up from
141142
*
142143
* @param {string} handle the handle of the member
143-
* @param {string} message the skip reason
144+
* @param {string} type skip to skip the onboarding wizard; forward to use retUrl
145+
* @param {string} message the skip/carry forward reason
144146
* @returns {promise}
145147
*/
146-
async function addSkipOnboardingInOnboardingChecklist (handle, message) {
148+
async function addOverrideOnboardingChecklist (handle, type, message) {
147149
const token = await getM2MToken()
148150

149151
const existingOnboardingCheckilst = await getOnboardingChecklist(handle, token)
@@ -152,10 +154,10 @@ async function addSkipOnboardingInOnboardingChecklist (handle, message) {
152154
const onboardingWizardIndex = _.findIndex(existingOnboardingCheckilst, data => data['onboarding_wizard'] != null)
153155
const onboardingWizardData = {
154156
onboarding_wizard: {
155-
skip: true,
157+
override: type,
156158
date: new Date().getTime(),
157159
metadata: {
158-
skipReason: message
160+
overrideReason: message
159161
},
160162
status: 'pending_at_user'
161163
}
@@ -208,5 +210,5 @@ module.exports = {
208210
createTable,
209211
deleteTable,
210212
updateRecord,
211-
addSkipOnboardingInOnboardingChecklist
213+
addOverrideOnboardingChecklist
212214
}

src/services/ProcessorService.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ async function processCreateUser (message, producer) {
133133
logger.info(`Registration source for member with handle ${message.payload.handle} is ${regSource}.`)
134134
if (_.find(config.SKIP_ONBOARDING_REG_SOURCES, source => source === regSource) != null) {
135135
logger.info(`Registration source is part of sources that can skip onboarding.`)
136-
helper.addSkipOnboardingInOnboardingChecklist(message.payload.handle, `Registration source[${regSource}] doesn't require onboarding.`)
137-
} else {
136+
helper.addOverrideOnboardingChecklist(message.payload.handle, 'skip', `Registration source[${regSource}] doesn't require onboarding.`)
137+
} else if (_.find(config.FORWARD_TO_RET_URL_REG_SOURCES, source => source === regSource) != null) {
138+
logger.info(`Registration source is part of sources that require taking user to original registration url (retUrl).`)
139+
helper.addOverrideOnboardingChecklist(message.payload.handle, 'useRetUrl', `Registration source[${regSource}] requires taking user to original registration url at the end of onboarding flow.`)
140+
}
141+
else {
138142
logger.info(`Registration source requires member to be presented with the onboarding wizard.`)
139143
}
140144
}

0 commit comments

Comments
 (0)