Skip to content

Commit 627b61e

Browse files
committed
fix(analytics): address PR review — add endpoint check and document trade-offs
1 parent 5f6bcd1 commit 627b61e

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

apps/sim/lib/analytics/profound.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let flushTimer: NodeJS.Timeout | null = null
3333
* Returns true if Profound analytics is configured.
3434
*/
3535
export 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
}

apps/sim/proxy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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
*/
203206
function track(request: NextRequest, response: NextResponse): NextResponse {
204207
if (isProfoundEnabled()) {

0 commit comments

Comments
 (0)