-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: support global enabled for goodid feature flag
- Loading branch information
Showing
3 changed files
with
16 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { retry } from './async' | ||
|
||
export const supportedCountries = async (supportedCountries = '', whitelist = [], account) => { | ||
export const supportedCountries = async (supportedCountries = '', whitelist = [], account, enabled) => { | ||
if (enabled || whitelist?.includes(account)) { | ||
return true | ||
} | ||
if (!supportedCountries) { | ||
return false | ||
} | ||
const country = await retry(async () => (await fetch('https://get.geojs.io/v1/ip/country.json')).json(), 3, 2000) | ||
.then(data => data.country) | ||
.catch(() => false) | ||
|
||
const isEligible = supportedCountries?.split(',')?.includes(country) || whitelist?.includes(account) | ||
|
||
return isEligible | ||
return supportedCountries?.split(',')?.includes(country) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters