Fetaure: Add Analytics Admin Page, Navigation & Controls#203
Fetaure: Add Analytics Admin Page, Navigation & Controls#203
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new “Analytics” admin submenu under the plugin’s Mailchimp menu, providing UI controls for selecting a date range (presets + custom), filtering by list, and linking out to Mailchimp’s audience analytics dashboard. It also renames the existing settings submenu entry to “Form Settings” to distinguish it from the new Analytics page.
Changes:
- Register a new Analytics admin submenu page and conditionally enqueue its CSS/JS (including Chart.js).
- Add an Analytics template with date range + list filters and an external deep link to Mailchimp analytics.
- Attempt to rename the default settings submenu item to “Form Settings”.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| mailchimp.php | Bootstraps the new Analytics class during plugin load. |
| includes/class-mailchimp-analytics.php | Registers the Analytics submenu and enqueues Analytics assets + Chart.js. |
| includes/class-mailchimp-admin.php | Adds a submenu entry intended to rename the default “Mailchimp” settings submenu item. |
| includes/admin/templates/analytics.php | New Analytics admin page markup (filters + deep link). |
| assets/js/analytics.js | Implements filter interactions and dispatches a refresh event on changes. |
| assets/css/analytics.css | Styles the Analytics filters/content/deep link layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
iamdharmesh
left a comment
There was a problem hiding this comment.
Thanks for the PR, @alaca. This looks good overall. I’ve added a few points for discussion, but otherwise this looks good. There is also some feedback from Copilot, could you please review it and address the valid items? Feel free to ignore anything that isn’t relevant.
Thank you.
|
|
||
| $user = get_option( 'mc_user' ); | ||
| $is_logged_in = ! ( ! $user || ( ! get_option( 'mc_api_key' ) && ! mailchimp_sf_get_access_token() ) ); | ||
| $lists = get_option( 'mailchimp_sf_lists', array() ); |
There was a problem hiding this comment.
Better to use existing function. Something like:
$lists = ( new Mailchimp_List_Subscribe_Form_Blocks() )->get_lists();
Though we should move get_lists() to utils, but it’s fine not to handle that in this PR.
There was a problem hiding this comment.
This seems not resolved yet.
|
@iamdharmesh this is ready for your review. |
Description of the Change
Adds a new "Analytics" submenu page under the Mailchimp admin menu
Includes date range selector (presets + custom date pickers), list filter dropdown, and a deep link to Mailchimp's audience analytics dashboard
Renames the existing top-level submenu item to "Form Settings" so both pages are clearly distinguished
Closes #197
How to test the Change
Verify "Form Settings" and "Analytics" appear as submenu items under Mailchimp when an account is connected
Verify the Analytics submenu does not appear when no Mailchimp account is connected
Confirm date range dropdown works with all presets and shows resolved date text
Confirm selecting "Custom" reveals from/to date pickers
Confirm that the list filter populates from connected lists and defaults to the currently selected list
Confirm that changing any filter dispatches a refresh event
Verify the deep link opens the Mailchimp dashboard in a new tab
Verify that Chart.js and analytics assets only load on the Analytics page
Changelog Entry
Credits
Props @alaca
Checklist: