Skip to content

Commit 8275f96

Browse files
committed
adds optin service
1 parent 2a9dd4a commit 8275f96

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
const EMEA_LOCALES = [
2+
'bg-bg',
3+
'cs-cz',
4+
'cy-gb',
5+
'da-dk',
6+
'de-de',
7+
'el-gr',
8+
'en-gb',
9+
'et-ee',
10+
'fi-fi',
11+
'fr-fr',
12+
'ga-ie',
13+
'hr-hr',
14+
'hu-hu',
15+
'is-is',
16+
'it-it',
17+
'lb-lu',
18+
'lt-lt',
19+
'lv-lv',
20+
'mk-mk',
21+
'mt-mt',
22+
'nl-nl',
23+
'no-no',
24+
'pl-pl',
25+
'pt-pt',
26+
'ro-ro',
27+
'ru-ru',
28+
'sk-sk',
29+
'sl-si',
30+
'sr-rs',
31+
'sv-se',
32+
'uk-ua'
33+
]
34+
35+
const APAC_LOCALES = [
36+
'as-in',
37+
'az-az',
38+
'bn-bd',
39+
'bn-in',
40+
'bo-cn',
41+
'fil-ph',
42+
'gu-in',
43+
'hi-in',
44+
'hy-am',
45+
'id-id',
46+
'ja-jp',
47+
'ka-ge',
48+
'km-kh',
49+
'kn-in',
50+
'ko-kr',
51+
'lo-la',
52+
'ml-in',
53+
'mn-mn',
54+
'mr-in',
55+
'ms-my',
56+
'my-mm',
57+
'ne-np',
58+
'or-in',
59+
'pa-in',
60+
'ps-af',
61+
'sa-in',
62+
'si-lk',
63+
'ta-in',
64+
'te-in',
65+
'th-th',
66+
'tr-tr',
67+
'ug-cn',
68+
'ur-in',
69+
'ur-pk',
70+
'vi-vn',
71+
'zh-cn',
72+
'zh-hk',
73+
'zh-tw'
74+
]
75+
76+
const AMERICAS_LOCALES = [
77+
'ay-bo',
78+
'en-029',
79+
'en-ca',
80+
'en-us',
81+
'es-419',
82+
'es-ar',
83+
'es-bo',
84+
'es-cl',
85+
'es-co',
86+
'es-cr',
87+
'es-cu',
88+
'es-do',
89+
'es-ec',
90+
'es-gq',
91+
'es-gt',
92+
'es-hn',
93+
'es-mx',
94+
'es-ni',
95+
'es-pa',
96+
'es-pe',
97+
'es-pr',
98+
'es-py',
99+
'es-sv',
100+
'es-uy',
101+
'es-ve',
102+
'fr-029',
103+
'fr-ca',
104+
'gn-py',
105+
'pt-419',
106+
'pt-br',
107+
'qu-pe'
108+
]
109+
110+
const OPTED_IN_LOCALES = [...EMEA_LOCALES]
111+
112+
const userPrefersQuery = (): boolean => {
113+
const prefersOldBrowser = localStorage.getItem('prefersOldBrowser')
114+
const doesPreferQuery = prefersOldBrowser === 'false'
115+
return doesPreferQuery || prefersOldBrowser === null
116+
}
117+
118+
export const optedInByRegion = (): boolean => {
119+
return (
120+
OPTED_IN_LOCALES.includes(navigator.language.toLowerCase()) &&
121+
userPrefersQuery()
122+
)
123+
}

0 commit comments

Comments
 (0)