Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function getRemoteFeatureFlags() {
if (isTest) return INITIAL_FEATURE_FLAGS;
if (isDev) firebase.config().enableDeveloperMode();
const firebaseConfig = firebase.config();
firebaseConfig.setDefaults(INITIAL_FEATURE_FLAGS);
await firebaseConfig.fetch(0).catch(() => null); // 0 – try no caching, though Firebase can still throttle requests
await firebaseConfig.activateFetched().catch(() => null);
const featureFlagKeys = Object.keys(INITIAL_FEATURE_FLAGS || {});
const fetchedFlags = await firebaseConfig.getValues(featureFlagKeys).catch(() => ({}));
const mappedFeatureFlags = Object.keys(fetchedFlags).reduce((flags, flagKey) => ({
...flags,
[flagKey]: !!fetchedFlags[flagKey].val(),
}), {});
return isDev
? { ...mappedFeatureFlags, ...DEVELOPMENT_FEATURE_FLAGS }
: mappedFeatureFlags;
}
export async function get(value: String): any {
const result = await firebase.config().getValue(value);
if (result) {
return JSON.parse(result.val());
}
return null;
}
async function loadConfig() {
if (__DEV__) {
firebase.config().enableDeveloperMode();
}
await firebase.config().fetch();
await firebase.config().activateFetched();
}
async function loadConfig() {
if (__DEV__) {
firebase.config().enableDeveloperMode();
}
await firebase.config().fetch();
await firebase.config().activateFetched();
}
.then(() => {
return firebase.config().activateFetched();
})
.then(() => {
async function loadConfig() {
if (__DEV__) {
firebase.config().enableDeveloperMode();
}
await firebase.config().fetch();
await firebase.config().activateFetched();
}
async function loadConfig() {
if (__DEV__) {
firebase.config().enableDeveloperMode();
}
await firebase.config().fetch();
await firebase.config().activateFetched();
}