@segment/analytics-browser-actions-vwo 1.74.0 → 1.75.1-node20.18
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/dist/cjs/identifyUser/index.js +1 -1
- package/dist/cjs/identifyUser/index.js.map +1 -1
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/init-script.js +158 -56
- package/dist/cjs/init-script.js.map +1 -1
- package/dist/cjs/trackEvent/index.js +1 -1
- package/dist/cjs/trackEvent/index.js.map +1 -1
- package/dist/cjs/types.d.ts +1 -1
- package/dist/esm/init-script.js +159 -57
- package/dist/esm/init-script.js.map +1 -1
- package/dist/esm/types.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/init-script.ts +158 -59
package/src/init-script.ts
CHANGED
|
@@ -8,74 +8,173 @@ export function initScript({
|
|
|
8
8
|
useExistingJquery = false,
|
|
9
9
|
isSpa = 1
|
|
10
10
|
}) {
|
|
11
|
-
window._vwo_code
|
|
12
|
-
window._vwo_code ||
|
|
11
|
+
window._vwo_code ||
|
|
13
12
|
(function () {
|
|
14
13
|
var account_id = vwoAccountId,
|
|
14
|
+
version = 2.1,
|
|
15
15
|
settings_tolerance = settingsTolerance,
|
|
16
|
-
library_tolerance = libraryTolerance,
|
|
17
|
-
use_existing_jquery = useExistingJquery,
|
|
18
|
-
is_spa = isSpa,
|
|
19
16
|
hide_element = 'body',
|
|
20
|
-
|
|
17
|
+
hide_element_style =
|
|
18
|
+
'transition:none;',
|
|
21
19
|
f = false,
|
|
20
|
+
w = window,
|
|
22
21
|
d = document,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
v = d.querySelector('#vwoCode'),
|
|
23
|
+
cK = '_vwo_' + account_id + '_settings',
|
|
24
|
+
cc = {}
|
|
25
|
+
try {
|
|
26
|
+
var c = JSON.parse(localStorage.getItem('_vwo_' + account_id + '_config'))
|
|
27
|
+
cc = c && typeof c === 'object' ? c : {}
|
|
28
|
+
} catch (e) { }
|
|
29
|
+
var stT = cc.stT === 'session' ? w.sessionStorage : w.localStorage
|
|
30
|
+
var code = {
|
|
31
|
+
nonce: v && v.nonce,
|
|
32
|
+
use_existing_jquery: function () {
|
|
33
|
+
return typeof use_existing_jquery !== 'undefined' ? use_existing_jquery : undefined
|
|
34
|
+
},
|
|
35
|
+
library_tolerance: function () {
|
|
36
|
+
return typeof library_tolerance !== 'undefined' ? library_tolerance : undefined
|
|
37
|
+
},
|
|
38
|
+
settings_tolerance: function () {
|
|
39
|
+
return cc.sT || settings_tolerance
|
|
40
|
+
},
|
|
41
|
+
hide_element_style: function () {
|
|
42
|
+
return '{' + (cc.hES || hide_element_style) + '}'
|
|
43
|
+
},
|
|
44
|
+
hide_element: function () {
|
|
45
|
+
if (
|
|
46
|
+
typeof performance.getEntriesByName === 'function' &&
|
|
47
|
+
performance.getEntriesByName('first-contentful-paint')[0]
|
|
48
|
+
) {
|
|
49
|
+
return ''
|
|
50
|
+
}
|
|
51
|
+
return typeof cc.hE === 'string' ? cc.hE : hide_element
|
|
52
|
+
},
|
|
53
|
+
getVersion: function () {
|
|
54
|
+
return version
|
|
55
|
+
},
|
|
56
|
+
finish: function (e) {
|
|
57
|
+
if (!f) {
|
|
58
|
+
f = true
|
|
59
|
+
var t = d.getElementById('_vis_opt_path_hides')
|
|
60
|
+
if (t) t.parentNode.removeChild(t)
|
|
61
|
+
if (e) new Image().src = 'https://dev.visualwebsiteoptimizer.com/ee.gif?a=' + account_id + e
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
finished: function () {
|
|
65
|
+
return f
|
|
66
|
+
},
|
|
67
|
+
addScript: function (e) {
|
|
68
|
+
var t = d.createElement('script')
|
|
69
|
+
t.type = 'text/javascript'
|
|
70
|
+
if (e.src) {
|
|
71
|
+
t.src = e.src
|
|
72
|
+
} else {
|
|
73
|
+
t.text = e.text
|
|
74
|
+
}
|
|
75
|
+
v && t.setAttribute('nonce', v.nonce)
|
|
76
|
+
d.getElementsByTagName('head')[0].appendChild(t)
|
|
77
|
+
},
|
|
78
|
+
load: function (e, t) {
|
|
79
|
+
var n = this.getSettings(),
|
|
80
|
+
i = d.createElement('script'),
|
|
81
|
+
r = this
|
|
82
|
+
t = t || {}
|
|
83
|
+
if (n) {
|
|
84
|
+
i.textContent = n
|
|
85
|
+
d.getElementsByTagName('head')[0].appendChild(i)
|
|
86
|
+
if (!w.VWO || VWO.caE) {
|
|
87
|
+
stT.removeItem(cK)
|
|
88
|
+
r.load(e)
|
|
35
89
|
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
90
|
+
} else {
|
|
91
|
+
var o = new XMLHttpRequest()
|
|
92
|
+
o.open('GET', e, true)
|
|
93
|
+
o.withCredentials = !t.dSC
|
|
94
|
+
o.responseType = t.responseType || 'text'
|
|
95
|
+
o.onload = function () {
|
|
96
|
+
if (t.onloadCb) {
|
|
97
|
+
return t.onloadCb(o, e)
|
|
98
|
+
}
|
|
99
|
+
if (o.status === 200 || o.status === 304) {
|
|
100
|
+
_vwo_code.addScript({
|
|
101
|
+
text: o.responseText
|
|
102
|
+
})
|
|
103
|
+
} else {
|
|
104
|
+
_vwo_code.finish('&e=loading_failure:' + e)
|
|
105
|
+
}
|
|
47
106
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
_vwo_code.finish()
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
107
|
+
o.onerror = function () {
|
|
108
|
+
if (t.onerrorCb) {
|
|
109
|
+
return t.onerrorCb(e)
|
|
110
|
+
}
|
|
111
|
+
_vwo_code.finish('&e=loading_failure:' + e)
|
|
112
|
+
}
|
|
113
|
+
o.send()
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
getSettings: function () {
|
|
117
|
+
try {
|
|
118
|
+
var e = stT.getItem(cK)
|
|
119
|
+
if (!e) {
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
e = JSON.parse(e)
|
|
123
|
+
if (Date.now() > e.e) {
|
|
124
|
+
stT.removeItem(cK)
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
return e.s
|
|
128
|
+
} catch (e) {
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
init: function () {
|
|
133
|
+
if (d.URL.indexOf('__vwo_disable__') > -1) return
|
|
134
|
+
var e = this.settings_tolerance()
|
|
135
|
+
w._vwo_settings_timer = setTimeout(function () {
|
|
136
|
+
_vwo_code.finish()
|
|
137
|
+
stT.removeItem(cK)
|
|
138
|
+
}, e)
|
|
139
|
+
var t
|
|
140
|
+
if (this.hide_element() !== 'body') {
|
|
141
|
+
t = d.createElement('style')
|
|
142
|
+
var n = this.hide_element(),
|
|
143
|
+
i = n ? n + this.hide_element_style() : '',
|
|
144
|
+
r = d.getElementsByTagName('head')[0]
|
|
145
|
+
t.setAttribute('id', '_vis_opt_path_hides')
|
|
146
|
+
v && t.setAttribute('nonce', v.nonce)
|
|
147
|
+
t.setAttribute('type', 'text/css')
|
|
148
|
+
if (t.styleSheet) t.styleSheet.cssText = i
|
|
149
|
+
else t.appendChild(d.createTextNode(i))
|
|
150
|
+
r.appendChild(t)
|
|
151
|
+
} else {
|
|
152
|
+
t = d.getElementsByTagName('head')[0]
|
|
153
|
+
var i = d.createElement('div')
|
|
154
|
+
i.style.cssText =
|
|
155
|
+
'z-index: 2147483647 !important;position: fixed !important;left: 0 !important;top: 0 !important;width: 100% !important;height: 100% !important;background: white !important;display: block !important;'
|
|
156
|
+
i.setAttribute('id', '_vis_opt_path_hides')
|
|
157
|
+
i.classList.add('_vis_hide_layer')
|
|
158
|
+
t.parentNode.insertBefore(i, t.nextSibling)
|
|
159
|
+
}
|
|
160
|
+
var o = window._vis_opt_url || d.URL,
|
|
161
|
+
s =
|
|
65
162
|
'https://dev.visualwebsiteoptimizer.com/j.php?a=' +
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
|
|
163
|
+
account_id +
|
|
164
|
+
'&u=' +
|
|
165
|
+
encodeURIComponent(o) +
|
|
166
|
+
'&vn=' +
|
|
167
|
+
version
|
|
168
|
+
if (w.location.search.indexOf('_vwo_xhr') !== -1) {
|
|
169
|
+
this.addScript({
|
|
170
|
+
src: s
|
|
171
|
+
})
|
|
172
|
+
} else {
|
|
173
|
+
this.load(s + '&x=true')
|
|
76
174
|
}
|
|
77
175
|
}
|
|
78
|
-
|
|
79
|
-
|
|
176
|
+
}
|
|
177
|
+
w._vwo_code = code
|
|
178
|
+
code.init()
|
|
80
179
|
})()
|
|
81
|
-
}
|
|
180
|
+
}
|