Add partner link titles and comments - #4275
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughPartner 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. ChangesPartner link metadata and display
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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
apps/web/ui/analytics/use-analytics-filters.tsx (1)
426-448: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRefresh 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.🤖 Prompt for AI Agents
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.apps/web/ui/analytics/events/events-table.tsx (1)
174-199: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winDo 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
getPrettyUrlwhen the value is a partner link title.🤖 Prompt for AI Agents
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.
🤖 Prompt for all review comments with AI agents
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.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6c1b54b1-b032-4aa7-b1e8-6ea097767961
📒 Files selected for processing (26)
apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/count/route.tsapps/web/app/(ee)/api/partner-profile/programs/[programId]/earnings/count/route.tsapps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.tsapps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.tsapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/use-partner-customer-filters.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-display.tsxapps/web/lib/analytics/get-analytics.tsapps/web/lib/api/links/create-link.tsapps/web/lib/api/links/update-link.tsapps/web/lib/swr/use-partner-links-display.tsxapps/web/lib/zod/schemas/analytics-response.tsapps/web/lib/zod/schemas/customer-activity.tsapps/web/lib/zod/schemas/links.tsapps/web/lib/zod/schemas/partner-profile.tsapps/web/lib/zod/schemas/partners.tsapps/web/prisma/schema/link.prismaapps/web/scripts/migrations/backfill-partner-link-comments.tsapps/web/ui/analytics/events/events-table.tsxapps/web/ui/analytics/top-links.tsxapps/web/ui/analytics/use-analytics-filters.tsxapps/web/ui/modals/partner-link-modal.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
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.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 446f49c6-d348-484c-b784-2f66e6b96278
📒 Files selected for processing (4)
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-display.tsxapps/web/lib/swr/use-partner-links-display.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
- 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
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/scripts/migrations/backfill-partner-link-comments.ts (1)
36-43: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winCount 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.Proposed fix
- 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;🤖 Prompt for AI Agents
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.
🤖 Prompt for all review comments with AI agents
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.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 599b4e22-120f-4c2d-9e1e-b115587a7c3b
📒 Files selected for processing (4)
apps/web/lib/swr/use-partner-links-display.tsxapps/web/scripts/migrations/backfill-partner-link-comments.tsapps/web/ui/analytics/events/events-table.tsxapps/web/ui/analytics/use-analytics-filters.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
- apps/web/ui/analytics/events/events-table.tsx
- apps/web/lib/swr/use-partner-links-display.tsx
- apps/web/ui/analytics/use-analytics-filters.tsx
|
@coderabbitai full review. any breaking changes or security issues? |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
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.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a2359374-3ed2-4135-9410-4894b1799a7b
📒 Files selected for processing (26)
apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/count/route.tsapps/web/app/(ee)/api/partner-profile/programs/[programId]/earnings/count/route.tsapps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.tsapps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.tsapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/use-partner-customer-filters.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsxapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-display.tsxapps/web/lib/analytics/get-analytics.tsapps/web/lib/api/links/create-link.tsapps/web/lib/api/links/update-link.tsapps/web/lib/swr/use-partner-links-display.tsxapps/web/lib/zod/schemas/analytics-response.tsapps/web/lib/zod/schemas/customer-activity.tsapps/web/lib/zod/schemas/links.tsapps/web/lib/zod/schemas/partner-profile.tsapps/web/lib/zod/schemas/partners.tsapps/web/prisma/schema/link.prismaapps/web/scripts/migrations/backfill-partner-link-comments.tsapps/web/ui/analytics/events/events-table.tsxapps/web/ui/analytics/top-links.tsxapps/web/ui/analytics/use-analytics-filters.tsxapps/web/ui/modals/partner-link-modal.tsx
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
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.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: bea9d121-5817-4bd9-a1c6-d4e08c285a3a
📒 Files selected for processing (10)
apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.tsapps/web/app/(ee)/api/partner-profile/programs/[programId]/links/route.tsapps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsxapps/web/lib/actions/partners/update-program-enrollment-preferences.tsapps/web/lib/analytics/get-analytics.tsapps/web/lib/swr/use-partner-links-display.tsxapps/web/lib/types.tsapps/web/lib/zod/schemas/partner-profile.tsapps/web/lib/zod/schemas/programs.tsapps/web/prisma/schema/program.prisma
🚧 Files skipped from review as they are similar to previous changes (2)
- 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
|
@coderabbitai final review. any breaking changes? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 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 expandedLength 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 -100Length of output: 50676
To avoid the break, accept 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. You are interacting with an AI system. |
Summary by CodeRabbit
New Features
Improvements