mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-09 20:27:44 +00:00
Co-authored-by: Bereket Engida <86073083+Bekacru@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
36 lines
866 B
TypeScript
36 lines
866 B
TypeScript
import { logEventToAnalytics } from "@/lib/inkeep-analytics";
|
|
import { NextRequest, NextResponse } from "next/server";
|
|
|
|
export const runtime = "edge";
|
|
|
|
export async function POST(req: NextRequest) {
|
|
try {
|
|
const { type, entityType, messageId, conversationId } = await req.json();
|
|
|
|
if (!type || !entityType) {
|
|
return NextResponse.json(
|
|
{ error: "type and entityType are required" },
|
|
{ status: 400 },
|
|
);
|
|
}
|
|
|
|
if (entityType !== "message" && entityType !== "conversation") {
|
|
return NextResponse.json(
|
|
{ error: "entityType must be 'message' or 'conversation'" },
|
|
{ status: 400 },
|
|
);
|
|
}
|
|
|
|
const result = await logEventToAnalytics({
|
|
type,
|
|
entityType,
|
|
messageId,
|
|
conversationId,
|
|
});
|
|
|
|
return NextResponse.json(result);
|
|
} catch (error) {
|
|
return NextResponse.json({ error: "Failed to log event" }, { status: 500 });
|
|
}
|
|
}
|