feat(event-module): implement Event_Module::boot()#105
Merged
Conversation
…API, ability (#95) Moves event tracking init, sybgo_init_api(), and sybgo/track-events ability registration from Sybgo::init_event_tracking() and init_abilities() into Event_Module::boot(). Ability registration is deferred to the 'init' hook at priority 5; Ability_Manager::init() is scheduled at priority 20 so it captures all module-registered abilities. Adds EventModuleTest covering tracker storage, API side-effect, and deferred ability registration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2be7ce4 to
4cf8474
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Moves event tracking initialisation, the public extensibility API call, and the `sybgo/track-events` Ability registration out of `Sybgo::init_event_tracking()` and `init_abilities()` into `Event_Module::boot()`, making the event-domain wiring independently testable as a named method.
Closes #95
Type of change
Detailed scenario
What was tested
Behaviour is identical to develop — the same hooks, API, and ability are registered; only the location of that wiring changed. Manual verification on a local wp-env install:
wp cron event list | grep sybgo— all four cron events present and scheduled as before.wp cron event run sybgo_freeze_weekly_report— weekly report frozen successfully; event tracking continued writing rows towp_sybgo_eventsbefore and after the freeze.How to test
feat/event-module-95and runcomposer dump-autoloadinsidewp-plugin/.cd tests/e2e && npx wp-env start.cd wp-plugin && vendor/bin/phpunit --testsuite=Unit— 4 new EventModuleTest tests pass; 5 pre-existing DashboardWidgetTest errors (unrelated, present on develop too).wp post create --post_title="Test" --post_status=publish.wp db query "SELECT event_type FROM wp_sybgo_events ORDER BY id DESC LIMIT 1"— should showpost_published.wp cron event run sybgo_freeze_weekly_reportand confirm the report freezes without PHP errors in the debug log.Affected Features & Quality Assurance Scope
Event tracking, the public extensibility API (
sybgo_init_api), and thesybgo/track-eventsAbility are affected — behaviour unchanged but wired from a new location. All other plugin features are untouched.Technical description
Event_Module::boot()now:Factory::create_event_repository()andcreate_aggregated_event_repository(), constructsEvent_Tracker, callsinit()on it, and stores it viaFactory::set_event_tracker().sybgo_init_api($event_repo)to expose the public extension API.add_action('init', …, 5)that callsAbility_Manager::register('sybgo/track-events', …)with the translated label and description. Priority 5 ensures registration runs beforeAbility_Manager::init(), which is now deferred toadd_action('init', …, 20)insideSybgo::init().The
initaction deferral preserves the fix for the WP 6.7+ textdomain early-loading bug: calling__()duringplugins_loadedbefore the text domain is loaded triggers_doing_it_wrong()→trigger_error()→ captured by Error_Tracker, polluting aggregated event counts.Sybgo::init_event_tracking()is deleted (dead code after extraction).init_abilities()now only handlessybgo/generate-summary, which will move toAI_Modulein #98.See wp-plugin/docs/development.md — Feature Module Architecture section.
New dependencies
None.
Risks
None identified. The ability registration timing (priority 5 → priority 20 on
init) is the only subtle change; it preserves the existing WP7 deferral fix and is covered byEventModuleTest::test_boot_registers_track_events_on_init_hook_priority_5.Mandatory Checklist
Code validation
Code style
Unticked items justification
None.
Additional Checks