wp-calypso icon indicating copy to clipboard operation
wp-calypso copied to clipboard

Stats: Track authors stats for all wp-admin users

Open kangzj opened this issue 1 year ago • 10 comments

Currently Stats only names authors that have a working WordPress.com connection. All other authors are lumped together as shown here: https://github.com/Automattic/wp-calypso/pull/70808

For a multi-author site to get properly author attribution, each wp-admin account must have its own WordPress.com connection which is difficult for a site admin to manage. An example of how this looks on a real-world site see here: pejTkB-4F-p2

Ideally, instead of requiring a connection for each wp-admin account, we could track this based on a single connection. If we sync up the user table, we could look up the author details and build our author stats around that.

In practice, I imagine the Stats on a multi-user site are most beneficial to the site admin. As an admin, we don't necessarily have control over which accounts have a WordPress.com connection which means getting full-fidelity stats is mostly out of the admin or site owner's hands.

Update: With a brand new site, author information is hidden completely for any users without a WordPress.com connection. For sites showing the "Untracked Author", running a full sync should remove that author from the results. Then end result is that we still only surface meaningful author stats for WordPress.com-connected users.

kangzj avatar Nov 10 '23 00:11 kangzj

Hi @mdbitz, do you have any pointer on this one please? Is the user table synced / could it be synced? Thanks

cc @fgiannar - in case you have any insights.

kangzj avatar Nov 10 '23 00:11 kangzj

It seems core has a public API /wp-json/wp/v2/users/1 - I don't know whether we could leverage this 🤔

kangzj avatar Dec 05 '23 21:12 kangzj

This has occurred with a user here: 7429452-zd-a8c

janmckell avatar Dec 16 '23 08:12 janmckell

Support References

This comment is automatically generated. Please do not edit it.

  • [ ] 7429452-zen
  • [ ] 7502648-zen
  • [ ] pejTkB-1h1-p2#comment-1326

github-actions[bot] avatar Dec 16 '23 08:12 github-actions[bot]

A Jetpack user is writing in about this here: 7502648-zen

jenhooks avatar Dec 27 '23 18:12 jenhooks

I think we are already syncing unconnected users into the jetpack_shadow_users table. At least that is what we use for Search indexing.

gibrown avatar Feb 21 '24 02:02 gibrown

@gibrown more discussions here: https://github.com/Automattic/jpop-issues/issues/8824

kangzj avatar Feb 21 '24 07:02 kangzj

We have the feature occasionally requested, and we really want to support it.

All other authors are lumped together as shown here: https://github.com/Automattic/wp-calypso/pull/70808

This statement is not true. I don't think we ever supported 'Untracked Authors' before. The PR that added 'Untracked Authors' is only a interim fix as the backend is giving out some records that have empty user information. This is because either the wpcom users are removed somehow, or there was some kind of discrepancy in the synced data. In both cases tho, the post_author column is not 0 but with no valid wpcom users associated.

Second which is a requested feature is to sync all authors' information for sites even if they are not WPCOM users. That would definitely have some implications, at the moment we do have a jetpack_shadow_users table with info for the users.

We do have a shadow user table but we don't have the relations between posts and unconnected authors, because post_author is replaced with wpcom user id if exists otherwise 0. We'll need that to support tracking unconnected authors. As suggested by @darssen, I wonder whehter @Automattic/jetpack-vulcan can help? I understand this might be a big one, just want to know the options at the stage.

More discussions here: https://github.com/Automattic/jpop-issues/issues/8824

cc @foleynotrose

kangzj avatar Feb 21 '24 21:02 kangzj

we don't have the relations between posts and unconnected authors, because post_author is replaced with wpcom user id if exists otherwise 0

@kangzj this is incorrect it is stored in post_meta on the cache site. We have indexing code that handles these cases so I think we just need to do a similar thing for the Stats apis.

gibrown avatar Feb 21 '24 23:02 gibrown

Thanks for the information @gibrown

So _jetpack_post_author_external_id in table wp_blabla_postmeta is the key! Awesome! I don't think we have any blockers then! 👍

kangzj avatar Feb 22 '24 01:02 kangzj

Non-wpcom authors are now supported. More information could be found pejTkB-1h1-p2#comment-1326.

kangzj avatar Apr 29 '24 21:04 kangzj