Files
better-auth/docs/app/api/analytics/feedback/route.ts
2025-10-12 00:17:48 +00:00

38 lines
828 B
TypeScript

import { submitFeedbackToAnalytics } from "@/lib/inkeep-analytics";
import { NextRequest, NextResponse } from "next/server";
export const runtime = "edge";
export async function POST(req: NextRequest) {
try {
const { messageId, type, reasons } = await req.json();
if (!messageId || !type) {
return NextResponse.json(
{ error: "messageId and type are required" },
{ status: 400 },
);
}
if (type !== "positive" && type !== "negative") {
return NextResponse.json(
{ error: "type must be 'positive' or 'negative'" },
{ status: 400 },
);
}
const result = await submitFeedbackToAnalytics({
messageId,
type,
reasons,
});
return NextResponse.json(result);
} catch (error) {
return NextResponse.json(
{ error: "Failed to submit feedback" },
{ status: 500 },
);
}
}