Skip to content

Commit 8338070

Browse files
authored
fix: improve error handling around vwo-script anti-flicker (#5593)
1 parent ace015d commit 8338070

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/App.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,27 @@ const App: FC = () => {
8383
}
8484

8585
if (CLOUD && isFlagEnabled('vwoAbTesting')) {
86-
executeVWO()
86+
const removeAntiFlickerStyle = () => {
87+
// This id must correspond to the id of the <style> tag set in the VWO script.
88+
const antiFlickerStyle = document.getElementById('_vis_opt_path_hides')
89+
if (antiFlickerStyle) {
90+
antiFlickerStyle.remove()
91+
}
92+
}
93+
94+
try {
95+
setTimeout(() => {
96+
removeAntiFlickerStyle()
97+
}, 2000)
98+
99+
executeVWO()
100+
} catch (err) {
101+
removeAntiFlickerStyle()
102+
103+
reportErrorThroughHoneyBadger(err, {
104+
name: 'VWO script failed to execute successfully',
105+
})
106+
}
87107
}
88108

89109
setAutoFreeze(false)

src/utils/vwo.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// this code is related to implementing the A/B testing tool VMO: https://vwo.com/
2+
// Whenever this script is updated, ensure that any changes are reflected in the
3+
// error handling in App.tsx, especially for any elements that change opacity of the page.
24
/* eslint-disable */
35
// @ts-nocheck
46
export const executeVWO = () => {
@@ -10,7 +12,7 @@ export const executeVWO = () => {
1012
library_tolerance = 2500,
1113
use_existing_jquery = false,
1214
is_spa = 1,
13-
hide_element = 'body',
15+
hide_element = '',
1416
/* DO NOT EDIT BELOW THIS LINE */
1517
f = false,
1618
d = document,

0 commit comments

Comments
 (0)