22 lines
795 B
TypeScript
22 lines
795 B
TypeScript
import type {NextRequest} from 'next/server';
|
|
import {engagementApi} from '@/services/api/engagementApi';
|
|
import {toReportWindow, toSiteParam} from '@/services/api/range';
|
|
import {serveUpstream} from '@/shared/services/bff';
|
|
import {toJourney} from '@/features/engagement/services/mapEngagement';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
/**
|
|
* GET /api/reports/journey — visit → take part → buy → come back → refer.
|
|
*
|
|
* Distinct people per stage. Not a strict funnel, and the panel says so.
|
|
*/
|
|
export async function GET(req: NextRequest) {
|
|
return serveUpstream(req, async (token, query) => {
|
|
const window = toReportWindow(query.range, new Date(query.nowMs));
|
|
return toJourney(
|
|
await engagementApi.journey(token, window, toSiteParam(query.storeId)),
|
|
);
|
|
});
|
|
}
|