@ons/design-system 67.0.3 → 67.0.4
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/components/details/_details.scss +5 -0
- package/components/details/_macro.njk +9 -9
- package/components/header/example-header-external-with-sub-navigation-removed.njk +70 -0
- package/components/input/_input.scss +6 -0
- package/components/input/_macro.njk +32 -2
- package/components/input/example-input-text-width-constrained.njk +1 -1
- package/components/label/_macro.njk +4 -1
- package/components/navigation/_macro.njk +17 -15
- package/components/navigation/navigation.spec.js +89 -14
- package/components/tabs/_macro.njk +1 -1
- package/components/tabs/_macro.spec.js +0 -10
- package/css/main.css +1 -1
- package/js/analytics.js +26 -24
- package/js/main.js +1 -0
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
package/js/analytics.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import domready from './domready';
|
|
2
2
|
|
|
3
|
-
export let trackEvent = (
|
|
4
|
-
console.log(
|
|
5
|
-
console.log(data); // eslint-disable-line no-console
|
|
3
|
+
export let trackEvent = () => {
|
|
4
|
+
console.log('Google analytics not connected'); // eslint-disable-line no-console
|
|
6
5
|
};
|
|
6
|
+
setTimeout(() => {
|
|
7
|
+
if (window.google_tag_manager !== 'undefined') {
|
|
8
|
+
console.log('GA active');
|
|
9
|
+
window.dataLayer = window.dataLayer || [];
|
|
10
|
+
trackEvent = (data) => {
|
|
11
|
+
console.log('Data sent to Data Layer');
|
|
12
|
+
window.dataLayer.push({ data });
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}, 300);
|
|
7
16
|
|
|
8
|
-
|
|
9
|
-
trackEvent
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export const trackElement = (el) => {
|
|
15
|
-
return trackEvent('send', {
|
|
16
|
-
hitType: 'event',
|
|
17
|
-
eventCategory: el.getAttribute('data-ga-category') || '',
|
|
18
|
-
eventAction: el.getAttribute('data-ga-action') || '',
|
|
19
|
-
eventLabel: el.getAttribute('data-ga-label') || '',
|
|
17
|
+
export const trackElement = (el, type) => {
|
|
18
|
+
return trackEvent({
|
|
19
|
+
event_type: type,
|
|
20
|
+
event_category: el.getAttribute('data-ga-category') || '',
|
|
21
|
+
event_action: el.getAttribute('data-ga-action') || '',
|
|
22
|
+
event_label: el.getAttribute('data-ga-label') || '',
|
|
20
23
|
});
|
|
21
24
|
};
|
|
22
25
|
|
|
@@ -25,27 +28,26 @@ export default function initAnalytics() {
|
|
|
25
28
|
|
|
26
29
|
const interval = window.setInterval(() => {
|
|
27
30
|
trackVisibleElements = trackVisibleElements.filter((element) => {
|
|
28
|
-
return element ? trackElement(element) && false : true;
|
|
31
|
+
return element ? trackElement(element, 'visible') && false : true;
|
|
29
32
|
});
|
|
30
33
|
if (trackVisibleElements.length === 0) {
|
|
31
34
|
window.clearInterval(interval);
|
|
32
35
|
}
|
|
33
36
|
}, 200);
|
|
34
37
|
|
|
35
|
-
[...document.querySelectorAll('[data-ga=error]')].map(trackElement);
|
|
36
|
-
|
|
37
38
|
document.body.addEventListener('click', ({ target }) => {
|
|
38
39
|
if (target.getAttribute('data-ga') === 'click') {
|
|
39
|
-
trackElement(target);
|
|
40
|
+
trackElement(target, target.getAttribute('data-ga'));
|
|
40
41
|
}
|
|
41
42
|
});
|
|
43
|
+
[...document.querySelectorAll('[data-ga=error]')].map((element) => trackElement(element, 'error'));
|
|
42
44
|
|
|
43
45
|
const afterPrint = () => {
|
|
44
|
-
return trackEvent(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
return trackEvent({
|
|
47
|
+
event_tracked: 'true',
|
|
48
|
+
event_category: 'Print Intent',
|
|
49
|
+
event_action: 'Print Intent',
|
|
50
|
+
event_label: window.location.pathname.split('/').slice(-3).join('/'),
|
|
49
51
|
});
|
|
50
52
|
};
|
|
51
53
|
|
package/js/main.js
CHANGED