🪢 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
Add events to ph (#175)
Marc Klingen5f10f21c9f10
diff --git a/src/features/projects/components/NewProjectButton.tsx b/src/features/projects/components/NewProjectButton.tsxindex b5c14ae5db..da43436c61 100644--- a/src/features/projects/components/NewProjectButton.tsx+++ b/src/features/projects/components/NewProjectButton.tsx@@ -26,6 +26,7 @@ import { cn } from "@/src/utils/tailwind";import { useState } from "react";import { useSession } from "next-auth/react";import { chatRunTrigger } from "@/src/features/support-chat/chat";+import { usePostHog } from "posthog-js/react";const formSchema = z.object({name: z.string().min(3, "Must have at least 3 characters"),@@ -46,6 +47,7 @@ export function NewProjectButton({ size = "default" }: NewProjectButtonProps) {});const utils = api.useContext();const router = useRouter();+ const posthog = usePostHog();const createProjectMutation = api.projects.create.useMutation({onSuccess: (newProject) => {void updateSession();@@ -56,6 +58,7 @@ export function NewProjectButton({ size = "default" }: NewProjectButtonProps) {});function onSubmit(values: z.infer<typeof formSchema>) {+ posthog.capture("projects:new_project_form_submit");createProjectMutation.mutateAsync(values).then(() => {diff --git a/src/features/publicApi/components/ApiKeyList.tsx b/src/features/publicApi/components/ApiKeyList.tsxindex 998d571108..312561d9ac 100644--- a/src/features/publicApi/components/ApiKeyList.tsx+++ b/src/features/publicApi/components/ApiKeyList.tsx@@ -22,6 +22,7 @@ import { useHasAccess } from "@/src/features/rbac/utils/checkAccess";import { api } from "@/src/utils/api";import { DialogDescription } from "@radix-ui/react-dialog";import { TrashIcon } from "lucide-react";+import { usePostHog } from "posthog-js/react";import { useState } from "react";export function ApiKeyList(props: { projectId: string }) {@@ -97,6 +98,7 @@ export function ApiKeyList(props: { projectId: string }) {// show dialog to let user confirm that this is a destructive actionfunction DeleteApiKeyButton(props: { projectId: string; apiKeyId: string }) {+ const posthog = usePostHog();const hasAccess = useHasAccess({projectId: props.projectId,scope: "apiKeys:delete",@@ -134,7 +136,10 @@ function DeleteApiKeyButton(props: { projectId: string; apiKeyId: string }) {projectId: props.projectId,id: props.apiKeyId,})- .then(() => setOpen(false))+ .then(() => {+ posthog.capture("project_settings:api_key_delete");+ setOpen(false);+ }).catch((error) => {console.error(error);});diff --git a/src/features/publicApi/components/CreateApiKeyButton.tsx b/src/features/publicApi/components/CreateApiKeyButton.tsxindex 43eb3fffe4..a3604350ea 100644--- a/src/features/publicApi/components/CreateApiKeyButton.tsx+++ b/src/features/publicApi/components/CreateApiKeyButton.tsx@@ -11,9 +11,11 @@ import {} from "@/src/components/ui/dialog";import { CodeView } from "@/src/components/ui/code";import { useHasAccess } from "@/src/features/rbac/utils/checkAccess";+import { usePostHog } from "posthog-js/react";export function CreateApiKeyButton(props: { projectId: string }) {const utils = api.useContext();+ const posthog = usePostHog();const hasAccess = useHasAccess({projectId: props.projectId,scope: "apiKeys:create",@@ -43,6 +45,7 @@ export function CreateApiKeyButton(props: { projectId: string }) {publicKey,});setOpen(true);+ posthog.capture("project_settings:api_key_create");}).catch((error) => {console.error(error);diff --git a/src/features/publicTraces/components/PublishTraceSwitch.tsx b/src/features/publicTraces/components/PublishTraceSwitch.tsxindex ff7e7a805a..0031b380f6 100644--- a/src/features/publicTraces/components/PublishTraceSwitch.tsx+++ b/src/features/publicTraces/components/PublishTraceSwitch.tsx@@ -2,6 +2,7 @@ import { Switch } from "@/src/components/ui/switch";import { useHasAccess } from "@/src/features/rbac/utils/checkAccess";import { api } from "@/src/utils/api";import { Link, Lock } from "lucide-react";+import { usePostHog } from "posthog-js/react";import { useState } from "react";export const PublishTraceSwitch = (props: {@@ -9,6 +10,7 @@ export const PublishTraceSwitch = (props: {projectId: string;isPublic: boolean;}) => {+ const posthog = usePostHog();const hasAccess = useHasAccess({projectId: props.projectId,scope: "traces:publish",@@ -60,6 +62,7 @@ export const PublishTraceSwitch = (props: {public: !props.isPublic,projectId: props.projectId,});+ posthog.capture("trace_detail:publish_trace_button_click");}}disabled={!hasAccess}/>