feat: track block add/remove events via telemetry#2862
Open
ineagu wants to merge 1 commit into
Open
Conversation
Add an editor-side tracker that watches the block-editor store and emits a signed-delta telemetry event whenever an Otter block (any block in the `themeisle-blocks` category) is added to or removed from a post. Until now Otter only stored a cumulative, add-only instance snapshot in the `otter_blocks_logger_data` option, which is never sent off-site and cannot represent removals. This mirrors the approach Feedzy already ships in `js/FeedzyLoop/tracking.js`, reusing the existing `window.oTrk` (`tiTrk.with( 'otter' )`) accumulator, so no new SDK wiring, enqueue or option is required. Events use the same `feature: 'block-usage'` shape Feedzy sends and are gated on the existing tracking opt-in (`otter_blocks_logger_flag`). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Bundle Size Diff
|
Contributor
|
Plugin build for 767e52b is ready 🛎️!
|
Contributor
E2E TestsPlaywright Test Status: See serial and parallel matrix jobs Performance ResultsserverResponse: {"q25":396.1,"q50":421.7,"q75":427,"cnt":10}, firstPaint: {"q25":560.7,"q50":681.7,"q75":835.6,"cnt":10}, domContentLoaded: {"q25":3285.5,"q50":3330.45,"q75":3391.5,"cnt":10}, loaded: {"q25":3286.1,"q50":3330.85,"q75":3392.1,"cnt":10}, firstContentfulPaint: {"q25":8860.9,"q50":8944,"q75":9048.3,"cnt":10}, firstBlock: {"q25":13526.7,"q50":13749.75,"q75":13782.3,"cnt":10}, type: {"q25":21.55,"q50":24.26,"q75":26.21,"cnt":10}, typeWithoutInspector: {"q25":20.09,"q50":20.69,"q75":21.54,"cnt":10}, typeWithTopToolbar: {"q25":26.31,"q50":28.67,"q75":29.51,"cnt":10}, typeContainer: {"q25":12.5,"q50":13,"q75":14.81,"cnt":10}, focus: {"q25":103.99,"q50":106.23,"q75":113.08,"cnt":10}, inserterOpen: {"q25":36.43,"q50":37.67,"q75":37.98,"cnt":10}, inserterSearch: {"q25":12.44,"q50":12.55,"q75":12.67,"cnt":10}, inserterHover: {"q25":5.01,"q50":5.13,"q75":5.27,"cnt":20}, loadPatterns: {"q25":1443.16,"q50":1468.66,"q75":1495.16,"cnt":10}, listViewOpen: {"q25":203.27,"q50":205.37,"q75":213.21,"cnt":10} |
This was referenced Jun 16, 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.
Summary
Adds an editor-side tracker that emits a telemetry event whenever an Otter block is added to or removed from a post, so we finally have visibility into block add/remove behaviour (not just a local, add-only snapshot).
Background. Today the only block-usage signal is
src/blocks/plugins/data-logging/index.js, which writes a cumulative, monotonically-increasing instance count perthemeisle-blocks-category block into theotter_blocks_logger_dataoption on post publish/save. That option is read/written only inside the editor — nothing POSTs it off-site (Otter doesn't hook the SDK's_logger_datafilter), and by design it can only ever add (removals are invisible). So we currently cannot answer "how often are blocks removed" or "which blocks get added during editing."Approach. This mirrors what Feedzy already ships in
js/FeedzyLoop/tracking.js:subscribe()to the block-editor store, recursively count every block in thethemeisle-blockscategory (the same category filterdata-logging/index.jsalready uses), and on each change emit the signed delta per changed block type.window.oTrk(tiTrk.with( 'otter' )) accumulator, using the samefeature: 'block-usage'shape Feedzy sends — so Otter and Feedzy block usage line up under one schema, and this does not collide with the existing per-blockaction: 'block-created'events (the 5 Pro blocks).Minimal by design: one new file + one import line. No PHP, no new enqueue, no SDK registration, no new option. Reuses
window.oTrk, thethemeisle-blockscategory filter, and the existingotter_blocks_logger_flagopt-in.Event payload (per changed block type, per change tick):
Test instructions
npm run build) and load the plugin with the tracking opt-in enabled (otter_blocks_logger_flag = 'yes', i.e.window.themeisleGutenberg.canTrack === true; Pro/licensed sites are opted in by default).window.oTrk.base.eventsaccumulatesfeature: 'block-usage'entries with a positivefeatureValue, and that events flush on Save / tab close toapi.themeisle.com/tracking/events.block-usageevent with a negativefeatureValue.canTrackfalse) → confirm the subscriber never attaches and no events fire.Checklist before the final review
isBlockEditor+canTrack)envis auto-tagged by the SDK: post-editor / site-editor / widgets — worth a quick FSE smoke test)Notes for reviewers / telemetry side
feature: 'block-usage'rows will start arriving forslug: 'otter'— heads-up to whoever owns the Metabaseeventstable so ablock-usagebreakdown can be added. Same schema as Feedzy's, so they can be compared byslug.clientIdidentity was intentionally left out.tiTrk.start()/ changeeventsLimit(Feedzy does); Otter already flushes on post save (css-handler) and onbeforeunload, so the global timer behaviour is left untouched.🤖 Generated with Claude Code