Skip to content

Commit 8363d9c

Browse files
authored
fix: adding project id to payload
1 parent 795bacc commit 8363d9c

File tree

1 file changed

+4
-3
lines changed
  • examples/nextjs-app-router/app/api/analytics

1 file changed

+4
-3
lines changed

examples/nextjs-app-router/app/api/analytics/route.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import { NextRequest, NextResponse } from 'next/server';
22

33
export async function POST(req: NextRequest) {
4-
if (!process.env.UNIFORM_INSIGHTS_ENDPOINT || !process.env.UNIFORM_INSIGHTS_KEY) {
4+
if (!process.env.UNIFORM_INSIGHTS_ENDPOINT || !process.env.UNIFORM_INSIGHTS_KEY || !process.env.UNIFORM_PROJECT_ID) {
55
throw Error('Check Uniform Insights connection settings');
66
}
77
const destination = new URL(process.env.UNIFORM_INSIGHTS_ENDPOINT);
88
destination.pathname = '/v0/events';
99
destination.searchParams.set('name', 'analytics_events');
1010

11-
const data = await req.json();
11+
const originalBody = await req.json();
12+
const body = JSON.stringify({ ...originalBody, project_id: process.env.UNIFORM_PROJECT_ID });
1213
const response = await fetch(destination.toString(), {
1314
method: 'POST',
1415
headers: {
1516
Authorization: `Bearer ${process.env.UNIFORM_INSIGHTS_KEY}`,
1617
},
17-
body: JSON.stringify(data),
18+
body,
1819
});
1920

2021
const ingestionResponse = await response.json();

0 commit comments

Comments
 (0)