Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(billing): add optional cancellation comment to the Billing V2 cancel reason event (#8634)

Andrew Huangbbf69b88285f
diff --git a/ANALYTICS.md b/ANALYTICS.md
index ea3e3fd650..ada0ba981d 100644
--- a/ANALYTICS.md
+++ b/ANALYTICS.md
@@ -106,6 +106,15 @@ errors, arbitrary URLs, or unbounded user-entered content. Define lifecycle
terms such as viewed, clicked, created, succeeded, failed, and canceled so they
cannot overlap accidentally.
+The one exception is the optional `comment` on
+`Billing Cancellation Reason Submitted`. It is free text that a user writes
+when they cancel, and it exists for churn analysis. It is capped at 500
+characters, trimmed, and omitted when empty. Never use it as a breakdown, and
+never put secrets, credentials, tokens, secret values, or other sensitive data
+in it from code. The field shows a hint that tells users not to enter secrets or
+credentials. Do not add free text to any other event without its own documented
+exception here.
+
Every paywall has a required, lowercase dot-separated `paywallKey` owned by
its call site. Keep the key stable when copy or plan names change; use modal
text only as display context. Record the matched route ID, not a concrete URL
diff --git a/frontend/src/lib/analytics/events.ts b/frontend/src/lib/analytics/events.ts
index 2ca0a828db..f7434549ec 100644
--- a/frontend/src/lib/analytics/events.ts
+++ b/frontend/src/lib/analytics/events.ts
@@ -183,6 +183,7 @@ type BillingCancellationReasonSubmittedProperties = {
action: BillingCancellationAction;
productId: string;
reason: string;
+ comment?: string;
};
export type OrganizationAnalyticsEventMap = {
diff --git a/frontend/src/pages/organization/BillingV2Page/components/CancellationFeedbackDialog.tsx b/frontend/src/pages/organization/BillingV2Page/components/CancellationFeedbackDialog.tsx
index 8ed6ab78e0..68c32a867b 100644
--- a/frontend/src/pages/organization/BillingV2Page/components/CancellationFeedbackDialog.tsx
+++ b/frontend/src/pages/organization/BillingV2Page/components/CancellationFeedbackDialog.tsx
@@ -14,11 +14,14 @@ import {
AlertDialogTitle,
Button,
Field,
+ FieldContent,
+ FieldDescription,
FieldError,
FieldLabel,
Label,
RadioGroup,
- RadioGroupItem
+ RadioGroupItem,
+ TextArea
} from "@app/components/v3";
import { analytics, AnalyticsEvent, type BillingCancellationAction } from "@app/lib/analytics";
@@ -35,6 +38,8 @@ const CANCELLATION_REASONS = [
{ value: "other", label: "Other" }
] as const;
+const COMMENT_MAX_LENGTH = 500;
+
type CancellationReason = (typeof CANCELLATION_REASONS)[number]["value"];
const formSchema = z.object({
@@ -44,7 +49,11 @@ const formSchema = z.object({
...CancellationReason[]
],
{ message: "Select a reason to continue." }
- )
+ ),
+ comment: z
+ .string()
+ .trim()
+ .max(COMMENT_MAX_LENGTH, `Keep your comment under ${COMMENT_MAX_LENGTH} characters.`)
});
type FormData = z.infer<typeof formSchema>;
@@ -88,10 +97,11 @@ export const CancellationFeedbackDialog = ({
handleSubmit,
formState: { isSubmitting }
} = useForm<FormData>({
- resolver: zodResolver(formSchema)
+ resolver: zodResolver(formSchema),
+ defaultValues: { comment: "" }
});
- const onSubmit = async ({ reason }: FormData) => {
+ const onSubmit = async ({ reason, comment }: FormData) => {
try {
await onConfirm();
} catch {
@@ -101,7 +111,8 @@ export const CancellationFeedbackDialog = ({
analytics.captureForOrganization(AnalyticsEvent.BillingCancellationReasonSubmitted, orgId, {
action,
productId,
- reason
+ reason,
+ ...(comment && { comment })
});
onConfirmed();
};
@@ -156,6 +167,36 @@ export const CancellationFeedbackDialog = ({
</Field>
)}
/>
+ <Controller
+ control={control}
+ name="comment"
+ render={({ field, fieldState }) => (
+ <Field>
+ <FieldLabel htmlFor="cancellation-comment">Comment (optional)</FieldLabel>
+ <FieldContent>
+ <TextArea
+ {...field}
+ id="cancellation-comment"
+ aria-describedby="cancellation-comment-hint"
+ rows={3}
+ maxLength={COMMENT_MAX_LENGTH}
+ disabled={isSubmitting}
+ placeholder="Tell us what would have made you stay"
+ isError={Boolean(fieldState.error)}
+ />
+ <FieldDescription className="flex justify-between gap-4">
+ <span id="cancellation-comment-hint">
+ Don&apos;t include secrets, credentials, or personal data.
+ </span>
+ <span className="tabular-nums">
+ {field.value.length}/{COMMENT_MAX_LENGTH}
+ </span>
+ </FieldDescription>
+ <FieldError>{fieldState.error?.message}</FieldError>
+ </FieldContent>
+ </Field>
+ )}
+ />
<AlertDialogFooter>
<AlertDialogCancel isDisabled={isSubmitting}>{dismissLabel}</AlertDialogCancel>
<Button