|
1 | 1 | // @flow |
2 | 2 |
|
3 | 3 | export function loadHeap() { |
4 | | - window.heap = window.heap || []; |
5 | | - heap.load = function(e, t) { |
6 | | - window.heap.appid = e; |
7 | | - window.heap.config = t = t || {}; |
8 | | - let r = document.createElement("script"); |
9 | | - r.type = "text/javascript"; |
10 | | - r.async = !0; |
11 | | - r.src = "https://cdn.heapanalytics.com/js/heap-" + e + ".js"; |
12 | | - let a = document.getElementsByTagName("script")[0]; |
13 | | - a.parentNode.insertBefore(r, a); |
14 | | - for ( |
15 | | - let n = function(e) { |
16 | | - return function() { |
17 | | - heap.push([e].concat(Array.prototype.slice.call(arguments, 0))); |
18 | | - }; |
19 | | - }, |
20 | | - p = [ |
21 | | - "addEventProperties", |
22 | | - "addUserProperties", |
23 | | - "clearEventProperties", |
24 | | - "identify", |
25 | | - "resetIdentity", |
26 | | - "removeEventProperty", |
27 | | - "setEventProperties", |
28 | | - "track", |
29 | | - "unsetEventProperty", |
30 | | - ], |
31 | | - o = 0; |
32 | | - o < p.length; |
33 | | - o++ |
34 | | - ) |
35 | | - heap[p[o]] = n(p[o]); |
36 | | - }; |
37 | | - heap.load(window.HEAP_ANALYTICS_ID); |
38 | | - window.democracyLabEvents = { heapLoaded: true }; |
39 | | - window.dispatchEvent(new Event("heapLoaded")); |
| 4 | + if (window.HEAP_ANALYTICS_ID) { |
| 5 | + window.heap = window.heap || []; |
| 6 | + heap.load = function(e, t) { |
| 7 | + window.heap.appid = e; |
| 8 | + window.heap.config = t = t || {}; |
| 9 | + let r = document.createElement("script"); |
| 10 | + r.type = "text/javascript"; |
| 11 | + r.async = !0; |
| 12 | + r.src = "https://cdn.heapanalytics.com/js/heap-" + e + ".js"; |
| 13 | + let a = document.getElementsByTagName("script")[0]; |
| 14 | + a.parentNode.insertBefore(r, a); |
| 15 | + for ( |
| 16 | + let n = function(e) { |
| 17 | + return function() { |
| 18 | + heap.push([e].concat(Array.prototype.slice.call(arguments, 0))); |
| 19 | + }; |
| 20 | + }, |
| 21 | + p = [ |
| 22 | + "addEventProperties", |
| 23 | + "addUserProperties", |
| 24 | + "clearEventProperties", |
| 25 | + "identify", |
| 26 | + "resetIdentity", |
| 27 | + "removeEventProperty", |
| 28 | + "setEventProperties", |
| 29 | + "track", |
| 30 | + "unsetEventProperty", |
| 31 | + ], |
| 32 | + o = 0; |
| 33 | + o < p.length; |
| 34 | + o++ |
| 35 | + ) |
| 36 | + heap[p[o]] = n(p[o]); |
| 37 | + }; |
| 38 | + heap.load(window.HEAP_ANALYTICS_ID); |
| 39 | + window.democracyLabEvents = { heapLoaded: true }; |
| 40 | + window.dispatchEvent(new Event("heapLoaded")); |
| 41 | + } |
40 | 42 | } |
41 | 43 |
|
42 | 44 | loadHeap(); |
0 commit comments