Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rum instrumentation #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix: rum instrumentation #36

wants to merge 1 commit into from

Conversation

fkakatie
Copy link
Member

No description provided.

@aem-code-sync
Copy link

aem-code-sync bot commented Feb 23, 2023

Hello, I'm Franklin Bot and I will run some test suites that validate the page speed.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-run PSI Checks

Copy link

@trieloff trieloff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also add to loadLazy:

  sampleRUM('lazy');
  sampleRUM.observe(main.querySelectorAll('div[data-block-name]'));
  sampleRUM.observe(main.querySelectorAll('picture > img'));

from https://github.com/adobe/helix-project-boilerplate/blob/31c70e12527604005cf80a4d3830e1b71e04fbe9/scripts/scripts.js#L103-L105

and to loadDelayed()/delayed.js:

// Core Web Vitals RUM collection
sampleRUM('cwv');

from https://github.com/adobe/helix-project-boilerplate/blob/10c37787d5f8450d470cc13cc2af183f58bbb02f/scripts/delayed.js#L4-L5

And to 404.html:

  <script type="module">
    import { sampleRUM } from '/assets/scripts/scripts.js';

    window.addEventListener('load', () => {
      sampleRUM('404', { source: document.referrer, target: window.location.href });
    });
  </script>

from https://github.com/adobe/helix-project-boilerplate/blob/10c37787d5f8450d470cc13cc2af183f58bbb02f/404.html#L13-L31

Comment on lines +992 to +1000
window.addEventListener('load', () => sampleRUM('load'));

window.addEventListener('unhandledrejection', (event) => {
sampleRUM('error', { source: event.reason.sourceURL, target: event.reason.line });
});

window.addEventListener('error', (event) => {
sampleRUM('error', { source: event.filename, target: event.lineno });
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to keep this just below the sampleRUM definition, so that the RUM code isn't as scattered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants