From 14aa874122ec1374f2f155a61ae52ad42f2031f4 Mon Sep 17 00:00:00 2001 From: kptdobe Date: Fri, 18 Oct 2024 10:49:35 +0200 Subject: [PATCH] feat(rum-oversight): do not collapse solo entry --- tools/oversight/elements/link-facet.js | 12 ++++++------ tools/oversight/elements/list-facet.js | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/oversight/elements/link-facet.js b/tools/oversight/elements/link-facet.js index df127542..6b5381be 100644 --- a/tools/oversight/elements/link-facet.js +++ b/tools/oversight/elements/link-facet.js @@ -10,8 +10,8 @@ function urlDecode(part, rich = false) { : part.replace(/%3[Cc](number|hex|base64|uuid)%3[Ee]/g, '<$1>'); } -function labelURLParts(url, prefix) { - if (prefix && url.startsWith(prefix)) { +function labelURLParts(url, prefix, solo = false) { + if (prefix && url.startsWith(prefix) && !solo) { return `${prefix}${urlDecode(url.replace(prefix, ''), true)}`; } const u = new URL(url); @@ -31,7 +31,7 @@ function labelURLParts(url, prefix) { */ export default class LinkFacet extends ListFacet { // eslint-disable-next-line class-methods-use-this - createLabelHTML(labelText, prefix) { + createLabelHTML(labelText, prefix, solo = false) { const thumbnailAtt = this.getAttribute('thumbnail'); const faviconAtt = this.getAttribute('favicon'); const isCensored = labelText.includes('...') @@ -40,21 +40,21 @@ export default class LinkFacet extends ListFacet { || labelText.includes('') || labelText.includes('%3Cbase64%3E') || labelText.includes('') || labelText.includes('%3Cuuid%3E'); if (isCensored) { - return labelURLParts(labelText, prefix); + return labelURLParts(labelText, prefix, solo); } if (thumbnailAtt && labelText.startsWith('https://')) { const u = new URL('https://www.aem.live/tools/rum/_ogimage'); u.searchParams.set('proxyurl', labelText); return ` thumbnail image for ${labelText} - ${labelURLParts(labelText, prefix)}`; + ${labelURLParts(labelText, prefix, solo)}`; } if (thumbnailAtt && (labelText.startsWith('http://') || labelText.startsWith('https://') || labelText.startsWith('android-app://'))) { const u = new URL('https://www.aem.live/tools/rum/_ogimage'); u.searchParams.set('proxyurl', labelText); return ` thumbnail image for ${labelText} - ${labelURLParts(labelText, prefix)}`; + ${labelURLParts(labelText, prefix, solo)}`; } if (labelText.startsWith('https://') || labelText.startsWith('http://')) { return `${labelText}`; diff --git a/tools/oversight/elements/list-facet.js b/tools/oversight/elements/list-facet.js index 21fa74ee..0c15970a 100644 --- a/tools/oversight/elements/list-facet.js +++ b/tools/oversight/elements/list-facet.js @@ -250,7 +250,7 @@ export default class ListFacet extends HTMLElement { countspan.setAttribute('sample-size', metrics.pageViews.count); countspan.setAttribute('total', this.dataChunks.totals.pageViews.sum); countspan.setAttribute('fuzzy', 'false'); - const valuespan = this.createValueSpan(entry, prefix); + const valuespan = this.createValueSpan(entry, prefix, filteredKeys.length === 1); label.append(valuespan, countspan); @@ -371,9 +371,9 @@ export default class ListFacet extends HTMLElement { } } - createValueSpan(entry, prefix) { + createValueSpan(entry, prefix, solo = false) { const valuespan = document.createElement('span'); - valuespan.innerHTML = this.createLabelHTML(entry.value, prefix); + valuespan.innerHTML = this.createLabelHTML(entry.value, prefix, solo); const highlightFromParam = this.getAttribute('highlight'); if (highlightFromParam) { const highlightValue = new URL(window.location).searchParams.get(highlightFromParam) || '';