Skip to content

feat: track post-signup activity on customer subsites (issue #399)#416

Merged
superdav42 merged 1 commit intomainfrom
feature/issue-399-metrics-post-signup
Mar 25, 2026
Merged

feat: track post-signup activity on customer subsites (issue #399)#416
superdav42 merged 1 commit intomainfrom
feature/issue-399-metrics-post-signup

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

Summary

  • Adds Post_Signup_Activity_Manager that hooks into WordPress multisite actions on customer subsites and records them as WU events linked to the originating site/membership
  • Four new event types registered: subsite_post_created, subsite_cpt_created, subsite_user_registered, subsite_woocommerce_order
  • Events appear in the existing site edit page Events widget — no new admin UI required

What was implemented

New file: inc/managers/class-post-signup-activity-manager.php

Hooks registered on plugins_loaded (priority 20, non-main sites only):

Action Event slug Trigger
transition_post_status subsite_post_created First publish of a standard post
transition_post_status subsite_cpt_created First publish of a custom post type entry
add_user_to_blog subsite_user_registered User added to a subsite
woocommerce_new_order subsite_woocommerce_order WooCommerce order created

Each event carries object_type='site' and object_id=<blog_id> so it surfaces in the existing site edit page → Events widget without any new admin UI.

Modified: inc/class-wp-ultimo.php — registers the new manager after Site_Manager.

New test: tests/WP_Ultimo/Managers/Post_Signup_Activity_Manager_Test.php

Guards

  • Main site is always skipped
  • Sites without a WU membership are skipped (non-customer sites)
  • Internal post types (revision, auto-draft, nav_menu_item, etc.) are excluded
  • Re-saves of already-published posts are ignored (only first publish fires)
  • WooCommerce hook is no-op when WooCommerce is not active

Admin view

Events are viewable at Network Admin → Sites → [site] → Events tab — this widget already filters by object_type='site' and object_id, so no changes to the admin UI were needed.

Closes #399

Adds Post_Signup_Activity_Manager that hooks into WordPress multisite
actions on customer subsites and records events against the WU site
object (object_type='site', object_id=blog_id) so they appear in the
existing site edit page Events widget.

Tracked actions:
- Post creation (transition_post_status → publish)
- Custom post type entry creation (same hook, non-post/page types)
- User added to subsite (add_user_to_blog)
- WooCommerce order created (woocommerce_new_order)

Each event carries site + membership payload so admins can see
per-subsite activity metrics from the network admin.

Four new event types registered:
  subsite_post_created, subsite_cpt_created,
  subsite_user_registered, subsite_woocommerce_order

Closes #399
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 25, 2026

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 9 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ec80b598-5e15-4510-a4d3-f41ce7d66f0a

📥 Commits

Reviewing files that changed from the base of the PR and between 7336642 and 8ae4bae.

📒 Files selected for processing (3)
  • inc/class-wp-ultimo.php
  • inc/managers/class-post-signup-activity-manager.php
  • tests/WP_Ultimo/Managers/Post_Signup_Activity_Manager_Test.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/issue-399-metrics-post-signup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42 superdav42 merged commit a67ed4f into main Mar 25, 2026
8 of 10 checks passed
superdav42 added a commit that referenced this pull request Mar 25, 2026
…ty_Manager)

Post_Signup_Activity_Manager was merged into main in #416 before this
branch was rebased. Remove the duplicate Activity_Tracker class and its
instantiation from class-wp-ultimo.php.

Update Dashboard_Statistics::get_data_site_activity() to use the event
slugs produced by Post_Signup_Activity_Manager (subsite_post_created,
subsite_cpt_created, subsite_user_registered, subsite_woocommerce_order)
instead of the now-removed Activity_Tracker slugs.

Update Signup_Metrics_Test to match the corrected slugs.
superdav42 added a commit that referenced this pull request Mar 25, 2026
* feat: add signup flow metrics and post-signup activity tracking (#297, #398)

Implements two new tracking classes:

- Signup_Metrics: hooks into the checkout lifecycle to record
  checkout_started, checkout_step_completed, checkout_completed, and
  checkout_failed events in the wu_events table. Each event type is
  also registered for webhooks and email triggers.

- Activity_Tracker: hooks into sub-site WordPress actions to record
  site_post_published, site_user_registered, and site_woocommerce_order
  events for any customer-owned sub-site. Only tracks sites managed by
  WP Ultimo (via wu_get_site_by_blog_id).

Dashboard_Statistics gains two new data methods:
- get_data_signup_funnel(): returns per-stage counts + conversion rate
- get_data_site_activity(): returns post/user/order counts per date range

Both classes are wired up in class-wp-ultimo.php alongside the existing
Tracker singleton. Tests cover singleton behaviour, event type registration,
filter pass-through, and dashboard statistics key structure.

Closes #297
Closes #398

* ci: re-trigger E2E tests

* fix: remove duplicate Activity_Tracker (covered by Post_Signup_Activity_Manager)

Post_Signup_Activity_Manager was merged into main in #416 before this
branch was rebased. Remove the duplicate Activity_Tracker class and its
instantiation from class-wp-ultimo.php.

Update Dashboard_Statistics::get_data_site_activity() to use the event
slugs produced by Post_Signup_Activity_Manager (subsite_post_created,
subsite_cpt_created, subsite_user_registered, subsite_woocommerce_order)
instead of the now-removed Activity_Tracker slugs.

Update Signup_Metrics_Test to match the corrected slugs.

* fix: correct wu_checkout_errors hook to prevent TypeError fatal error

wu_checkout_errors is an action (not a filter) that fires with the
checkout form name as a string argument (views/checkout/form.php:23).

The previous implementation used add_filter and declared a return type
of \WP_Error. When the action fired with a string argument, the method
returned the string, causing a PHP TypeError (return type mismatch)
that produced a fatal error on the /register page.

Fix:
- Change add_filter to add_action (correct hook type)
- Change method signature to accept a string form name
- Remove \WP_Error return type (void action callback)
- Access checkout errors via Checkout::get_instance()->errors
- Update test to verify string argument is accepted without error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metrics: Track post-signup actions (subtask of #297)

1 participant