govuk_publishing_components 29.15.1 → 29.15.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9201a328c875b8cb5c93315a6365ea7dbc632027d0b973f9b0e700c86e01f6a
4
- data.tar.gz: 78cd444356c208537d7108cda4c471774a09b140c9db3e7aec1b0899adebf968
3
+ metadata.gz: dc8afcd723e5dd4096349ddfbce6a967b852d9525f46bb3a1b078c11ab0b5b41
4
+ data.tar.gz: b2c550b431ad6892bdee23afa7f2e83315e52725007d16149f20ce9a0ef29e7a
5
5
  SHA512:
6
- metadata.gz: cf29058c5c655fed33c3f10e34728752117387c0006893c70dccf563862a5cc98dae584218e974b40b63b71f64aef1ea8ffb9b9f0c98dde7bbc49fcea331da99
7
- data.tar.gz: 94bac53144fd6f7685976fbc884485d054ac991f07e1bee42c31707509cf6702063f3c1b9f67314e54dc48ea5f5d08ab00562a68e2af65b9b7dd0f98a7d5e1e5
6
+ metadata.gz: 0bd443616d7ab532ec0f2fe36549782986c3cb5bdbab636bdeec40ff595b7873b006d432f75c16f33311dda1c78b7e4533a4376ad52f19a8d1bf07b882dc03cd
7
+ data.tar.gz: 3f64655cddd38bf346a6ab3dd8c69917a70b3de614ad0d4f73b16b28f777b3c7901b466fe8479d0c7abc8205f0b123469f35c3f97f44ab3fdb6456cde97883f1
@@ -7,7 +7,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
7
7
 
8
8
  function GtmClickTracking (module) {
9
9
  this.module = module
10
- this.trackingTrigger = 'data-gtm-event-name' // elements with this attribute get tracked
10
+ this.trackingTrigger = 'data-ga4' // elements with this attribute get tracked
11
11
  }
12
12
 
13
13
  GtmClickTracking.prototype.init = function () {
@@ -18,12 +18,24 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
18
18
  if (window.dataLayer) {
19
19
  var target = this.findTrackingAttributes(event.target)
20
20
  if (target) {
21
- var data = {
22
- event: 'analytics',
23
- event_name: target.getAttribute('data-gtm-event-name'),
24
- // get entire URL apart from domain
25
- link_url: window.location.href.substring(window.location.origin.length),
26
- ui: JSON.parse(target.getAttribute('data-gtm-attributes')) || {}
21
+ var schema = new window.GOVUK.analyticsGA4.Schemas().eventSchema()
22
+
23
+ try {
24
+ var data = target.getAttribute(this.trackingTrigger)
25
+ data = JSON.parse(data)
26
+ } catch (e) {
27
+ // if there's a problem with the config, don't start the tracker
28
+ console.error('GA4 configuration error: ' + e.message, window.location)
29
+ return
30
+ }
31
+
32
+ schema.event = 'event_data'
33
+ // get attributes from the data attribute to send to GA
34
+ // only allow it if it already exists in the schema
35
+ for (var property in data) {
36
+ if (schema.event_data[property]) {
37
+ schema.event_data[property] = data[property]
38
+ }
27
39
  }
28
40
 
29
41
  // Ensure it only tracks aria-expanded in an accordion element, instead of in any child of the clicked element
@@ -39,15 +51,14 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
39
51
  var detailsElement = target.closest('details')
40
52
 
41
53
  if (ariaExpanded) {
42
- data.ui.text = data.ui.text || target.innerText
43
- data.ui.action = (ariaExpanded === 'false') ? 'opened' : 'closed'
54
+ schema.event_data.text = data.text || target.innerText
55
+ schema.event_data.action = (ariaExpanded === 'false') ? 'opened' : 'closed'
44
56
  } else if (detailsElement) {
45
- data.ui.text = data.ui.text || detailsElement.textContent
57
+ schema.event_data.text = data.text || detailsElement.textContent
46
58
  var openAttribute = detailsElement.getAttribute('open')
47
- data.ui.action = (openAttribute == null) ? 'opened' : 'closed'
59
+ schema.event_data.action = (openAttribute == null) ? 'opened' : 'closed'
48
60
  }
49
-
50
- window.dataLayer.push(data)
61
+ window.dataLayer.push(schema)
51
62
  }
52
63
  }
53
64
  }
@@ -9,29 +9,26 @@
9
9
  sendPageView: function () {
10
10
  if (window.dataLayer) {
11
11
  var data = {
12
- event: 'config_ready',
12
+ event: 'page_view',
13
13
  page: {
14
14
  location: this.getLocation(),
15
15
  referrer: this.getReferrer(),
16
16
  title: this.getTitle(),
17
- status_code: this.getStatusCode()
18
- },
19
- publishing: {
17
+ status_code: this.getStatusCode(),
18
+
20
19
  document_type: this.getMetaContent('format'),
21
20
  publishing_app: this.getMetaContent('publishing-app'),
22
21
  rendering_app: this.getMetaContent('rendering-app'),
23
22
  schema_name: this.getMetaContent('schema-name'),
24
- content_id: this.getMetaContent('content-id')
25
- },
26
- taxonomy: {
23
+ content_id: this.getMetaContent('content-id'),
24
+
27
25
  section: this.getMetaContent('section'),
28
26
  taxon_slug: this.getMetaContent('taxon-slug'),
29
27
  taxon_id: this.getMetaContent('taxon-id'),
30
28
  themes: this.getMetaContent('themes'),
31
29
  taxon_slugs: this.getMetaContent('taxon-slugs'),
32
- taxon_ids: this.getMetaContent('taxon-ids')
33
- },
34
- content: {
30
+ taxon_ids: this.getMetaContent('taxon-ids'),
31
+
35
32
  language: this.getLanguage(),
36
33
  history: this.getHistory(),
37
34
  withdrawn: this.getWithDrawn(),
@@ -65,9 +62,9 @@
65
62
  // https://github.com/alphagov/static/blob/main/app/views/root/_error_page.html.erb#L32
66
63
  getStatusCode: function () {
67
64
  if (window.httpStatusCode) {
68
- return window.httpStatusCode
65
+ return window.httpStatusCode.toString()
69
66
  } else {
70
- return 200
67
+ return '200'
71
68
  }
72
69
  },
73
70
 
@@ -0,0 +1,32 @@
1
+ ;(function (global) {
2
+ 'use strict'
3
+
4
+ var GOVUK = global.GOVUK || {}
5
+
6
+ var Schemas = function () {
7
+ this.null = 'n/a'
8
+ }
9
+
10
+ Schemas.prototype.eventSchema = function () {
11
+ return {
12
+ event: this.null,
13
+
14
+ event_data: {
15
+ event_name: this.null,
16
+ type: this.null,
17
+ url: this.null,
18
+ text: this.null,
19
+ index: this.null,
20
+ index_total: this.null,
21
+ section: this.null,
22
+ action: this.null,
23
+ external: this.null
24
+ }
25
+ }
26
+ }
27
+
28
+ GOVUK.analyticsGA4 = GOVUK.analyticsGA4 || {}
29
+ GOVUK.analyticsGA4.Schemas = Schemas
30
+
31
+ global.GOVUK = GOVUK
32
+ })(window)
@@ -1,4 +1,5 @@
1
1
  // The following modules are imported in a specific order
2
+ //= require ./analytics-ga4/gtm-schemas
2
3
  //= require ./analytics-ga4/pii-remover
3
4
  //= require ./analytics-ga4/gtm-page-views
4
5
  //= require ./analytics-ga4/gtm-click-tracking
@@ -25,12 +25,23 @@
25
25
  $caption-side: top; // Caption alignment. Top or bottom.
26
26
  $key-width: 160px; // Only used by IE. Other browsers get smallest width that fits content
27
27
 
28
+ // The following accessible colour palette has been developed to meet the colour contrast requirements for adjacent colours (as set out in WCAG 2.1)
29
+ // For charts, the palette should be used instead of the GOV.UK colour palette - https://design-system.service.gov.uk/styles/colour/
30
+ // https://gss.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/#section-5
31
+
32
+ $gss-colour-dark-blue: #12436d;
33
+ $gss-colour-turquoise: #28a197;
34
+ $gss-colour-dark-pink: #801650;
35
+ $gss-colour-orange: #f46a25;
36
+ $gss-colour-dark-grey: #3d3d3d;
37
+ $gss-colour-plum: #a285d1;
38
+
28
39
  // CHART COLOUR SCHEME
29
40
 
30
41
  $chart-border: govuk-colour("white"); // Chart border colour
31
42
  $key-border: govuk-colour("white"); // Key border colour
32
- $bar-colours: govuk-colour("blue"), govuk-colour("turquoise"), govuk-colour("green"), govuk-colour("light-green"), govuk-colour("yellow"), govuk-colour("orange"), govuk-colour("red"), govuk-colour("bright-purple", $legacy: "bright-red");
33
- $bar-text-colours: govuk-colour("white"), govuk-colour("black"), govuk-colour("white"), govuk-colour("black"), govuk-colour("black"), govuk-colour("black"), govuk-colour("white"), govuk-colour("white");
43
+ $bar-colours: $gss-colour-dark-blue, $gss-colour-turquoise, $gss-colour-dark-pink, $gss-colour-orange, $gss-colour-dark-grey, $gss-colour-plum;
44
+ $bar-text-colours: govuk-colour("white"), govuk-colour("white"), govuk-colour("white"), govuk-colour("black"), govuk-colour("white"), govuk-colour("black");
34
45
  $bar-cell-colour: govuk-colour("black");
35
46
  $bar-outdented-colour: govuk-colour("black");
36
47
 
@@ -181,6 +181,11 @@ examples:
181
181
  </tbody>
182
182
  </table>
183
183
  charts:
184
+ description: |
185
+ The Government Statistical Service (GSS) guidance recommends [a limit of four categories as best practice for basic data visualisations](https://gss.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/#section-5).
186
+
187
+ Note that charts which have up to 7 categories, [chart with colours](http://govuk-publishing-components.dev.gov.uk/component-guide/govspeak/chart_with_colours/preview), for example, will display subsequent bars in `#3d3d3d`, `#a285d1` and the 7th bar in the default colour of `#0b0c0c` and will still meet the colour contrast requirements for adjacent colours.
188
+ Charts that have 8 or more categories will display additional bars in the default colour and will not meet colour contrast requirements for adjacent colours.
184
189
  data:
185
190
  block: |
186
191
  <table class='js-barchart-table mc-auto-outdent'>
@@ -214,8 +219,6 @@ examples:
214
219
  <th scope="col">Grapes</th>
215
220
  <th scope="col">Strawberries</th>
216
221
  <th scope="col">Plums</th>
217
- <th scope="col">Apricots</th>
218
- <th scope="col">Pineapples</th>
219
222
  </tr>
220
223
  </thead>
221
224
  <tbody>
@@ -228,8 +231,6 @@ examples:
228
231
  <td>24</td>
229
232
  <td>10</td>
230
233
  <td>62</td>
231
- <td>29</td>
232
- <td>81</td>
233
234
  </tr>
234
235
  <tr>
235
236
  <td>Numbers outside bar</td>
@@ -238,10 +239,8 @@ examples:
238
239
  <td>2</td>
239
240
  <td>1</td>
240
241
  <td>1</td>
241
- <td>3</td>
242
- <td>3</td>
243
- <td>1</td>
244
242
  <td>2</td>
243
+ <td>1</td>
245
244
  </tr>
246
245
  </tbody>
247
246
  </table>
@@ -188,7 +188,7 @@ examples:
188
188
  data:
189
189
  large: true
190
190
  href: "/still-not-a-page"
191
- image_src: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG"
191
+ image_src: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/91397/s712_SG_Swear_in_1_.jpg"
192
192
  image_alt: "some meaningful alt text please"
193
193
  context:
194
194
  date: 2017-06-14 11:30:00
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "29.15.1".freeze
2
+ VERSION = "29.15.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 29.15.1
4
+ version: 29.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-20 00:00:00.000000000 Z
11
+ date: 2022-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -438,6 +438,7 @@ files:
438
438
  - app/assets/javascripts/govuk_publishing_components/analytics-ga4.js
439
439
  - app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-click-tracking.js
440
440
  - app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-page-views.js
441
+ - app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-schemas.js
441
442
  - app/assets/javascripts/govuk_publishing_components/analytics-ga4/pii-remover.js
442
443
  - app/assets/javascripts/govuk_publishing_components/analytics.js
443
444
  - app/assets/javascripts/govuk_publishing_components/analytics/analytics.js