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

Add real user metrics using Speedcurve's LUX #2135

Merged
merged 2 commits into from
Jun 15, 2021
Merged

Conversation

injms
Copy link
Contributor

@injms injms commented Jun 15, 2021

What

Adds the real user metrics to the public layout component by adding the LUX scripts. This includes:

  • Adding tests to ensure both LUX scripts are present in the public layout component only when a user has allowed usage tracking cookies
  • Adding lux and lux-polyfill to the assets precompile list
  • Updating the LUX script to ensure that the image beacon is used
  • Updating the LUX script to add GDS's Speedcurve user ID number - usually this is appended to the script src with a query string, but that doesn't work in this instance as Rails adds a fingerprint to the filename that prevents the script from finding itself
  • Prettifying lux-polyfill to make it slightly easier to see what's going on; this is compressed when going through the asset pipeline
  • Adding documentation explaining RUM and how to update the LUX scripts

Why

Real user metrics will give a much greater insight into the performance of GOV.UK for everyone. This will show in greater detail what parts of GOV.UK can be improved without using synthetic tests and what steps can be taken to improve the experience for everyone.

This is a sibling pull request to alphagov/static#2445 - that covers the core_layout template; this pull request ensures that the gem_layout in static has feature parity.

Visual Changes

None.

@bevanloon bevanloon temporarily deployed to govuk-publis-add-rum-to-xvdqeo June 15, 2021 12:30 Inactive
 - Add test to ensure both scripts are present in the public layout
   component only when a user has allowed usage tracking cookies
 - Adds `lux` and `lux-polyfill` to the assets precompile list
 - Updates the LUX script to ensure that the image beacon is used
 - Updates the LUX script to add GDS's Speedcurve user ID number -
   usually this is appended to the script `src` with a query string, but
   that doesn't work in this instance as Rails adds a fingerprint to the
   filename that prevents the script from finding itself
 - Prettifies `lux-polyfill` to make it slightly easier to see what's
   going on; this is compressed when going through the asset pipeline
 - Add documentation explaining RUM and how to update the LUX scripts
@injms injms force-pushed the add-rum-to-public-layout branch from 44fbf33 to 51fd6a2 Compare June 15, 2021 12:32
@bevanloon bevanloon temporarily deployed to govuk-publis-add-rum-to-xvdqeo June 15, 2021 12:32 Inactive
@injms injms requested a review from alex-ju June 15, 2021 12:57
Copy link
Contributor

@andysellick andysellick left a comment

Choose a reason for hiding this comment

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

Looks good, just a few questions and thoughts.

// Setting debug to `true` shows what happening as it happens. Running
// `LUX.getDebug()` in the browser's console will show the history of what's
// happened.
LUX.debug = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

This adds quite a lot of JS. Do we know exactly what the file size impact of this change will be?

Copy link
Contributor Author

@injms injms Jun 15, 2021

Choose a reason for hiding this comment

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

So the file sizes are:

File rum-loader lux-polyfill lux
Uncompressed 1.5kb 3.5kb 33.5kb
Minified 1.1kb 2.3kb 21.8kb
Minified and compressed 0.4kb 0.7kb 6.6kb

So the total sent over the wire is 7.8kb.

All of which is loaded using the async attribute - so it won't block any loading or rendering of the page.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good numbers, and good to see you've got the stats. Worth adding to the docs?

docs/real-user-metrics.md Outdated Show resolved Hide resolved
docs/real-user-metrics.md Show resolved Hide resolved
docs/real-user-metrics.md Show resolved Hide resolved
docs/real-user-metrics.md Outdated Show resolved Hide resolved
spec/components/layout_for_public_spec.rb Show resolved Hide resolved
@bevanloon bevanloon temporarily deployed to govuk-publis-add-rum-to-xvdqeo June 15, 2021 13:50 Inactive
Copy link
Contributor

@andysellick andysellick left a comment

Choose a reason for hiding this comment

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

Looks good.

@injms injms merged commit 1b130d8 into master Jun 15, 2021
@injms injms deleted the add-rum-to-public-layout branch June 15, 2021 14:28
@injms injms mentioned this pull request Jun 15, 2021
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.

3 participants