/helix-rum-js

Helix RUM Event Generator for JavaScript

Primary LanguageJavaScriptApache License 2.0Apache-2.0

Helix RUM JS

Helix RUM Event Generator for JavaScript

Status

codecov CircleCI GitHub license GitHub issues LGTM Code Quality Grade: JavaScript semantic-release

Usage

If you want to collect a RUM event programmatically, use this in your JavaScript code:

import { sampleRUM } from 'https://rum.hlx.page/.rum/@adobe/helix-rum-js@^1/src/index.js';

sampleRUM('top');
window.addEventListener('load', () => sampleRUM('load'));
document.addEventListener('click', () => sampleRUM('click'));

You can pin a version number by using a URL like https://rum.hlx.page/.rum/@adobe/helix-rum-js@1.0.0/src/index.js instead.

To enable advanced RUM functionality, such as reporting of Core Web Vitals, fire the lazy checkpoint as soon as your render-critical Javascript has executed.

// after all render-critical Javascript has been run
sampleRUM('lazy');

While the above line enables collection of Core Web Vitals as a prerequisite, the cwv checkpoint must also be fired to actually perform the collection. Typically this is called with a 3-second delay after page load to not interfere with performance.

sampleRUM('cwv');

For usage of the sampleRUM function, follow the API documentation.

Development

Build

$ npm install

Test

$ npm test

Lint

$ npm run lint