-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add noop response to /track/lead (instead of error) #2827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughIntroduces an early null-return path in lead tracking when no clickId/customer exists and updates the lead response schema to allow nullable click/customer. Sale tracking files and tests receive terminology changes to “direct sale tracking” without altering behavior. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant API as TrackLead API
participant DB as DB
Client->>API: POST /track-lead (externalId?, clickId?)
alt No clickId AND no customer with clickId
API-->>Client: 200 { click: null, customer: null }
else clickId present or customer has clickId
API->>DB: Lookup click/customer and process lead
DB-->>API: Records found/created
API-->>Client: 200 { click: {id}, customer: {...} }
end
note over API: Early-return path replaces previous error in the no-click/no-customer branch.
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Poem
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. ✨ Finishing Touches
🧪 Generate unit tests
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/web/lib/api/conversions/track-lead.ts (1)
55-60
: Add observability for the noop path to match sale endpoint behaviorLog the noop decision (like sale does) to aid debugging and metrics parity.
if (!clickId) { if (!customer || !customer.clickId) { - return trackLeadResponseSchema.parse({ + waitUntil( + logConversionEvent({ + workspace_id: workspace.id, + path: "/track/lead", + body: JSON.stringify(rawBody), + error: + `No existing customer with customerExternalId (${customerExternalId}) and no clickId provided. Returning noop.`, + }), + ); + return trackLeadResponseSchema.parse({ click: null, customer: null, }); }apps/web/lib/zod/schemas/sales.ts (1)
60-60
: Keep comments consistent with new terminologyUpdate the inline comment to say “direct sale tracking.”
- // advanced fields: leadEventName + fields for sale tracking without a lead event + // advanced fields: leadEventName + fields for direct sale tracking
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/web/lib/api/conversions/track-lead.ts
(1 hunks)apps/web/lib/api/conversions/track-sale.ts
(1 hunks)apps/web/lib/zod/schemas/leads.ts
(1 hunks)apps/web/lib/zod/schemas/sales.ts
(1 hunks)apps/web/tests/tracks/track-sale.test.ts
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/web/lib/api/conversions/track-lead.ts (1)
apps/web/lib/zod/schemas/leads.ts (1)
trackLeadResponseSchema
(75-89)
⏰ 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). (2)
- GitHub Check: Vade Review
- GitHub Check: build
🔇 Additional comments (4)
apps/web/lib/zod/schemas/leads.ts (1)
76-88
: Schema nullability change aligns with noop response — verify downstream null-safetytrackLead response now makes click and customer nullable; search found unguarded reads that may break on noop responses. Verify or guard these call sites:
- apps/web/app/(ee)/api/events/export/route.ts — column accessors use r.customer.name and r.click.id (no null-checks).
- apps/web/lib/integrations/slack/transform.ts — templates interpolate customer.name / customer.email directly.
- apps/web/lib/integrations/segment/transform.ts — uses customer.externalId and click.ip without guards.
- apps/web/tests/tracks/track-lead-client.test.ts and apps/web/tests/tracks/track-lead.test.ts — some assertions expect a non-null customer; add/null-case coverage.
- UI components mostly use fallbacks (customer.name || customer.email, avatar fallbacks) — still scan for direct interpolations and string templates.
Verify callers tolerate null (optional chaining, fallbacks, or narrowed types) and update tests/integrations where needed.
apps/web/tests/tracks/track-sale.test.ts (1)
230-230
: Terminology rename LGTMTest name now matches “direct sale tracking.” No behavior change.
apps/web/lib/api/conversions/track-sale.ts (1)
126-135
: Message copy aligns with “direct sale tracking”Good consistency update; behavior unchanged.
apps/web/lib/zod/schemas/sales.ts (1)
66-96
: Copy updates for direct sale tracking LGTMDescriptions for
leadEventName
,clickId
,customerName
,customerEmail
, andcustomerAvatar
look good.
Summary by CodeRabbit
Bug Fixes
Documentation
Tests