Lead and sales rewards metadata condition#4032
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR adds complete support for metadata-based reward conditions in the partner rewards system. It introduces a new ChangesMetadata-Based Reward Conditions Feature
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. 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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/ui/partners/program-reward-modifiers-tooltip.tsx (1)
179-220:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRender numeric
0condition values in tooltip text.At Line 182,
condition.value && ...suppresses valid falsy operands like0(e.g.,greater_than 0), so the tooltip can render an incomplete condition.Suggested fix
- {condition.value && + {condition.value !== undefined && + condition.value !== null && + (typeof condition.value !== "string" || + condition.value.trim() !== "") && (condition.attribute === "country" ? // Country names Array.isArray(condition.value)🤖 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/partners/program-reward-modifiers-tooltip.tsx` around lines 179 - 220, The tooltip logic is skipping falsy but valid values like 0 because it uses "condition.value && ..."; update the check to explicitly allow 0 by replacing that truthy check with an explicit null/undefined check (e.g., condition.value !== undefined && condition.value !== null, or condition.value != null) before the big rendering expression so all the downstream branches (country lookup using COUNTRIES, subscription formatting via formatSubscriptionDuration, product label handling, Array.isArray branches using attribute?.options, currencyFormatter, formatDateTime, and options lookup on attribute) still run for numeric 0 or other valid falsy values; keep the rest of the rendering logic and symbols (CONDITION_OPERATOR_LABELS, COUNTRIES, formatSubscriptionDuration, currencyFormatter, formatDateTime, attribute) unchanged.
🤖 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/.env.example`:
- Line 32: The QSTASH_URL variable is quoted and triggers dotenv-linter's
QuoteCharacter rule; update the QSTASH_URL entry (the QSTASH_URL key in the .env
example) to use an unquoted URL value (remove the surrounding double quotes) so
the line reads a bare URL and passes the linter.
---
Outside diff comments:
In `@apps/web/ui/partners/program-reward-modifiers-tooltip.tsx`:
- Around line 179-220: The tooltip logic is skipping falsy but valid values like
0 because it uses "condition.value && ..."; update the check to explicitly allow
0 by replacing that truthy check with an explicit null/undefined check (e.g.,
condition.value !== undefined && condition.value !== null, or condition.value !=
null) before the big rendering expression so all the downstream branches
(country lookup using COUNTRIES, subscription formatting via
formatSubscriptionDuration, product label handling, Array.isArray branches using
attribute?.options, currencyFormatter, formatDateTime, and options lookup on
attribute) still run for numeric 0 or other valid falsy values; keep the rest of
the rendering logic and symbols (CONDITION_OPERATOR_LABELS, COUNTRIES,
formatSubscriptionDuration, currencyFormatter, formatDateTime, attribute)
unchanged.
🪄 Autofix (Beta)
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
Run ID: 7834f79f-5668-4266-bea9-f64a458aa69d
📒 Files selected for processing (13)
.github/workflows/e2e.yaml.github/workflows/playwright.yamlapps/web/.env.exampleapps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.tsapps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.tsapps/web/lib/api/conversions/track-lead.tsapps/web/lib/api/conversions/track-sale.tsapps/web/lib/partners/evaluate-reward-conditions.tsapps/web/lib/zod/schemas/rewards.tsapps/web/tests/rewards/reward-conditions.test.tsapps/web/ui/partners/program-reward-modifiers-tooltip.tsxapps/web/ui/partners/rewards/add-edit-reward-sheet.tsxapps/web/ui/partners/rewards/rewards-logic.tsx
|
|
||
| # Upstash QStash – required for queues and background jobs | ||
| # Get your QStash Token here: https://upstash.com/docs/qstash/overall/getstarted | ||
| QSTASH_URL="https://qstash-us-east-1.upstash.io" |
There was a problem hiding this comment.
Remove unnecessary quotes from QSTASH_URL to satisfy dotenv-linter.
Line 32 is flagged by dotenv-linter (QuoteCharacter). Use an unquoted URL value to avoid lint noise.
Suggested fix
-QSTASH_URL="https://qstash-us-east-1.upstash.io"
+QSTASH_URL=https://qstash-us-east-1.upstash.io📝 Committable suggestion
‼️ 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.
| QSTASH_URL="https://qstash-us-east-1.upstash.io" | |
| QSTASH_URL=https://qstash-us-east-1.upstash.io |
🧰 Tools
🪛 dotenv-linter (4.0.0)
[warning] 32-32: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
🤖 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/.env.example` at line 32, The QSTASH_URL variable is quoted and
triggers dotenv-linter's QuoteCharacter rule; update the QSTASH_URL entry (the
QSTASH_URL key in the .env example) to use an unquoted URL value (remove the
surrounding double quotes) so the line reads a bare URL and passes the linter.
Source: Linters/SAST tools
Summary by CodeRabbit
Release Notes
New Features
QSTASH_URLenvironment variable configuration.Tests
Chores