I see how this works, using the root element to always handle clicks (and it's definitely simpler), but I think there's potentially an issue if event bubbling is cancelled (ie, via stopPropagation()) somewhere along the way. In that case we might not track any outlinks. Is this something we want to handle @tsteur?
@diosmosis that's something we can't prevent but we set the third parameter in addEventListener to
true so we should be receiving the event as they are usually not cancelled in the
A Boolean indicating whether events of this type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree
it basically starts in the html/body elements and then goes down before it would bubble up again AFAIK. And usually someone might stop propagation only at a later stage (they have default useCapture=false). It works quite well eg in TagManager etc and it shouldn't be a problem
Tested locally, works well. Created https://github.com/matomo-org/test-examples/pull/7 for testing.
Also left one small comment, otherwise looks good.
fyi because the 4.3 release is soon and the RC is already out we might want to merge that one only after the 4.3 release just in case anything is breaking etc. And then we could directly update the SPA guide etc to mention the method no longer needs to be called etc
Changed it for now 👍 Hoping it won't be later renamed to 4.5.0 after releasing 4.3. Then we would change the milestone again.
I could create a 4.3.1 milestone but there we'd mostly want fixes and not changes in there.