I have a react app that is used with google analytics and autotrack plugin and it fires this error a lot:
Uncaught TypeError: Failed to execute 'unobserve' on 'IntersectionObserver': parameter 1 is not of type 'Element'.
at impression-tracker.js:329:43
at Array.forEach (<anonymous>)
at ye.handleDomElementRemoved (impression-tracker.js:327:16)
at ye.walkNodeTree (impression-tracker.js:251:7)
at ye.handleDomMutations (impression-tracker.js:234:14)
Here is how google analytics is configured:
ga("require", "impressionTracker", {
elements: [
{
id: "my-id",
threshold: 0.5,
}, ...]});
I found that this component is currently controlled in react so that it appears and disappears based on the data:
<div>
{data && <div id="my-id>...</div>}
</div>
When I caught this exception in Dev Tools, I found that the element that is passed to the unobserve function is actually div#my-id, so I'm not sure why it is complaining that it is not of a type 'Element`.
Here is the corresponding line in impression-tracker.js where the exception is thrown:
this.thresholdMap[item.threshold].unobserve(element);
It looks like this issue is happening to others as well even without react involvement: