Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@steven-tey
Copy link
Collaborator

@steven-tey steven-tey commented Nov 8, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messages during link validation to include specific identifiers for better troubleshooting
    • Added validation to prevent lead and sale tracking on disabled links with appropriate error responses
    • Enhanced error handling for cross-workspace link mismatches with more descriptive messaging

@vercel
Copy link
Contributor

vercel bot commented Nov 8, 2025

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

Project Deployment Preview Updated (UTC)
dub Ready Ready Preview Nov 8, 2025 6:56pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 8, 2025

Walkthrough

The changes add validation to reject tracking conversions for disabled links in both lead and sale tracking functions. Link IDs are included in error messages for improved clarity. The disabledAt field is checked after confirming workspace ownership to prevent tracking through deactivated links.

Changes

Cohort / File(s) Summary
Conversion tracking validation enhancements
apps/web/lib/api/conversions/track-lead.ts, apps/web/lib/api/conversions/track-sale.ts
Added checks to reject conversions on disabled links by examining disabledAt field. Improved error messages to include link ID for workspace mismatch scenarios. Both files now throw not_found errors with detailed context when processing disabled links.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Repetitive validation logic applied consistently across two similar files
  • Straightforward conditional checks for disabledAt field
  • Error message improvements follow existing patterns

Possibly related PRs

  • dubinc/dub#2828: Modifies the same conversion tracking endpoints (track-lead.ts and track-sale.ts) with changes to link data retrieval and validation logic
  • dubinc/dub#2669: Adds link validation and ownership checks to track-lead.ts with similar guard clause patterns
  • dubinc/dub#2693: Modifies track-sale.ts to add conversion logic alongside link validation changes

Suggested reviewers

  • devkiran

Poem

🐰 A link once shiny, now disabled it stands,
We check disabledAt with careful rabbit hands,
No tracking through ghosts of the workspace past,
With IDs in errors, the truth holds fast! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: preventing lead and sales tracking for disabled links, which is the core functionality added across both modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 disabled-no-track

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 85b1138 and 23c2af4.

📒 Files selected for processing (2)
  • apps/web/lib/api/conversions/track-lead.ts (1 hunks)
  • apps/web/lib/api/conversions/track-sale.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-06-06T07:59:03.120Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2177
File: apps/web/lib/api/links/bulk-create-links.ts:66-84
Timestamp: 2025-06-06T07:59:03.120Z
Learning: In apps/web/lib/api/links/bulk-create-links.ts, the team accepts the risk of potential undefined results from links.find() operations when building invalidLinks arrays, because existing links are fetched from the database based on the input links, so matches are expected to always exist.

Applied to files:

  • apps/web/lib/api/conversions/track-sale.ts
  • apps/web/lib/api/conversions/track-lead.ts
📚 Learning: 2025-10-02T22:46:22.739Z
Learnt from: steven-tey
Repo: dubinc/dub PR: 2924
File: apps/web/lib/api/conversions/track-lead.ts:7-7
Timestamp: 2025-10-02T22:46:22.739Z
Learning: In apps/web/lib/api/conversions/track-lead.ts, lead events are cached in Redis for 5 minutes (keys: `leadCache:${customer.id}` and `leadCache:${customer.id}:${stringifiedEventName}`) to provide immediate data availability while Tinybird ingestion happens asynchronously. This caching pattern allows for async-only recording without breaking "wait" mode semantics.

Applied to files:

  • apps/web/lib/api/conversions/track-lead.ts
🧬 Code graph analysis (2)
apps/web/lib/api/conversions/track-sale.ts (1)
apps/web/lib/api/errors.ts (1)
  • DubApiError (75-92)
apps/web/lib/api/conversions/track-lead.ts (1)
apps/web/lib/api/errors.ts (1)
  • DubApiError (75-92)
⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (5)
apps/web/lib/api/conversions/track-lead.ts (2)

134-136: LGTM: Enhanced error message with link ID.

Including the link ID in the error message improves debuggability when tracking down issues with click events and workspace mismatches.


138-143: LGTM: Disabled link validation prevents unwanted tracking.

The validation correctly prevents lead tracking for disabled links. The check is properly positioned after workspace ownership verification and before lead creation.

apps/web/lib/api/conversions/track-sale.ts (3)

179-179: LGTM: Essential field addition for disabled link validation.

Adding disabledAt to the select clause ensures the field is available for the validation check introduced below.


193-195: LGTM: Enhanced error message with link ID.

Including the link ID in the error message maintains consistency with the track-lead.ts changes and improves debuggability.


197-202: LGTM: Disabled link validation prevents unwanted tracking.

The validation correctly prevents sale tracking for disabled links. The check is properly positioned after workspace ownership verification and before customer creation, mirroring the implementation in track-lead.ts.


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.

@steven-tey steven-tey merged commit dbdb828 into main Nov 8, 2025
8 of 9 checks passed
@steven-tey steven-tey deleted the disabled-no-track branch November 8, 2025 19:07
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