Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(ui): add request dashboard button (#1122)

Richard Krümmelffe95cf42790
diff --git a/src/components/layouts/layout.tsx b/src/components/layouts/layout.tsx
index 8d91508312..aa3ab31466 100644
--- a/src/components/layouts/layout.tsx
+++ b/src/components/layouts/layout.tsx
@@ -647,7 +647,12 @@ const MainNavigation: React.FC<{
) : null}
</li>
))}
- <FeedbackButtonWrapper className="w-full">
+ <FeedbackButtonWrapper
+ className="w-full"
+ title="Provide feedback"
+ description="What do you think about this project? What can be improved?"
+ type="feedback"
+ >
<li className="group flex cursor-pointer gap-x-3 rounded-md p-2 text-sm font-semibold leading-6 text-gray-700 hover:bg-gray-50 hover:text-indigo-600">
<MessageSquarePlus
className="h-6 w-6 shrink-0 text-gray-400 group-hover:text-indigo-600"
diff --git a/src/features/feedback/component/FeedbackButton.tsx b/src/features/feedback/component/FeedbackButton.tsx
index 3406d1ea52..75177a7d84 100644
--- a/src/features/feedback/component/FeedbackButton.tsx
+++ b/src/features/feedback/component/FeedbackButton.tsx
@@ -1,4 +1,3 @@
-import * as Sentry from "@sentry/nextjs";
import { Button } from "@/src/components/ui/button";
import {
Dialog,
@@ -18,17 +17,28 @@ import {
FormItem,
FormMessage,
} from "@/src/components/ui/form";
-import { type PropsWithChildren, useState } from "react";
+import { useState } from "react";
import { useSession } from "next-auth/react";
import { Textarea } from "@/src/components/ui/textarea";
+interface FeedbackDialogProps {
+ className?: string;
+ children: React.ReactNode;
+ title: string;
+ description: string;
+ type: "feedback" | "dashboard";
+}
const formSchema = z.object({
feedback: z.string().min(3, "Must have at least 3 characters"),
});
-export function FeedbackButtonWrapper(
- props: PropsWithChildren<{ className?: string }>,
-) {
+export function FeedbackButtonWrapper({
+ className,
+ children,
+ title,
+ description,
+ type,
+}: FeedbackDialogProps) {
const [open, setOpen] = useState(false);
const session = useSession();
@@ -40,16 +50,6 @@ export function FeedbackButtonWrapper(
});
async function onSubmit(values: z.infer<typeof formSchema>) {
- // Add to sentry
- if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
- const eventId = Sentry.captureMessage(`User submitted feedback`);
- Sentry.captureUserFeedback({
- event_id: eventId,
- email: session.data?.user?.email ?? "",
- name: session.data?.user?.name ?? "",
- comments: values.feedback,
- });
- }
try {
const res = await fetch("https://cloud.langfuse.com/api/feedback", {
method: "POST",
@@ -57,6 +57,7 @@ export function FeedbackButtonWrapper(
"Content-Type": "application/json",
},
body: JSON.stringify({
+ type,
...values,
url: window.location.href,
user: session.data?.user,
@@ -84,12 +85,12 @@ export function FeedbackButtonWrapper(
return (
<Dialog open={open} onOpenChange={setOpen}>
- <DialogTrigger className={props.className} asChild>
- {props.children}
+ <DialogTrigger className={className} asChild>
+ {children}
</DialogTrigger>
<DialogContent>
<DialogHeader>
- <DialogTitle className="mb-5">Provide feedback</DialogTitle>
+ <DialogTitle className="mb-5">{title}</DialogTitle>
</DialogHeader>
<Form {...form}>
<form
@@ -102,9 +103,7 @@ export function FeedbackButtonWrapper(
name="feedback"
render={({ field }) => (
<FormItem>
- <FormDescription>
- What do you think about this project? What can be improved?
- </FormDescription>
+ <FormDescription>{description}</FormDescription>
<FormControl>
<Textarea {...field} />
</FormControl>
diff --git a/src/pages/project/[projectId]/index.tsx b/src/pages/project/[projectId]/index.tsx
index e4fd30f9b2..c1d70eae6a 100644
--- a/src/pages/project/[projectId]/index.tsx
+++ b/src/pages/project/[projectId]/index.tsx
@@ -25,6 +25,9 @@ import {
import { isValidOption } from "@/src/utils/types";
import { api } from "@/src/utils/api";
import { usePostHog } from "posthog-js/react";
+import { FeedbackButtonWrapper } from "@/src/features/feedback/component/FeedbackButton";
+import { BarChart2 } from "lucide-react";
+import { Button } from "@/src/components/ui/button";
export type DashboardDateRange = {
from: Date;
@@ -92,13 +95,35 @@ export default function Start() {
return (
<div className="md:container">
<Header title={project?.name ?? "Dashboard"} />
- <DatePickerWithRange
- dateRange={dateRange}
- setAgg={setAgg}
- setDateRangeAndOption={setDateRangeAndOption}
- selectedOption={selectedOption}
- className=" max-w-full overflow-x-auto"
- />
+ <div className="flex items-center justify-between">
+ <DatePickerWithRange
+ dateRange={dateRange}
+ setAgg={setAgg}
+ setDateRangeAndOption={setDateRangeAndOption}
+ selectedOption={selectedOption}
+ className=" max-w-full overflow-x-auto"
+ />
+ <FeedbackButtonWrapper
+ className="border-box"
+ title="Request Chart"
+ description="Your feedback matters! Let us know what additional data or metrics you'd like to see in your dashboard."
+ type="dashboard"
+ >
+ <Button
+ id="date"
+ variant={"outline"}
+ className={
+ "group justify-start gap-x-3 text-left font-semibold text-gray-700 hover:bg-gray-50 hover:text-indigo-600"
+ }
+ >
+ <BarChart2
+ className="h-6 w-6 shrink-0 text-gray-700 group-hover:text-indigo-600"
+ aria-hidden="true"
+ />
+ Request Chart
+ </Button>
+ </FeedbackButtonWrapper>
+ </div>
<div className="grid w-full grid-cols-1 gap-4 overflow-hidden lg:grid-cols-2 xl:grid-cols-6">
<TracesBarListChart
className="col-span-1 xl:col-span-2 "