MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / maybePromptRenderFeedback

Function maybePromptRenderFeedback

packages/cli/src/telemetry/feedback.ts:26–86  ·  view source on GitHub ↗
(opts: {
  renderDurationMs: number;
  quiet: boolean;
})

Source from the content-addressed store, hash-verified

24 */
25// fallow-ignore-next-line complexity
26export async function maybePromptRenderFeedback(opts: {
27 renderDurationMs: number;
28 quiet: boolean;
29}): Promise<void> {
30 if (promptedThisSession) return;
31 if (opts.quiet) return;
32 if (!shouldTrack()) return;
33 if (process.env.CI) return;
34
35 const config = readConfig();
36 config.renderSuccessCount = (config.renderSuccessCount ?? 0) + 1;
37
38 const lastAt = config.lastFeedbackPromptAt ?? 0;
39 const isFirstEverRender = lastAt === 0;
40 const sinceLastPrompt = config.renderSuccessCount - lastAt;
41 if (!isFirstEverRender && sinceLastPrompt < getFeedbackInterval()) {
42 writeConfig(config);
43 return;
44 }
45
46 if (detectAgentRuntime()) {
47 promptedThisSession = true;
48 config.lastFeedbackPromptAt = config.renderSuccessCount;
49 writeConfig(config);
50 console.log(
51 c.dim(" [hyperframes] ") +
52 c.dim("Agent feedback: ") +
53 c.accent('hyperframes feedback --rating <1-5> --comment "..."'),
54 );
55 return;
56 }
57
58 if (!process.stdin.isTTY) {
59 writeConfig(config);
60 return;
61 }
62
63 // Time to ask
64 promptedThisSession = true;
65 config.lastFeedbackPromptAt = config.renderSuccessCount;
66 writeConfig(config);
67
68 const answer = await askQuestion(
69 ` ${c.dim("How was this render?")} ${c.accent("[1=poor 5=great, enter to skip]")} `,
70 );
71
72 const rating = parseInt(answer.trim(), 10);
73 if (rating >= 1 && rating <= 5) {
74 // Ask for optional text feedback
75 const details = await askQuestion(` ${c.dim("Any details?")} ${c.accent("(enter to skip)")} `);
76 const trimmedDetails = details.trim();
77
78 trackRenderFeedback({
79 rating,
80 renderDurationMs: opts.renderDurationMs,
81 comment: trimmedDetails || undefined,
82 doctorSummary: await getDoctorSummary(),
83 });

Callers 1

renderLocalFunction · 0.85

Calls 8

readConfigFunction · 0.85
writeConfigFunction · 0.85
detectAgentRuntimeFunction · 0.85
askQuestionFunction · 0.85
trackRenderFeedbackFunction · 0.85
getDoctorSummaryFunction · 0.85
shouldTrackFunction · 0.70
getFeedbackIntervalFunction · 0.70

Tested by

no test coverage detected