Skip to content

Commit 911d8d1

Browse files
authored
feat: Remove wrap-events usage from soft nav (#1244)
1 parent 37dd552 commit 911d8d1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/features/soft_navigations/instrument/index.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { isBrowserScope } from '../../../common/constants/runtime'
33
import { handle } from '../../../common/event-emitter/handle'
44
import { windowAddEventListener } from '../../../common/event-listener/event-listener-opts'
55
import { debounce } from '../../../common/util/invoke'
6-
import { wrapEvents } from '../../../common/wrap/wrap-events'
76
import { wrapHistory } from '../../../common/wrap/wrap-history'
87
import { InstrumentBase } from '../../utils/instrument-base'
98
import { FEATURE_NAME, INTERACTION_TRIGGERS } from '../constants'
@@ -23,7 +22,12 @@ export class Instrument extends InstrumentBase {
2322
if (!isBrowserScope || !gosNREUMOriginals().o.MO) return // soft navigations is not supported outside web env or browsers without the mutation observer API
2423

2524
const historyEE = wrapHistory(this.ee)
26-
const eventsEE = wrapEvents(this.ee)
25+
26+
INTERACTION_TRIGGERS.forEach((trigger) => {
27+
windowAddEventListener(trigger, (evt) => {
28+
processUserInteraction(evt)
29+
}, true)
30+
})
2731

2832
const trackURLChange = () => handle('newURL', [now(), '' + window.location], undefined, this.featureName, this.ee)
2933
historyEE.on('pushState-end', trackURLChange)
@@ -50,13 +54,6 @@ export class Instrument extends InstrumentBase {
5054
domObserver.observe(document.body, { attributes: true, childList: true, subtree: true, characterData: true })
5155
}, UI_WAIT_INTERVAL, { leading: true })
5256

53-
eventsEE.on('fn-start', ([evt]) => { // set up a new user ixn before the callback for the triggering event executes
54-
if (INTERACTION_TRIGGERS.includes(evt?.type)) {
55-
processUserInteraction(evt)
56-
}
57-
})
58-
for (let eventType of INTERACTION_TRIGGERS) document.addEventListener(eventType, () => { /* no-op, this ensures the UI events are monitored by our callback above */ })
59-
6057
this.abortHandler = abort
6158
this.importAggregator(agentRef, { domObserver })
6259

tests/assets/soft-nav-interaction-on-click.html

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<title>RUM Unit Test</title>
55
{init}
66
{config}
7+
<script>
8+
NREUM.init.feature_flags = ['soft_nav']
9+
</script>
710
{loader}
811
</head>
912
<body>

0 commit comments

Comments
 (0)