Skip to content

Commit c596bd4

Browse files
feat(flagged): add code to call out to VMO a/b testing framework (#5061)
1 parent b259a09 commit c596bd4

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

src/App.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ import {AppState} from 'src/types'
3939
// Utils
4040
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
4141
import {CLOUD} from 'src/shared/constants'
42-
import {shouldUseQuartzIdentity} from './identity/utils/shouldUseQuartzIdentity'
42+
import {shouldUseQuartzIdentity} from 'src/identity/utils/shouldUseQuartzIdentity'
43+
import {executeVWO} from 'src/utils/vwo'
4344

4445
// Styles
4546
const fullScreen = {height: '100%', width: '100%'}
@@ -78,6 +79,11 @@ const App: FC = () => {
7879
document.body.removeChild(script)
7980
}
8081
}
82+
83+
if (CLOUD && isFlagEnabled('vwoAbTesting')) {
84+
executeVWO()
85+
}
86+
8187
setAutoFreeze(false)
8288
}, [])
8389

src/utils/vwo.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// this code is related to implementing the A/B testing tool VMO: https://vwo.com/
2+
/* eslint-disable */
3+
// @ts-nocheck
4+
export const executeVWO = () => {
5+
window._vwo_code =
6+
window._vwo_code ||
7+
(function() {
8+
var account_id = 634566,
9+
settings_tolerance = 2000,
10+
library_tolerance = 2500,
11+
use_existing_jquery = false,
12+
is_spa = 1,
13+
hide_element = 'body',
14+
/* DO NOT EDIT BELOW THIS LINE */
15+
f = false,
16+
d = document,
17+
code = {
18+
use_existing_jquery: function() {
19+
return use_existing_jquery
20+
},
21+
library_tolerance: function() {
22+
return library_tolerance
23+
},
24+
finish: function() {
25+
if (!f) {
26+
f = true
27+
var a = d.getElementById('_vis_opt_path_hides')
28+
if (a) a.parentNode.removeChild(a)
29+
}
30+
},
31+
finished: function() {
32+
return f
33+
},
34+
load: function(a) {
35+
var b = d.createElement('script')
36+
b.src = a
37+
b.type = 'text/javascript'
38+
b.innerText
39+
b.onerror = function() {
40+
window._vwo_code.finish()
41+
}
42+
d.getElementsByTagName('head')[0].appendChild(b)
43+
},
44+
init: function() {
45+
window.settings_timer = setTimeout(function() {
46+
window._vwo_code.finish()
47+
}, settings_tolerance)
48+
var a = d.createElement('style'),
49+
b = hide_element
50+
? hide_element +
51+
'{opacity:0 !important;filter:alpha(opacity=0) !important;background:none !important;}'
52+
: '',
53+
h = d.getElementsByTagName('head')[0]
54+
a.setAttribute('id', '_vis_opt_path_hides')
55+
a.setAttribute('type', 'text/css')
56+
if (a.styleSheet) a.styleSheet.cssText = b
57+
else a.appendChild(d.createTextNode(b))
58+
h.appendChild(a)
59+
this.load(
60+
'https://dev.visualwebsiteoptimizer.com/j.php?a=' +
61+
account_id +
62+
'&u=' +
63+
encodeURIComponent(d.URL) +
64+
'&f=' +
65+
+is_spa +
66+
'&r=' +
67+
Math.random()
68+
)
69+
return window.settings_timer
70+
},
71+
}
72+
window._vwo_settings_timer = code.init()
73+
return code
74+
})()
75+
}

0 commit comments

Comments
 (0)