Add partner link titles and comments #4275
[vc]: #p70XDlf08p3dF/4F3g9s/HIQw9+UMcDXfZFBQ2f49+Y=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJkdWIiLCJwcm9qZWN0SWQiOiJwcmpfYkx6SmdUUFdoQXlMSjZLS0dhWWVtQ3gxdlpWVSIsImluc3BlY3RvclVybCI6Imh0dHBzOi8vdmVyY2VsLmNvbS9kdWJpbmMvZHViLzc1NVRXajVaaVoyWG5BV1Qzbmh1bUJVeldjd1EiLCJwcmV2aWV3VXJsIjoiZHViLWdpdC1wYXJ0bmVyLWxpbmstdGl0bGVzLmR1Yi5jbyIsIm5leHRDb21taXRTdGF0dXMiOiJERVBMT1lFRCIsInJvb3REaXJlY3RvcnkiOiJhcHBzL3dlYiIsInYwIjpmYWxzZX1dLCJyZXF1ZXN0UmV2aWV3VXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL3ZlcmNlbC1hZ2VudC9yZXF1ZXN0LXJldmlldz9vd25lcj1kdWJpbmMmcmVwbz1kdWImcHI9NDI3NSJ9
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Actions | Updated |
| :--- | :----- | :------ | :------ |
| <a href="https://vercel.com/dubinc/dub"><sup><img src="https://vercel.com/api/www/avatar?projectId=prj_bLzJgTPWhAyLJ6KKGaYemCx1vZVU&teamId=team_y0zuoaL8RHti4hQoucTdqRSG&s=32" width="16" height="16" align="middle" alt="" /></sup></a> dub | !Ready Ready | Preview | <relative-time datetime="2026-10-16T17:43:20.889Z">Oct 16, 2026 5:43pm UTC</relative-time> |
<a href="https://vercel.com/vercel-agent/request-review?owner=dubinc&repo=dub&pr=4275" rel="noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://agents-vade-review.vercel.sh/request-review-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://agents-vade-review.vercel.sh/request-review-light.svg"><img src="https://agents-vade-review.vercel.sh/request-review-light.svg" alt="Request Review"></picture></a>
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->

<!-- review_stack_entry_end -->
<!-- This is an auto-generated comment: review paused by coderabbit.ai -->
[!NOTE]
## Reviews paused
> It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.> - Last reviewed commit: 69d63f7155a92b5d32b507554155a3c4b5515aa2
- Latest commit, not reviewed: 6bca1fbf4e0720d740fb177f28dc9ada90327255
> Use the following commands to manage reviews:
- @coderabbitai resume to resume automatic reviews.- @coderabbitai review to trigger a single review.> Use the checkboxes below for quick actions:
- [ ] <!-- {"checkboxId": "7f6cc2e2-2e4e-497a-8c31-c9e4573e93d1"} --> ▶️ Resume reviews
- [ ] <!-- {"checkboxId": "e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review
<!-- end of auto-generated comment: review paused by coderabbit.ai -->
<!-- walkthrough_start -->
<details>
<summary><strong>📝 Walkthrough</strong></summary>
<dl>
<dd>
Partner links now support private titles and comments. APIs and analytics return partner link titles. Partner pages share persisted display preferences for link titles, short links, and analytics layouts.
Changes: Partner link metadata and display
|Layer / File(s)|Summary|
|:---|:---|
|Metadata contracts and data flow <br> apps/web/prisma/schema/, apps/web/lib/zod/schemas/, apps/web/lib/api/links/, apps/web/app/(ee)/api/partner-profile/, apps/web/ui/modals/partner-link-modal.tsx, apps/web/scripts/migrations/|Partner links store partnerLinkTitle and partnerLinkComments. Schemas, creation and update APIs, analytics responses, grouped counts, forms, restoration, and the comments backfill use the new fields.|
|Shared display preferences <br> apps/web/lib/swr/use-partner-links-display.tsx, apps/web/lib/actions/partners/, apps/web/lib/zod/schemas/programs.ts, apps/web/prisma/schema/program.prisma, apps/web/app/(ee)/partners.dub.co/.../links/|Partner enrollment preferences store link display modes and properties. The provider resolves defaults, tracks changes, persists settings, and supplies the link display controls.|
|Partner customer, earnings, and analytics surfaces <br> apps/web/app/(ee)/partners.dub.co/.../customers/, apps/web/app/(ee)/partners.dub.co/.../earnings/, apps/web/ui/analytics/|Partner titles appear in link cards, customer and earnings views, event tables, top links, and filters when title display is enabled. Views retain formatted short-link fallbacks.|
Estimated code review effort: 4 (Complex) | ~45 minutes
Sequence Diagram(s)
sequenceDiagram
participant PartnerLinkAPI
participant PrismaLink
participant PartnerLinksDisplayProvider
participant PartnerAnalyticsView
PartnerLinkAPI->>PrismaLink: store partnerLinkTitle and partnerLinkComments
PrismaLink-->>PartnerAnalyticsView: return partnerLinkTitle with link metrics
PartnerAnalyticsView->>PartnerLinksDisplayProvider: read displayProperties
PartnerLinksDisplayProvider-->>PartnerAnalyticsView: return title or link preference
PartnerAnalyticsView-->>PartnerAnalyticsView: render title or short-link fallback
Possibly related PRs
earnings-composite-chart.tsx.use-analytics-filters.tsx and partner-link filter behavior.Suggested reviewers: devkiran, steven-tey
</dd>
</dl>
</details>
<!-- walkthrough_end -->
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary>
<dl>
<dd>
<strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong>
| Check name | Status | Explanation | Resolution |
| :---------------- | :----------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- |
| Docstring Coverage | !Warning | Docstring coverage is 5.56% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
<details>
<summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary>
<dl>
<dd>
| Check name | Status | Explanation |
| :------------------------ | :--------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Linked Issues check | !Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | !Passed | Check skipped because no linked issues were found for this pull request. |
| Description Check | !Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | !Passed | The title clearly and concisely describes the primary changes: adding partner link titles and comments across the data model, APIs, forms, and display components. |
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary><strong>✨ Finishing Touches 💡 1</strong></summary>
<dl>
<dd>
<!-- finishing_touch_suggestion:docstrings -->
<details>
<summary><strong>📝 Generate docstrings 💡</strong></summary>
<dl>
<dd>
</dd>
</dl>
</details>
<details>
<summary><strong>🧪 Generate unit tests (beta)</strong></summary>
<dl>
<dd>
partner-link-titles</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->
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.
<details>
<summary><strong>❤️ Share</strong></summary>
<dl>
<dd>
</dd>
</dl>
</details>
<sub>Comment @coderabbitai help to get the list of available commands.</sub>
<!-- tips_end -->
_🩺 Stability & Availability_ | _🟡 Minor_ | _⚡ Quick win_
<details>
<summary>🧩 Analysis chain</summary>
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 4 'datasource .*|provider *=|partnerLinkComments|`@db`\.Text|`@db`\.LongText' apps/web/prisma/schema
Repository: dubinc/dub
Length of output: 26950
---
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '--- partner schema excerpt ---\n'
sed -n '800,835p' apps/web/lib/zod/schemas/partners.ts || true
printf '\n--- link schema excerpt ---\n'
sed -n '75,86p' apps/web/prisma/schema/link.prisma
printf '\n--- writer helpers / partnerLinkComments usages ---\n'
rg -n -C 4 'partnerLinkComments|partnerLinkTitle|processLink|createLink|update.*link|Link\.' apps/web/lib apps/web/app apps/web/scripts --glob '!**/.next/**' || true
Repository: dubinc/dub
Length of output: 239
---
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- partner schema excerpt ---'
sed -n '800,835p' apps/web/lib/zod/schemas/partners.ts || true
printf '%s\n' ''
printf '%s\n' '--- link schema excerpt ---'
sed -n '75,86p' apps/web/prisma/schema/link.prisma
printf '%s\n' ''
printf '%s\n' '--- writer helpers / partnerLinkComments usages ---'
rg -n -C 4 'partnerLinkComments|partnerLinkTitle|processLink|createLink|update.*link|Link\.' apps/web/lib apps/web/app apps/web/scripts --glob '!**/.next/**' || true
Repository: dubinc/dub
Length of output: 50367
---
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the exact schema area for partner link props and the shared link schema area.
sed -n '700,828p' apps/web/lib/zod/schemas/partners.ts
printf '%s\n' ''
sed -n '380,408p' apps/web/lib/zod/schemas/links.ts
printf '%s\n' ''
sed -n '680,730p' apps/web/lib/zod/schemas/links.ts
# Find direct Prisma writes for Link.partnerLinkComments and createLink/createLinkBodySchema mapping.
rg -n -C 3 'partnerLinkComments:\s*(input|data|rest)|partnerLinkTitle:\s*(input|data|rest)|createLinkBodySchema|updateLinkBodySchema|recordLink|prisma\.link\.(create|update)' apps/web/lib/api apps/web/lib --glob '!**/.next/**' --glob '!**/node_modules/**' | head -n 240
Repository: dubinc/dub
Length of output: 22951
---
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- processLink implementation ---'
rg -n -C 8 'function processLink|const processLink|export .*processLink' apps/web/lib apps/web/app
Repository: dubinc/dub
Length of output: 2902
---
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,80p' apps/web/lib/api/links/process-link.ts
sed -n '80,180p' apps/web/lib/api/links/create-link.ts
sed -n '70,105p' apps/web/lib/api/links/update-link.ts
printf '%s\n' ''
printf '%s\n' '--- targeted create/update data shape around partnerLinkComments ---'
sed -n '50,68p' apps/web/lib/api/links/create-link.ts
sed -n '80,98p' apps/web/lib/api/links/update-link.ts
Repository: dubinc/dub
Length of output: 7496
---
</details>
Bound partnerLinkComments before persisting the link.
createLink and updateLink pass rest.partnerLinkComments through to Prisma without truncation, while Link.partnerLinkComments is a native MySQL @db.Text column. Set the product maximum on this field in the shared link validation schemas, and enforce the same limit in the persistence boundary.
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/web/lib/zod/schemas/partners.ts` around lines 818 - 825, Apply the
product maximum for partnerLinkComments in the shared link validation schemas,
then enforce the same bound in both createLink and updateLink before passing
rest.partnerLinkComments to Prisma. Keep partnerLinkTitle behavior unchanged and
ensure persisted comments cannot exceed the Link.partnerLinkComments Text-column
limit.
</details>
<!-- fingerprinting:phantom:poseidon:caracal -->
<!-- cr-indicator-types:potential_issue -->
<!-- cr-comment:v1:f22820e38908d611757ec283 -->
<!-- This is an auto-generated comment by CodeRabbit -->
_🗄️ Data Integrity & Integration_ | _🟠 Major_ | _⚡ Quick win_
Keep the null condition in the write.
The batch read requires partnerLinkComments: null, but this update matches only id. If a partner saves comments before this update runs, the migration overwrites the newer private comments with the legacy value. Use updateMany with where: { id, partnerLinkComments: null }.
<details>
<summary>Proposed fix</summary>
- prisma.link.update({
- where: { id },
+ prisma.link.updateMany({
+ where: { id, partnerLinkComments: null },
data: { partnerLinkComments: comments },
}),
</details>
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
await Promise.all(
links.map(({ id, comments }) =>
prisma.link.updateMany({
where: { id, partnerLinkComments: null },
data: { partnerLinkComments: comments },
}),
),
);
</details>
<!-- suggestion_end -->
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/web/scripts/migrations/backfill-partner-link-comments.ts` around lines
34 - 41, Update the migration’s write in the links batch around the prisma link
update to use updateMany with both id and partnerLinkComments: null in the where
clause, preserving the null guard so newly saved comments are not overwritten by
legacy values.
</details>
<!-- fingerprinting:phantom:medusa:tapir -->
<!-- cr-indicator-types:potential_issue -->
<!-- cr-comment:v1:6d5f9ce9420e555a253c4a4a -->
<!-- This is an auto-generated comment by CodeRabbit -->
✅ Addressed in commit aec9d02
Actionable comments posted: 3
[!CAUTION]
Some comments are outside the diff and can’t be posted inline due to platform limitations.
>
> <details>
<summary>⚠️ Outside diff range comments (2)</summary><blockquote>
> <details>
<summary>apps/web/ui/analytics/use-analytics-filters.tsx (1)</summary><blockquote>
> 426-448: _🎯 Functional Correctness_ | _🟡 Minor_ | _⚡ Quick win_> Refresh filter labels when display preferences change.
>LinkFilterItemnow readspartnerDisplayProperties, but thefiltersuseMemodoes not depend on it. When the preference changes after mount, link filter labels can retain the old title setting. AddpartnerDisplayPropertiesto that dependency array.
> <details>
<summary>🤖 Prompt for AI Agents</summary>
>> Verify each finding against current code. Fix only still-valid issues, skip the > rest with a brief reason, keep changes minimal, and validate. > > In `@apps/web/ui/analytics/use-analytics-filters.tsx` around lines 426 - 448, > Update the filters useMemo in use-analytics-filters.tsx so it includes > partnerDisplayProperties in its dependency array, since LinkFilterItem derives > its label from that value. Keep the existing LinkFilterItem and options mapping > logic unchanged, and ensure the memo recomputes when display preferences change > so link labels refresh after mount. >
> </details>
> <!-- cr-comment:v1:404a5dd3a918a19117cdbc31 -->
> </blockquote></details>
<details>
<summary>apps/web/ui/analytics/events/events-table.tsx (1)</summary><blockquote>
> 174-199: _🎯 Functional Correctness_ | _🟡 Minor_ | _⚡ Quick win_> Do not format a partner link title as a URL.
>shortLinkTitlereturns arbitrarypartnerLinkTitlevalues on partner pages. The Link cell later callsgetPrettyUrlon that value. A title such aswww.example/renders asexample.
> Return label metadata from this callback, or skip getPrettyUrl when the value is a partner link title.> <details>
<summary>🤖 Prompt for AI Agents</summary>
>> Verify each finding against current code. Fix only still-valid issues, skip the > rest with a brief reason, keep changes minimal, and validate. > > In `@apps/web/ui/analytics/events/events-table.tsx` around lines 174 - 199, Update > shortLinkTitle and the Link cell’s rendering path so partnerLinkTitle values are > treated as display labels rather than URLs; either return metadata identifying > the title source and bypass getPrettyUrl, or conditionally skip getPrettyUrl for > that result. Preserve URL formatting for actual shortLink values and existing > fallback behavior. >
> </details>
> <!-- cr-comment:v1:a5121dba072145c2ac4035f6 -->
> </blockquote></details>
> </blockquote></details>
<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/lib/swr/use-partner-links-display.tsx`:
- Around line 149-158: Update the resolved preferences logic around
resolvedPersisted and resolveDefaultViewMode so persisted "cards" preferences
are overridden to row mode when showDetailedAnalytics is unavailable, preventing
PartnerLinkCard from rendering StatsCharts without analytics. Preserve the
original persisted preference separately if eligible programs need to restore it
later, while leaving eligible saved preferences unchanged.
In `@apps/web/lib/zod/schemas/partners.ts`:
- Around line 818-825: Apply the product maximum for partnerLinkComments in the
shared link validation schemas, then enforce the same bound in both createLink
and updateLink before passing rest.partnerLinkComments to Prisma. Keep
partnerLinkTitle behavior unchanged and ensure persisted comments cannot exceed
the Link.partnerLinkComments Text-column limit.
In `@apps/web/scripts/migrations/backfill-partner-link-comments.ts`:
- Around line 34-41: Update the migration’s write in the links batch around the
prisma link update to use updateMany with both id and partnerLinkComments: null
in the where clause, preserving the null guard so newly saved comments are not
overwritten by legacy values.
---
Outside diff comments:
In `@apps/web/ui/analytics/events/events-table.tsx`:
- Around line 174-199: Update shortLinkTitle and the Link cell’s rendering path
so partnerLinkTitle values are treated as display labels rather than URLs;
either return metadata identifying the title source and bypass getPrettyUrl, or
conditionally skip getPrettyUrl for that result. Preserve URL formatting for
actual shortLink values and existing fallback behavior.
In `@apps/web/ui/analytics/use-analytics-filters.tsx`:
- Around line 426-448: Update the filters useMemo in use-analytics-filters.tsx
so it includes partnerDisplayProperties in its dependency array, since
LinkFilterItem derives its label from that value. Keep the existing
LinkFilterItem and options mapping logic unchanged, and ensure the memo
recomputes when display preferences change so link labels refresh after mount.
</details>
<details>
<summary>🪄 Autofix</summary>
Fix all unresolved CodeRabbit comments on this PR:
</details>
---
<details>
<summary>ℹ️ Review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6c1b54b1-b032-4aa7-b1e8-6ea097767961
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 05e219396472b4c37613dad0a01428f56fdc7c86 and dbc4db1fdde7a4142749c85092e3a8ccb4bf36f3.
</details>
<details>
<summary>📒 Files selected for processing (26)</summary>
apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/count/route.ts
apps/web/app/(ee)/api/partner-profile/programs/[programId]/earnings/count/route.ts
apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts
apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.ts
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/use-partner-customer-filters.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-display.tsx
apps/web/lib/analytics/get-analytics.ts
apps/web/lib/api/links/create-link.ts
apps/web/lib/api/links/update-link.ts
apps/web/lib/swr/use-partner-links-display.tsx
apps/web/lib/zod/schemas/analytics-response.ts
apps/web/lib/zod/schemas/customer-activity.ts
apps/web/lib/zod/schemas/links.ts
apps/web/lib/zod/schemas/partner-profile.ts
apps/web/lib/zod/schemas/partners.ts
apps/web/prisma/schema/link.prisma
apps/web/scripts/migrations/backfill-partner-link-comments.ts
apps/web/ui/analytics/events/events-table.tsx
apps/web/ui/analytics/top-links.tsx
apps/web/ui/analytics/use-analytics-filters.tsx
apps/web/ui/modals/partner-link-modal.tsx
</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
_🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_
Normalize legacy stored preferences before using them.
STORAGE_KEY is unchanged, but the stored field changed from viewMode to displayOption. An existing preference passes if (persisted) and supplies undefined for displayOption. This leaves the page without a valid display mode until the user changes and saves the setting.
Migrate the old shape before returning it, or version the storage key and discard incompatible values. Based on supplied context, this change removes the legacy migration while retaining the same storage key.
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/web/lib/swr/use-partner-links-display.tsx` around lines 75 - 84, The
persisted preference path in use-partner-links-display currently returns legacy
stored data as-is, so an object with viewMode but no displayOption bypasses the
defaulting logic. Update the resolvedPersisted memo to normalize the persisted
shape before returning it, using displayOption as the canonical field and
falling back to the computed default when the stored value is missing or
incompatible; keep STORAGE_KEY unchanged unless you choose to version and ignore
old values instead.
</details>
<!-- fingerprinting:phantom:poseidon:tapir -->
<!-- cr-indicator-types:potential_issue -->
<!-- cr-comment:v1:65583378094d3f7091d99072 -->
<!-- This is an auto-generated reply by CodeRabbit -->
Actionable comments posted: 1
<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/lib/swr/use-partner-links-display.tsx`:
- Around line 75-84: The persisted preference path in use-partner-links-display
currently returns legacy stored data as-is, so an object with viewMode but no
displayOption bypasses the defaulting logic. Update the resolvedPersisted memo
to normalize the persisted shape before returning it, using displayOption as the
canonical field and falling back to the computed default when the stored value
is missing or incompatible; keep STORAGE_KEY unchanged unless you choose to
version and ignore old values instead.
</details>
<details>
<summary>🪄 Autofix</summary>
Fix all unresolved CodeRabbit comments on this PR:
</details>
---
<details>
<summary>ℹ️ Review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 446f49c6-d348-484c-b784-2f66e6b96278
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between dbc4db1fdde7a4142749c85092e3a8ccb4bf36f3 and 263551b368c413df533219d9af1782846d5a0ddc.
</details>
<details>
<summary>📒 Files selected for processing (4)</summary>
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-display.tsx
apps/web/lib/swr/use-partner-links-display.tsx
</details>
<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (2)</summary>
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-display.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
partnerLinkComments matches owner comments (no zod max / no truncate → @db.Text). partnerLinkTitle already mirrors title with a 120-char truncate
Safe to change since it has not been deployed yet
@pepeladeira, understood. Since this feature and STORAGE_KEY have not been deployed, no legacy stored preferences exist. The migration is not required.
<!-- <review_comment_withdrawn> -->
<sub>You are interacting with an AI system.</sub>
<!-- This is an auto-generated reply by CodeRabbit -->
[!CAUTION]
Some comments are outside the diff and can’t be posted inline due to platform limitations.
>
> <details>
<summary>⚠️ Outside diff range comments (1)</summary><blockquote>
> <details>
<summary>apps/web/scripts/migrations/backfill-partner-link-comments.ts (1)</summary><blockquote>
> 36-43: _📐 Maintainability & Code Quality_ | _🟡 Minor_ | _⚡ Quick win_> Count rows updated, not rows selected.
>updateManycan returncount: 0when another writer fillspartnerLinkCommentsbetweenfindManyand this write. The currenttotalProcessed += links.lengththen logs rows as backfilled even when no row changed. Sum the update results instead.
>
>
>
<details>
<summary>Proposed fix</summary>
>> - await Promise.all( > + const updates = await Promise.all( > links.map(({ id, comments }) => > prisma.link.updateMany({ > where: { id, partnerLinkComments: null }, > data: { partnerLinkComments: comments }, > }), > ), > ); > > - totalProcessed += links.length; > + const updatedCount = updates.reduce( > + (total, { count }) => total + count, > + 0, > + ); > + totalProcessed += updatedCount; >
</details>
> <details>
<summary>🤖 Prompt for AI Agents</summary>
>> Verify each finding against current code. Fix only still-valid issues, skip the > rest with a brief reason, keep changes minimal, and validate. > > In `@apps/web/scripts/migrations/backfill-partner-link-comments.ts` around lines > 36 - 43, Update the backfill loop to count rows actually modified by each > prisma.link.updateMany call rather than links selected by findMany. Capture the > updateMany results and sum their count values into totalProcessed, preserving > the existing conditional update behavior for concurrent writes. >
> </details>
> <!-- cr-comment:v1:04359c6e29e7aa55e7adcc60 -->
> </blockquote></details>
> </blockquote></details>
<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@apps/web/scripts/migrations/backfill-partner-link-comments.ts`:
- Around line 36-43: Update the backfill loop to count rows actually modified by
each prisma.link.updateMany call rather than links selected by findMany. Capture
the updateMany results and sum their count values into totalProcessed,
preserving the existing conditional update behavior for concurrent writes.
</details>
---
<details>
<summary>ℹ️ Review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 599b4e22-120f-4c2d-9e1e-b115587a7c3b
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 263551b368c413df533219d9af1782846d5a0ddc and aec9d02c13b76e0e4651e665bc6622cf6b0a450e.
</details>
<details>
<summary>📒 Files selected for processing (4)</summary>
apps/web/lib/swr/use-partner-links-display.tsx
apps/web/scripts/migrations/backfill-partner-link-comments.ts
apps/web/ui/analytics/events/events-table.tsx
apps/web/ui/analytics/use-analytics-filters.tsx
</details>
<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (3)</summary>
apps/web/ui/analytics/events/events-table.tsx
apps/web/lib/swr/use-partner-links-display.tsx
</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
@coderabbitai full review. any breaking changes or security issues?
<!-- This is an auto-generated reply by CodeRabbit -->
<!-- CodeRabbit review command invocation: e0acd47a-f9e5-43d1-b6bd-b981a13ef6c3 -->@pepeladeira I will run a full review of #4275. I will check breaking API changes, authorization boundaries, private metadata exposure, validation, and migration behavior.
<details>
<summary>✅ Action performed</summary>
Full review finished.
</details>
_🗄️ Data Integrity & Integration_ | _🟠 Major_ | _⚡ Quick win_
<details>
<summary>🧩 Analysis chain</summary>
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 4 'partnerLinkComments|partnerLinkTitle|comments' \
apps/web/app apps/web/lib packages \
--glob '*.{ts,tsx,md,json}' || true
Repository: dubinc/dub
Length of output: 50366
---
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== route handlers =="
cat -n "apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts" | sed -n '1,170p'
printf '\n'
cat -n "apps/web/app/(ee)/api/partner-profile/ungs/[programId]/links/route.ts" 2>/dev/null || cat -n "apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.ts" | sed -n '1,170p'
echo '\n== createPartnerLinkSchema definition =='
rg -n -C 6 'createPartnerLinkSchema|partnerLinkComments|partnerLinkTitle' apps/web/lib/zod/schemas/ apps/web/lib --glob '*.{ts,tsx}'
echo '\n== partner link creation/update consumers =='
rg -n -C 5 'createPartnerLinkSchema\.pick|createPartnerLinkSchema|partnerLinkComments|partnerLinkTitle' apps/web --glob '*.{ts,tsx,json,md}'
Repository: dubinc/dub
Length of output: 50366
---
</details>
Preserve or reject the legacy comments request field.
Both handler schemas still define comments, but both parseRequestBody calls only pick partnerLinkComments, so old clients may send comments without an error and without updating the partner link. Map comments to partnerLinkComments as a deprecated alias, or reject it with a clear 4xx.
<details>
<summary>📍 Affects 2 files</summary>
apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts#L18-L26 (this comment)apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.ts#L50-L58</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@apps/web/app/`(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts
around lines 18 - 26, Both partner-link handlers silently ignore the legacy
comments field. Update the request parsing in the link-by-ID handler and the
collection handler to map comments to partnerLinkComments as a deprecated alias,
or explicitly reject comments with a clear 4xx; ensure neither handler accepts
and ignores the field.
</details>
<!-- consolidated_sites_start -->
<!--
<consolidated_sites>
<site>
<role>anchor</role>
<file>apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts</file>
<line_range>18-26</line_range>
</site>
<site>
<role>sibling</role>
<file>apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.ts</file>
<line_range>50-58</line_range>
</site>
</consolidated_sites>
-->
<!-- consolidated_sites_end -->
<!-- fingerprinting:phantom:poseidon:caracal -->
<!-- cr-indicator-types:potential_issue -->
<!-- cr-comment:v1:bdec208d54d9b4ff98a76a42 -->
<!-- This is an auto-generated reply by CodeRabbit -->
_🗄️ Data Integrity & Integration_ | _🟠 Major_ | _🏗️ Heavy lift_
Preserve the comments response field during migration.
These lines remove comments from PartnerProfileLinkSchema. The partner link list and detail endpoints serialize this schema. Existing clients will no longer receive comments. Keep a deprecated alias that returns the current partnerLinkComments value, or version the endpoint before removing the field.
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/web/lib/zod/schemas/partner-profile.ts` around lines 96 - 97, Update
PartnerProfileLinkSchema to preserve the deprecated comments response field
during migration, mapping it to the current partnerLinkComments value so both
partner link list and detail endpoints continue serving existing clients.
</details>
<!-- fingerprinting:phantom:poseidon:tapir -->
<!-- cr-indicator-types:potential_issue -->
<!-- cr-comment:v1:25256569fcc3889965123502 -->
<!-- This is an auto-generated reply by CodeRabbit -->
_🗄️ Data Integrity & Integration_ | _🟠 Major_ | _⚡ Quick win_
<details>
<summary>🧩 Analysis chain</summary>
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 2 'partnerLinkTitle|partnerLinkComments' \
apps/web/prisma/migrations \
apps/web/prisma/schema/link.prisma
Repository: dubinc/dub
Length of output: 584
---
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Tracked files matching schema/migrations/link:"
git ls-files | rg '(^|/)prisma/|migration|link\.prisma$|partnerLinkTitle|partnerLinkComments' | sed -n '1,200p'
echo
echo "Schema context:"
sed -n '60,95p' apps/web/prisma/schema/link.prisma
echo
echo "All current references to partner fields:"
rg -n -C 3 'partnerLinkTitle|partnerLinkComments' .
Repository: dubinc/dub
Length of output: 41455
---
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Migration-related git status/diff summary:"
git status --short
git diff --stat -- apps/web/prisma/schema apps/web/prisma/migrations 2>/dev/null || true
echo
echo "Migration directories present in git status:"
git status --short | rg 'apps/web/prisma/migrations|prisma/migrations|schema/link.prisma|createPartnerLinkSchema|createPartnerLinkSchema' | sed -n '1,200p'
echo
echo "Search for schema-only references to Prisma schema migration:"
rg -n 'addColumn|partnerLinkTitle|partnerLinkComments|createPartnerLinkSchema|createPartnerLinkSchema =|z\.object' apps/web -g '*.ts' -g '*.tsx'
Repository: dubinc/dub
Length of output: 237
---
</details>
Apply the Prisma schema change before deploying the partner-link writers.
partnerLinkTitle and partnerLinkComments are nullable and safe for existing rows, but the partner profile create/update APIs now write these fields. Run the schema update/migration before deploying this code, or ensure the columns exist before new client installs can generate reads/writes for them.
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/web/prisma/schema/link.prisma` around lines 81 - 83, Ensure the Prisma
schema migration adding partnerLinkTitle and partnerLinkComments is applied
before deploying the partner-link profile create/update writers, and verify
these nullable columns exist before generating or deploying clients that read or
write them.
</details>
<!-- fingerprinting:phantom:poseidon:caracal -->
<!-- cr-indicator-types:potential_issue -->
<!-- cr-comment:v1:8ac8ce20b3a5170026a88482 -->
<!-- This is an auto-generated comment by CodeRabbit -->
Actionable comments posted: 3
<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/web/app/`(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts:
- Around line 18-26: Both partner-link handlers silently ignore the legacy
comments field. Update the request parsing in the link-by-ID handler and the
collection handler to map comments to partnerLinkComments as a deprecated alias,
or explicitly reject comments with a clear 4xx; ensure neither handler accepts
and ignores the field.
In `@apps/web/lib/zod/schemas/partner-profile.ts`:
- Around line 96-97: Update PartnerProfileLinkSchema to preserve the deprecated
comments response field during migration, mapping it to the current
partnerLinkComments value so both partner link list and detail endpoints
continue serving existing clients.
In `@apps/web/prisma/schema/link.prisma`:
- Around line 81-83: Ensure the Prisma schema migration adding partnerLinkTitle
and partnerLinkComments is applied before deploying the partner-link profile
create/update writers, and verify these nullable columns exist before generating
or deploying clients that read or write them.
</details>
<details>
<summary>🪄 Autofix</summary>
Fix all unresolved CodeRabbit comments on this PR:
</details>
---
<details>
<summary>ℹ️ Review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a2359374-3ed2-4135-9410-4894b1799a7b
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 05e219396472b4c37613dad0a01428f56fdc7c86 and aec9d02c13b76e0e4651e665bc6622cf6b0a450e.
</details>
<details>
<summary>📒 Files selected for processing (26)</summary>
apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/count/route.ts
apps/web/app/(ee)/api/partner-profile/programs/[programId]/earnings/count/route.ts
apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts
apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.ts
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/use-partner-customer-filters.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-display.tsx
apps/web/lib/analytics/get-analytics.ts
apps/web/lib/api/links/create-link.ts
apps/web/lib/api/links/update-link.ts
apps/web/lib/swr/use-partner-links-display.tsx
apps/web/lib/zod/schemas/analytics-response.ts
apps/web/lib/zod/schemas/customer-activity.ts
apps/web/lib/zod/schemas/links.ts
apps/web/lib/zod/schemas/partner-profile.ts
apps/web/lib/zod/schemas/partners.ts
apps/web/prisma/schema/link.prisma
apps/web/scripts/migrations/backfill-partner-link-comments.ts
apps/web/ui/analytics/events/events-table.tsx
apps/web/ui/analytics/top-links.tsx
apps/web/ui/analytics/use-analytics-filters.tsx
apps/web/ui/modals/partner-link-modal.tsx
</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
partner-profile UI only sends partnerLinkComments, and existing values are covered by the backfill.
@pepeladeira, understood. The supported partner-profile UI sends partnerLinkComments, and the backfill migrates existing values. The legacy comments compatibility concern does not apply here. I will withdraw this finding.
<!-- <review_comment_withdrawn> -->
---
<details>
<summary>✏️ Learnings added</summary>
Learnt from: pepeladeira
Repo: dubinc/dub PR: 4275
File: apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts:18-26
Timestamp: 2026-08-05T17:13:32.932Z
Learning: For partner-profile link creation and updates, the supported UI sends `partnerLinkComments` rather than the legacy `comments` request field. Existing link comments are migrated by `apps/web/scripts/migrations/backfill-partner-link-comments.ts`.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
</details>
<sub>You are interacting with an AI system.</sub>
<!-- This is an auto-generated reply by CodeRabbit -->
response now returns partnerLinkComments only. UI is updated, and existing comment values are backfilled.
<details>
<summary>🧩 Analysis chain</summary>
🏁 Script executed:
#!/bin/bash
set -euo pipefail
schema='apps/web/lib/zod/schemas/partner-profile.ts'
ast-grep outline "$schema" --items all --type variable --match 'PartnerProfileLinkSchema'
printf '\n--- Partner profile link route candidates ---\n'
fd -t f 'route\.ts$' apps/web/app | rg '/partner-profile/.*/links(/|$)'
printf '\n--- Schema references and partner link response field references ---\n'
rg -n -C 3 '\bPartnerProfileLinkSchema\b|\bpartnerLinkComments\b|\bcomments\b' \
apps/web/app apps/web/lib apps/web/ui \
-g '*.ts' -g '*.tsx' \
-g '!apps/web/lib/zod/schemas/partner-profile.ts'
Length of output: 54330
---
</details>
@pepeladeira, the backfill preserves the comment data, and the updated UI uses partnerLinkComments.
The compatibility concern still applies. PartnerProfileLinkSchema also serializes links in partner event, export, and embed responses. In particular, /api/embed/referrals/events uses this schema. Removing comments changes those response contracts for consumers outside the updated link UI.
If this breaking API change is intentional and all embed and API consumers have migrated, please confirm that scope. Otherwise, retain a deprecated comments alias during the migration.
<sub>You are interacting with an AI system.</sub>
<!-- This is an auto-generated reply by CodeRabbit -->
_🗄️ Data Integrity & Integration_ | _🟠 Major_ | _⚡ Quick win_
Use a separate update schema for partner-link PATCH requests.
url is optional here. The sibling PATCH route compares the existing URL with this omitted value, then writes url: url || program.url. A metadata-only PATCH can therefore change a partner link destination to the program default URL.
Preserve link.url when the PATCH body omits url. Validate the destination only when the request explicitly changes it. Based on supplied sibling PATCH route context.
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/web/lib/zod/schemas/partner-profile.ts` around lines 89 - 94, Introduce
a separate update schema for partner-link PATCH requests rather than reusing
createPartnerProfileLinkSchema. Make the update schema distinguish an omitted
url from an explicitly supplied destination, and update the sibling PATCH route
to preserve link.url when url is omitted while validating and applying only an
explicitly changed URL.
</details>
<!-- fingerprinting:phantom:medusa:tapir -->
<!-- cr-indicator-types:potential_issue -->
<!-- cr-comment:v1:73dd871f9d35e09cee47a401 -->
<!-- This is an auto-generated comment by CodeRabbit -->
✅ Addressed in commit e917165
_🗄️ Data Integrity & Integration_ | _🟠 Major_ | _⚡ Quick win_
<details>
<summary>🧩 Analysis chain</summary>
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -i -C 4 \
'partnerPreferences|ALTER TABLE.*ProgramEnrollment' \
-g '*.sql' . || true
Repository: dubinc/dub
Length of output: 148
---
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== tracked files matching migrations/prisma/web =="
git ls-files | rg '(^|/)apps/web/prisma/(schema|prisma)|migration|prisma|schema' | sed -n '1,200p'
echo
echo "== schema.program.prisma relevant section =="
file=$(git ls-files | rg '(^|/)apps/web/prisma/schema/program\.prisma$' | head -n1 || true)
if [ -n "${file}" ]; then
echo "FILE=$file"
wc -l "$file"
sed -n '120,170p' "$file" | cat -n -v
fi
echo
echo "== partnerPreferences occurrences =="
rg -n -i -C 3 'partnerPreferences' . --glob '!node_modules' --glob '!dist' --glob '!build' --glob '!coverage' || true
echo
echo "== DB migration paths =="
git ls-files | rg '(_prisma|migrations|prisma/migrations|migrat)' | sed -n '1,240p'
Repository: dubinc/dub
Length of output: 14376
---
</details>
Add a PartnerEnrollment.partnerPreferences migration.
This PR changes the schema and server action to write partnerPreferences, but the repository has no migration adding that column. Add an SQL migration including the new JSON column and apply it in the release flow before enabling preference saves.
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/web/prisma/schema/program.prisma` at line 150, Add a Prisma migration
for the PartnerEnrollment.partnerPreferences field, creating the nullable JSON
column to match the schema. Ensure the release flow applies this migration
before enabling server actions that save partner preferences.
</details>
<!-- fingerprinting:phantom:medusa:tapir -->
<!-- cr-indicator-types:potential_issue -->
<!-- cr-comment:v1:4edb1ce23d733b1bb3fcc7d2 -->
<!-- This is an auto-generated comment by CodeRabbit -->
Actionable comments posted: 2
<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/lib/zod/schemas/partner-profile.ts`:
- Around line 89-94: Introduce a separate update schema for partner-link PATCH
requests rather than reusing createPartnerProfileLinkSchema. Make the update
schema distinguish an omitted url from an explicitly supplied destination, and
update the sibling PATCH route to preserve link.url when url is omitted while
validating and applying only an explicitly changed URL.
In `@apps/web/prisma/schema/program.prisma`:
- Line 150: Add a Prisma migration for the PartnerEnrollment.partnerPreferences
field, creating the nullable JSON column to match the schema. Ensure the release
flow applies this migration before enabling server actions that save partner
preferences.
</details>
<details>
<summary>🪄 Autofix</summary>
Fix all unresolved CodeRabbit comments on this PR:
</details>
---
<details>
<summary>ℹ️ Review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: bea9d121-5817-4bd9-a1c6-d4e08c285a3a
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between aec9d02c13b76e0e4651e665bc6622cf6b0a450e and 69d63f7155a92b5d32b507554155a3c4b5515aa2.
</details>
<details>
<summary>📒 Files selected for processing (10)</summary>
apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts
apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.ts
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsx
apps/web/lib/actions/partners/update-program-enrollment-preferences.ts
apps/web/lib/analytics/get-analytics.ts
apps/web/lib/swr/use-partner-links-display.tsx
apps/web/lib/types.ts
apps/web/lib/zod/schemas/partner-profile.ts
apps/web/lib/zod/schemas/programs.ts
apps/web/prisma/schema/program.prisma
</details>
<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (2)</summary>
apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsx
</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
@coderabbitai final review. any breaking changes?
<!-- This is an auto-generated reply by CodeRabbit -->
[!TIP]
For best results, initiate chat on the files or code changes.
<details>
<summary>🧩 Analysis chain</summary>
🏁 Script executed:
#!/bin/bash
set -euo pipefail
git diff --stat HEAD^ HEAD
git diff -- apps/web/app/\(ee\)/api/partner-profile/programs/\[programId\]/links/route.ts \
apps/web/app/\(ee\)/api/partner-profile/programs/\[programId\]/links/\[linkId\]/route.ts \
apps/web/lib/actions/partners/update-program-enrollment-preferences.ts \
apps/web/lib/zod/schemas/partner-profile.ts \
apps/web/lib/zod/schemas/programs.ts \
apps/web/lib/swr/use-partner-links-display.tsx \
apps/web/scripts/migrations/backfill-partner-link-comments.ts \
apps/web/lib/api/links/create-link.ts \
apps/web/lib/api/links/update-link.ts \
apps/web/lib/analytics/get-analytics.ts \
apps/web/prisma/schema/link.prisma \
apps/web/prisma/schema/program.prisma
ast-grep outline 'apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.ts' --view expanded
ast-grep outline 'apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts' --view expanded
ast-grep outline apps/web/lib/actions/partners/update-program-enrollment-preferences.ts --view expanded
ast-grep outline apps/web/lib/zod/schemas/partner-profile.ts --view expanded
ast-grep outline apps/web/lib/zod/schemas/programs.ts --view expanded
Length of output: 5332
---
🏁 Script executed:
#!/bin/bash
set -euo pipefail
base_ref=""
for ref in origin/main main; do
if git rev-parse --verify -q "$ref" >/dev/null; then
base_ref="$ref"
break
fi
done
if [ -z "$base_ref" ]; then
echo "ERROR: main base ref is unavailable"
exit 1
fi
merge_base="$(git merge-base "$base_ref" HEAD)"
printf 'BASE=%s\nMERGE_BASE=%s\n' "$base_ref" "$merge_base"
git diff --stat "$merge_base"...HEAD
git diff --name-status "$merge_base"...HEAD
git diff --find-renames -- "$merge_base"...HEAD -- \
'apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.ts' \
'apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts' \
apps/web/lib/actions/partners/update-program-enrollment-preferences.ts \
apps/web/lib/zod/schemas/partner-profile.ts \
apps/web/lib/zod/schemas/programs.ts \
apps/web/lib/swr/use-partner-links-display.tsx \
apps/web/scripts/migrations/backfill-partner-link-comments.ts \
apps/web/lib/api/links/create-link.ts \
apps/web/lib/api/links/update-link.ts \
apps/web/lib/analytics/get-analytics.ts \
apps/web/prisma/schema/link.prisma \
apps/web/prisma/schema/program.prisma \
apps/web/scripts/misc/restore-program-enrollments.ts
sed -n '1,230p' 'apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts'
sed -n '80,155p' apps/web/lib/zod/schemas/partner-profile.ts
sed -n '1,130p' apps/web/lib/actions/partners/update-program-enrollment-preferences.ts
sed -n '130,180p' apps/web/lib/zod/schemas/programs.ts
sed -n '1,130p' apps/web/scripts/migrations/backfill-partner-link-comments.ts
rg -n -C 3 'updateProgramEnrollmentPreferences\s*\(' apps/web --glob '*.{ts,tsx}'
rg -n -C 3 'partnerLinkComments|partnerLinkTitle' 'apps/web/app/(ee)/api/partner-profile' --glob '*.{ts,tsx}'
Length of output: 18606
---
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,190p' 'apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.ts'
sed -n '1,240p' apps/web/lib/swr/use-partner-links-display.tsx
sed -n '1,240p' 'apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-display.tsx'
sed -n '1,220p' apps/web/ui/modals/partner-link-modal.tsx
sed -n '1,120p' apps/web/prisma/schema/link.prisma
sed -n '1,110p' apps/web/prisma/schema/program.prisma
sed -n '1,130p' apps/web/scripts/misc/restore-program-enrollments.ts
rg -n -C 4 '\bcomments\b|partnerLinkComments|partnerLinkTitle' \
'apps/web/app/(ee)/api/partner-profile/programs/[programId]/links' \
apps/web/ui/modals/partner-link-modal.tsx \
--glob '*.{ts,tsx}' || true
rg -n -C 4 '\bupdateProgramEnrollmentPreferences\b' apps/web --glob '*.{ts,tsx}' || true
fd -a -t d 'migrations|migration' apps/web/prisma . | head -40
fd -a -t f . apps/web/prisma | head -100
Length of output: 50676
---
</details>
@pepeladeira I found one breaking API change.
comments with partnerLinkComments in both POST and PATCH requests and partner-link responses.comments will not update comments. The request succeeds because the schema strips the unknown field.comments will no longer receive it.To avoid the break, accept comments as a deprecated alias during a transition period and return it alongside partnerLinkComments, or release this as a documented versioned API change.
I found no security issue in the reviewed authorization paths. The new enrollment-preferences action verifies that the authenticated partner owns the target enrollment before it updates preferences.
<sub>You are interacting with an AI system.</sub>
<!-- linear-linkback -->
<p><a href="https://linear.app/dubinc/issue/ENG-1852">ENG-1852</a></p>
The workspace creates embed tokens with its API key, so it can read the partner's private title and comments here. Should the embed responses leave these fields out?
Same as the events route: this returns the private title to a token the workspace can create. Should we drop includePartnerLinkTitle here?
This copies Link.comments but leaves them on Link, so the workspace still sees old partner notes. Should we clear them after the copy, or can workspace members also write these comments?
If a partner edits a link before this runs, the new row has no comments and this filter skips it. Should we also fill rows that have empty comments?
The e2e build fails at approve-program-application.ts:181, since the new partnerPreferences JSON column breaks the updateMany data type. Should we leave partnerPreferences out of that object?
Fixed in 524f813ac4. The embed routes now return no partner link title or comments.
Fixed in 524f813ac4, together with the events route.
Fixed in e63929190d. The backfill now also fills existing rows that have no comments.
Kept as is, with a comment in 8e2b6e0071. Workspace members also write Link.comments from the link builder and the API, so clearing it can delete their notes.
Fixed the build error in b67931f265. I also merged main in c37b4b0835, where the earnings chart and table moved to ui/partners/earnings/.
pepeladeira
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
- Add optional private titles and comments to partner links.
- Customize partner link displays between short links and titles, with Full or Cards analytics layouts.
- Save, reset, and set display preferences as defaults.
- Show partner link titles consistently across customer, earnings, events, and analytics views.
- Link titles are supported in filters, charts, tables, tooltips, and top-link reports.
- Existing link comments are preserved during migration.
- Long partner link titles are automatically limited to 120 characters.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---
Deployment Steps
1. Deploy deploy request 607, then merge this PR.
2. After the production deploy is live, run the comments backfill from
apps/web:pnpm run script migrations/backfill-partner-link-commentsIt copies existing partner link comments into
PartnerLinkDetails, 500 at a time. Until it finishes, those older notes stay off the partner link cards.---
How to test
1. In
apps/web, start the local services withdocker compose up -d. Then runpnpm prisma:pushso partner links can store a title and comments, and each program enrollment can store display preferences. If Prisma asks to droppartnerLinkTitleandpartnerLinkCommentsfromLink, runpnpm prisma:push --accept-data-loss.2. From the repo root, run
pnpm dev.3. Sign in to http://partners.localhost:8888 as an approved partner of the Acme program. Open Links at http://partners.localhost:8888/programs/acme/links. If the page says the program is unavailable, use another enrolled Acme partner. Click Create Link. If that button is disabled, open the ⋯ menu on an existing link and click Edit.
4. In New Link or Edit Link, set Title to
Instagram bioand Comments toPrivate note. Leave the destination as it is, then click Create link or Save changes.- The card heading is still the short link, with the destination underneath.
- A page icon appears next to the short link. Hovering it shows Link comments and
Private note.- A link with no title still shows only its short link.
5. Open Display. Click Title, then Set as default. Reload the page.
- The link you titled shows
Instagram bioas the heading, and the short link moves to the line under it.- Links with no title still show the short link.
- Short link and Title switch each other. You cannot turn both off.
- Click Cards. The charts are replaced by the click, lead, and sale counts on the card, and the date picker is disabled.
- Click Full. The charts come back and the date picker works again.
- Change Title back to Short link without clicking Set as default, then click Reset to default. The heading returns to
Instagram bio.6. Open the default link (its Destination URL is greyed out) from the ⋯ menu and click Edit. Change only Title to
Default link, then click Save changes.- The destination is unchanged.
- Comments still shows
Private noteif that note was already saved on this link.- With Title selected in Display, the card heading is
Default link.7. With Title still saved as the default, check the other partner pages. Open the short link once in a new tab first, so Analytics and Events have a click to list.
- Analytics at http://partners.localhost:8888/programs/acme/analytics: under Short Links, the link is labeled
Instagram bioorDefault link, not the short link.- Events at http://partners.localhost:8888/programs/acme/events: the link column uses that same title.
- Earnings and Customers: the Link column and the Link filter use the title for any link that already has a commission or a customer. If those tables are empty, leave them. This does not need a new sale.
8. Sign in to http://localhost:8888 as a member of the
acmeworkspace.- Links at http://localhost:8888/acme/links still shows the short link. Display → Title there uses the link's public title, not
Instagram bio.- Open that link. Comments is empty, and
Instagram biodoes not appear.- Analytics and Events under Short Links also keep the short link or the public title. The partner title and the private note do not appear.