Skip to content

Comments

Better API call logging#964

Merged
elie222 merged 2 commits intomainfrom
chore/log-api-calls
Nov 14, 2025
Merged

Better API call logging#964
elie222 merged 2 commits intomainfrom
chore/log-api-calls

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Nov 14, 2025

Summary by CodeRabbit

  • Chores
    • Updated internal middleware routing identifiers across API endpoints.
    • Refactored logging infrastructure to use request-scoped loggers.
    • Improved type safety in middleware composition.
    • Version bumped to v2.18.24.

Note: This release consists primarily of internal infrastructure improvements with no user-facing changes.

@vercel
Copy link

vercel bot commented Nov 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
inbox-zero Ready Ready Preview Nov 14, 2025 0:37am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Walkthrough

This PR systematically updates API route handlers across the application to register route identifiers with middleware wrappers (withEmailAccount, withAuth, withError, withEmailProvider) and migrates logging from module-scoped loggers to request-scoped loggers. Version bumped to v2.18.24.

Changes

Cohort / File(s) Summary
Route handlers with middleware scope registration
apps/web/app/api/chats/[chatId]/route.ts, apps/web/app/api/chats/route.ts, apps/web/app/api/clean/history/route.ts, apps/web/app/api/google/calendar/auth-url/route.ts, apps/web/app/api/google/contacts/route.ts, apps/web/app/api/google/linking/auth-url/route.ts, apps/web/app/api/google/watch/all/route.ts, apps/web/app/api/knowledge/route.ts, apps/web/app/api/mcp/integrations/route.ts, apps/web/app/api/messages/attachment/route.ts, apps/web/app/api/messages/batch/route.ts, apps/web/app/api/organizations/[organizationId]/executed-rules-count/route.ts, apps/web/app/api/organizations/[organizationId]/members/route.ts, apps/web/app/api/outlook/linking/auth-url/route.ts, apps/web/app/api/referrals/code/route.ts, apps/web/app/api/referrals/stats/route.ts, apps/web/app/api/stripe/success/route.ts, apps/web/app/api/user/api-keys/route.ts, apps/web/app/api/user/calendars/route.ts, apps/web/app/api/user/categories/route.ts, apps/web/app/api/user/categorization-preferences/route.ts, apps/web/app/api/user/categorize/senders/progress/route.ts, apps/web/app/api/user/categorize/senders/uncategorized/route.ts, apps/web/app/api/user/cold-email/route.ts, apps/web/app/api/user/digest-schedule/route.ts, apps/web/app/api/user/digest-settings/route.ts, apps/web/app/api/user/draft-actions/route.ts, apps/web/app/api/user/email-accounts/route.ts, apps/web/app/api/user/executed-rules/batch/route.ts, apps/web/app/api/user/folders/route.ts, apps/web/app/api/user/group/[groupId]/items/route.ts, apps/web/app/api/user/group/[groupId]/messages/route.ts, apps/web/app/api/user/group/[groupId]/rules/route.ts, apps/web/app/api/user/group/route.ts, apps/web/app/api/user/labels/route.ts, apps/web/app/api/user/me/route.ts, apps/web/app/api/user/no-reply/route.ts, apps/web/app/api/user/persona/route.ts, apps/web/app/api/user/rules/[id]/example/route.ts, apps/web/app/api/user/rules/[id]/route.ts, apps/web/app/api/user/rules/prompt/route.ts, apps/web/app/api/user/rules/route.ts, apps/web/app/api/user/settings/multi-account/route.ts, apps/web/app/api/user/setup-progress/route.ts, apps/web/app/api/user/stats/day/route.ts, apps/web/app/api/user/stats/newsletters/route.ts, apps/web/app/api/user/stats/recipients/route.ts, apps/web/app/api/user/stats/route.ts, apps/web/app/api/user/stats/sender-emails/route.ts, apps/web/app/api/user/stats/senders/route.ts, apps/web/app/api/watch/all/route.ts, apps/web/app/api/watch/route.ts
Added route identifier string as first argument to middleware wrappers (e.g., withAuth("route/path", handler) instead of withAuth(handler)). No changes to internal handler logic.
Route handlers with middleware scope + logger migration
apps/web/app/api/email-stream/route.ts, apps/web/app/api/google/watch/route.ts, apps/web/app/api/labels/route.ts, apps/web/app/api/mcp/[integration]/auth-url/route.ts, apps/web/app/api/messages/route.ts, apps/web/app/api/outlook/watch/route.ts, apps/web/app/api/resend/digest/route.ts, apps/web/app/api/resend/summary/route.ts, apps/web/app/api/sso/signin/route.ts, apps/web/app/api/threads/[id]/route.ts, apps/web/app/api/threads/basic/route.ts, apps/web/app/api/threads/batch/route.ts, apps/web/app/api/threads/route.ts, apps/web/app/api/unsubscribe/route.ts, apps/web/app/api/user/executed-rules/history/route.ts
Added route identifier to middleware wrapper AND replaced module-scoped logger (via createScopedLogger) with request-scoped request.logger. Removed logger imports and initialization; updated all logging calls to use request.logger. Some functions like getExecutedRules signature extended to accept logger parameter.
Middleware utilities
apps/web/utils/middleware.ts
Exported RequestWithLogger interface; updated withError overloads to use NextHandler<RequestWithLogger> generic; tightened error header typing from any to Record<string, unknown>; updated internal type casts to align with new specialization.
Version
version.txt
Bumped version from v2.18.23 to v2.18.24.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Primary complexity: The changes are highly repetitive (55+ route files with identical middleware pattern applied) but heterogeneous across logging migration (15 files with additional logger refactoring).
  • Middleware changes require closer attention: The apps/web/utils/middleware.ts file involves type system updates and overload refinements that may interact with downstream code; verify that all NextHandler<RequestWithLogger> casts are correct.
  • Logger migration verification: Files in the second cohort should be checked to ensure all logging callsites are correctly updated from logger.* to request.logger.* and that logger parameter propagation (e.g., in getExecutedRules) is correctly wired.
  • Route identifier consistency: Spot-check that route identifiers match the file path structure and are correctly spelled (e.g., "user/group/items", "threads/detail", "google/watch/all").

Possibly related PRs

  • Pass logger from req #934: Refactors middleware surface and request-scoped logger infrastructure; directly related to the middleware wrapper and RequestWithLogger type updates.
  • Better action logging #798: Migrates logging from module-scoped to contextual/request-scoped loggers across middleware and actions; overlaps with the logger refactoring applied in this PR.
  • Fix empty digest email #744: Modifies apps/web/app/api/resend/digest/route.ts digest handlers and validation; touches the same route file updated in this PR's logger cohort.

Poem

🐰 Routes now wear their names with pride,
Middleware wraps them, logged with tied—
Request-scoped loggers light the way,
Scope identifiers lead the day!
From module shadows to the light,
Each handler's path now shines so bright. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Better API call logging' directly describes the main objective of this PR, which systematically adds route identifiers to all API middleware wrappers and introduces request-scoped logging across 60+ route files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/log-api-calls

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
apps/web/app/api/google/contacts/route.ts (1)

25-36: Add null check for emailAccount before creating client.

The database query can return null if the email account doesn't exist. While optional chaining prevents a runtime error, passing undefined tokens to getContactsClient may cause issues downstream.

Apply this diff to add proper validation:

  const emailAccount = await prisma.emailAccount.findUnique({
    where: { id: emailAccountId },
    select: {
      account: {
        select: { access_token: true, refresh_token: true, expires_at: true },
      },
    },
  });
+
+  if (!emailAccount) {
+    return NextResponse.json(
+      { error: "Email account not found" },
+      { status: 404 },
+    );
+  }
+
  const client = getContactsClient({
-    accessToken: emailAccount?.account.access_token,
-    refreshToken: emailAccount?.account.refresh_token,
+    accessToken: emailAccount.account.access_token,
+    refreshToken: emailAccount.account.refresh_token,
  });
apps/web/app/api/watch/all/route.ts (1)

32-39: Consider adding route identifier to POST handler for consistency.

The GET handler was updated with the route identifier "watch/all", but the POST handler was not. Both handlers perform the same watchAllEmails() operation and would benefit from consistent logging context.

Apply this diff to add the route identifier:

-export const POST = withError(async (request) => {
+export const POST = withError("watch/all", async (request) => {
   if (!(await hasPostCronSecret(request))) {
apps/web/app/api/google/watch/all/route.ts (1)

142-151: Update POST handler to match GET pattern.

The GET handler was updated with a route identifier, but the POST handler was not. For consistency and complete logging coverage, apply the same pattern.

Apply this diff:

-export const POST = withError(async (request) => {
+export const POST = withError("google/watch/all", async (request) => {
   if (!(await hasPostCronSecret(request))) {
🧹 Nitpick comments (7)
apps/web/app/api/user/folders/route.ts (1)

8-20: Consider adding error handling for consistency.

For consistency with other routes (e.g., apps/web/app/api/labels/route.ts), consider wrapping the getFolders call in a try-catch block and using request.logger.error() to log failures. This would better leverage the request-scoped logging infrastructure introduced by this PR.

Example pattern:

 export const GET = withEmailProvider("user/folders", async (request) => {
   const emailProvider = request.emailProvider;
 
   if (!isMicrosoftProvider(emailProvider.name)) {
     return NextResponse.json(
       { error: "Only Microsoft email providers are supported" },
       { status: 400 },
     );
   }
 
+  try {
     const result = await getFolders({ emailProvider });
     return NextResponse.json(result);
+  } catch (error) {
+    request.logger.error("Error fetching folders", { error });
+    return NextResponse.json(
+      { error: "Failed to fetch folders" },
+      { status: 500 },
+    );
+  }
 });
apps/web/app/api/email-stream/route.ts (1)

40-43: Consider handling subscription failures more gracefully.

Currently, if psubscribe fails, the error is logged but the SSE stream is still created and returned to the client, potentially causing the client to wait indefinitely without receiving any messages. Consider returning an error response if the subscription fails to provide clearer feedback.

Note: This is a pre-existing behavior pattern, not introduced by this PR.

apps/web/app/api/resend/digest/route.ts (1)

36-40: Consider adding emailAccountId to logger context.

The logger is initialized with force: true but doesn't include the emailAccountId in the context. The POST handler (line 63) includes it, and other similar routes (e.g., resend/summary) typically include the emailAccountId in the logger context for better traceability.

Apply this diff to add emailAccountId to the logger context:

  const logger = request.logger.with({
+   emailAccountId,
    force: true,
  });
apps/web/app/api/messages/route.ts (1)

32-46: Use a concrete Logger type instead of any for logger in getMessages

Since this function is always called with request.logger, you can tighten the type by using your Logger interface instead of any, which improves type safety and editor support.

You could apply something like:

-import type { EmailProvider } from "@/utils/email/types";
+import type { EmailProvider } from "@/utils/email/types";
+import type { Logger } from "@/utils/logger";
@@
-  logger,
+  logger,
 }: {
@@
-  logger: any;
+  logger: Logger;
 }

Please confirm the Logger import path matches the one used in apps/web/utils/middleware.ts and adjust if needed. Based on learnings.

apps/web/app/api/watch/all/route.ts (1)

8-8: Consider migrating to request-scoped logging.

While the GET handler now has route context via the wrapper, the module-scoped logger is still in use. Other files in this PR (e.g., labels/route.ts) have migrated to request.logger for better request-specific context. Consider doing the same here for consistency.

Also applies to: 18-18

apps/web/app/api/google/watch/all/route.ts (1)

10-10: Consider migrating to request-scoped logger.

The PR objectives mention migrating from module-scoped to request-scoped loggers. The middleware provides request.logger for request-scoped logging. Consider replacing the module-scoped logger with request-scoped logging throughout this file for better traceability.

apps/web/app/api/user/stats/newsletters/route.ts (1)

16-16: Consider migrating the module-scoped logger to request-scoped logging.

While the route identifier has been added, the module-scoped logger on Line 16 is still in use (e.g., Line 225 in getNewsletterCounts). To fully align with this PR's objective of migrating to request-scoped logging, consider passing request.logger as a parameter to helper functions like getNewsletterCounts.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 05ef067 and 711d281.

📒 Files selected for processing (69)
  • apps/web/app/api/chats/[chatId]/route.ts (1 hunks)
  • apps/web/app/api/chats/route.ts (1 hunks)
  • apps/web/app/api/clean/history/route.ts (1 hunks)
  • apps/web/app/api/email-stream/route.ts (7 hunks)
  • apps/web/app/api/google/calendar/auth-url/route.ts (1 hunks)
  • apps/web/app/api/google/contacts/route.ts (1 hunks)
  • apps/web/app/api/google/linking/auth-url/route.ts (1 hunks)
  • apps/web/app/api/google/watch/all/route.ts (1 hunks)
  • apps/web/app/api/google/watch/route.ts (2 hunks)
  • apps/web/app/api/knowledge/route.ts (1 hunks)
  • apps/web/app/api/labels/route.ts (2 hunks)
  • apps/web/app/api/mcp/[integration]/auth-url/route.ts (1 hunks)
  • apps/web/app/api/mcp/integrations/route.ts (1 hunks)
  • apps/web/app/api/messages/attachment/route.ts (1 hunks)
  • apps/web/app/api/messages/batch/route.ts (1 hunks)
  • apps/web/app/api/messages/route.ts (3 hunks)
  • apps/web/app/api/organizations/[organizationId]/executed-rules-count/route.ts (1 hunks)
  • apps/web/app/api/organizations/[organizationId]/members/route.ts (1 hunks)
  • apps/web/app/api/outlook/linking/auth-url/route.ts (1 hunks)
  • apps/web/app/api/outlook/watch/route.ts (3 hunks)
  • apps/web/app/api/referrals/code/route.ts (1 hunks)
  • apps/web/app/api/referrals/stats/route.ts (1 hunks)
  • apps/web/app/api/resend/digest/route.ts (1 hunks)
  • apps/web/app/api/resend/summary/route.ts (1 hunks)
  • apps/web/app/api/sso/signin/route.ts (2 hunks)
  • apps/web/app/api/stripe/success/route.ts (1 hunks)
  • apps/web/app/api/threads/[id]/route.ts (1 hunks)
  • apps/web/app/api/threads/basic/route.ts (2 hunks)
  • apps/web/app/api/threads/batch/route.ts (3 hunks)
  • apps/web/app/api/threads/route.ts (2 hunks)
  • apps/web/app/api/unsubscribe/route.ts (3 hunks)
  • apps/web/app/api/user/api-keys/route.ts (1 hunks)
  • apps/web/app/api/user/calendars/route.ts (1 hunks)
  • apps/web/app/api/user/categories/route.ts (1 hunks)
  • apps/web/app/api/user/categorization-preferences/route.ts (1 hunks)
  • apps/web/app/api/user/categorize/senders/progress/route.ts (1 hunks)
  • apps/web/app/api/user/categorize/senders/uncategorized/route.ts (1 hunks)
  • apps/web/app/api/user/cold-email/route.ts (1 hunks)
  • apps/web/app/api/user/digest-schedule/route.ts (1 hunks)
  • apps/web/app/api/user/digest-settings/route.ts (1 hunks)
  • apps/web/app/api/user/draft-actions/route.ts (1 hunks)
  • apps/web/app/api/user/email-accounts/route.ts (1 hunks)
  • apps/web/app/api/user/executed-rules/batch/route.ts (1 hunks)
  • apps/web/app/api/user/executed-rules/history/route.ts (2 hunks)
  • apps/web/app/api/user/folders/route.ts (1 hunks)
  • apps/web/app/api/user/group/[groupId]/items/route.ts (1 hunks)
  • apps/web/app/api/user/group/[groupId]/messages/route.ts (1 hunks)
  • apps/web/app/api/user/group/[groupId]/rules/route.ts (1 hunks)
  • apps/web/app/api/user/group/route.ts (1 hunks)
  • apps/web/app/api/user/labels/route.ts (1 hunks)
  • apps/web/app/api/user/me/route.ts (1 hunks)
  • apps/web/app/api/user/no-reply/route.ts (1 hunks)
  • apps/web/app/api/user/persona/route.ts (1 hunks)
  • apps/web/app/api/user/rules/[id]/example/route.ts (1 hunks)
  • apps/web/app/api/user/rules/[id]/route.ts (1 hunks)
  • apps/web/app/api/user/rules/prompt/route.ts (1 hunks)
  • apps/web/app/api/user/rules/route.ts (1 hunks)
  • apps/web/app/api/user/settings/multi-account/route.ts (1 hunks)
  • apps/web/app/api/user/setup-progress/route.ts (1 hunks)
  • apps/web/app/api/user/stats/day/route.ts (1 hunks)
  • apps/web/app/api/user/stats/newsletters/route.ts (1 hunks)
  • apps/web/app/api/user/stats/recipients/route.ts (1 hunks)
  • apps/web/app/api/user/stats/route.ts (1 hunks)
  • apps/web/app/api/user/stats/sender-emails/route.ts (1 hunks)
  • apps/web/app/api/user/stats/senders/route.ts (1 hunks)
  • apps/web/app/api/watch/all/route.ts (1 hunks)
  • apps/web/app/api/watch/route.ts (1 hunks)
  • apps/web/utils/middleware.ts (3 hunks)
  • version.txt (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-07-17T04:19:57.099Z
Learnt from: edulelis
Repo: elie222/inbox-zero PR: 576
File: packages/resend/emails/digest.tsx:78-83
Timestamp: 2025-07-17T04:19:57.099Z
Learning: In packages/resend/emails/digest.tsx, the DigestEmailProps type uses `[key: string]: DigestItem[] | undefined | string | Date | undefined` instead of intersection types like `& Record<string, DigestItem[] | undefined>` due to implementation constraints. This was the initial implementation approach and cannot be changed to more restrictive typing.

Applied to files:

  • apps/web/app/api/resend/digest/route.ts
  • apps/web/app/api/user/digest-schedule/route.ts
  • apps/web/app/api/user/digest-settings/route.ts
📚 Learning: 2025-07-08T13:14:03.250Z
Learnt from: elie222
Repo: elie222/inbox-zero PR: 537
File: apps/web/app/api/user/stats/newsletters/route.ts:235-239
Timestamp: 2025-07-08T13:14:03.250Z
Learning: The user prefers proper TypeScript error type checking (using `error instanceof Error`) over type assertions with `as any` for better type safety and code quality.

Applied to files:

  • apps/web/utils/middleware.ts
🧬 Code graph analysis (66)
apps/web/app/api/outlook/linking/auth-url/route.ts (2)
apps/web/app/api/google/linking/auth-url/route.ts (1)
  • GET (28-41)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/app/api/resend/digest/route.ts (3)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/app/api/resend/summary/route.ts (1)
  • GET (254-263)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/stats/day/route.ts (3)
apps/web/app/api/labels/route.ts (1)
  • GET (23-42)
apps/web/app/api/user/rules/[id]/example/route.ts (1)
  • GET (36-49)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/user/stats/senders/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/stripe/success/route.ts (2)
apps/web/app/api/email-stream/route.ts (1)
  • GET (11-113)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/app/api/user/rules/prompt/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/me/route.ts (2)
apps/web/app/api/google/watch/all/route.ts (1)
  • GET (131-140)
apps/web/utils/middleware.ts (1)
  • withError (328-346)
apps/web/app/api/user/digest-schedule/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/no-reply/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/user/labels/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/rules/[id]/example/route.ts (2)
apps/web/app/api/labels/route.ts (1)
  • GET (23-42)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/google/contacts/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/executed-rules/batch/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/stats/recipients/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/messages/attachment/route.ts (4)
apps/web/app/api/labels/route.ts (1)
  • GET (23-42)
apps/web/app/api/messages/batch/route.ts (1)
  • GET (33-51)
apps/web/app/api/messages/route.ts (1)
  • GET (11-30)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/user/categorization-preferences/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/watch/all/route.ts (2)
apps/web/app/api/google/watch/all/route.ts (1)
  • GET (131-140)
apps/web/utils/middleware.ts (1)
  • withError (328-346)
apps/web/app/api/google/watch/all/route.ts (2)
apps/web/app/api/outlook/watch/all/route.ts (1)
  • GET (122-131)
apps/web/utils/middleware.ts (1)
  • withError (328-346)
apps/web/app/api/organizations/[organizationId]/members/route.ts (3)
apps/web/app/api/organizations/[organizationId]/executed-rules-count/route.ts (1)
  • GET (10-22)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/utils/organizations/access.ts (1)
  • fetchAndCheckIsAdmin (60-82)
apps/web/app/api/google/linking/auth-url/route.ts (2)
apps/web/app/api/outlook/linking/auth-url/route.ts (1)
  • GET (21-36)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/app/api/user/draft-actions/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/mcp/[integration]/auth-url/route.ts (6)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/app/api/google/calendar/auth-url/route.ts (1)
  • GET (31-48)
apps/web/app/api/google/linking/auth-url/route.ts (1)
  • GET (28-41)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/utils/oauth/state.ts (5)
  • generateOAuthState (10-18)
  • getMcpOAuthStateType (48-49)
  • getMcpStateCookieName (42-43)
  • oauthStateCookieOptions (34-40)
  • getMcpPkceCookieName (45-46)
apps/web/utils/mcp/oauth.ts (1)
  • generateOAuthUrl (30-75)
apps/web/app/api/chats/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/stats/newsletters/route.ts (6)
apps/web/app/api/messages/batch/route.ts (1)
  • GET (33-51)
apps/web/app/api/messages/route.ts (1)
  • GET (11-30)
apps/web/app/api/threads/[id]/route.ts (1)
  • GET (28-55)
apps/web/app/api/threads/route.ts (1)
  • GET (13-54)
apps/web/app/api/user/stats/sender-emails/route.ts (1)
  • GET (72-93)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/threads/batch/route.ts (4)
apps/web/app/api/labels/route.ts (1)
  • GET (23-42)
apps/web/app/api/messages/batch/route.ts (1)
  • GET (33-51)
apps/web/app/api/messages/route.ts (1)
  • GET (11-30)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/user/rules/route.ts (2)
apps/web/app/api/user/rules/[id]/route.ts (1)
  • GET (50-62)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/organizations/[organizationId]/executed-rules-count/route.ts (2)
apps/web/app/api/organizations/[organizationId]/members/route.ts (1)
  • GET (10-29)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/app/api/user/group/[groupId]/items/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/google/watch/route.ts (6)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/app/api/email-stream/route.ts (1)
  • GET (11-113)
apps/web/app/api/google/linking/auth-url/route.ts (1)
  • GET (28-41)
apps/web/app/api/google/watch/all/route.ts (1)
  • GET (131-140)
apps/web/app/api/labels/route.ts (1)
  • GET (23-42)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/app/api/clean/history/route.ts (3)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/app/api/chats/route.ts (1)
  • GET (7-11)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/knowledge/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/categorize/senders/uncategorized/route.ts (3)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/app/api/google/calendar/auth-url/route.ts (1)
  • GET (31-48)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/watch/route.ts (2)
apps/web/app/api/email-stream/route.ts (1)
  • GET (11-113)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/app/api/threads/basic/route.ts (3)
apps/web/app/api/labels/route.ts (1)
  • GET (23-42)
apps/web/app/api/messages/route.ts (1)
  • GET (11-30)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/user/categorize/senders/progress/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/outlook/watch/route.ts (3)
apps/web/app/api/email-stream/route.ts (1)
  • GET (11-113)
apps/web/app/api/google/watch/route.ts (1)
  • GET (9-68)
apps/web/app/api/outlook/watch/all/route.ts (1)
  • GET (122-131)
apps/web/app/api/chats/[chatId]/route.ts (2)
apps/web/app/api/chats/route.ts (1)
  • GET (7-11)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/email-stream/route.ts (2)
apps/web/app/api/google/linking/auth-url/route.ts (1)
  • GET (28-41)
apps/web/app/api/google/watch/route.ts (1)
  • GET (9-68)
apps/web/app/api/user/persona/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/setup-progress/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/group/[groupId]/rules/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/stats/sender-emails/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/sso/signin/route.ts (2)
apps/web/app/api/email-stream/route.ts (1)
  • GET (11-113)
apps/web/utils/middleware.ts (1)
  • withError (328-346)
apps/web/app/api/resend/summary/route.ts (3)
apps/web/app/api/email-stream/route.ts (1)
  • GET (11-113)
apps/web/app/api/resend/digest/route.ts (1)
  • GET (32-45)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/google/calendar/auth-url/route.ts (3)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/utils/calendar/constants.ts (1)
  • CALENDAR_STATE_COOKIE_NAME (1-1)
apps/web/utils/oauth/state.ts (1)
  • oauthStateCookieOptions (34-40)
apps/web/app/api/user/folders/route.ts (2)
apps/web/app/api/labels/route.ts (1)
  • GET (23-42)
apps/web/app/api/messages/attachment/route.ts (1)
  • GET (5-36)
apps/web/app/api/threads/[id]/route.ts (4)
apps/web/app/api/email-stream/route.ts (1)
  • GET (11-113)
apps/web/app/api/labels/route.ts (1)
  • GET (23-42)
apps/web/app/api/threads/route.ts (1)
  • GET (13-54)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/user/api-keys/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/app/api/user/email-accounts/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/app/api/referrals/stats/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/app/api/labels/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/user/group/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/messages/batch/route.ts (2)
apps/web/app/api/messages/route.ts (1)
  • GET (11-30)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/user/stats/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/referrals/code/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/app/api/threads/route.ts (3)
apps/web/app/api/messages/route.ts (1)
  • GET (11-30)
apps/web/app/api/threads/[id]/route.ts (1)
  • GET (28-55)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/user/group/[groupId]/messages/route.ts (2)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/app/api/user/group/[groupId]/messages/controller.ts (1)
  • getGroupEmails (23-59)
apps/web/app/api/user/digest-settings/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/cold-email/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/executed-rules/history/route.ts (3)
apps/web/app/api/messages/route.ts (1)
  • GET (11-30)
apps/web/utils/middleware.ts (1)
  • withEmailProvider (402-415)
apps/web/utils/logger.ts (1)
  • Logger (5-5)
apps/web/app/api/user/rules/[id]/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/app/api/user/rules/route.ts (1)
  • GET (18-22)
apps/web/app/api/user/calendars/route.ts (2)
apps/web/app/api/google/calendar/auth-url/route.ts (1)
  • GET (31-48)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/categories/route.ts (3)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/app/api/chats/route.ts (1)
  • GET (7-11)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/mcp/integrations/route.ts (2)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/utils/middleware.ts (1)
  • withEmailAccount (374-392)
apps/web/app/api/user/settings/multi-account/route.ts (1)
apps/web/utils/middleware.ts (1)
  • withAuth (354-362)
apps/web/app/api/unsubscribe/route.ts (3)
apps/web/app/api/chats/[chatId]/route.ts (1)
  • GET (7-24)
apps/web/app/api/resend/digest/route.ts (2)
  • GET (32-45)
  • POST (47-79)
apps/web/utils/middleware.ts (2)
  • withError (328-346)
  • RequestWithLogger (26-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Jit Security
  • GitHub Check: test
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (86)
version.txt (1)

1-1: Version bump is appropriate for this release.

The patch version increment (v2.18.23 → v2.18.24) is semantically correct for a maintenance release focused on logging improvements and refactoring without breaking changes.

apps/web/app/api/outlook/linking/auth-url/route.ts (1)

21-21: LGTM! Route identifier added for improved observability.

The addition of the route identifier "outlook/linking/auth-url" to the withAuth wrapper aligns with the PR objective of better API call logging. This change follows the established pattern shown in the Google linking route and enables request-scoped tracking without altering the handler logic.

apps/web/app/api/user/api-keys/route.ts (1)

20-20: LGTM! Route identifier correctly added for logging.

The addition of the "user/api-keys" route identifier to the withAuth wrapper correctly implements the PR objective of improving API call logging. The identifier accurately reflects the endpoint path and follows the consistent pattern applied across the application.

apps/web/app/api/messages/batch/route.ts (1)

33-33: LGTM! Route identifier enhances logging.

The addition of the "messages/batch" route identifier to the withEmailProvider wrapper aligns with the PR objective of improving API call logging. The route identifier correctly corresponds to the API path and follows the same pattern as other routes (e.g., "messages" in apps/web/app/api/messages/route.ts).

apps/web/app/api/user/categories/route.ts (1)

12-12: LGTM! Route identifier added for better observability.

The addition of the "user/categories" scope parameter enables request-scoped logging while preserving the handler logic. The identifier correctly reflects the route path and follows the established pattern across the codebase.

apps/web/app/api/google/linking/auth-url/route.ts (1)

28-28: LGTM! Route identifier correctly added for improved logging.

The route identifier string "google/linking/auth-url" accurately matches the endpoint path and follows the established pattern used across other routes (e.g., outlook/linking/auth-url). This change enhances API call observability without altering functionality.

apps/web/app/api/user/settings/multi-account/route.ts (1)

28-28: LGTM! Route identifier correctly added for improved logging.

The route identifier "user/settings/multi-account" accurately reflects the route path and follows the established pattern shown in the middleware implementation. This change aligns with the PR's objective of better API call logging.

apps/web/app/api/stripe/success/route.ts (1)

8-8: LGTM! Route identifier added for better observability.

The addition of the route identifier "stripe/success" to the withAuth wrapper aligns perfectly with the PR objective of improving API call logging. This enables request-scoped logging and better tracing without affecting the handler logic.

apps/web/app/api/user/categorize/senders/progress/route.ts (1)

18-25: LGTM! Route identifier correctly registered.

The addition of the route scope "user/categorize/senders/progress" to the withEmailAccount wrapper aligns with the PR objective of better API call logging. The route identifier correctly matches the file path structure, and the handler logic remains unchanged.

apps/web/app/api/user/stats/route.ts (1)

73-73: LGTM! Proper route scoping for improved observability.

The addition of the route identifier "user/stats" enhances logging and traceability while maintaining existing functionality. The identifier appropriately matches the API route path.

apps/web/app/api/user/categorization-preferences/route.ts (1)

33-40: LGTM! Route identifier added for better logging.

The addition of the route identifier "user/categorization-preferences" to the withEmailProvider wrapper is correct and aligns with the PR objective of improving API call logging. The handler logic remains unchanged and the route identifier follows a consistent naming pattern based on the file path.

apps/web/app/api/user/draft-actions/route.ts (1)

8-8: LGTM! Good enhancement for observability.

The addition of the route scope identifier to withEmailAccount improves logging and monitoring capabilities without affecting the handler logic. The scope string follows a clear naming pattern that corresponds to the route structure.

apps/web/app/api/google/calendar/auth-url/route.ts (1)

31-48: LGTM! Route identifier correctly added for improved logging.

The addition of the "google/calendar/auth-url" route identifier as the first parameter to withEmailAccount is correct and aligns with the PR objective of better API call logging. The route identifier matches the API path convention, and the handler logic remains functionally unchanged.

apps/web/app/api/google/contacts/route.ts (1)

19-19: LGTM: Route identifier added for better logging.

The route identifier "google/contacts" correctly identifies this endpoint for middleware logging and tracing.

apps/web/app/api/threads/batch/route.ts (1)

13-13: LGTM! Clean migration to request-scoped logging.

The changes successfully migrate this route to the improved logging pattern:

  • Adding the route identifier "threads/batch" enables better observability in logs and monitoring
  • Using request.logger provides automatic request context instead of the global logger
  • Error handling remains robust with appropriate context (threadId, emailAccountId)

This is consistent with the logging migration pattern applied across other route handlers in this PR.

Also applies to: 40-40, 52-55

apps/web/app/api/user/executed-rules/batch/route.ts (1)

48-68: LGTM! Route identifier correctly added for logging.

The addition of the route identifier "user/executed-rules/batch" to the withEmailAccount wrapper correctly implements the PR's logging improvement objective. The identifier matches the API route path, and the handler logic remains unchanged.

apps/web/app/api/user/executed-rules/history/route.ts (4)

8-8: LGTM! Type import added for request-scoped logger.

The type-only import is correct and supports the migration from module-scoped to request-scoped logging.


18-37: LGTM! GET handler properly updated with route identifier and request-scoped logger.

The route identifier "user/executed-rules/history" correctly matches the file path, and the logger is properly passed from request.logger to the core function. This change improves request traceability and aligns with the PR's logging enhancement objectives.


39-51: LGTM! Function signature updated to accept request-scoped logger.

The signature change is safe since getExecutedRules is a private function only used within this file. The logger parameter enables proper request-scoped logging throughout the execution path.


107-110: LGTM! Proper error logging with request-scoped logger.

The logger is appropriately used in the error handler with good context (error and messageId). Request-scoped logging improves traceability by allowing correlation of all logs within a single request.

apps/web/app/api/user/folders/route.ts (1)

8-8: LGTM! Route identifier correctly added.

The route identifier "user/folders" correctly matches the API route path and aligns with the PR's objective of enabling better API call logging through request-scoped identifiers.

apps/web/app/api/email-stream/route.ts (2)

11-11: LGTM! Route identifier registration is correct.

The addition of the "email-stream" identifier to the withAuth wrapper aligns with the middleware pattern and improves request tracing by explicitly associating this handler with its route scope.


18-20: Excellent logging migration to request-scoped logger.

The consistent migration from module-scoped logger to request.logger across all logging points properly associates log entries with request context, significantly improving observability and debugging capabilities without altering the underlying logic or error handling.

Also applies to: 32-35, 41-42, 54-54, 67-69, 90-90, 99-101

apps/web/app/api/mcp/[integration]/auth-url/route.ts (5)

17-19: LGTM! Route identifier added for better observability.

The route wrapper now includes the identifier "mcp/auth-url" which enables better API call logging as per the PR objectives. The pattern matches other routes updated in this PR.


20-22: Correct handling of async params for Next.js 15.

The code properly awaits params before destructuring, which is required in Next.js 15 where route params are asynchronous.


24-26: Excellent use of request-scoped logging.

The logger is properly configured with integration context via request.logger.with({ integration }), which ensures all subsequent logs from this handler will include the integration identifier. This aligns with the PR's goal of better API call logging.


28-36: Proper validation with clear error messages.

The integration existence and OAuth support checks are correctly implemented with appropriate SafeError exceptions for user-facing error messages.


38-72: Secure OAuth flow implementation with proper error handling.

The OAuth flow is correctly implemented with:

  • Proper state generation including userId, emailAccountId, and type
  • Secure cookie options (httpOnly, secure, sameSite) for state and PKCE verifier
  • Appropriate 10-minute expiry for OAuth state
  • Good error handling with request-scoped logging before throwing user-facing errors
apps/web/app/api/user/rules/route.ts (1)

18-18: LGTM! Route identifier enhances observability.

The addition of the "user/rules" route identifier to the middleware wrapper improves logging and tracing capabilities while preserving the existing handler logic.

apps/web/app/api/user/digest-schedule/route.ts (1)

9-9: LGTM! Consistent route identifier addition.

The "user/digest-schedule" identifier properly scopes the middleware for enhanced logging while maintaining existing functionality.

apps/web/app/api/chats/route.ts (1)

7-7: LGTM! Route scoping applied correctly.

The "chats" route identifier aligns with the file path and enhances request traceability.

apps/web/app/api/user/digest-settings/route.ts (1)

24-24: LGTM! Route identifier applied consistently.

The "user/digest-settings" identifier follows the established pattern and improves logging granularity.

apps/web/app/api/knowledge/route.ts (1)

10-10: LGTM! Clean route identifier addition.

The "knowledge" identifier is concise and properly scopes this API endpoint for logging purposes.

apps/web/app/api/clean/history/route.ts (1)

16-16: LGTM! Hierarchical route identifier applied correctly.

The "clean/history" identifier accurately reflects the nested route structure and enhances request tracking.

apps/web/app/api/watch/route.ts (1)

8-8: LGTM! Route identifier applied to withAuth wrapper.

The "watch" identifier extends the logging pattern to the withAuth middleware consistently.

apps/web/app/api/user/me/route.ts (1)

68-68: LGTM! Route identifier applied to withError wrapper.

The "user/me" identifier completes the logging pattern across different middleware types (withEmailAccount, withAuth, withError) while preserving the intentional authentication behavior explained in the comment above.

apps/web/app/api/user/no-reply/route.ts (1)

48-48: LGTM! Route identifier added correctly.

The wrapper signature update follows the established pattern, providing a descriptive route scope for better API call logging.

apps/web/app/api/organizations/[organizationId]/members/route.ts (1)

10-29: LGTM! Route identifier added correctly.

The wrapper signature update follows the established pattern, providing a descriptive route scope for better API call logging. The handler logic, including authorization checks, remains unchanged.

apps/web/app/api/user/group/[groupId]/messages/route.ts (1)

5-24: LGTM! Route identifier added correctly.

The wrapper signature update follows the established pattern, providing a descriptive route scope for better API call logging.

apps/web/app/api/user/stats/sender-emails/route.ts (1)

72-93: LGTM! Route identifier added correctly.

The wrapper signature update follows the established pattern, providing a descriptive route scope for better API call logging.

apps/web/app/api/resend/digest/route.ts (1)

32-32: LGTM! Route identifier added correctly.

The wrapper signature update follows the established pattern, providing a descriptive route scope for better API call logging.

apps/web/app/api/user/group/route.ts (1)

20-20: LGTM! Route identifier added correctly.

The wrapper signature update follows the established pattern, providing a descriptive route scope for better API call logging.

apps/web/app/api/user/group/[groupId]/rules/route.ts (1)

31-43: LGTM! Route identifier added correctly.

The wrapper signature update follows the established pattern, providing a descriptive route scope for better API call logging.

apps/web/app/api/threads/[id]/route.ts (1)

28-55: LGTM! Route identifier added and logging migrated correctly.

The wrapper signature update follows the established pattern, and the migration from module-scoped to request-scoped logging (line 44) aligns with the PR's objective of better API call logging.

apps/web/app/api/threads/basic/route.ts (1)

13-13: Scoped email provider + per-request error logging look good

Using withEmailProvider("threads/basic", ...) and logging via request.logger.error with emailAccountId matches the new middleware pattern and improves observability without changing behavior.

Also applies to: 31-34

apps/web/app/api/outlook/watch/route.ts (1)

8-8: Outlook watch now correctly uses scoped auth and structured per-account logging

withAuth("outlook/watch", ...) plus the new request.logger.warn/error calls (including emailAccountId and error details) make this route consistent with the rest of the API and improve diagnosability of account-specific issues.

Also applies to: 45-45, 64-66, 74-77

apps/web/app/api/messages/route.ts (1)

11-11: Messages GET correctly wires email provider and request logger

The withEmailProvider("messages", ...) wrapper and passing request.logger into getMessages are consistent with the new middleware pattern and ensure downstream logging stays request-scoped.

Also applies to: 20-27

apps/web/utils/middleware.ts (1)

26-28: RequestWithLogger export, withError typings, and error type guard look consistent and type-safe

Exporting RequestWithLogger, threading it through the scoped withError overload, and tightening isErrorWithConfigAndHeaders to use Record<string, unknown> all align well with the logging middleware design and remove unnecessary any usage; I don’t see further changes needed here. Based on learnings.

Also applies to: 319-346, 417-425

apps/web/app/api/referrals/code/route.ts (1)

9-13: Scoped withAuth usage for referrals route is consistent

Wrapping GET with withAuth("referrals/code", ...) matches the new route-scoped middleware pattern and keeps the existing handler logic unchanged.

apps/web/app/api/user/setup-progress/route.ts (1)

11-16: LGTM! Route identifier correctly added.

The route identifier "user/setup-progress" accurately reflects the file path and aligns with the PR's objective of improving API call logging through route-scoped context.

apps/web/app/api/referrals/stats/route.ts (1)

31-35: LGTM! Route identifier correctly added.

The route identifier "referrals/stats" accurately reflects the file path and follows the established pattern for improved logging context.

apps/web/app/api/user/stats/day/route.ts (1)

96-112: LGTM! Route identifier correctly added.

The route identifier "user/stats/day" accurately reflects the file path and maintains consistency with the PR's logging improvements.

apps/web/app/api/labels/route.ts (1)

23-42: LGTM! Route identifier and request-scoped logging correctly implemented.

Two improvements here:

  1. Route identifier "labels" added for better API call logging
  2. Migration from module-scoped logger to request.logger provides better context for error tracking

Both changes align well with the PR objectives.

apps/web/app/api/user/persona/route.ts (1)

8-13: LGTM! Route identifier correctly added.

The route identifier "user/persona" accurately reflects the file path and follows the established pattern for improved API call logging.

apps/web/app/api/watch/all/route.ts (1)

23-30: LGTM on GET handler route identifier.

The route identifier "watch/all" is correctly added to the GET handler.

apps/web/app/api/messages/attachment/route.ts (1)

5-36: LGTM! Route identifier correctly added.

The route identifier "messages/attachment" accurately reflects the file path and follows the established pattern for improved API call logging.

apps/web/app/api/chats/[chatId]/route.ts (1)

7-24: LGTM! Route identifier correctly added.

The route identifier "chats/detail" is well-chosen for this dynamic route. Using "detail" distinguishes it from the list endpoint while avoiding the parameterized path segment in the identifier.

apps/web/app/api/user/cold-email/route.ts (1)

44-44: LGTM! Route identifier added for better logging context.

The addition of the "user/cold-email" route identifier to the withEmailAccount wrapper aligns with the PR's objective of improving API call logging by providing route context to the middleware.

apps/web/app/api/threads/route.ts (2)

13-13: LGTM! Route identifier added for better logging context.

The addition of the "threads" route identifier to the withEmailProvider wrapper enables better API call logging by providing route context.


48-48: LGTM! Migrated to request-scoped logging.

The migration from a module-scoped logger to request.logger provides better request context and aligns with the PR's logging improvements.

apps/web/app/api/mcp/integrations/route.ts (1)

8-8: LGTM! Route identifier added for better logging context.

The addition of the "mcp/integrations" route identifier follows the established pattern across the PR.

apps/web/app/api/resend/summary/route.ts (3)

254-254: LGTM! Route identifier added for better logging context.

The addition of the "resend/summary" route identifier to the GET handler aligns with the PR pattern.


258-258: LGTM! Migrated to request-scoped logging.

The GET handler now uses request.logger for request-scoped logging context.


265-267: Verify: Inconsistent logging approach between GET and POST handlers.

The GET handler (line 254-258) migrated to request-scoped logging using request.logger, but the POST handler continues to use createScopedLogger("resend/summary") at line 266. This inconsistency may be intentional since POST is a cron endpoint with hasCronSecret validation, or it may be an oversight in the logging migration.

Should the POST handler also migrate to request-scoped logging for consistency, or is the module-scoped logger intentional for cron endpoints?

apps/web/app/api/organizations/[organizationId]/executed-rules-count/route.ts (1)

10-22: LGTM! Route identifier added for better logging context.

The addition of the "organizations/executed-rules-count" route identifier to the withAuth wrapper follows the established pattern across the PR.

apps/web/app/api/sso/signin/route.ts (3)

18-18: LGTM! Route identifier added for better logging context.

The addition of the "sso/signin" route identifier to the withError wrapper enables better API call logging.


25-25: LGTM! Migrated to request-scoped logging.

Successfully migrated from module-scoped logger to request.logger for better request context.


39-42: LGTM! Migrated to request-scoped logging.

Error logging now uses request.logger for consistent request-scoped logging throughout the handler.

apps/web/app/api/user/categorize/senders/uncategorized/route.ts (1)

10-25: LGTM! Route identifier added for better logging context.

The addition of the "user/categorize/senders/uncategorized" route identifier to the withEmailAccount wrapper follows the established pattern across the PR.

apps/web/app/api/unsubscribe/route.ts (5)

6-8: LGTM! Route identifier added and delegating to shared unsubscribe function.

The GET handler now uses scoped withError("unsubscribe", ...) and delegates to the shared unsubscribe function.


10-12: Verify: Inconsistent withError usage between GET and POST.

The GET handler uses withError("unsubscribe", ...) with a route scope (line 6), while the POST handler uses withError(...) without a scope (line 10). Both inject RequestWithLogger, so the cast on line 11 is safe but highlights the inconsistency.

Should the POST handler also use withError("unsubscribe", ...) for consistency with the GET handler?


63-66: LGTM! Migrated to request-scoped logging.

Error logging now uses request.logger for consistent request-scoped logging.


78-83: LGTM! Migrated to request-scoped logging.

Error logging for token deletion now uses request.logger.


85-87: LGTM! Migrated to request-scoped logging.

Success logging now uses request.logger for consistent request-scoped logging throughout the handler.

apps/web/app/api/google/watch/all/route.ts (1)

131-131: LGTM! Route identifier added for better logging.

The GET handler now includes the route identifier for request-scoped logging.

apps/web/app/api/user/stats/senders/route.ts (1)

82-82: LGTM! Route identifier properly added.

The change adds request-scoped logging context for this endpoint.

apps/web/app/api/user/email-accounts/route.ts (1)

53-53: LGTM! Route identifier properly added.

The authentication wrapper now includes the route identifier for improved observability.

apps/web/app/api/user/calendars/route.ts (1)

7-7: LGTM! Route identifier properly added.

The change enhances logging context for this API route.

apps/web/app/api/user/rules/[id]/example/route.ts (1)

36-49: LGTM! Route identifier properly added.

The email provider wrapper now includes the route identifier for better API call tracking.

apps/web/app/api/user/rules/prompt/route.ts (1)

14-14: LGTM! Route identifier properly added.

The change adds proper logging context for this endpoint.

apps/web/app/api/user/group/[groupId]/items/route.ts (1)

26-38: LGTM! Route identifier properly added.

The change properly adds logging context while preserving the route params handling.

apps/web/app/api/user/labels/route.ts (1)

13-13: LGTM! Route identifier properly added.

The change enhances observability for this labels endpoint.

apps/web/app/api/user/rules/[id]/route.ts (1)

50-62: LGTM: Route identifier successfully added.

The GET handler now registers the route identifier "user/rules/detail" with the middleware wrapper, aligning with the PR's objective to improve API call logging. The inner handler logic remains unchanged and correct.

apps/web/app/api/user/stats/newsletters/route.ts (1)

247-273: LGTM: Route identifier successfully added.

The GET handler now registers the route identifier "user/stats/newsletters" with the middleware wrapper, consistent with the PR's objective.

apps/web/app/api/google/watch/route.ts (1)

9-9: LGTM: Route identifier and request-scoped logging successfully implemented.

The GET handler has been updated to:

  1. Register the route identifier "google/watch" with the middleware wrapper
  2. Migrate from module-scoped logging to request-scoped logging using request.logger

These changes fully align with the PR's objectives for better API call logging.

Also applies to: 43-56

apps/web/app/api/user/stats/recipients/route.ts (1)

50-67: LGTM: Route identifier successfully added.

The GET handler now registers the route identifier "user/stats/recipients" with the middleware wrapper, consistent with the PR's objective to improve API call logging. The inner handler logic remains unchanged and correct.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 69 files

@elie222 elie222 merged commit cd5f01c into main Nov 14, 2025
16 checks passed
@elie222 elie222 deleted the chore/log-api-calls branch November 14, 2025 00:47
Copy link

@ryancarlos1880 ryancarlos1880 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

@coderabbitai coderabbitai bot mentioned this pull request Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants