Skip to content

Feature/form performance chart#207

Open
alaca wants to merge 8 commits intofeature/200from
feature/form-performance-chart
Open

Feature/form performance chart#207
alaca wants to merge 8 commits intofeature/200from
feature/form-performance-chart

Conversation

@alaca
Copy link
Copy Markdown
Collaborator

@alaca alaca commented Apr 21, 2026

Description of the Change

Adds the Forms performance over time chart to the Analytics admin page.

image

How to test the Change

  1. Submit a few forms on the frontend to generate tracking data
  2. Navigate to Mailchimp -> Analytics

Changelog Entry

Added - New "Forms performance over time" chart on the Analytics admin page, showing submissions over time for the selected list and date range.

Credits

Props @alaca

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@alaca alaca requested a review from iamdharmesh April 21, 2026 14:27
@alaca
Copy link
Copy Markdown
Collaborator Author

alaca commented Apr 21, 2026

@iamdharmesh I based this branch on your branch feature/200

@iamdharmesh iamdharmesh changed the base branch from feature/data-layer-and-form-event-tracking to feature/200 April 21, 2026 16:44
@iamdharmesh iamdharmesh requested a review from Copilot April 21, 2026 16:47
@iamdharmesh iamdharmesh added this to the 2.1.0 milestone Apr 21, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_performance endpoint 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.

Comment thread includes/class-mailchimp-form-performance.php Outdated
Comment thread includes/class-mailchimp-form-performance.php
Comment thread includes/admin/templates/analytics.php Outdated
Comment thread includes/class-mailchimp-form-performance.php
Comment thread assets/js/analytics.js
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/cypress/e2e/settings/analytics.test.js
Comment thread includes/class-mailchimp-form-performance.php Outdated
Comment on lines +119 to +135
// Build the complete ordered set of bucket keys covering the range.
$buckets = array();
$one_day = new DateInterval( 'P1D' );
$cursor = $from_dt;
while ( $cursor <= $to_dt ) {
$date = $cursor->format( 'Y-m-d' );
$key = $this->get_bucket_key( $date, $interval, $tz );
if ( ! isset( $buckets[ $key ] ) ) {
$buckets[ $key ] = array(
'key' => $key,
'label' => $this->get_bucket_label( $date, $interval, $tz ),
'views' => 0,
'submissions' => 0,
);
}
$cursor = $cursor->add( $one_day );
}
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aggregate() builds buckets by iterating over every day in the requested range, even when the chosen interval is monthly/quarterly/yearly. For large custom ranges this is O(days) work and can be slow in admin-ajax. Consider iterating by bucket interval boundaries instead (or enforcing a max range), so runtime scales with number of buckets rather than number of days.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iteration cost is negligible at realistic date ranges. Proper bucket-step refactor can land if it ever becomes a performance concern

Comment thread includes/class-mailchimp-form-performance.php Outdated
alaca and others added 4 commits April 22, 2026 11:48
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.

3 participants