Feature/form performance chart#207
Conversation
|
@iamdharmesh I based this branch on your branch feature/200 |
There was a problem hiding this comment.
Pull request overview
Adds a new “Forms performance over time” chart to the Mailchimp → Analytics admin page, backed by a new admin-only AJAX endpoint that aggregates local analytics DB rows into chart-ready series.
Changes:
- Registers a new
wp_ajax_mailchimp_sf_get_form_performanceendpoint and data provider for per-form submissions-over-time aggregation. - Adds a new Analytics card (markup + JS module) rendering a Chart.js line chart with loading/empty/error states.
- Adds SCSS styling for the new Form Performance analytics section.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
mailchimp.php |
Bootstraps the new Form Performance data provider on plugin init. |
includes/class-mailchimp-form-performance.php |
Implements the AJAX handler, DB query, and bucketing/aggregation logic for the chart payload. |
includes/admin/templates/analytics.php |
Adds the new “Forms performance over time” card markup, error banner, and canvas placeholder. |
assets/js/analytics.js |
Introduces a new frontend module that fetches/render form performance data and manages UI states. |
assets/css/analytics.scss |
Styles the new Form Performance section to match existing analytics card patterns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…into feature/form-performance-chart
iamdharmesh
left a comment
There was a problem hiding this comment.
Thanks for PR @alaca. As the work still pending in this PR, I haven't reviewed this yet but just added some notes to existing feedback worth resolving. Could you please help with address those?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| describe('Form performance chart (stubbed)', () => { | ||
| const analyticsUrl = '/wp-admin/admin.php?page=mailchimp_sf_analytics'; | ||
|
|
||
| function stubFormPerformance(replyFn) { | ||
| cy.intercept('POST', '**/admin-ajax.php', (req) => { | ||
| if (!isFormPerformanceRequest(req)) { | ||
| req.continue(); | ||
| return; | ||
| } | ||
| const payload = typeof replyFn === 'function' ? replyFn(req) : replyFn; | ||
| req.reply({ | ||
| statusCode: 200, | ||
| headers: { 'content-type': 'application/json; charset=UTF-8' }, | ||
| body: payload, | ||
| }); | ||
| }).as('formPerformance'); | ||
| } |
There was a problem hiding this comment.
The Form performance Cypress tests only stub the mailchimp_sf_get_form_performance admin-ajax call, but assets/js/analytics.js dispatches mailchimp-analytics-refresh on page init, which also triggers a mailchimp_sf_get_subscriber_activity request. Without stubbing that request here, these tests can hit the real subscriber-activity endpoint (and potentially the external Mailchimp API), making CI runs flaky. Consider stubbing subscriber activity in this describe as well (e.g., return a basic wpJsonSuccess(buildSuccessData())) so the page’s other analytics section doesn’t make real network calls during these tests.
iamdharmesh
left a comment
There was a problem hiding this comment.
Thanks for the changes @alaca. This looks good now. I just added minor comment regarding empty state. Once that is resolved. we are good to go here.
| const totalSubs = payload.total_submissions || 0; | ||
|
|
||
| // Empty when there's literally no tracked activity for the range. | ||
| if (rows.length === 0 || (totalViews === 0 && totalSubs === 0)) { |
There was a problem hiding this comment.

Description of the Change
Adds the Forms performance over time chart to the Analytics admin page.
How to test the Change
Changelog Entry
Credits
Props @alaca
Checklist: