🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat: add crisp events in posthog (#3667)
Marc Klingen7cdbc7f46473
diff --git a/web/src/features/posthog-analytics/usePostHogClientCapture.ts b/web/src/features/posthog-analytics/usePostHogClientCapture.tsindex a834f63ad5..1ad2cdd594 100644--- a/web/src/features/posthog-analytics/usePostHogClientCapture.ts+++ b/web/src/features/posthog-analytics/usePostHogClientCapture.ts@@ -128,6 +128,7 @@ const events = {],help_popup: ["opened", "href_clicked"],navigate_detail_pages: ["button_click_prev_or_next"],+ support_chat: ["initiated", "opened", "message_sent"], // also used on landing page for consistency} as const;// type that represents all possible event names, e.g. "traces:bookmark"diff --git a/web/src/features/support-chat/chat.tsx b/web/src/features/support-chat/chat.tsxindex d440574251..5048a7f19e 100644--- a/web/src/features/support-chat/chat.tsx+++ b/web/src/features/support-chat/chat.tsx@@ -3,12 +3,30 @@import { useEffect } from "react";import { Crisp } from "crisp-sdk-web";import { env } from "@/src/env.mjs";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";const CrispChat = () => {+ const capture = usePostHogClientCapture();+useEffect(() => {- if (env.NEXT_PUBLIC_CRISP_WEBSITE_ID)+ if (env.NEXT_PUBLIC_CRISP_WEBSITE_ID) {Crisp.configure(env.NEXT_PUBLIC_CRISP_WEBSITE_ID);- });+ Crisp.chat.onChatInitiated(() => {+ capture("support_chat:initiated");+ });+ Crisp.chat.onChatOpened(() => {+ capture("support_chat:opened");+ });+ Crisp.message.onMessageSent(() => {+ capture("support_chat:message_sent");+ });+ return () => {+ Crisp.chat.offChatInitiated();+ Crisp.chat.offChatOpened();+ Crisp.message.offMessageSent();+ };+ }+ }, [capture]);return null;};