Repository navigation
fix(analytics): show only the hotspot label in the layer rail - #2078
Conversation
The player tracker writes each hotspot event's layer_name as the parent layer name, a separator, then "Hotspot N". The detail-panel rail already shows the parent layer as its card title, so that prefix was pure repetition, and the row's truncation then hid the "Hotspot N" that actually identifies it. Strip the parent-name prefix from the sub-hotspot name so each row reads just "Hotspot N". Woo product rows carry a bare product_name and are left alone. This reads what is already stored, so it fixes existing data with no change to the wire format. Add unit tests for the strip, the untouched Woo case, and a custom name that does not start with the parent prefix.
There was a problem hiding this comment.
Pull request overview
Updates analytics rail labels to display only each hotspot’s identifying label.
Changes:
- Removes redundant parent-name prefixes from hotspot rows.
- Adds tests for hotspot, Woo, and custom labels.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
pages/analytics/hooks/useVideoLayerData.js |
Normalizes hotspot sub-row labels. |
pages/analytics/hooks/useVideoLayerData.test.js |
Tests label normalization behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🔍 WordPress Plugin Check Report
📊 Report
❌ Errors (1)📁 readme.txt (1 error)
|
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
mismatched_plugin_name | Plugin name "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" is different from the name declared in plugin header "GoDAM". |
0 |
trademarked_term | The plugin name includes a restricted term. Your chosen plugin name - "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" - contains the restricted term "wordpress" which cannot be used at all in your plugin name. |
📁 composer.json (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
missing_composer_json_file | The "/vendor" directory using composer exists, but "composer.json" file is missing. |
📁 assets/build/blocks/godam-gallery-v2/render.php (2 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
15 |
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound | Global variables defined by a theme/plugin should start with the theme/plugin prefix. Found: "$inner_block_video_ids". |
23 |
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound | Global variables defined by a theme/plugin should start with the theme/plugin prefix. Found: "$inner_block_video_ids". |
📁 assets/build/css/main.css (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedStylesScope | This style is being loaded in all contexts. |
📁 assets/src/libs/analytics.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/08/21/hello-world/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
📁 assets/build/js/main.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/08/21/hello-world/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check
| rawSubName = rawSubName | ||
| .slice( md.parent_layer_name.length ) | ||
| .replace( /^[\s\p{Pd}]+/u, '' ); | ||
| } |
There was a problem hiding this comment.
The separator cleanup is greedy across dashes, so it can also eat a dash that belongs to the hotspot's own label.
/^[\s\p{Pd}]+/u consumes every leading whitespace/dash character, not just the one separator. A hotspot named -50% off inside a layer named Summer sale is tracked as Summer sale — -50% off (hotspotLayerManager.js composes ${parentLayerName} — ${subLabel}). After slice() the remainder is " — -50% off", and the character class then swallows space + em dash + space and the label's own hyphen, so the rail row reads 50% off — the opposite meaning. Same for something like —Limited—.
Anchoring the strip to a single separator occurrence keeps the label intact, e.g.:
rawSubName = rawSubName
.slice( md.parent_layer_name.length )
.replace( /^\s*\p{Pd}\s*/u, '' );(or only strip when the composite actually matches parent + SEP). Minor/edge-case — everything else in the change looks right to me: the ! md.product_name guard correctly exempts Woo, startsWith avoids touching unrelated names, parent_layer_name landed in the same commit as the composite name so there's no historical-data gap, and an empty result still falls through to the "<Type> #N" ordinal.
There was a problem hiding this comment.
Fixed in b91bdab. Went with your "only strip when the composite actually matches parent + SEP" option, which resolves this greedy-dash case and the Copilot prefix-collision case in one check. The strip now matches the exact <parent> — prefix and slices just that — no character-class replace — so a label that begins with its own dash keeps it: Summer sale — -50% off -> -50% off, not 50% off.
The separator is now a module constant HOTSPOT_NAME_SEPARATOR = ' — ' with a comment pointing at hotspotLayerManager.js:213, since that is the source of truth for the composite. Added two tests (leading-dash and prefix-collision); both fail on the old logic and pass now. 15/15 in the suite.
…ot labels
Match the exact "<parent> — " prefix the tracker composes instead of
stripping on the bare parent name plus a greedy run of leading dashes.
This leaves intact a custom label that merely begins with the parent
name ("Sale" -> "Sale special") and a label that itself starts with a
dash ("Summer sale — -50% off" -> "-50% off", not "50% off").
Add guard tests for both cases.
Connected ticket - https://github.com/rtCamp/godam-analytics/issues/196
What
In the Video Layer Timeline detail panel, every hotspot row in the "Hotspots in this layer" rail repeated the parent layer name and then truncated the part that identifies the hotspot. Every row read "Hotspot layer at 4.59s ..." so you could not tell the hotspots apart.
Why it happened
The player tracker writes each hotspot event's
layer_nameas the parent layer name, then a separator dash, then "Hotspot N". The rail already shows the parent layer as its card title, sogroupRowswas rendering that whole string as the row name, and the rail'struncatestyle then clipped off the "Hotspot N".Woo product rows were already fine, because they carry a bare
product_name("Lamp", "Sofa").The fix
In
groupRows(pages/analytics/hooks/useVideoLayerData.js), strip the parent-name prefix from a hotspot sub-row's name so each row reads just "Hotspot N". It only runs for rows with noproduct_name(so Woo is untouched) and only when the name starts with the exact “ — ” prefix the tracker composes (matching the full separator, not just the parent name, so a custom label that merely begins with the parent name or one that itself starts with a dash is left intact). It reads what is already stored, so it fixes existing and historical data too, with no change to the wire format.Verification
godam-dev.localpointed at the develop analytics service, video "People": the 4.59s hotspot rail now reads "Hotspot 1 / Hotspot 2", and the Woo layer still reads "Lamp / Sofa".Automation impact
Rail row labels changed from the prefixed form ("" then "Hotspot N") to just "Hotspot N". Any test asserting the old, prefixed label needs updating.
Known follow-up (not this PR)
Hotspots are numbered by position ("Hotspot N"), so when one is removed or reordered the numbers can collide (you can see two "Hotspot 2" rows, one active and one "Removed"). Giving each hotspot a stable identity label is a separate change.
Screenshots
Before
After