Projects based on the boilerplate are already instrumented with RUM, there is no need for you to do any specific action.
sampleRUM
will be initialized in aem-lib and the main checkpoints will be tracked automatically for you.
For Edge Delivery Services projects not based on the boilerplate, it is recommended to use the standalone instrumentation.
Loading of additional scripts such as RUM enhancer and data tracking are using the same origin, by default https://rum.hlx.page
.
These origins can be customized by setting the variables, after importing sampleRUM
and before invoking the function.
sampleRUM.baseURL
: URL used as a base for loading additional scriptssampleRUM.collectBaseURL
: URL used as a base for data collection.
Starting on Helix5 architecture it is possible collect data using the current website domain, which would optimize data collection and prevent it from being blocked:
sampleRUM.collectBaseURL = new URL(window.origin);
- Find the
function sampleRUM()
definition in youraem.js
orlib-franklin.js
- Replace the content of the function by the content of the file
src/index.js
- Find the
init()
function and replace any existingsampleRUM
call by simply:
sampleRUM()
load
, error
, and other default checkpoints are automatically tracked by the RUM code. There's no need to add additional listeners
sampleRUM.on
and sampleRUM.always.on
hooks are no longer available.
They are replaced by a CustomEvent
called rum
.
The detail
of the custom event is an object containing the keys:
{
checkpoint: checkpoint-name,
data: { checkpoint-data},
}
Simplified sample code to listen to this event:
document.addEventListener('rum', (event) => {
if(event.detail) {
const checkpoint = event.detail.checkpoint;
const data = event.detail.data;
console.log(`RUM Event: checkpoint ${checkpoint} source: ${data.source}`};
}
});
For usage of the sampleRUM
function, follow the API documentation, but note that you should not and do not have to call the function directly anymore.