Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(analytics): address PR review — add endpoint check and document t…
…rade-offs
  • Loading branch information
waleedlatif1 committed Mar 29, 2026
commit 627b61ea2d98d6e8e3bd33e9a409f6d705a5d9bd
4 changes: 3 additions & 1 deletion apps/sim/lib/analytics/profound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let flushTimer: NodeJS.Timeout | null = null
* Returns true if Profound analytics is configured.
*/
export function isProfoundEnabled(): boolean {
return isHosted && Boolean(env.PROFOUND_API_KEY)
return isHosted && Boolean(env.PROFOUND_API_KEY) && Boolean(env.PROFOUND_ENDPOINT)
}
Comment thread
waleedlatif1 marked this conversation as resolved.

/**
Expand Down Expand Up @@ -69,6 +69,8 @@ async function flush(): Promise<void> {
logger.error(`Profound API returned ${response.status}`)
}
} catch (error) {
// Entries are intentionally not re-queued on failure to prevent unbounded memory growth.
// Under a Profound outage, analytics data is lost — acceptable for non-critical telemetry.
logger.error('Failed to flush logs to Profound', error)
}
Comment thread
waleedlatif1 marked this conversation as resolved.
}
Expand Down
3 changes: 3 additions & 0 deletions apps/sim/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ export async function proxy(request: NextRequest) {

/**
* Sends request data to Profound analytics (fire-and-forget) and returns the response.
* Note: `NextResponse.next()` always carries status 200 — it signals "continue to route handler",
* not the final HTTP status. Only redirects (307/308) and explicit blocks (403) have accurate codes.
* This matches the Vercel log drain behavior where proxy-level status reflects middleware outcome.
*/
function track(request: NextRequest, response: NextResponse): NextResponse {
if (isProfoundEnabled()) {
Expand Down
Loading