feat: add campaign performance benchmarking analytics and recommendat…#451
feat: add campaign performance benchmarking analytics and recommendat…#451Mohitmhatre32 wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughThe dashboard analytics API now returns benchmark rates for open and reply performance. The analytics page renders benchmark recommendations, updates them on time-range changes, and charts open and reply rates with benchmark overlays. Tests cover the new benchmark data under tenant isolation. ChangesCampaign Performance Benchmarking Analytics
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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 `@frontend/analytics.html`:
- Around line 518-525: The Y-axis in the chart config still displays raw numeric
ticks, so update the existing y scale configuration to format tick labels as
percentages as well. Add a tick callback within the chart options around the
y-axis setup in the analytics chart so the axis labeling matches the
percentage-based tooltip and the “Percentage (%)” title.
- Around line 279-369: The benchmark insights in updateBenchmarkInsights
currently treat missing volume as zero, so empty campaigns render false “below
benchmark” warnings. Add a guard in updateBenchmarkInsights that checks
emails_sent (or equivalent sent volume) before building openHTML and replyHTML,
and when it is 0 or absent, either hide benchmark-insights-section or render a
neutral empty state instead of the warning cards.
🪄 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 Plus
Run ID: d0ca5f50-b3b7-4146-9b2d-85935ecbb285
📒 Files selected for processing (4)
.gitignorebackend/campaigns/tests.pybackend/campaigns/views.pyfrontend/analytics.html
Pull Request
🔗 Related Issue
Closes #406
📝 Summary of Changes
backend/campaigns/views.py):DashboardAnalyticsViewresponse payload to return standard industry benchmarks (open_rate: 20.0andreply_rate: 5.0) within a newbenchmarksdictionary structure.backend/campaigns/tests.py):CampaignWorkflowTeststo verify tenant data isolation and that the benchmark values are correctly returned.frontend/analytics.html):--paused-bg/--paused-fgcolors displays actionable advice (personalizing subject lines, using dynamic fields like{{first_name}}, shortening copy, refining Call-to-Actions).--active-bg/--active-fgis shown.🏷️ Type of Change
🧪 Testing
Steps to test:
frontenddirectory:python manage.py test campaigns.tests.CampaignWorkflowTests.test_dashboard_analytics_isolates_data_by_tenant campaigns.tests.CampaignWorkflowTests.test_dashboard_analytics_requires_authentication/analytics.html). Verify that the Performance Insights & Recommendations card loads correctly, displays proper comparative values (e.g.0% vs 20%), has readable contrast, and that the Campaign Performance chart displays open/reply rate bars alongside dashed benchmark reference lines.📸 Screenshots (if applicable)
(Please attach screenshots of the Analytics dashboard here)


✅ Checklist
Summary by CodeRabbit