Skip to content

Commit

Permalink
Fixes and tweaks to RUM
Browse files Browse the repository at this point in the history
  • Loading branch information
injms committed Jun 15, 2021
1 parent 51fd6a2 commit ab0fbbe
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/* eslint-disable */

/*
* Part of Speedcurve's LUX script, which allows us to run real user metrics on
* pages using the public layout template.
*
* See docs/real-user-metrics.md for more information.
*/

LUX = (function () {
var a =
"undefined" !== typeof LUX && "undefined" !== typeof LUX.gaMarks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
/* eslint-disable */

// ! Remember to keep the settings at the end of this file when updating LUX.
//
// The settings are:
// * `LUX.customerid = 47044334` to let LUX know who this is
// * `LUX.beaconMode = "simple"` to fire the beacon as an image, which is now
// allowed by the content security policy.
// * `LUX.debug = false` turns debugging on and off. Left set to false - and
// kept in the file so it's easier to remember that this can be turned on.
/*
* Part of Speedcurve's LUX script, which allows us to run real user metrics on
* pages using the public layout template.
*
* See docs/real-user-metrics.md for more information.
*/


/* ! Remember to keep the settings at the end of this file when updating LUX.
*
* The settings are:
* * `LUX.customerid = 47044334` to let LUX know who this is
* * `LUX.beaconMode = "simple"` to fire the beacon as an image, which is now
* allowed by the content security policy.
* * `LUX.debug = false` turns debugging on and off. Left set to false - and
* kept in the file so it's easier to remember that this can be turned on.
*/

var LUX_t_start = Date.now(),
LUX = window.LUX || {};
Expand Down
6 changes: 4 additions & 2 deletions docs/real-user-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ The LUX scripts should only be loaded when a user has opted into usage tracking.

## Custom changes when updating LUX

The scripts for the real user metrics are loaded from our servers - this allows us to know what is contained within the scripts and reduce the risk of unwelcome things being added to GOV.UK
The scripts for the real user metrics are loaded from our servers - this allows us to know what is contained within the scripts and reduce the risk of unwelcome things being added to GOV.UK.

Because of this, the scripts are audited before being updated and then two extra lines are added to make sure it works correctly. These two lines set the customer ID and turn on beacon mode.

### Customer ID

The customer ID is an identifier for the site using LUX, not for the user visiting the site. It won't change from page to page, or from visitor to visitor.

When loading `lux.js` from Speedcurve's CDN, the customer ID is appended to the end of the URI as a query string. The script looks for a script in the DOM with a source of `lux.js`, and from that extracts the customer ID.

Rails adds a fingerprint to the URI which means that `lux.js` becomes (for example) `lux.self-7137780d5344a93190a2c698cd660619d4197420b9b1ef963b639a825a6aa5ff.js` and the script can't find itself.
Expand Down Expand Up @@ -55,6 +57,6 @@ LUX.getDebug()

[LUX]: https://speedcurve.com/features/lux/

[Public Layout component]: components.publishing.service.gov.uk/component-guide/layout_for_public
[Public Layout component]: https://components.publishing.service.gov.uk/component-guide/layout_for_public

[csp-govuk-app-config]: https://github.com/alphagov/govuk_app_config/blob/87e445eccee5fba2449a170d5ba628e8a380fcb8/lib/govuk_app_config/govuk_content_security_policy.rb#L36-L38

0 comments on commit ab0fbbe

Please sign in to comment.