Skip to content

UNI-1091: Premium Analytics: Add Bot activity to the post page - #55540

Draft
Nikschavan wants to merge 3 commits into
add/uni-1088-bot-activityfrom
add/uni-1091-post-page-ai-widgets
Draft

Nikschavan wants to merge 3 commits into
add/uni-1088-bot-activityfrom
add/uni-1091-post-page-ai-widgets

Conversation

@Nikschavan

@Nikschavan Nikschavan commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Fixes UNI-1110
Related to UNI-1091

Proposed changes

Builds on #55485 (Bot activity), which builds on #55334. This PR's own changes are the last two commits. It is the first part of UNI-1091: the other post page widgets come in later PRs.

  • Add the Bot activity widget to the Post traffic section of the post page, counted for that post only. The page report reuses that layout, so pages get it too. It sits above All-time traffic, which stays the last card.
  • The edge logs have no post ID, so the edge templates scope a report by the page's path (url=/2026/11/21/hello-world/), not by post_id. The widget still passes reportParams as it does on the AI tab. When they carry a post_id, the data hook reads the post's permalink from stats/post/<id>?fields=post, the query the post page header already runs, so no extra request goes out, and sends the permalink's path and query string as url. This works like the UTM widget, which also reads post_id from reportParams, but stats/utm takes the ID directly.
  • The report does not run until the path is known. Without that wait, the first request would count the whole site and show it under the post's heading.
  • The widget shows only where the AI tab shows. The ai-traffic/* widgets join the widget support check in widget-type-support.php, as File downloads does for WPCOM Simple and the video widgets do for VideoPress: off the AI traffic surfaces they do not register, and default layouts drop them. Requests by source and Top AI companies get the same gate, so the layout lists Bot activity with no condition of its own.
  • The post page header now also takes its live-post link from the Stats permalink, after the core-data link and the URL a list page carries. A post type with show_in_rest: false opened from a bookmark or a notification had no link before.

Edge cases this does not handle yet:

  • The edge keeps paths exactly as the client sent them. A non-ASCII slug arrives as both %e3%81%82 and %E3%81%82, and the permalink matches only the lower-case form, which is the one WordPress writes. On sites with Japanese and Chinese slugs, that misses about half of those requests. The fix belongs in the templates (compare the path without regard to case), so I will raise it on DLINK-570.
  • After a slug change, requests to the old path do not count for the post. DLINK-582 matches requests to the post itself.
  • The "latest posts" home page (post 0) has no permalink, so the widget shows its empty state there.

On a local site with made-up edge data:

Before After
The post page: the likes, comments and UTM row, then All-time traffic as the last card The post page: a Bot activity card with six bot groups and this post's requests, then All-time traffic as the last card
All-time traffic follows the likes, comments and UTM row Bot activity, with the post's own requests per group, sits above All-time traffic

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

Edge data exists only for VIP sites, so a site you can test on gets an empty widget. You can still check that the request is scoped to the post. Check out this branch on a Jetpack Docker site, or sync it to a Jurassic Ninja site, and build plugins/premium-analytics.

  • Turn on the AI traffic surfaces with an mu-plugin:
    add_filter( 'jetpack_feature_flag_enabled_jetpack-stats-ai-tab', '__return_true' ); add_filter( 'jetpack_premium_analytics_ai_traffic_available', '__return_true' );
  • Open Stats › Posts & pages and open a post.
  • At the bottom of Post traffic, Bot activity shows.
  • In the browser's network panel, find the stats/ua-queries?template=bot-activity request. It has url= set to the post's path, such as %2F2026%2F11%2F21%2Fhello-world%2F. No stats/ua-queries request goes out without url.
  • Remove the two filters and reload: the post page has no Bot activity widget, and the AI tab is gone.
  • Open the AI tab with the filters on. Bot activity there sends no url.

I checked the steps above on a local site, with a local mu-plugin that answers stats/ua-queries with made-up rows. I did not check against the real endpoint on a VIP site.

@Nikschavan Nikschavan added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress labels Nov 27, 2026
@Nikschavan Nikschavan self-assigned this Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/uni-1091-post-page-ai-widgets branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/uni-1091-post-page-ai-widgets

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: December 8, 2026
    • Code freeze: December 7, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Premium Analytics 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.


Stats Data 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.

@jp-launch-control

jp-launch-control Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

No summary data is available for parent commit b28e028, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for b28e028 is available.

Full summary · PHP report · JS report

The Stats post row carries the post's public URL for every post type. Type it, and fall back to it in the post page header when core data has no entity and no list page carried a URL.
…e post's path

The edge logs have no post ID, so a post-scoped edge report reads the post's path from its Stats permalink and sends it as url. The report waits for the path, so it never counts the whole site under a post's heading. The ai-traffic widgets join the widget support check, as File downloads and the VideoPress widgets do, so they register and appear in default layouts only where the AI traffic surfaces are available.
…ports

Bot activity moves above it, so the reports still end on the post's whole history.
@Nikschavan
Nikschavan force-pushed the add/uni-1091-post-page-ai-widgets branch from b6ba11d to 8580273 Compare November 27, 2026 10:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Plugin] Stats Data [Status] In Progress [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant