🪢 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
Analytics (alpha) (#48)
Marc Klingen0d4cc760aacc
diff --git a/src/components/ui/alert.tsx b/src/components/ui/alert.tsxnew file mode 100644index 0000000000..6972ae7405--- /dev/null+++ b/src/components/ui/alert.tsx@@ -0,0 +1,59 @@+import * as React from "react"+import { cva, type VariantProps } from "class-variance-authority"++import { cn } from "@/src/utils/tailwind"++const alertVariants = cva(+ "relative w-full rounded-lg border p-4 [&:has(svg)]:pl-11 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",+ {+ variants: {+ variant: {+ default: "bg-background text-foreground",+ destructive:+ "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",+ },+ },+ defaultVariants: {+ variant: "default",+ },+ }+)++const Alert = React.forwardRef<+ HTMLDivElement,+ React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>+>(({ className, variant, ...props }, ref) => (+ <div+ ref={ref}+ role="alert"+ className={cn(alertVariants({ variant }), className)}+ {...props}+ />+))+Alert.displayName = "Alert"++const AlertTitle = React.forwardRef<+ HTMLParagraphElement,+ React.HTMLAttributes<HTMLHeadingElement>+>(({ className, ...props }, ref) => (+ <h5+ ref={ref}+ className={cn("mb-1 font-medium leading-none tracking-tight", className)}+ {...props}+ />+))+AlertTitle.displayName = "AlertTitle"++const AlertDescription = React.forwardRef<+ HTMLParagraphElement,+ React.HTMLAttributes<HTMLParagraphElement>+>(({ className, ...props }, ref) => (+ <div+ ref={ref}+ className={cn("text-sm [&_p]:leading-relaxed", className)}+ {...props}+ />+))+AlertDescription.displayName = "AlertDescription"++export { Alert, AlertTitle, AlertDescription }diff --git a/src/pages/project/[projectId]/analytics.tsx b/src/pages/project/[projectId]/analytics.tsxnew file mode 100644index 0000000000..710ab4ae20--- /dev/null+++ b/src/pages/project/[projectId]/analytics.tsx@@ -0,0 +1,74 @@+import Header from "@/src/components/layouts/header";+import { useRouter } from "next/router";+import { FeatureFlagToggle } from "@/src/features/featureFlags/components/FeatureFlagToggle";+import { Alert, AlertDescription, AlertTitle } from "@/src/components/ui/alert";+import { Construction } from "lucide-react";++export default function AnalyticsPage() {+ const router = useRouter();+ const projectId = router.query.projectId as string;++ return (+ <div className="container">+ <Header title="Analytics" />+ <FeatureFlagToggle+ featureFlag="analytics-alpha"+ whenDisabled={<AnalyticsDisabled />}+ whenEnabled={<DashboardEmbed projectId={projectId} />}+ />+ </div>+ );+}++const AnalyticsDisabled = () => (+ <Alert>+ <Construction className="h-4 w-4" />+ <AlertTitle>Analytics is in closed alpha</AlertTitle>+ <AlertDescription>+ <span>+ Read more about langfuse Analytics on langfuse.com. Reach out if you are+ interested in joining the closed alpha or have specific analytics needs.+ </span>+ {process.env.NEXT_PUBLIC_HOSTNAME !== "cloud.langfuse.com" ? (+ <span>+ <br />+ During the alpha, Analytics is only available for langfuse cloud+ users.+ </span>+ ) : null}+ </AlertDescription>+ </Alert>+);++const DashboardEmbed = (props: { projectId: string }) => {+ const reportUrl =+ "https://lookerstudio.google.com/embed/reporting/434d92a5-cdbd-4835-b5c6-4a8590924e1d/page/p_refqjqlv7c";++ const filteredReportUrl =+ process.env.NEXT_PUBLIC_HOSTNAME === "cloud.langfuse.com"+ ? reportUrl ++ "?params=%7B%22df14%22:%22include%25EE%2580%25800%25EE%2580%2580IN%25EE%2580%2580" ++ props.projectId ++ "%22%7D"+ : reportUrl;++ return (+ <>+ <Alert>+ <Construction className="h-4 w-4" />+ <AlertTitle>You are part of the closed alpha</AlertTitle>+ <AlertDescription>+ Please reach out if you have any problems or additional analytics+ needs. If you cannot access the Looker-powered dashboards, please sign+ into your Google Account in another tab and try again. A version for+ smaller screens is not yet available.+ </AlertDescription>+ </Alert>+ <iframe+ width="100%"+ src={filteredReportUrl}+ className="mt-5 aspect-[1.1]"+ />+ </>+ );+};