File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
examples/nextjs-app-router/app/api/analytics Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 11import { NextRequest , NextResponse } from 'next/server' ;
22
33export 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 ( ) ;
You can’t perform that action at this time.
0 commit comments