MCPcopy
hub / github.com/prisma/prisma / handleNpsSurveyImpl

Function handleNpsSurveyImpl

packages/cli/src/utils/nps/survey.ts:92–129  ·  view source on GitHub ↗
(
  now: Date,
  statusLookup: NpsStatusLookup,
  rl: ReadlineInterface,
  eventCapture: EventCapture,
  commandState: CommandState,
)

Source from the content-addressed store, hash-verified

90}
91
92export async function handleNpsSurveyImpl(
93 now: Date,
94 statusLookup: NpsStatusLookup,
95 rl: ReadlineInterface,
96 eventCapture: EventCapture,
97 commandState: CommandState,
98) {
99 if (
100 isCi() ||
101 maybeInGitHook() ||
102 isInNpmLifecycleHook() ||
103 isInContainer() ||
104 daysSinceFirstCommand(commandState) < 1
105 ) {
106 return
107 }
108
109 const config = await readConfig()
110 if (config && isWithinTimeframe(now, config.acknowledgedTimeframe)) {
111 // the user has already acknowledged an NPS survey covering the current date
112 return
113 }
114
115 const status = await statusLookup.status()
116 if (!status.currentTimeframe || !isWithinTimeframe(now, status.currentTimeframe)) {
117 // no NPS survey is currently active
118 return
119 }
120
121 const result = await collectFeedback(rl)
122
123 if (result.rating) {
124 await submitSurveyEvent({ rating: result.rating, ...result }, eventCapture)
125 rl.write('Thanks for your feedback!\n')
126 }
127
128 await writeConfig({ acknowledgedTimeframe: status.currentTimeframe })
129}
130
131async function collectFeedback(rl: ReadlineInterface): Promise<NpsSurveyResult> {
132 const question = rl.question(

Callers 2

nps.test.tsFile · 0.90
handleNpsSurveyFunction · 0.85

Calls 12

isCiFunction · 0.90
maybeInGitHookFunction · 0.90
isInNpmLifecycleHookFunction · 0.90
isInContainerFunction · 0.90
daysSinceFirstCommandFunction · 0.90
readConfigFunction · 0.85
isWithinTimeframeFunction · 0.85
collectFeedbackFunction · 0.85
submitSurveyEventFunction · 0.85
writeConfigFunction · 0.85
statusMethod · 0.80
writeMethod · 0.65

Tested by

no test coverage detected