File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ let flushTimer: NodeJS.Timeout | null = null
3333 * Returns true if Profound analytics is configured.
3434 */
3535export function isProfoundEnabled ( ) : boolean {
36- return isHosted && Boolean ( env . PROFOUND_API_KEY )
36+ return isHosted && Boolean ( env . PROFOUND_API_KEY ) && Boolean ( env . PROFOUND_ENDPOINT )
3737}
3838
3939/**
@@ -69,6 +69,8 @@ async function flush(): Promise<void> {
6969 logger . error ( `Profound API returned ${ response . status } ` )
7070 }
7171 } catch ( error ) {
72+ // Entries are intentionally not re-queued on failure to prevent unbounded memory growth.
73+ // Under a Profound outage, analytics data is lost — acceptable for non-critical telemetry.
7274 logger . error ( 'Failed to flush logs to Profound' , error )
7375 }
7476}
Original file line number Diff line number Diff line change @@ -199,6 +199,9 @@ export async function proxy(request: NextRequest) {
199199
200200/**
201201 * Sends request data to Profound analytics (fire-and-forget) and returns the response.
202+ * Note: `NextResponse.next()` always carries status 200 — it signals "continue to route handler",
203+ * not the final HTTP status. Only redirects (307/308) and explicit blocks (403) have accurate codes.
204+ * This matches the Vercel log drain behavior where proxy-level status reflects middleware outcome.
202205 */
203206function track ( request : NextRequest , response : NextResponse ) : NextResponse {
204207 if ( isProfoundEnabled ( ) ) {
You can’t perform that action at this time.
0 commit comments