Repository navigation
UNI-832: Premium Analytics: Open the dashboard from the admin bar and action bar Stats links - #52905
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Wpcomsh plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
a2d1c02 to
c3030c8
Compare
662b02d to
a216127
Compare
Code Coverage SummaryCoverage changed in 4 files.
1 file is newly checked for coverage.
|
|
Please check this comment: Automattic/wp-calypso#114763 (review) |
chihsuan
left a comment
There was a problem hiding this comment.
Nice work moving the Stats links over! @Nikschavan I tested the admin bar links, Views column and the Simple action bar with v2 on, and they work nicely. Approving. 👍
Before this merges, could we add changelog entries to plugins/jetpack and plugins/wpcomsh, since their users see these links change? I also left two inline notes.
Add a jetpack_stats_url filter to the admin bar Stats links (stats-admin and jetpack-mu-wpcom) and the newsletter action bar post stats link. Premium Analytics hooks it with Stats_Links and maps each view to a dashboard route, so the links fall back to classic Stats when the dashboard is off.
Move the action bar post stats link into Action_Bar::get_post_stats_url() so it can be tested, and give the unknown-view test a post ID so it fails when the post-view check is removed.
Phan rejects @internal on Action_Bar::get_post_stats_url() because its test lives in the Tests namespace. The capability and post ID guards now live in Stats_Links, whose tests already cover them.
Matches the keys of the JS AnalyticsView in _inc/shared/analytics-url.ts, before the filter becomes a public contract.
Personal and Premium plans on Atomic redirect My Jetpack to Stats, so sites with Stats v2 on now land on the dashboard instead.
Links from the Stats widget into the Premium Analytics dashboard encode date ranges with an offset per day; gmt_offset alone cannot follow daylight saving.
…lpers private Deprecate jetpack_stats_post_list_column_url in favor of jetpack_stats_url, drop Post_List_Link now that Stats_Links claims the column, test the action bar link through the rendered bar, and add Jetpack and wpcomsh changelog entries.
ed691ea to
540fdd9
Compare
Fixes UNI-832
Proposed changes
admin.php?page=stats.jetpack_stats_urlfilter, with anarray( 'view' => …, 'id' => … )argument that names the page the link opens rather than the surface it sits on, with the same keys as the JSAnalyticsViewin_inc/shared/analytics-url.ts.Stats_Linksin Premium Analytics hooks it and mapsdashboardto the dashboard root andpostto/post/<id>. Any other view, apostview without a post ID, or a user without theview_analyticscapability keeps the classic URL.Post_List_Linkkeeps its name and public methods and now delegates toStats_Links, so the post list column behaves as before.page=stats; only the link target changes.timezone. The WP Admin dashboard widget, which comes from the Odyssey bundle built in Calypso, links into the dashboard on date ranges in UNI-832: Stats: Open Premium Analytics from the WP Admin dashboard widget wp-calypso#114767 and needs the timezone to keep whole days across daylight-saving changes, whichgmt_offsetalone cannot. It is empty for a site set to a fixed UTC offset.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Self-hosted and Atomic. Use a Jurassic Ninja site with this branch through the Jetpack Beta Tester plugin, with Jetpack connected and the Stats module active. Turn Stats v2 on with
wp option update jetpack_premium_analytics_enabled 1. Keep the standalone Premium Analytics plugin inactive: it turns the dashboard on unconditionally, so the option has no effect while it runs.?page=jetpack-premium-analytics-wp-admin).wp option update jetpack_premium_analytics_enabled 0, reload, and confirm all three links open classic Stats (?page=stats) again.wp-admin/admin.php?page=my-jetpackand confirm it redirects to the dashboard.Simple. Sandbox a Simple site that has Stats v2 on, through its own opt-in or the
jetpack-premium-analyticssticker. Then put this branch's builds on your sandbox by running both of these from the wpcom root: thejetpackbuild carries Premium Analytics, which hooks the filter, and thejetpack-mu-wpcom-pluginbuild carries the site-name "Stats" item.admin.php?page=jetpack-premium-analytics-wp-admin&p=%2F.p=%2Fpost%2F<id>).bin/jetpack-downloader reset jetpackandbin/jetpack-downloader reset jetpack-mu-wpcom-plugin.I checked this with PHP unit tests only. I have not clicked through the links on a site with this branch yet, and the WordPress.com site menu only renders on WordPress.com sites.
Action_Bar_Testcovers the action bar link.