Add analytics POC infrastructure (activation-funnel custom events)#1187
Merged
Conversation
Phase 1 POC scaffolding for plugin analytics. Adds a fail-silent, server-side custom-events emitter and a client-side bridge, reusing the existing Cloudinary analytics collector (analytics-api.cloudinary.com) — the same endpoint already used for deactivation feedback. No funnel event call-sites are wired yet; that follows in a separate PR. - New Analytics component: builds the global parameter envelope (mandatory params always, cloud_name/plan once connected), emits via non-blocking wp_remote_post, and never disrupts wp-admin on failure. - Internal REST route (cloudinary/v1/events) so client-side events are enriched server-side, avoiding the collector's GET-only CORS. - JS analytics module exposing a fail-silent track() helper. - Flag-gated smoke-test event (cloudinary_analytics_smoke_test, off by default) to validate the collector path end-to-end during the POC. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hezzy-cloudinary
approved these changes
Jun 24, 2026
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.
Phase 1 POC scaffolding for plugin analytics — see the POC definition and implementation plan.
This is PR #1 of 2 — the infrastructure only. It introduces the custom-events framework but wires no funnel event call-sites yet; that is PR #2.
Approach
The plugin already posts deactivation feedback to Cloudinary's analytics collector (
analytics-api.cloudinary.com). This PR reuses that same collector under a new feature (wp_plugin_event), so no backend changes are required.Analyticscomponent (php/class-analytics.php) — the single egress. Builds the global parameter envelope (mandatory params on every event;cloud_name+planonce an account is connected), generatesevent_id/event_timestamp/session_id(sha256(wp_get_session_token())), and emits via non-blockingwp_remote_post(1s timeout, no retries). Wrapped in try/catch — a collector outage or any error never disrupts wp-admin.cloudinary/v1/events) — client-side events post here and are enriched with the server-side envelope, sidestepping the collector's GET-only CORS. Admin-gated + nonce.src/js/components/analytics.js) — exposes a fail-silenttrack()helper onwindow.cloudinary. Self-inits; reads config fromcldData.analytics. (Bundle rebuilt:js/cloudinary.js.)cloudinary_analytics_smoke_test(default off) emits a one-offpoc_smoke_testevent to validate the collector path end-to-end during the POC. Throttled to once / 5 min.Why PHP-side egress: most mandatory params and all contextual params are server-known, and most funnel events (activation, save-wizard, first sync, first API call) fire in PHP. The JS bridge exists only for the wizard's client-only signals.
Dormant by default: nothing emits in production until either a funnel event is wired (PR #2) or the smoke flag is turned on.
QA notes
add_filter( 'cloudinary_analytics_smoke_test', '__return_true' );wp_plugin_eventwithevent_name=poc_smoke_testreaches the collector with the mandatory params (andcloud_name/planif connected).npm run lint:jsandnpm run lint:phppass.Test matrix (full QA in PR #2 once events are wired): WP 5.6 / 6.9.x / 7.0, PHP 7.4 / 8.x, single + multisite, classic + block.