Integrating web SDK
Xtremepush web SDK can be integrated with the website by adding a js tracking code that look like this:
The above code does 4 main things:
- Initializes a global xtremepush function (called the xtremepush() command queue) that allows you to schedule commands to be run once the sdk.js library is loaded and ready to go.
The xtremepush() function is a command queue because rather than executing the commands it receives immediately, it adds them to a queue that delays execution until the sdk.js library is fully loaded.
This pattern allows developers to use the xtremepush
() command queue without having to worry about whether or not the sdk.js library has finished loading. It provides a simple, synchronous-looking interface that abstracts away most of the complexities of asynchronous code.
SDK behavior when loaded
It uses several type of API requests to send data to our servers. All the API requests are going through HTTPS and are being sent asynchronously.
All the communication between client code and SDK is happening through the xtremepush() command queue.
User identification & data collection
In order for our SDK to persist client information between different page views and sessions we store client ID in cookie called "_xpid". We also store a local storage item called "xtremepush" to keep information about the client.
During the first page load for the new user an API request will be send to Xtremepush server to register the client.
During the following page loads an API request will be sent only if some of user's information were changed, such as user language.
In order to support Chrome and Firefox webpush notifications our SDK registers the service worker.
Our service worker implements following callbacks:
It doesn't implement anything that could affect application usage, such as providing additional network cache.
Our SDK also adds a reference to manifest.json to the head of the page if missed.