Sha256: 490d4ba4a091f616d4483c6ddcfb7387f8d886fb9fa521a740b0124b2b118ce3

Contents?: true

Size: 1.12 KB

Versions: 127

Compression:

Stored size: 1.12 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 () {
    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', function () {
      insertScript()
    })
  }
})()

Version data entries

127 entries across 127 versions & 1 rubygems

Version Path
govuk_publishing_components-37.2.4 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-37.2.3 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-37.2.2 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-37.2.1 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-37.2.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-37.1.1 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-37.1.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-37.0.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-36.1.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-36.0.3 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-36.0.2 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-36.0.1 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-36.0.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-35.23.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-35.22.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-35.21.4 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-35.21.3 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-35.21.2 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-35.21.1 app/assets/javascripts/govuk_publishing_components/rum-loader.js
govuk_publishing_components-35.21.0 app/assets/javascripts/govuk_publishing_components/rum-loader.js