Skip to content

fix(analytics): show only the hotspot label in the layer rail - #2078

Merged
subodhr258 merged 2 commits into
developfrom
fix/hotspot-rail-label
Aug 21, 2026
Merged

subodhr258 merged 2 commits into
developfrom
fix/hotspot-rail-label

Conversation

@subodhr258

@subodhr258 subodhr258 commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator

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_name as the parent layer name, then a separator dash, then "Hotspot N". The rail already shows the parent layer as its card title, so groupRows was rendering that whole string as the row name, and the rail's truncate style 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 no product_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

  • Unit tests: 15/15 pass, including 5 new ones (the strip, the untouched Woo case, a custom name that does not start with the parent prefix, a label that only shares the parent name as a prefix, and a label that itself begins with a dash). The last two fail on the pre-review greedy logic and pass with the exact-separator match.
  • On godam-dev.local pointed 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

Screenshot 2026-08-13 at 5 08 21 PM

After

image

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.
Copilot AI balanced review requested due to automatic review settings August 13, 2026 11:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

🔍 WordPress Plugin Check Report

❌ Status: Failed

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
17 1 16

❌ Errors (1)

📁 readme.txt (1 error)
📍 Line 🔖 Check 💬 Message
0 outdated_tested_upto_header Tested up to: 7.0 < 7.1. The "Tested up to" value in your plugin is not set to the current version of WordPress. This means your plugin will not show up in searches, as we require plugins to be compatible and documented as tested up to the most recent version of WordPress.

⚠️ Warnings (16)

📁 readme.txt (2 warnings)
📍 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

@subodhr258
subodhr258 requested a review from KMchaudhary August 13, 2026 12:02
rawSubName = rawSubName
.slice( md.parent_layer_name.length )
.replace( /^[\s\p{Pd}]+/u, '' );
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@subodhr258
subodhr258 merged commit 852c99f into develop Aug 21, 2026
4 of 6 checks passed
@subodhr258
subodhr258 deleted the fix/hotspot-rail-label branch August 21, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants