Capture codegen accept/reject events in PostHog.

This commit is contained in:
Sam Rose 2025-04-14 16:24:09 +01:00
parent c3d4b6c7fc
commit 6f3aa7341d
No known key found for this signature in database
2 changed files with 11 additions and 0 deletions

View File

@ -3,6 +3,8 @@ export const Events = {
COMPONENT_UPDATED: "component:updated",
APP_VIEW_PUBLISHED: "app:view_published",
BLOCK_EJECTED: "block:ejected",
AI_JS_ACCEPTED: "ai_js:accepted",
AI_JS_REJECTED: "ai_js:rejected",
}
export const EventSource = {

View File

@ -4,6 +4,7 @@
import { API } from "@/api"
import type { EnrichedBinding } from "@budibase/types"
import BBAI from "assets/bb-ai.svg"
import analytics, { Events } from "@/analytics"
export let bindings: EnrichedBinding[] = []
export let value: string | null = ""
@ -64,11 +65,19 @@
}
function acceptSuggestion() {
analytics.captureEvent(Events.AI_JS_ACCEPTED, {
code: suggestedCode,
prompt: promptText,
})
dispatch("accept")
resetExpand()
}
function rejectSuggestion() {
analytics.captureEvent(Events.AI_JS_REJECTED, {
code: suggestedCode,
prompt: promptText,
})
dispatch("reject", { code: previousContents })
resetExpand()
}