- 05 Sep 2024
- 2 Minutes To Read
-
Print
-
DarkLight
-
PDF
Configure Mutation Observer
- Updated On 05 Sep 2024
- 2 Minutes To Read
-
Print
-
DarkLight
-
PDF
What is MutationObserver?
MutationObserver is a web API that enables developers to observe changes to the DOM (Document Object Model) of a web page. When enabled, MutationObserver listens for specific types of mutations or changes in the DOM and triggers actions based on those changes.
In the case of Whatfix, when Mutation Observer config is enabled, Whatfix monitors mutations on the page that match the specified configuration. This configuration is used by Smart-Tips, Beacons, Launchers, and Smart Context.
By defining this configuration, Whatfix can use the MutationObserver API to monitor changes happening on the page. This enables Whatfix to dynamically adjust its content, such as Smart-Tips, based on changes in the underlying web application's DOM structure. For example, if elements on the page are dynamically added or removed, Whatfix can detect these changes and adjust its tooltips accordingly.
Use the following steps to configure Mutation Observer:
-
On the Whatfix Guidance dashboard, click Settings.
-
Click Advanced customisation.
-
Click Technical configuration.
-
Click Add preferences.
- Based on what mutations you want to monitor, Whatfix enables you to configure the Mutation Observer for the following:
-
Click Common Properties.
-
Select the Mutation Observer Config checkbox.
This config is used by Smart Context to re-evaluate all widgets if Page Tags have changed due to these mutations.
-
Click Common Properties.
-
Select the Mutation Observer Config for Smart Context checkbox.
-
Click User Action.
-
Select the Mutation Observer Config for User Action checkbox.
-
Click Add.
-
In the Config dropdown, select what mutations you want to observe.
Whatfix observes the following types of mutations:
Attributes: When an HTML element changes its characteristics, like its class or ID, it's called an attributes mutation. For example, if a button's color changes from blue to red, that's an attribute mutation.
Child List: Child list mutations happen when new things are added or taken away from a section of a webpage. This could mean adding or removing things from that list or changing their order. For example, if you add a new item to a shopping cart on a website, that's a child list mutation because you're changing what's inside the container.
Subtree: Subtree mutations occur when anything inside a specific part of a webpage changes. This could be anything from changing the size of an image to adding a new paragraph. If it happens within the area we're looking at, it counts as a subtree mutation.
- Click Save.