Sha256: f21c2b78ee62061fc8e1ef765bf6a673fd7de813eecb3d9547c5740bc24db885

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

;(function (global) {
  'use strict'

  var GOVUK = global.GOVUK || {}

  var Schemas = function () {
    this.undefined = undefined
  }

  Schemas.prototype.eventSchema = function () {
    return {
      event: this.undefined,

      event_data: {
        event_name: this.undefined,
        type: this.undefined,
        url: this.undefined,
        text: this.undefined,
        index: this.undefined,
        index_total: this.undefined,
        section: this.undefined,
        action: this.undefined,
        external: this.undefined,
        method: this.undefined,
        link_domain: this.undefined,
        link_path_parts: this.undefined,
        tool_name: this.undefined
      }
    }
  }

  // get attributes from the data attribute to send to GA
  // only allow it if it already exists in the schema
  Schemas.prototype.mergeProperties = function (data, eventAttribute) {
    var schema = this.eventSchema()
    schema.event = eventAttribute
    for (var property in data) {
      if (property in schema.event_data) {
        schema.event_data[property] = data[property]
      }
    }
    return schema
  }

  GOVUK.analyticsGa4 = GOVUK.analyticsGa4 || {}
  GOVUK.analyticsGa4.Schemas = Schemas

  global.GOVUK = GOVUK
})(window)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
govuk_publishing_components-34.10.1 app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js
govuk_publishing_components-34.10.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js
govuk_publishing_components-34.9.1 app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js
govuk_publishing_components-34.9.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js
govuk_publishing_components-34.8.1 app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js
govuk_publishing_components-34.8.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js