Instrument connection, sync, settings, media, cache, features, and deactivation analytics events - #1226
Draft
gabrielcld2 wants to merge 11 commits into
Draft
Instrument connection, sync, settings, media, cache, features, and deactivation analytics events#1226gabrielcld2 wants to merge 11 commits into
gabrielcld2 wants to merge 11 commits into
Conversation
Develop to uat
Release process GH Action
…activation analytics events Wires the remaining 7 event categories from the analytics tracking spec on top of the existing WPP-1210 custom-events framework: connection management, asset sync, settings & navigation, media & asset actions, non-media cache, extensions & gallery, and deactivation. All call sites reuse Analytics::track() / Analytics.track() and were live-verified against wp-env via WP-CLI/REST dispatch. Adds a permanent e2e analytics-capture mu-plugin and two Playwright specs covering connection and deactivation events. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The previous commit only included src/js/* source changes. This repo ships compiled js/* output directly, so the extension_toggled, special_offer_clicked, deactivation_modal_viewed, and deactivation_skipped tracking calls weren't actually live until this rebuild. Live-verified via the full Playwright e2e suite against wp-env with real Cloudinary credentials (13/13 passing). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…nts-tracking # Conflicts: # php/class-admin.php # php/class-deactivation.php
develop bumped phpstan to level 5 after this branch was cut. The Analytics component (added in WPP-1210) was missing from get_component()'s @return union, so every ->track() call site read as "method.notFound" once merged. Re-verified clean at level 5 and against the full Playwright e2e suite.
…e load Image_Preview::preview() set the sample <img>'s src to a bare '#', which resolves to the current document's own URL — every load of Image Settings, Video Settings, or the Responsive/Breakpoints preview (Video_Preview and Breakpoints_Preview both extend Image_Preview) fired a second real HTTP request back at the same admin page before global-transformations.js replaced it with a real preview URL. Found while investigating why settings_page_viewed fired twice per page load: confirmed via wp-env access logs that the second request carried an image/* Accept header and a self-referencing Referer, matching this exact placeholder-image bug. Fixed with an inert 1x1 data-URI placeholder instead. Re-verified: single event per load, single request in the access log, full Playwright suite still green (13/13).
…nts-tracking # Conflicts: # js/cloudinary.js # js/syntax-highlight.js # src/js/main.js
The merge commit resolved js/cloudinary.js and js/syntax-highlight.js conflicts by taking develop's compiled output, dropping the SpecialOffer wiring and the deactivate.js Prettier reformat. Rebuilding restores both on top of develop's dependency upgrades and ESLint flat-config migration. Re-verified: phpcs/phpstan clean, full Playwright suite green (13/13).
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.
Approach
Wires the remaining 7 event categories from the Analytics Event Tracking Spec POC's custom-events framework:
connection management, asset sync, settings & navigation, media & asset actions, non-media cache, extensions & gallery, and deactivation (30 events total).
No changes to the transport layer (
Analytics::track()/Analytics.track()) — this is call-site wiring only.Design decisions worth a second look
bulk_sync_startedonly covers the manual REST trigger (Push_Sync::rest_start_sync()). Theauto_restartcase insideSync_Queue::stop_maybe()is treated as internal plumbing and isn't instrumented.asset_sync_failedhooks the broad, already-genericSync::log_sync_result()rather than the narrowerUpload_Sync::upload_asset(), trading a smallasset_typelookup cost for covering every sync type in one place.sync_completedneeded new state (Sync_Queue::mark_run_started()/tally_run_result()/track_run_completed()) since noexisting signal survives the queue's internal restart cycles.
account_switchedis new comparison logic inConnect::verify_connection()—Connect::switch_account()turned out to be dead code (no callers since 2021), not something to hook into.php/assets/class-rest-assets.php, notphp/class-cache.php— the latter is never instantiated (dead code), confirmed via exploration before wiring anything.gallery_configured'slayout/media_countare parsed out of thegallery_configfield's serialized JSON blob rather than being real submitted fields.Unrelated fix included: duplicate page-view bug
While QA'ing
settings_page_viewed, we found it firing twice per single page load on Image Settings / Video Settings. Root cause:Image_Preview::preview()set the sample<img>'ssrc="#", which resolves to the current page's own URL — so the browser fired a second real request back at the same admin page (as an image fetch) beforeglobal-transformations.jsreplaced it with a real preview URL.Video_PreviewandBreakpoints_Previewboth extendImage_Previewand inherited the same bug.This is a genuine, pre-existing perf bug unrelated to the analytics work, but it directly corrupted the accuracy of the new
settings_page_viewedevent on exactly the pages it affects, so it's fixed here rather than filed separately:src="#"→ an inert 1x1 data-URI placeholder. Confirmed via raw Apache access logs (down to one request) and the capture log (down to one event) that the duplicate is gone; full Playwright suite still green afterward.QA notes
Setup
npm run env:start— the capture mu-plugin (.wp-env/mu-plugins/analytics-capture.php) loads automatically and intercepts every outgoing event instead of hitting the real collector.npm run env:cli -- wp cloudinary analytics-events --clearnpm run env:cli -- wp cloudinary analytics-events— confirm the expectedevent_name/event_category/ params appear.npm run env:cli -- wp option update cloudinary_connect '{"cloudinary_url":"..."}' --format=json+ setcloudinary_connection_signatureto match (seetests/e2e/utils/connection.js:fakeCloudinaryConnected()for the exact snippet).Connection management
connection_string_updated(status: success/error depending onvalidity)
account_switchedconnection_disconnectedconnectivity_check_failedis cron-only (daily ping/REST-API self-check) — not user-triggerable, skip manual checkAsset sync
bulk_sync_started, thensync_completedonce the queuedrains
asset_sync_failedsync_settings_changedSettings & navigation
settings_page_viewedsettings_savednotice_dismissedspecial_offer_clickedMedia & asset actions
asset_edited+transformation_applied(scope: asset)transformation_applied(scope: global)Non-media cache
cache_items_viewedcache_items_toggledasset_cache_purged; "Purge all" →all_cache_purgedcache_uploadedExtensions & gallery
extension_toggledgallery_configuredDeactivation
deactivation_modal_viewed(checkis_connectedmatches actual state)deactivation_submitteddeactivation_skippedplugin_uninstalled(alongsidedeactivation_submitted)Regression check: confirm no PHP notices/fatals in
wp-content/debug.logand no new JS console errors across the above — none of this should be visible to a site admin who isn't looking for it.settings_page_viewedevent (was firing twice before this PR's fix)