diff --git a/packages/rum-core/src/common/observers/page-clicks.js b/packages/rum-core/src/common/observers/page-clicks.js index 2a0b6c528..19022b90e 100644 --- a/packages/rum-core/src/common/observers/page-clicks.js +++ b/packages/rum-core/src/common/observers/page-clicks.js @@ -108,13 +108,15 @@ function buildTransactionName(target) { } function findCustomTransactionName(target) { + const trCustomNameAttribute = 'data-transaction-name' + const fallbackName = target.getAttribute(trCustomNameAttribute) if (target.closest) { // Leverage closest API to traverse the element and its parents // only links and buttons are considered. const element = target.closest(INTERACTIVE_SELECTOR) - return element ? element.dataset.transactionName : null + return element ? element.getAttribute(trCustomNameAttribute) : fallbackName } - // browsers which don't support closest API will just look at the target element - return target.dataset.transactionName + // browsers (such as IE11) which don't support closest API will just look at the target element + return fallbackName } diff --git a/packages/rum-core/test/common/observers/page-clicks.spec.js b/packages/rum-core/test/common/observers/page-clicks.spec.js index efcd6168c..44dc2e6a0 100644 --- a/packages/rum-core/test/common/observers/page-clicks.spec.js +++ b/packages/rum-core/test/common/observers/page-clicks.spec.js @@ -144,53 +144,88 @@ describe('observePageClicks', () => { describeIf( 'browsers supporting closest API', () => { - let childElement = document.createElement('span') ;[ { name: - 'should use customTransactionName when click target is a