// app/api/checkout/route.ts
import { signal, getSessionInfo } from '@/lib/signal-server';
import { NextRequest } from 'next/server';
export async function POST(request: NextRequest) {
const { sessionId, windowId, distinctId } = getSessionInfo(request);
const body = await request.json();
const orderId = await processOrder(body);
signal.capture({
distinctId: distinctId || body.userId,
event: 'order_processed',
properties: { orderId, amount: body.amount },
sessionId,
windowId,
});
return Response.json({ success: true, orderId });
}