Skip to content

Conversation

@pfefferle
Copy link
Member

@pfefferle pfefferle commented Dec 15, 2025

Fixes #2597

Proposed changes:

  • Implements Fediverse statistics dashboard widget using React/TypeScript
  • Statistics class for collecting engagement metrics (likes, reposts, comments)
  • REST API endpoint for fetching statistics data
  • Dashboard widget showing:
    • Stat highlights (followers, posts, likes, reposts) with year-over-year comparison
    • Interactive line chart for monthly engagement
    • Chart legend showing engagement types
    • Top supporter section
    • Top posts section
  • Support for stored monthly stats (for historical data)
  • CLI command for populating demo data (local dev only)

Removed from original scope:

  • Shareable HTML wrapped card (will be a separate block later)
  • Annual email template

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

Setup demo data (optional):

npx wp-env run cli wp activitypub stats populate

Dashboard Widget:

  1. Go to WordPress Dashboard (/wp-admin/)
  2. Look for "Fediverse Stats" widget
  3. If multiple actors enabled, use the selector to switch between user/blog stats
  4. Verify:
    • Stat highlights show followers, posts, likes, reposts counts
    • Line chart displays monthly engagement data
    • Legend shows engagement types with colors
    • Top supporter section (if data exists)
    • Top posts section (if data exists)

Clear demo data:

npx wp-env run cli wp activitypub stats clear

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Add Fediverse statistics dashboard widget with engagement metrics and charts.

Implements monthly/annual statistics collection and display:
- Core Statistics class for collecting engagement metrics
- Scheduler for monthly stats collection and annual compilation
- Dashboard widget showing stats with charts
- Annual email template for year-end summaries
- Shareable wrapped card for public sharing

Known issues:
- URL rewrite rules for wrapped card need debugging (year parameter not captured)
- Stats display shows 0 values on HTTP requests despite correct query var registration

Related to #2597
@pfefferle pfefferle added the Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary. label Dec 15, 2025
@pfefferle pfefferle self-assigned this Dec 15, 2025
@pfefferle pfefferle added the Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary. label Dec 15, 2025
@pfefferle pfefferle requested a review from a team December 15, 2025 15:27
Eliminated the Fediverse Wrapped shareable card functionality by deleting the template, removing related rewrite rules, query vars, and rendering logic from Statistics, and cleaning up associated JavaScript and dashboard UI elements.
- Replace jQuery-based widget with React components
- Add REST API endpoint for statistics data
- Add TypeScript types for stats data structures
- Add chart legend showing engagement types
- Support stored monthly stats for demo/historical data
- Add CLI command for populating demo data (local dev only)
@github-actions github-actions bot added [Feature] REST API [Focus] Editor Changes to the ActivityPub experience in the block editor labels Dec 17, 2025
- Make StatHighlights display engagement types dynamically from API
- Add period label "This month vs. last year" to clarify comparison
- Draw individual lines for each engagement type in the chart
- Use WordPress default color palette CSS variables with fallbacks
- Remove hardcoded comment types - all types now dynamic
- Move demo data generation from Statistics class to local CLI
Copy link
Member

@obenland obenland left a comment

Choose a reason for hiding this comment

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

Keeping it to structure, I'd see if there are stats we can bump as they occur instead of aggregating monthly. I reckon that'll probably be more accurate, especially for things we can't or are hard to query after the fact.

One of the reasons Jetpack is so powerful is because it can store large amounts of data, process them remotely, and aggregate them. It might be worth considering making this a jetpack integration instead of hoping an option is enough?

The dashboard widget is neat, is there something we can do to make that a bit more interactive?

);

// Add inline script to initialize the widget.
$actors = self::get_available_actors();
Copy link
Member

Choose a reason for hiding this comment

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

we should be able to get that on the JS side, like in the reader.

*
* @return array Modified cron schedules.
*/
public static function add_cron_schedules( $schedules ) {
Copy link
Member

Choose a reason for hiding this comment

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

add_cron_schedules, register_schedules, deregister_schedules should live in Scheduler.

*/
public static function init() {
\add_action( 'activitypub_collect_monthly_stats', array( self::class, 'collect_all_monthly_stats' ) );
\add_action( 'activitypub_compile_annual_stats', array( self::class, 'compile_and_send_annual_stats' ) );
Copy link
Member

Choose a reason for hiding this comment

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

Rather than sending it as an email, I'd create a landing page that can be shared. maybe we could even create a summary image or something?

The email should just link to the landing page.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about a block, so that you can use it in a post and share that.


// Schedule annual stats compilation for January 1st.
if ( ! \wp_next_scheduled( 'activitypub_compile_annual_stats' ) ) {
$next_year = self::get_next_january_first();
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this is still structural, but I'd send it on the first of December or in the first week of December.
That's when others send out those notifications, ready for the end of the year.

Copy link
Member Author

Choose a reason for hiding this comment

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

Normally yes, but I though maybe I can have a version out by januar ;)

@pfefferle
Copy link
Member Author

@obenland thanks for your feedback! 🫶

@pfefferle
Copy link
Member Author

One of the reasons Jetpack is so powerful is because it can store large amounts of data, process them remotely, and aggregate them. It might be worth considering making this a jetpack integration instead of hoping an option is enough?

I somehow agree, that we might be able to have a collab, but you checked the number of folks that have both installed an that is quite low. So I would love to have at least a basic stats feature in the plugin, to maybe motivate users to interact a bit more!?

- Move cron schedule methods (add_cron_schedules, register_schedules,
  deregister_schedules) from Scheduler\Statistics to main Scheduler
- Move helper methods (get_next_first_of_month, get_next_january_first)
  to main Scheduler
- Update dashboard stats widget to get actors on JS side like the reader
- Use @wordpress/core-data to check actor mode and capabilities
- Remove PHP-passed actors from Statistics_Dashboard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] REST API [Feature] WP Admin [Focus] Editor Changes to the ActivityPub experience in the block editor Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary. [Status] In Progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Fediverse Wrapped - Annual Blog Summary

3 participants