Skip to content

Commit 182f060

Browse files
adam.wilsoncursoragent
andcommitted
feat(web): add posthog event for chat preferences saved
Registers `wa_chat_preferences_saved` in `PosthogEventMap` and fires it on a successful save from the Chat Preferences page. The `wa_` prefix is correct here: the event can only originate from the web app. Properties capture adoption signals without leaking the actual preference content: - `dimensionsSet`: count of dimensions the user has chosen (0-6) - `hasCustomInstructions`: boolean flag for free-text usage - `customInstructionsLength`: length of the trimmed custom instructions so we can later distinguish drive-by notes from heavy use No preference values, level names, or instruction text are sent. Refs #1242 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1a7c835 commit 182f060

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

packages/web/src/app/(app)/settings/chatPreferences/chatPreferencesPage.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import { useToast } from "@/components/hooks/use-toast";
4+
import useCaptureEvent from "@/hooks/useCaptureEvent";
45
import { LoadingButton } from "@/components/ui/loading-button";
56
import { Textarea } from "@/components/ui/textarea";
67
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
@@ -25,6 +26,7 @@ export function ChatPreferencesPage({
2526
initialCustomInstructions,
2627
}: ChatPreferencesPageProps) {
2728
const { toast } = useToast();
29+
const captureEvent = useCaptureEvent();
2830

2931
const [preferences, setPreferences] = useState<ChatPreferences>(initialPreferences);
3032
const [customInstructions, setCustomInstructions] = useState<string>(initialCustomInstructions ?? "");
@@ -102,6 +104,11 @@ export function ChatPreferencesPage({
102104
preferences,
103105
customInstructions,
104106
});
107+
captureEvent("wa_chat_preferences_saved", {
108+
dimensionsSet: Object.keys(preferences).length,
109+
hasCustomInstructions: trimmedCustom.length > 0,
110+
customInstructionsLength: trimmedCustom.length,
111+
});
105112
toast({
106113
title: "Chat preferences saved",
107114
description: "Sourcebot will apply these to future chats.",
@@ -115,7 +122,7 @@ export function ChatPreferencesPage({
115122
} finally {
116123
setIsSaving(false);
117124
}
118-
}, [preferences, customInstructions, isOverLimit, toast]);
125+
}, [preferences, customInstructions, isOverLimit, toast, captureEvent]);
119126

120127
return (
121128
<div className="flex flex-col gap-8">

packages/web/src/lib/posthogEvents.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ export type PosthogEventMap = {
185185
chatId: string,
186186
currentVisibility: 'PUBLIC' | 'PRIVATE',
187187
},
188+
wa_chat_preferences_saved: {
189+
/** Number of preference dimensions the user has set (0-6). */
190+
dimensionsSet: number,
191+
/** True if the user supplied any non-empty custom instructions. */
192+
hasCustomInstructions: boolean,
193+
/** Length of the custom instructions string, for adoption sizing. */
194+
customInstructionsLength: number,
195+
},
188196
wa_chat_visibility_changed: {
189197
chatId: string,
190198
fromVisibility: 'PUBLIC' | 'PRIVATE',

0 commit comments

Comments
 (0)