Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post list: Add track events for quick links and stats #40935

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

BogdanUngureanu
Copy link
Contributor

Related to Automattic/wp-calypso#95621

Proposed changes:

  • Add tracking events for Post list quick links and post list stats

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

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

Testing instructions:

  • Test the PR on both AT and Simple
  • Go to Posts/Pages and make sure that when you click on the quick links you have a wpcom_post_list_quick_links_clicked triggered
  • Go to Posts/Posts and make sure that when you click on the Stats in the post list a wpcom_post_list_stats_clicked event is triggered

Copy link
Contributor

github-actions bot commented Jan 9, 2025

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 WordPress.com Simple 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, and enable the update/tracking-for-posts-list branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/tracking-for-posts-list
    

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

Copy link
Contributor

github-actions bot commented Jan 9, 2025

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 Team Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Jan 9, 2025
@BogdanUngureanu BogdanUngureanu added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jan 9, 2025
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Is that something that could be added directly to the Post List package? If the two are closely related, it may be easier to maintain in the future.

If we do it in the package directly, maybe we'd be able to add the tracking to the links without having to rely on JavaScript, fully relying on the Automattic\Jetpack\Tracking class, that handles enqueuing Tracks as well as managing whether a site has already agreed to our ToS. I haven't dealt with Tracks in PHP in a long time, but I believe it should be enough to add the jptracks class to a link, and a data-jptracks-name with the non-prefixed name of the event you want to fire.

@BogdanUngureanu
Copy link
Contributor Author

Hi @jeherve! I think I picked a confusing name for the PR. :)

This PR is part of the Remove duplicate views project and these tracks events are added only for WPCOM Simple and Atomic sites in order to have some parity with the events we trigger in Calypso pages and posts screens (/pages/ and /posts/).

In Calypso, we have tracks for all of the post links we display in the hamburger menu:
Screenshot 2025-01-10 at 15 23 20

The equivalent for this menu is the quick links (below the post title) and the "Stats" column.

@jeherve
Copy link
Member

jeherve commented Jan 13, 2025

The equivalent for this menu is the quick links (below the post title) and the "Stats" column.

Right, and we do some amount of customizing that classic Posts list screen with the Post List package already.

* Sets up Post List action callbacks.

That package is loaded on Atomic sites here:

$config = new Config();
$config->ensure( 'post_list' );

Since you're aiming to further customize the post list screen, I figured that package may be a good place for it?

@BogdanUngureanu
Copy link
Contributor Author

@jeherve I see your point and it could work. My concern was that since these events are meant only for WPCOM (Atomic and Simple), shipping it in posts-list package would mean also shipping it in Jetpack - the plugin.

We could of course add some guards to only load it on WPCOM, but we would still ship the actual code with the plugin. :)

I don't have a strong preference here. :) If you think it makes more sense to have it in posts-list package, let me know and I'll move it there. :)

@jeherve
Copy link
Member

jeherve commented Jan 14, 2025

I'm not particularly worried about self-hosted sites here since the feature is not automatically activated and not surfaced in the modern settings page. Very few sites consequently use the module today. But even for those that do, tracking can work on self-hosted as well, and we can split between environments in Tracks.

That said, I do not have any strong preference here either, feel free to ship this in the mu-wpcom plugin if you'd prefer. :)

@dsas
Copy link
Contributor

dsas commented Jan 14, 2025

If changing it to work on self-hosted sites too (I use it!) then I guess we'd need to update "Does this pull request change what data or activity we track or use?" in the PR description, and I'm not sure what happens after that.

@jeherve
Copy link
Member

jeherve commented Jan 14, 2025

and I'm not sure what happens after that.

Mostly nothing from your end. The HEs in charge of updating our support docs use that data to ensure the privacy sections of our support docs stay up to date.

Copy link
Member

@mmtr mmtr left a comment

Choose a reason for hiding this comment

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

Is that something that could be added directly to the Post List package?

To be honest, I wondered the same when I ported other Calypso features to WP Admin as part of the "Remove duplicate views" experiment (pfYzsZ-1o5-p2).

Should we port these features to Jetpack(-the-plugin) rather than to jetpack-mu-wpcom?

I think we have been relying more on jetpack-mu-wpcom to speed up the project process and don't involve Jetpack sites into the product discussion, but it's true that some of these features could benefit self-hosted sites too.

Also, IIRC, jetpack-mu-wpcom is deployed more frequently to WP.com Atomic sites than Jetpack(-the-plugin), which can be another contributing factor.

Said that, I would lean towards migrating all these missing features to jetpack-mu-wpcom for now, just for the sake of keeping the current momentum we have with the project, and remove the Calypso screens as soon as possible.

But I wouldn't be against reconsidering this approach either, if folks strongly feel we should make these features available to Jetpack sites too.

cc @Copons

section: name,
}

window._tkq.push( [ 'recordEvent', 'wpcom_post_list_quick_links_clicked', props ] );
Copy link
Member

Choose a reason for hiding this comment

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

Is window._tkq always guaranteed to exist? I always assumed we need to initialize just in case. See PCYsg-4KT-p2

window._tkq = window._tkq || [];

I think the user is not identified by default when using window._tkq directly, and you need to do it manually:

However, this library does not automatically populate the blog_id property, nor does it automatically identify the current user.

See this example for reference.

And now that I found that reference, maybe you can use the wpcomTrackEvent helper?

@Copons
Copy link
Contributor

Copons commented Jan 16, 2025

Said that, I would lean towards migrating all these missing features to jetpack-mu-wpcom for now, just for the sake of keeping the current momentum we have with the project, and remove the Calypso screens as soon as possible.

But I wouldn't be against reconsidering this approach either, if folks strongly feel we should make these features available to Jetpack sites too.

Agreed!

To be perfectly blunt, if we were to fill all the gaps, the Untangling project would take 10 years, and would be deprioritized in 2 months. 😄


?>
<script>
document.querySelectorAll( '.column-primary .row-actions span' ).forEach( ( span ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work if the user uses the Quick Edit to save a change and then uses a quick link?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[mu wpcom Feature] Posts [Package] Jetpack mu wpcom WordPress.com Features [Status] Needs Team Review [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants