Conversation
captureRequestLog is async and returns recordApiLog; callers in withWorkspace, withPublishableKey, and track/open use waitUntil.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughRequest logging calls were moved from synchronous execution into Vercel's background task mechanism ( Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant RouteHandler as Route Handler
participant VercelWA as waitUntil (Vercel)
participant Capture as captureRequestLog
participant Store as recordApiLog / DB
Client->>RouteHandler: HTTP POST request
RouteHandler->>RouteHandler: process request, build response
RouteHandler->>VercelWA: waitUntil(captureRequestLog(req,...))
VercelWA->>Capture: invoke captureRequestLog(req, response, meta)
Capture->>Store: recordApiLog(request/response data)
RouteHandler-->>Client: return response (without waiting for Capture)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web/lib/api-logs/record-api-log.ts`:
- Line 53: Read paths are passing the raw workspaceId to Tinybird while
record-api-log.ts stores workspace_id via prefixWorkspaceId(workspaceId); update
get-api-logs.ts and get-api-logs-count.ts to apply the same normalization by
transforming workspaceId before querying (e.g., call
prefixWorkspaceId(workspaceId) or map it in the Tinybird query/schema similar to
get-audit-logs.ts). Locate the Tinybird parameter construction in
get-api-logs.ts (around the parameter named workspaceId) and in
get-api-logs-count.ts, replace the unprefixed value with the output of
prefixWorkspaceId(workspaceId) or add a schema-level alias so Tinybird queries
use workspace_id that matches record-api-log.ts.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c75296a2-1069-41be-a5bc-0575f0a8afe3
📒 Files selected for processing (1)
apps/web/lib/api-logs/record-api-log.ts
| id: createId({ prefix: "req_" }), | ||
| timestamp: new Date().toISOString(), | ||
| workspace_id: workspaceId, | ||
| workspace_id: prefixWorkspaceId(workspaceId), |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Tinybird pipe references =="
rg -n -C3 'get_api_logs' --glob '!**/node_modules/**'
echo
echo "== API log read-path callsites involving workspaceId =="
rg -n -C3 'getApiLogs|workspaceId|workspace_id' --type=ts --type=tsx --glob '!**/node_modules/**'
echo
echo "== Normalization callsites =="
rg -n -C3 'prefixWorkspaceId\\(' --type=ts --type=tsx --glob '!**/node_modules/**'Repository: dubinc/dub
Length of output: 1105
🏁 Script executed:
cat -n apps/web/lib/api-logs/get-api-logs.tsRepository: dubinc/dub
Length of output: 1499
🏁 Script executed:
cat -n apps/web/lib/api-logs/get-api-logs-count.tsRepository: dubinc/dub
Length of output: 2091
🏁 Script executed:
cat -n apps/web/lib/api-logs/record-api-log.ts | head -60Repository: dubinc/dub
Length of output: 1991
🏁 Script executed:
# Search for callsites of getApiLogs and getApiLogsCount functions
rg -n 'getApiLogs|getApiLogsCount' apps/web --type tsRepository: dubinc/dub
Length of output: 2160
🏁 Script executed:
cat -n apps/web/app/api/logs/route.tsRepository: dubinc/dub
Length of output: 1335
🏁 Script executed:
cat -n apps/web/app/api/logs/count/route.tsRepository: dubinc/dub
Length of output: 1168
🏁 Script executed:
# Search for prefixWorkspaceId usage in the codebase
rg -n 'prefixWorkspaceId' apps/web --type tsRepository: dubinc/dub
Length of output: 4753
Fix workspace ID normalization in API logs read paths.
The write path (record-api-log.ts:53) now prefixes workspace_id, but the read paths pass unprefixed workspaceId to Tinybird:
get-api-logs.ts:38passesworkspaceIddirectlyget-api-logs-count.ts:34passesworkspaceIddirectly
This mismatch means newly ingested rows with prefixed IDs won't be returned by queries. Apply the same normalization pattern used in get-audit-logs.ts by transforming workspaceId in the schema or before querying.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web/lib/api-logs/record-api-log.ts` at line 53, Read paths are passing
the raw workspaceId to Tinybird while record-api-log.ts stores workspace_id via
prefixWorkspaceId(workspaceId); update get-api-logs.ts and get-api-logs-count.ts
to apply the same normalization by transforming workspaceId before querying
(e.g., call prefixWorkspaceId(workspaceId) or map it in the Tinybird
query/schema similar to get-audit-logs.ts). Locate the Tinybird parameter
construction in get-api-logs.ts (around the parameter named workspaceId) and in
get-api-logs-count.ts, replace the unprefixed value with the output of
prefixWorkspaceId(workspaceId) or add a schema-level alias so Tinybird queries
use workspace_id that matches record-api-log.ts.
There was a problem hiding this comment.
@steven-tey, happy to help! To summarize the fix needed — both read paths need to apply the same prefixWorkspaceId() normalization before querying Tinybird:
get-api-logs.ts (around line 38):
workspace_id: prefixWorkspaceId(workspaceId),get-api-logs-count.ts (around line 34):
workspace_id: prefixWorkspaceId(workspaceId),Make sure to import prefixWorkspaceId from ../api/workspaces/workspace-id in both files, mirroring the pattern already used in get-audit-logs.ts. This will ensure newly ingested rows (with prefixed IDs) are correctly returned by queries.
🧠 Learnings used
Learnt from: steven-tey
Repo: dubinc/dub PR: 3679
File: apps/web/app/(ee)/api/discount-codes/route.ts:69-90
Timestamp: 2026-04-01T17:57:15.397Z
Learning: In the dubinc/dub codebase, a workspace can only ever have one installed Stripe integration at a time. Therefore, `prisma.installedIntegration.findFirst({ where: { projectId, integrationId: STRIPE_INTEGRATION_ID } })` is always deterministic and there is no risk of returning the wrong row. Do not flag this pattern as nondeterministic in future reviews.
Learnt from: devkiran
Repo: dubinc/dub PR: 3346
File: apps/web/lib/api/bounties/approve-bounty-submission.ts:165-165
Timestamp: 2026-01-13T12:06:42.476Z
Learning: Use 'noreply' as a sentinel for the replyTo email field: if replyTo === 'noreply', omit the replyTo property by spreading an empty object. Call sites can use replyTo: someEmail || 'noreply' to conditionally set replyTo without null/undefined. This pattern is broadly applicable across the TypeScript codebase; ensure this behavior is documented and that readability is preserved, using explicit conditional logic if the intent may be unclear.
Learnt from: devkiran
Repo: dubinc/dub PR: 3358
File: apps/web/app/(ee)/api/cron/partners/deactivate/route.ts:7-7
Timestamp: 2026-02-03T14:14:47.579Z
Learning: In all TypeScript files under apps/web, import zod using a namespace import: import * as z from 'zod/v4' and avoid using named import: import { z } from 'zod'. This ensures consistent API access and version specificity. During reviews, look for and replace any occurrences of import { z } from 'zod' with import * as z from 'zod/v4', and verify all zod usage continues to compile.
Learnt from: marcusljf
Repo: dubinc/dub PR: 3671
File: apps/web/ui/partners/program-card.tsx:93-93
Timestamp: 2026-03-31T20:45:16.716Z
Learning: In this codebase, Tailwind’s normal font weight (400) must use `font-normal`. Do not use `font-regular` (it is not a valid Tailwind utility here). When reviewing Tailwind class strings in `.ts`/`.tsx` files, flag any occurrence of `font-regular` and replace it with `font-normal` when the intent is weight 400.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
|
@coderabbitai full review, any breaking changes? |
🧩 Analysis chainI'll do a thorough analysis of the code before providing the full review. 🏁 Script executed: Length of output: 54543
Summary of ChangesThe core change is a refactoring of how File-by-File Review
|
Summary by CodeRabbit
New Features
Improvements
Chores