forked from binary-com/deriv-com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-browser.js
51 lines (42 loc) · 1.76 KB
/
gatsby-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { WrapPagesWithLocaleContext } from './src/components/localization'
import { isProduction } from './src/common/websocket/config'
import { LocalStore } from './src/common/storage'
import TrafficSource from './src/common/traffic-source'
import isMobile from './src/common/os-detect'
import 'typeface-ibm-plex-sans'
const is_browser = typeof window !== 'undefined'
export const onInitialClientRender = () => {
// Enable translation
// Check if not production and match ach or ach/
if (is_browser) {
const match_ach = window.location.pathname.match(/^(\/ach\/)|\/ach$/)
if (match_ach) {
// TODO: remove this line when production ready for translation
if (!isProduction()) LocalStore.set('i18n', 'ach')
}
const i18n = LocalStore.get('i18n')
if (!isProduction() && i18n && i18n.match('ach')) {
const jipt = document.createElement('script')
jipt.type = 'text/javascript'
jipt.text = `
var _jipt = []; _jipt.push(['project', 'deriv-com']);
var crowdin = document.createElement("script");
crowdin.setAttribute('src', '//cdn.crowdin.com/jipt/jipt.js');
document.head.appendChild(crowdin);
`
document.head.appendChild(jipt)
}
}
// Configure traffic source
TrafficSource.initUtmCookie()
TrafficSource.setData()
TrafficSource.setAffiliateData()
if (!LocalStore.get('signup_device')) {
LocalStore.set('signup_device', isMobile() ? 'mobile' : 'desktop')
}
}
export const onClientEntry = () => {
LocalStore.set('window_loaded', '')
window.onload = () => LocalStore.set('window_loaded', 'true')
}
export const wrapPageElement = WrapPagesWithLocaleContext