@ons/design-system 61.0.0 → 61.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/js/analytics.js CHANGED
@@ -20,16 +20,12 @@ export const trackElement = el => {
20
20
  });
21
21
  };
22
22
 
23
- const isVisible = el => {
24
- return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
25
- };
26
-
27
23
  export default function initAnalytics() {
28
24
  let trackVisibleElements = [...document.querySelectorAll('[data-ga=visible]')];
29
25
 
30
26
  const interval = window.setInterval(() => {
31
27
  trackVisibleElements = trackVisibleElements.filter(element => {
32
- return isVisible(element) ? trackElement(element) && false : true;
28
+ return element ? trackElement(element) && false : true;
33
29
  });
34
30
  if (trackVisibleElements.length === 0) {
35
31
  window.clearInterval(interval);
package/js/timeout.js CHANGED
@@ -1,3 +1,4 @@
1
+ import initAnalytics from './analytics';
1
2
  export default class Timeout {
2
3
  constructor(context, sessionExpiryEndpoint, initialExpiryTime, enableTimeoutReset, startOnLoad) {
3
4
  this.context = context;
@@ -8,6 +9,7 @@ export default class Timeout {
8
9
  this.countdown = context.querySelector('.ons-js-timeout-timer');
9
10
  this.accessibleCountdown = context.querySelector('.ons-js-timeout-timer-acc');
10
11
  this.timeOutRedirectUrl = context.getAttribute('data-redirect-url');
12
+ this.setGAAttributes = context.getAttribute('data-enable-ga');
11
13
 
12
14
  // Language dependent text strings
13
15
  this.minutesTextSingular = context.getAttribute('data-minutes-text-singular');
@@ -79,6 +81,11 @@ export default class Timeout {
79
81
  if (timerExpired) {
80
82
  $this.countdown.innerHTML = '<span class="ons-u-fw-b">' + $this.countdownExpiredText + '</span>';
81
83
  $this.accessibleCountdown.innerHTML = $this.countdownExpiredText;
84
+ if ($this.setGAAttributes && $this.context.classList.contains('ons-modal')) {
85
+ $this.context.setAttribute('data-ga-action', 'Modal closed by timed event');
86
+ $this.context.setAttribute('data-ga-label', `Timeout modal closed`);
87
+ initAnalytics();
88
+ }
82
89
  setTimeout($this.redirect.bind($this), 2000);
83
90
  } else {
84
91
  seconds--;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ons/design-system",
3
3
  "description": "ONS Design System built CSS, JS, and Nunjucks templates",
4
- "version": "61.0.0",
4
+ "version": "61.0.2",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
7
7
  "author": {