Skip to content

PartnerReferralLink email variable#3934

Open
pepeladeira wants to merge 2 commits into
mainfrom
partner-referral-link-email-variable
Open

PartnerReferralLink email variable#3934
pepeladeira wants to merge 2 commits into
mainfrom
partner-referral-link-email-variable

Conversation

@pepeladeira
Copy link
Copy Markdown
Collaborator

@pepeladeira pepeladeira commented May 21, 2026

Summary by CodeRabbit

  • New Features

    • Campaign emails now support a new PartnerReferralLink template variable that dynamically generates partner-specific referral links. These links render as clickable anchors in emails across preview, broadcast, and workflow systems.
  • Tests

    • Added test coverage verifying the new template variable renders correctly as clickable anchors with appropriate link attributes.

Review Change Stack

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 21, 2026

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

Project Deployment Actions Updated (UTC)
dub Ready Ready Preview May 21, 2026 6:53pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6f1484a6-6f46-4723-b948-ef3ccee94425

📥 Commits

Reviewing files that changed from the base of the PR and between 396ec06 and 7768b35.

📒 Files selected for processing (6)
  • apps/web/app/(ee)/api/campaigns/[campaignId]/preview/route.ts
  • apps/web/app/(ee)/api/cron/campaigns/broadcast/route.ts
  • apps/web/lib/api/workflows/execute-send-campaign-workflow.ts
  • apps/web/lib/api/workflows/interpolate-email-template.ts
  • apps/web/lib/zod/schemas/campaigns.ts
  • apps/web/tests/misc/interpolate-email-template.test.ts

📝 Walkthrough

Walkthrough

The PR introduces a new PartnerReferralLink email template variable for campaigns, replacing hardcoded referral URLs with computed values generated by a constructPartnerReferralLink helper across preview, broadcast, and workflow execution paths. It extends the email template interpolation system to render the placeholder as a clickable anchor for valid URLs and includes test coverage.

Changes

Partner Referral Link Template Variable

Layer / File(s) Summary
Template Variable Schema Definition
apps/web/lib/zod/schemas/campaigns.ts
The EMAIL_TEMPLATE_VARIABLES exported constant adds "PartnerReferralLink" to the allowable template placeholders.
Email Template Interpolation and Test
apps/web/lib/api/workflows/interpolate-email-template.ts, apps/web/tests/misc/interpolate-email-template.test.ts
Documentation and logic now handle both PartnerLink and PartnerReferralLink, converting valid HTTP/HTTPS URLs to clickable anchors with target="_blank" and rel="noopener noreferrer", with a test verifying the new placeholder renders correctly as an anchor.
Campaign Preview Email
apps/web/app/(ee)/api/campaigns/[campaignId]/preview/route.ts
Imports constructPartnerReferralLink and uses it to generate the PartnerReferralLink value with a fixed partner username and the current program slug.
Campaign Broadcast/Cron Email
apps/web/app/(ee)/api/cron/campaigns/broadcast/route.ts
Imports constructPartnerReferralLink, extends the partner user Prisma selection to include the username field, and uses the helper to compute PartnerReferralLink with the partner object and program slug.
Campaign Workflow Execution Email
apps/web/lib/api/workflows/execute-send-campaign-workflow.ts
Imports constructPartnerReferralLink and uses it to populate the PartnerReferralLink template variable when rendering campaign email HTML.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • steven-tey

Poem

🐰 A referral link springs forth with flair,
Constructed once, used everywhere with care,
From preview, broadcast, workflow's gentle hand,
Partner referrals bloom across the land! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'PartnerReferralLink email variable' accurately describes the main change: adding a new email template variable for partner referral links across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch partner-referral-link-email-variable

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.

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.

1 participant