Wpcomsh fatal-error: log deactivate clicks; stamp atomic_site_id#48479
Conversation
Follow-up to #48401. * Adds a `wpcomsh_fatal_deactivate` event (via WPCOMSH_Log) emitted from the fatal-error screen's signed deactivator endpoint, so we can tell which fatals lead to user-initiated deactivations. * Both that event and the existing `wpcomsh_fatal_signature` event now carry `properties.atomic_site_id` (preferring the constant; falling back to `wpcomsh_get_atomic_site_id()` when undefined). * Refactors the single-purpose log helper into `wpcomsh_fatal_log_event( $plugin, $message )` so both events share the signature/dedup/property pipeline. The deactivator path runs at mu-plugin load time before constants.php, so dependent paths are resolved via `dirname(__DIR__)` instead of WPCOMSH__PLUGIN_DIR_PATH. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
…omattic#48479) Co-authored-by: dognose24 <6869813+dognose24@users.noreply.github.com>
Fixes #
Proposed changes
Follow-up to #48401. Two related additions to wpcomsh fatal-error telemetry:
wpcomsh_fatal_deactivateevent. When a logged-in admin clicks the Deactivate button on the fatal-error screen, the signed deactivator endpoint (fatal-plugin-deactivator.php) now emits awpcomsh_fatal_deactivateevent viaWPCOMSH_Log::unsafe_direct_log_logstash()before persisting the option update. Pairs with the existingwpcomsh_fatal_signatureevent so we can tell which fatals lead to user-initiated deactivations vs. recovery-mode entry vs. abandonment. Logged viaWPCOMSH_Log's shutdown drain, which runs after the redirect'sexit— the queued payload still ships.properties.atomic_site_idon both events. Bothwpcomsh_fatal_signature(existing) andwpcomsh_fatal_deactivate(new) now stampproperties.atomic_site_id, sourced from theATOMIC_SITE_IDconstant first (avoids anapply_filters()dispatch on the common path) and falling back towpcomsh_get_atomic_site_id()when the constant is undefined. Stamps are skipped when the resolved id is 0 (off-Atomic / unresolved).Implementation notes
wpcomsh_fatal_log_signature()was refactored intowpcomsh_fatal_log_event( \$plugin, \$message )so both events share the signature / dedup / properties pipeline. The dedup cache key now includes the message (wpcomsh_fatal_event:HASH(message|signature)) so a recent signature event for an extension doesn't suppress the matching deactivate event.wpcomsh.phpline 28 loadsconstants.php, soWPCOMSH__PLUGIN_DIR_PATHis undefined when it fires. Manual requires now resolve the wpcomsh root via `dirname(DIR)` instead, which is correct in both the deactivator path and the fatal-screen render path.wpcomsh_get_atomic_site_id()fallback is wrapped intry { … } catch ( \Throwable )because the helper runs thewpcomsh_get_atomic_site_idfilter — a misbehaving callback must not bubble out of a best-effort logger.Related product discussion/links
Does this pull request change what data or activity we track or use?
Yes — additively. Two new fields ship in the
feature:atomic_extension_conflictlog stream:wpcomsh_fatal_deactivate, fires only when a logged-in admin (passing the existingdeactivate_plugincapability check + HMAC signature on the deactivator endpoint) clicks Deactivate on the fatal-error screen. Payload shape mirrorswpcomsh_fatal_signature:signature,kind,slug,extension_version,wp_version,php_version,site_url, plus the newatomic_site_id.properties.atomic_site_id(integer site id from theATOMIC_SITE_IDconstant orwpcomsh_get_atomic_site_id()filter) is stamped on both events. This is the same site id already exposed at `atomic_site_id` in thefeature:atomic_global_styles_gatepayload elsewhere in this plugin — no new per-site identifier is being introduced, just included on these two records.Both fields are non-PII server-side metadata about the site itself. No user-level data is collected.
Testing instructions
boom/boom.phpcontainingtrigger_error( 'boom', E_USER_ERROR )oninit).feature:atomic_extension_conflict) and confirm the initialwpcomsh_fatal_signaturerecord now carriesproperties.atomic_site_idalongside the other indexed fields.wp-admin/plugins.php?wpcomsh_deactivated=…. In the same log stream, confirm awpcomsh_fatal_deactivaterecord arrives with the samesignature/slug/kind/extension_versionas the corresponding fatal record, plusatomic_site_idandsite_url.wpcomsh_fatal_signaturerow arrives. Re-submit a deactivate form within the same window and confirm no duplicatewpcomsh_fatal_deactivaterow arrives. The two events do not dedup against each other (the cache key includes the message).ATOMIC_SITE_IDconstant, nowpcomsh_get_atomic_site_idfilter), trigger a fatal and confirm the event payload omitsatomic_site_idrather than emitting0.home_url('/')withwpcomsh_deactivate=…&wpcomsh_sig=…&wpcomsh_exp=…) still completes the redirect normally and produces awpcomsh_fatal_deactivatelog row, even though it runs beforeconstants.phploadsWPCOMSH__PLUGIN_DIR_PATH.🤖 Generated with Claude Code