MCPcopy
hub / github.com/prisma/prisma / collectFeedback

Function collectFeedback

packages/cli/src/utils/nps/survey.ts:131–158  ·  view source on GitHub ↗
(rl: ReadlineInterface)

Source from the content-addressed store, hash-verified

129}
130
131async function collectFeedback(rl: ReadlineInterface): Promise<NpsSurveyResult> {
132 const question = rl.question(
133 'How likely are you to recommend Prisma?\n\n' +
134 'Enter a number from 0 to 10 (0 = not at all, 10 = extremely likely) and press Enter — ' +
135 'or leave blank to skip and not be asked again.\n\n' +
136 `This prompt closes in ${promptTimeoutSecs}s and can be suppressed with --no-hints. ` +
137 'Learn more: https://pris.ly/why-nps\n\n' +
138 'Rating: ',
139 )
140 const ratingAnswer = await timeout(question, promptTimeoutSecs * 1000)
141 if (ratingAnswer === undefined) {
142 rl.write(`No response received within ${promptTimeoutSecs} seconds. Exiting the survey.\n`)
143 return {}
144 }
145
146 const rating = parseInt(ratingAnswer.trim(), 10)
147 if (isNaN(rating) || rating < 0 || rating > 10) {
148 rl.write('Not received a valid rating. Exiting the survey.\n')
149 return {}
150 }
151
152 const feedbackAnswer = await rl.question(
153 'Optional: Provide additional feedback or press Enter to skip.\n' + 'Additional feedback: ',
154 )
155 const feedback = feedbackAnswer.trim() === '' ? undefined : feedbackAnswer
156
157 return { rating, feedback }
158}
159
160function getConfigPath(): string {
161 return path.join(paths('prisma').config, 'nps.json')

Callers 1

handleNpsSurveyImplFunction · 0.85

Calls 2

timeoutFunction · 0.85
writeMethod · 0.65

Tested by

no test coverage detected