Skip to content

Commit c610d1f

Browse files
committed
opt in users by utc offset
1 parent 59e5960 commit c610d1f

File tree

2 files changed

+7
-50
lines changed

2 files changed

+7
-50
lines changed

src/browser/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ import ReactDOM from 'react-dom'
2323
import AppInit, { setupSentry } from './AppInit'
2424
import './init'
2525
import { navigateToPreview } from './modules/Stream/StartPreviewFrame'
26-
import { optedInByRegion } from './services/preview-optin-service'
26+
import { optedInByUtcOffset } from './services/preview-optin-service'
2727

2828
setupSentry()
2929

3030
;(async () => {
31-
const optedInToPreview = optedInByRegion()
31+
const optedInToPreview = optedInByUtcOffset()
3232
try {
3333
const response = await fetch('./preview/manifest.json')
3434
if (response.status === 200) {
Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,12 @@
1-
const EU_LOCALES = [
2-
'bg-bg', // Bulgarian (Bulgaria)
3-
'cs-cz', // Czech (Czech Republic)
4-
'cy-gb', // Welsh (United Kingdom)
5-
'da-dk', // Danish (Denmark)
6-
'de-at', // German (Austria)
7-
'de-ch', // German (Switzerland)
8-
'de-de', // German (Germany)
9-
'el-gr', // Greek (Greece)
10-
'en-gb', // English (United Kingdom)
11-
'en-ie', // English (Ireland)
12-
'et-ee', // Estonian (Estonia)
13-
'fi-fi', // Finnish (Finland)
14-
'fr-be', // French (Belgium)
15-
'fr-ch', // French (Switzerland)
16-
'fr-fr', // French (France)
17-
'ga-ie', // Irish (Ireland)
18-
'hr-hr', // Croatian (Croatia)
19-
'hu-hu', // Hungarian (Hungary)
20-
'is-is', // Icelandic (Iceland)
21-
'it-ch', // Italian (Switzerland)
22-
'it-it', // Italian (Italy)
23-
'lb-lu', // Luxembourgish (Luxembourg)
24-
'lt-lt', // Lithuanian (Lithuania)
25-
'lv-lv', // Latvian (Latvia)
26-
'mk-mk', // Macedonian (North Macedonia)
27-
'mt-mt', // Maltese (Malta)
28-
'nl-be', // Dutch (Belgium)
29-
'nl-nl', // Dutch (Netherlands)
30-
'no-no', // Norwegian (Norway)
31-
'pl-pl', // Polish (Poland)
32-
'pt-pt', // Portuguese (Portugal)
33-
'ro-ro', // Romanian (Romania)
34-
'ru-ru', // Russian (Russia)
35-
'sk-sk', // Slovak (Slovakia)
36-
'sl-si', // Slovenian (Slovenia)
37-
'sr-rs', // Serbian (Serbia)
38-
'sv-se', // Swedish (Sweden)
39-
'uk-ua' // Ukrainian (Ukraine)
40-
]
41-
42-
const OPTED_IN_LOCALES = [...EU_LOCALES]
43-
441
const userHasNotOptedOutOfPreview = (): boolean => {
452
const prefersOldBrowser = localStorage.getItem('prefersOldBrowser')
463
const doesPreferQuery = prefersOldBrowser === 'false'
474
return doesPreferQuery || prefersOldBrowser === null
485
}
496

50-
export const optedInByRegion = (): boolean => {
51-
return (
52-
OPTED_IN_LOCALES.includes(navigator.language.toLowerCase()) &&
53-
userHasNotOptedOutOfPreview()
54-
)
7+
export const optedInByUtcOffset = (): boolean => {
8+
const utcOffset = new Date().getTimezoneOffset()
9+
// UTC offset of -120 minutes (2 hours) e.g. CEST to 0 minutes (0 hours)
10+
const utcOffsetIsOptedIn = utcOffset >= -120 && utcOffset <= 0
11+
return utcOffsetIsOptedIn && userHasNotOptedOutOfPreview()
5512
}

0 commit comments

Comments
 (0)