@@ -12,7 +12,10 @@ export const FEEDBACK_MAX_CHARS = 2000;
1212export const FEEDBACK_PROMPT =
1313 "Please share your feedback. When done please hit enter. (Empty Enter cancels.)" ;
1414
15- export const FEEDBACK_THANKS = "Thanks — feedback sent." ;
15+ export const FEEDBACK_THANKS = "Thanks — feedback queued." ;
16+
17+ export const FEEDBACK_THANKS_TRUNCATED =
18+ "Thanks — feedback queued (truncated to 2000 characters)." ;
1619
1720export const FEEDBACK_EMPTY = "No feedback text provided." ;
1821
@@ -37,6 +40,11 @@ export function feedbackQuestionId(env: NodeJS.ProcessEnv = process.env): string
3740 return env . CORBITS_FEEDBACK_QUESTION_ID ?. trim ( ) ?? "" ;
3841}
3942
43+ /** True when both survey env ids are present (command is useful to show). */
44+ export function isFeedbackConfigured ( env : NodeJS . ProcessEnv = process . env ) : boolean {
45+ return feedbackSurveyId ( env ) . length > 0 && feedbackQuestionId ( env ) . length > 0 ;
46+ }
47+
4048export function capFeedbackMessage ( message : string ) : string {
4149 if ( message . length <= FEEDBACK_MAX_CHARS ) return message ;
4250 return message . slice ( 0 , FEEDBACK_MAX_CHARS ) ;
@@ -74,6 +82,8 @@ export function buildSurveyProperties(
7482/**
7583 * Capture intentional survey response. Returns whether the event was queued.
7684 * Empty/whitespace-only text is not sent. Missing survey/question ids fail closed.
85+ * "sent" means queued for flush (not a network delivery ack); "sent_truncated"
86+ * is the same after the free-text cap was applied.
7787 */
7888export function captureFeedback (
7989 telemetry : Telemetry ,
@@ -82,26 +92,30 @@ export function captureFeedback(
8292 turnTraceId ?: string | undefined ;
8393 env ?: NodeJS . ProcessEnv ;
8494 } = { } ,
85- ) : "empty" | "blocked" | "unconfigured" | "sent" {
95+ ) : "empty" | "blocked" | "unconfigured" | "sent" | "sent_truncated" {
8696 const trimmed = message . trim ( ) ;
8797 if ( trimmed . length === 0 ) return "empty" ;
8898 const env = options . env ?? process . env ;
89- if ( feedbackSurveyId ( env ) . length === 0 || feedbackQuestionId ( env ) . length === 0 ) {
99+ if ( ! isFeedbackConfigured ( env ) ) {
90100 return "unconfigured" ;
91101 }
102+ const truncated = trimmed . length > FEEDBACK_MAX_CHARS ;
92103 const ok = telemetry . captureIntentional (
93104 "survey sent" ,
94105 buildSurveyProperties ( trimmed , options ) ,
95106 ) ;
96- return ok ? "sent" : "blocked" ;
107+ if ( ! ok ) return "blocked" ;
108+ return truncated ? "sent_truncated" : "sent" ;
97109}
98110
99111export function feedbackResultMessage (
100- status : "empty" | "blocked" | "unconfigured" | "sent" ,
112+ status : "empty" | "blocked" | "unconfigured" | "sent" | "sent_truncated" ,
101113) : string {
102114 switch ( status ) {
103115 case "sent" :
104116 return FEEDBACK_THANKS ;
117+ case "sent_truncated" :
118+ return FEEDBACK_THANKS_TRUNCATED ;
105119 case "blocked" :
106120 return FEEDBACK_BLOCKED ;
107121 case "unconfigured" :
0 commit comments