Stats tracking code missing from AMP pages since 6.2
Steps to reproduce the issue
- Create a test site with Jetpack 6.1.1
- Connect Jetpack and enable stats.
- Install the AMP plugin: https://wordpress.org/plugins/amp/
- Publish a post.
- View the source code of the /amp/ version of a post. See the tracking code starting with
<amp-pixel - Upgrade to Jetpack 6.2
- View the source code again.
What I expected
The stats tracking code should still be there.
What happened instead
It's not there.
Reported in 1210111-zen
This is because the AMP plugin was updated to back off of adding JP support in 6.2: https://github.com/Automattic/amp-wp/commit/c280a5177aec0f9707e042326b399ef6e56b5905
Jetpack is checking for amp_is_canonical : https://github.com/Automattic/jetpack/commit/1bd4eaa3c6dee1e8fd10c10d5c8598c7fd27d41d#diff-f26e9ed01c2ca4e906e59c7c15b45ab1R69
That function, though, is to check if themes are declaring their own AMP support, thus short-circuiting the default templates: https://github.com/Automattic/amp-wp/blob/6e6275b84bba131010a90dbea4d325986728057b/amp.php#L274
EDIT: https://github.com/Automattic/jetpack/pull/9625 looks like it should have addressed this, so might be something else. No joy nevertheless for a pixel in amp.
I think I may have come across a site experiencing behaviour related to this in #1208872-zen.
Tracking code is present on non-AMP pages, but missing on AMP pages, which is causing stats from Twitter to not report correctly in Calypso.