makeMutationCallback
A factory to generate our Mutation Observer callback. The core of our auto-tracking and validation logic.
The callback orchestrates events handling and triggering, plus tagging validation based on the type of mutations it receives.
const makeMutationCallback = (
console?: TrackerConsole
) => MutationCallback
Parameters
type | default value | ||
---|---|---|---|
optional | console | TrackerConsole |
New nodes mutation
For each new node we invoke trackNewElements, which:
- Traverses the new Nodes and scouts for Elements that have been enriched with TaggingAttributes.
- For those Elements we attach Event Handlers to automatically handle their tracking.
- New Elements are also validated for LocationStack uniqueness.
- New Elements may trigger trackVisibility events.
Removed nodes mutation
- Removed Elements may trigger trackVisibility events.
Nodes attributes mutation
- Changed Elements may trigger trackVisibility events.
SPA URL changes
- On every DOM change we double-check the URL. If the last URL is different from the current we trigger a URL change event.