Sha256: 0932544c63dbef9a9e9d2ec38aa8aab035f20fce35d7c73ceafdb4dda2e063c4

Contents?: true

Size: 1.16 KB

Versions: 88

Compression:

Stored size: 1.16 KB

Contents

(function () {
  var parsedCookie = (function () {
    try {
      var cookies = document.cookie.split(';')

      for (var i = 0; i < cookies.length; i++) {
        var cookie = cookies[i].replace(/\s/g, '') // Remove all whitespace.
        var cookieName = 'cookies_policy='

        if (cookie.indexOf(cookieName) === 0) {
          return JSON.parse(cookie.substring(cookieName.length))
        }
      }
    } catch (error) {
      console.error(error)
    }

    return {}
  })()

  var insertScript = function () {
    window.removeEventListener('cookie-consent', insertScript)
    var marker = document.querySelector('script[data-lux-reporter-script]')

    if (!marker) {
      console.error("Failed to configure real-user-monitoring because couldn't the lux-reporter script path wasn't available")
      return
    }

    var script = document.createElement('script')
    script.src = marker.getAttribute('data-lux-reporter-script')
    script.async = true
    script.defer = true

    marker.parentNode.insertBefore(script, marker)
  }

  if (parsedCookie.usage === true) {
    insertScript()
  } else {
    window.addEventListener('cookie-consent', insertScript)
  }
})()

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
govuk_publishing_components-51.1.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-51.0.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-50.0.1 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-50.0.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-49.1.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-49.0.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-48.0.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-47.0.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-46.4.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-46.3.1 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-46.3.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-46.2.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-46.1.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-46.0.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-45.10.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-45.9.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-45.8.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-45.7.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-45.6.1 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-45.6.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js