Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughRefactors UTM extraction logic by introducing Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 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 |
| @@ -19,26 +41,19 @@ export async function fetchUserAndStoreUtms( | |||
| }); | |||
|
|
|||
| if (user && !user.utms) { | |||
There was a problem hiding this comment.
Persisting utms even when all values are undefined makes user.utms truthy and blocks saving real UTMs later. Consider only writing when at least one value is present (or treat an empty object as "no utms").
| if (user && !user.utms) { | |
| if (user && !user.utms && Object.values(utmValues).some((v) => v != null && v !== "")) { | |
| await storeUtms(userId, utmValues); | |
| } |
🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/web/app/(landing)/welcome/utms.tsx (1)
7-27: LGTM! Well-documented UTM extraction addresses Next.js limitation.The
extractUtmValuesfunction with clear documentation effectively solves the issue of accessing request APIs insideafter()callbacks. TheUtmValuestype provides good type safety for the extracted data.Consider exporting the
UtmValuestype for better developer experience:-type UtmValues = { +export type UtmValues = { utmCampaign?: string; utmMedium?: string; utmSource?: string; utmTerm?: string; affiliate?: string; };This would allow consumers of these functions to explicitly reference the type if needed, though TypeScript already infers it from function signatures.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsx(1 hunks)apps/web/app/(app)/[emailAccountId]/onboarding/page.tsx(2 hunks)apps/web/app/(landing)/welcome/page.tsx(2 hunks)apps/web/app/(landing)/welcome/utms.tsx(2 hunks)packages/cli/src/main.ts(1 hunks)packages/cli/src/utils.ts(1 hunks)version.txt(1 hunks)
🧰 Additional context used
📓 Path-based instructions (14)
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Use@/path aliases for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Follow consistent naming conventions using PascalCase for components
Centralize shared types in dedicated type filesImport specific lodash functions rather than entire lodash library to minimize bundle size (e.g.,
import groupBy from 'lodash/groupBy')
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
apps/web/app/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Follow NextJS app router structure with (app) directory
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
apps/web/**/*.tsx
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.tsx: Follow tailwindcss patterns with prettier-plugin-tailwindcss for class sorting
Prefer functional components with hooks over class components
Use shadcn/ui components when available
Ensure responsive design with mobile-first approach
Use LoadingContent component for async data with loading and error states
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/data-fetching.mdc)
**/*.{ts,tsx}: For API GET requests to server, use theswrpackage
Useresult?.serverErrorwithtoastErrorfrom@/components/Toastfor error handling in async operations
**/*.{ts,tsx}: Use wrapper functions for Gmail message operations (get, list, batch, etc.) from @/utils/gmail/message.ts instead of direct API calls
Use wrapper functions for Gmail thread operations from @/utils/gmail/thread.ts instead of direct API calls
Use wrapper functions for Gmail label operations from @/utils/gmail/label.ts instead of direct API calls
**/*.{ts,tsx}: For early access feature flags, create hooks using the naming conventionuse[FeatureName]Enabledthat return a boolean fromuseFeatureFlagEnabled("flag-key")
For A/B test variant flags, create hooks using the naming conventionuse[FeatureName]Variantthat define variant types, useuseFeatureFlagVariantKey()with type casting, and provide a default "control" fallback
Use kebab-case for PostHog feature flag keys (e.g.,inbox-cleaner,pricing-options-2)
Always define types for A/B test variant flags (e.g.,type PricingVariant = "control" | "variant-a" | "variant-b") and provide type safety through type casting
**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use empty type parameters in type aliases and interfaces
Don't use this and super in static contexts
Don't use any or unknown as type constraints
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
Don't export imported variables
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions
Don't use TypeScript namespaces
Don't use non-null assertions with the!postfix operator
Don't use parameter properties in class constructors
Don't use user-defined types
Useas constinstead of literal types and type annotations
Use eitherT[]orArray<T>consistently
Initialize each enum member value explicitly
Useexport typefor types
Use `impo...
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxpackages/cli/src/main.tsapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxpackages/cli/src/utils.tsapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
apps/web/app/(app)/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/page-structure.mdc)
apps/web/app/(app)/**/*.{ts,tsx}: Components for the page are either put inpage.tsx, or in theapps/web/app/(app)/PAGE_NAMEfolder
If we're in a deeply nested component we will useswrto fetch via API
If you need to useonClickin a component, that component is a client component and file must start withuse client
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxapps/web/app/(app)/[emailAccountId]/onboarding/page.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/prisma-enum-imports.mdc)
Always import Prisma enums from
@/generated/prisma/enumsinstead of@/generated/prisma/clientto avoid Next.js bundling errors in client componentsImport Prisma using the project's centralized utility:
import prisma from '@/utils/prisma'
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxpackages/cli/src/main.tsapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxpackages/cli/src/utils.tsapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
**/*.{tsx,ts}: Use Shadcn UI and Tailwind for components and styling
Usenext/imagepackage for images
For API GET requests to server, use theswrpackage with hooks likeuseSWRto fetch data
For text inputs, use theInputcomponent withregisterPropsfor form integration and error handling
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxpackages/cli/src/main.tsapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxpackages/cli/src/utils.tsapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
**/*.{tsx,ts,css}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
Implement responsive design with Tailwind CSS using a mobile-first approach
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxpackages/cli/src/main.tsapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxpackages/cli/src/utils.tsapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
**/*.tsx: Use theLoadingContentcomponent to handle loading states instead of manual loading state management
For text areas, use theInputcomponent withtype='text',autosizeTextareaprop set to true, andregisterPropsfor form integration
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useaccessKeyattribute on any HTML element
Don't setaria-hidden="true"on focusable elements
Don't add ARIA roles, states, and properties to elements that don't support them
Don't use distracting elements like<marquee>or<blink>
Only use thescopeprop on<th>elements
Don't assign non-interactive ARIA roles to interactive HTML elements
Make sure label elements have text content and are associated with an input
Don't assign interactive ARIA roles to non-interactive HTML elements
Don't assigntabIndexto non-interactive HTML elements
Don't use positive integers fortabIndexproperty
Don't include "image", "picture", or "photo" in img alt prop
Don't use explicit role property that's the same as the implicit/default role
Make static elements with click handlers use a valid role attribute
Always include atitleelement for SVG elements
Give all elements requiring alt text meaningful information for screen readers
Make sure anchors have content that's accessible to screen readers
AssigntabIndexto non-interactive HTML elements witharia-activedescendant
Include all required ARIA attributes for elements with ARIA roles
Make sure ARIA properties are valid for the element's supported roles
Always include atypeattribute for button elements
Make elements with interactive roles and handlers focusable
Give heading elements content that's accessible to screen readers (not hidden witharia-hidden)
Always include alangattribute on the html element
Always include atitleattribute for iframe elements
AccompanyonClickwith at least one of:onKeyUp,onKeyDown, oronKeyPress
AccompanyonMouseOver/onMouseOutwithonFocus/onBlur
Include caption tracks for audio and video elements
Use semantic elements instead of role attributes in JSX
Make sure all anchors are valid and navigable
Ensure all ARIA properties (aria-*) are valid
Use valid, non-abstract ARIA roles for elements with ARIA roles
Use valid AR...
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxpackages/cli/src/main.tsapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxpackages/cli/src/utils.tsapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{jsx,tsx}: Don't use unnecessary fragments
Don't pass children as props
Don't use the return value of React.render
Make sure all dependencies are correctly specified in React hooks
Make sure all React hooks are called from the top level of component functions
Don't forget key props in iterators and collection literals
Don't define React components inside other components
Don't use event handlers on non-interactive elements
Don't assign to React component props
Don't use bothchildrenanddangerouslySetInnerHTMLprops on the same element
Don't use dangerous JSX props
Don't use Array index in keys
Don't insert comments as text nodes
Don't assign JSX properties multiple times
Don't add extra closing tags for components without children
Use<>...</>instead of<Fragment>...</Fragment>
Watch out for possible "wrong" semicolons inside JSX elements
Make sure void (self-closing) elements don't have children
Don't usetarget="_blank"withoutrel="noopener"
Don't use<img>elements in Next.js projects
Don't use<head>elements in Next.js projects
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
!(pages/_document).{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
Don't use the next/head module in pages/_document.js on Next.js projects
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxversion.txtpackages/cli/src/main.tsapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxpackages/cli/src/utils.tsapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/utilities.mdc)
**/*.{js,ts,jsx,tsx}: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size (e.g.,import groupBy from 'lodash/groupBy')
Files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsxpackages/cli/src/main.tsapps/web/app/(app)/[emailAccountId]/onboarding/page.tsxpackages/cli/src/utils.tsapps/web/app/(landing)/welcome/page.tsxapps/web/app/(landing)/welcome/utms.tsx
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/security.mdc)
**/*.ts: ALL database queries MUST be scoped to the authenticated user/account by including user/account filtering in WHERE clauses to prevent unauthorized data access
Always validate that resources belong to the authenticated user before performing operations, using ownership checks in WHERE clauses or relationships
Always validate all input parameters for type, format, and length before using them in database queries
Use SafeError for error responses to prevent information disclosure. Generic error messages should not reveal internal IDs, logic, or resource ownership details
Only return necessary fields in API responses using Prisma'sselectoption. Never expose sensitive data such as password hashes, private keys, or system flags
Prevent Insecure Direct Object References (IDOR) by validating resource ownership before operations. AllfindUnique/findFirstcalls MUST include ownership filters
Prevent mass assignment vulnerabilities by explicitly whitelisting allowed fields in update operations instead of accepting all user-provided data
Prevent privilege escalation by never allowing users to modify system fields, ownership fields, or admin-only attributes through user input
AllfindManyqueries MUST be scoped to the user's data by including appropriate WHERE filters to prevent returning data from other users
Use Prisma relationships for access control by leveraging nested where clauses (e.g.,emailAccount: { id: emailAccountId }) to validate ownership
Files:
packages/cli/src/main.tspackages/cli/src/utils.ts
🧠 Learnings (14)
📚 Learning: 2025-11-25T14:37:09.306Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-11-25T14:37:09.306Z
Learning: Applies to apps/web/components/**/*Form*.tsx : Handle form submission results using `result?.serverError` to show error toasts and `toastSuccess` to show success messages after server action completion
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsx
📚 Learning: 2025-11-25T14:36:36.276Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/data-fetching.mdc:0-0
Timestamp: 2025-11-25T14:36:36.276Z
Learning: Applies to **/*.{ts,tsx} : Use `result?.serverError` with `toastError` and `toastSuccess` for error handling in server actions
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsx
📚 Learning: 2025-11-25T14:36:45.807Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:45.807Z
Learning: Applies to apps/web/env.ts : Add client-side environment variables to `apps/web/env.ts` under the `experimental__runtimeEnv` object to enable runtime access
Applied to files:
packages/cli/src/main.ts
📚 Learning: 2025-11-25T14:36:45.807Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:45.807Z
Learning: Applies to apps/web/env.ts : Add client-side environment variables to `apps/web/env.ts` under the `client` object with `NEXT_PUBLIC_` prefix and Zod schema validation
Applied to files:
packages/cli/src/main.ts
📚 Learning: 2025-11-25T14:36:18.416Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-11-25T14:36:18.416Z
Learning: Applies to apps/web/**/{.env.example,env.ts,turbo.json} : Add environment variables to `.env.example`, `env.ts`, and `turbo.json`
Applied to files:
packages/cli/src/main.ts
📚 Learning: 2025-11-25T14:36:43.454Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:43.454Z
Learning: Applies to apps/web/env.ts : For client-side environment variables in `apps/web/env.ts`, prefix them with `NEXT_PUBLIC_` and add them to both the `client` and `experimental__runtimeEnv` sections
Applied to files:
packages/cli/src/main.ts
📚 Learning: 2025-11-25T14:36:45.807Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:45.807Z
Learning: Applies to apps/web/env.ts : Add server-only environment variables to `apps/web/env.ts` under the `server` object with Zod schema validation
Applied to files:
packages/cli/src/main.ts
📚 Learning: 2025-11-25T14:36:43.454Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:43.454Z
Learning: Applies to apps/web/env.ts : Define environment variables in `apps/web/env.ts` using Zod schema validation, organizing them into `server` and `client` sections
Applied to files:
packages/cli/src/main.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to **/{pages,routes,components}/**/*.{ts,tsx} : Never call Gmail API directly from routes or components - always use wrapper functions from the utils folder
Applied to files:
apps/web/app/(app)/[emailAccountId]/onboarding/page.tsx
📚 Learning: 2025-07-08T13:14:07.449Z
Learnt from: elie222
Repo: elie222/inbox-zero PR: 537
File: apps/web/app/(app)/[emailAccountId]/clean/onboarding/page.tsx:30-34
Timestamp: 2025-07-08T13:14:07.449Z
Learning: The clean onboarding page in apps/web/app/(app)/[emailAccountId]/clean/onboarding/page.tsx is intentionally Gmail-specific and should show an error for non-Google email accounts rather than attempting to support multiple providers.
Applied to files:
apps/web/app/(app)/[emailAccountId]/onboarding/page.tsx
📚 Learning: 2025-11-25T14:42:11.919Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-11-25T14:42:11.919Z
Learning: Applies to utils/**/*.{js,ts,jsx,tsx} : The `utils` folder contains core app logic such as Next.js Server Actions and Gmail API requests
Applied to files:
apps/web/app/(app)/[emailAccountId]/onboarding/page.tsxapps/web/app/(landing)/welcome/page.tsx
📚 Learning: 2025-11-25T14:42:16.602Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-11-25T14:42:16.602Z
Learning: The `utils` folder contains core app logic such as Next.js Server Actions and Gmail API requests
Applied to files:
apps/web/app/(app)/[emailAccountId]/onboarding/page.tsx
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/llms/{index,model}.ts : Core LLM functionality must be defined in `utils/llms/index.ts`, model definitions and configurations in `utils/llms/model.ts`, and usage tracking in `utils/usage.ts`
Applied to files:
apps/web/app/(landing)/welcome/page.tsx
📚 Learning: 2025-11-25T14:39:23.326Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:23.326Z
Learning: Applies to app/api/**/*.ts : Use `withAuth` middleware for user-level operations (user settings, API keys, referrals) - provides only `userId` in `request.auth`
Applied to files:
apps/web/app/(landing)/welcome/utms.tsx
🧬 Code graph analysis (2)
apps/web/app/(app)/[emailAccountId]/onboarding/page.tsx (1)
apps/web/app/(landing)/welcome/utms.tsx (2)
extractUtmValues(19-27)fetchUserAndStoreUtms(29-46)
apps/web/app/(landing)/welcome/page.tsx (1)
apps/web/app/(landing)/welcome/utms.tsx (2)
extractUtmValues(19-27)fetchUserAndStoreUtms(29-46)
⏰ 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: Review for correctness
- GitHub Check: test
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (13)
version.txt (1)
1-1: LGTM! Version bump aligns with patch-level changes.The version increment from v2.21.30 to v2.21.31 is appropriate for the UTM handling refactoring and environment variable additions in this PR.
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsx (1)
131-131: LGTM! Concise label improves UI brevity.The shortened label "Actions:" maintains clarity while reducing visual clutter.
packages/cli/src/utils.ts (2)
53-53: LGTM! DIRECT_URL handling mirrors DATABASE_URL pattern.The addition of
DIRECT_URLfor Docker infrastructure correctly follows the same pattern asDATABASE_URL, supporting Prisma's direct connection requirements for migrations.
59-59: LGTM! DIRECT_URL properly handled for external infrastructure.Consistent with the Docker infrastructure path, this ensures
DIRECT_URLis configured for external database setups.packages/cli/src/main.ts (3)
528-528: LGTM! DIRECT_URL initialization appropriate for Docker setup.Setting
DIRECT_URLto matchDATABASE_URLis correct for Docker environments. In production deployments with connection pooling (e.g., PgBouncer), users can override these values as needed.
533-533: LGTM! DIRECT_URL initialization appropriate for host setup.Consistent with the Docker path, this correctly initializes
DIRECT_URLfor local development on the host.
539-539: LGTM! DIRECT_URL placeholder matches DATABASE_URL pattern.The placeholder correctly mirrors
DATABASE_URLfor external infrastructure, maintaining consistency with the setup flow.apps/web/app/(landing)/welcome/page.tsx (2)
9-12: LGTM! Import addition supports UTM extraction refactoring.The
extractUtmValuesimport enables the extraction of UTM values before theafter()callback, which is necessary due to Next.js restrictions on using request APIs insideafter()in Server Components.
33-38: LGTM! UTM extraction correctly moved outside after() callback.This refactoring properly addresses the Next.js limitation where request APIs cannot be used inside
after()in Server Components. Extracting UTM values at line 33 before passing them tofetchUserAndStoreUtmsat line 38 ensures correct execution order and compatibility.apps/web/app/(app)/[emailAccountId]/onboarding/page.tsx (2)
6-9: LGTM! Consistent UTM extraction pattern applied.The import addition aligns with the refactoring applied to the landing welcome page, ensuring consistent handling of UTM values across both onboarding flows.
31-36: LGTM! UTM extraction properly implemented.The extraction at line 31 and subsequent usage at line 36 correctly mirrors the pattern established in the welcome page, maintaining consistency across the codebase.
apps/web/app/(landing)/welcome/utms.tsx (2)
29-46: LGTM! Signature update maintains clean separation of concerns.The updated
fetchUserAndStoreUtmssignature acceptingutmValuesinstead of raw cookies is a clean refactoring that properly delegates cookie extraction to the caller (outsideafter()callbacks).
48-57: LGTM! Internal implementation correctly updated.The
storeUtmsfunction properly consumes theUtmValuesparameter instead of extracting from cookies, completing the refactoring consistently.
Populate
DIRECT_URLin CLI env setup and extract UTM values beforeafter()in onboarding and welcome pagesAdd
DIRECT_URLto CLI env generation and setup, and change server components to pass pre-extracted UTM values intofetchUserAndStoreUtms; also update the actions header copy in the assistant result display.📍Where to Start
Start with
extractUtmValuesand its use infetchUserAndStoreUtmsin utms.tsx, then review the call sites in apps/web/app/(app)/[emailAccountId]/onboarding/page.tsx and apps/web/app/(landing)/welcome/page.tsx.📊 Macroscope summarized 18e3dfa. 6 files reviewed, 7 issues evaluated, 6 issues filtered, 1 comment posted
🗂️ Filtered Issues
apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsx — 0 comments posted, 1 evaluated, 1 filtered
ResultDisplayContentuses React hooks (useRuleDialog,useAccount) inside a file that is not marked as a Client Component (no top-level"use client"directive). In Next.js App Router, calling hooks in a Server Component throws at runtime. Add"use client"at the top of the file or move this component into a client-marked module to avoid runtime errors when rendering. [ Out of scope ]apps/web/app/(app)/[emailAccountId]/onboarding/page.tsx — 0 comments posted, 1 evaluated, 1 filtered
stepparsing does not guard against non-numeric values.const step = searchParams.step ? Number.parseInt(searchParams.step, 10) : 1;can produceNaNwhensearchParams.stepis present but invalid (e.g., empty string, non-number). PassingNaNtoOnboardingContentcausesclampedStepto becomeNaN, breaking analytics (onNext(NaN)), routing (/onboarding?step=NaN), and indexing (steps[NaN - 1]). Add a numeric validation and fallback, e.g.,const parsed = Number.parseInt(searchParams.step ?? '', 10); const step = Number.isFinite(parsed) && parsed > 0 ? parsed : 1;. [ Out of scope ]apps/web/app/(landing)/welcome/page.tsx — 0 comments posted, 1 evaluated, 1 filtered
questionIndexis derived directly fromsearchParams.questionwithout validation:const questionIndex = searchParams.question ? Number.parseInt(searchParams.question) : 0;. If the URL contains a non-numeric value (e.g.,?question=foo) or an out-of-range value (negative or >= number of questions),Number.parseIntyieldsNaNor an invalid index. PassingNaNto the client component propquestionIndexcan cause serialization/runtime errors, and even if serialization succeeds, downstream code (e.g.,survey.questions[questionIndex]) will beundefinedand will crash when dereferenced. Add guards to coerce NaN to 0 and clamp within valid bounds before rendering. [ Out of scope ]packages/cli/src/utils.ts — 0 comments posted, 3 evaluated, 3 filtered
wrapInQuotesdoes not escape existing double-quote characters in the inputvalue. Ifvaluecontains", the resulting line (e.g.,KEY="some"quoted"value") becomes malformed for typical.envparsers and can break parsing. Consider escaping quotes or using a safer quoting strategy. [ Low confidence ]# ${key}=...with a space after#. Templates containing#${key}=...(no space) or with leading indentation will not be matched, causing the function to append a newKEY=valueline instead of updating/uncommenting the existing one. This can leave stale commented entries plus a new active entry, resulting in duplicate definitions and ambiguity. [ Low confidence ]setValuereplaces only the first matching occurrence and returns, leaving any additional occurrences of the same key elsewhere incontentuntouched. This can yield a final.envwith duplicate keys containing conflicting values, which is ambiguous and may lead to incorrect configuration being read by consumers that pick the last or first occurrence unpredictably. [ Low confidence ]Summary by CodeRabbit
Release Notes v2.21.31
Chores
Style
✏️ Tip: You can customize this high-level summary in your review settings.