|
20 | 20 | const attr = currentScript.getAttribute.bind(currentScript); |
21 | 21 | const website = attr(_data + 'website-id'); |
22 | 22 | const hostUrl = attr(_data + 'host-url'); |
23 | | - const tag = attr(_data + 'tag'); |
| 23 | + const tag = attr(_data + 'tag') || undefined; |
24 | 24 | const autoTrack = attr(_data + 'auto-track') !== _false; |
25 | 25 | const dnt = attr(_data + 'do-not-track') === _true; |
26 | 26 | const excludeSearch = attr(_data + 'exclude-search') === _true; |
|
45 | 45 | hostname, |
46 | 46 | url: currentUrl, |
47 | 47 | referrer: currentRef, |
48 | | - tag: tag ? tag : undefined, |
| 48 | + tag, |
49 | 49 | }); |
50 | 50 |
|
51 | 51 | const hasDoNotTrack = () => { |
|
73 | 73 | const handlePathChanges = () => { |
74 | 74 | const hook = (_this, method, callback) => { |
75 | 75 | const orig = _this[method]; |
76 | | - |
77 | 76 | return (...args) => { |
78 | 77 | callback.apply(null, args); |
79 | | - |
80 | 78 | return orig.apply(_this, args); |
81 | 79 | }; |
82 | 80 | }; |
|
87 | 85 |
|
88 | 86 | const handleClicks = () => { |
89 | 87 | const trackElement = async el => { |
90 | | - const attr = el.getAttribute.bind(el); |
91 | | - const eventName = attr(eventNameAttribute); |
| 88 | + const eventName = el.getAttribute(eventNameAttribute); |
92 | 89 | if (eventName) { |
93 | 90 | const eventData = {}; |
94 | 91 |
|
95 | 92 | el.getAttributeNames().forEach(name => { |
96 | 93 | const match = name.match(eventRegex); |
97 | | - if (match) eventData[match[1]] = attr(name); |
| 94 | + if (match) eventData[match[1]] = el.getAttribute(name); |
98 | 95 | }); |
99 | 96 |
|
100 | 97 | return track(eventName, eventData); |
|
106 | 103 | if (!parentElement) return trackElement(el); |
107 | 104 |
|
108 | 105 | const { href, target } = parentElement; |
109 | | - const eventName = parentElement.getAttribute(eventNameAttribute); |
110 | | - if (!eventName) return; |
| 106 | + if (!parentElement.getAttribute(eventNameAttribute)) return; |
111 | 107 |
|
112 | 108 | if (parentElement.tagName === 'BUTTON') { |
113 | 109 | return trackElement(parentElement); |
|
158 | 154 | cache = data.cache; |
159 | 155 | } |
160 | 156 | } catch (e) { |
161 | | - /* empty */ |
| 157 | + /* no-op */ |
162 | 158 | } |
163 | 159 | }; |
164 | 160 |
|
|
0 commit comments