summaryrefslogtreecommitdiff
path: root/src/utils/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/features')
-rw-r--r--src/utils/features/consts.ts13
-rw-r--r--src/utils/features/runtime.ts44
2 files changed, 57 insertions, 0 deletions
diff --git a/src/utils/features/consts.ts b/src/utils/features/consts.ts
new file mode 100644
index 0000000..393fea9
--- /dev/null
+++ b/src/utils/features/consts.ts
@@ -0,0 +1,13 @@
+/**
+ * This file is a place for defining any Feature Flag Constants used throughout the app
+ * In order to keep the API Interface same for Build Time vs Runtime Feature Flags
+ * We have ensured that all the flags have to be defined in this file
+ */
+// Actual Feature Flag Values have to be defined in the /apps/app-store/featureFlags.external.cjs
+// BUILD BASED FEATURE FLAGS DUMMY FLAG DEFINITIONS TO FIX THE NAME OF THE FEATURE FLAGS TO BE USED
+// Values of the BUILD BASED FLAGS will decide if they are evaluated to true in DEV mode
+export const __FF_SHOW_RADAR = 'r01234e98765';
+
+export const __FF_SHOW_LOC_KEYS = 'ffShowLocKeys';
+
+export const __FF_ARYA = 'asha123e7z124';
diff --git a/src/utils/features/runtime.ts b/src/utils/features/runtime.ts
new file mode 100644
index 0000000..ebb83ad
--- /dev/null
+++ b/src/utils/features/runtime.ts
@@ -0,0 +1,44 @@
+import {
+ buildFeatureConfig,
+ buildRuntimeFeatureKitConfig,
+ ENVIRONMENT,
+ loadFeatureKit,
+ type OnyxFeatures,
+} from '@amp/web-apps-featurekit';
+import type { LoggerFactory } from '@amp/web-apps-logger';
+import { BUILD } from '~/config/build';
+
+export async function setupRuntimeFeatures(
+ logger: LoggerFactory,
+): Promise<OnyxFeatures | void> {
+ // load featureKit only for internal builds
+ if (import.meta.env.APP_SCOPE === 'internal' || import.meta.env.DEV) {
+ const features = await import('./consts');
+
+ // Build FeatureKit Config with overrides
+ const config = buildRuntimeFeatureKitConfig(features, {
+ [features.__FF_SHOW_RADAR]: buildFeatureConfig({
+ [ENVIRONMENT.DEV]: true,
+ }),
+ [features.__FF_ARYA]: {
+ ...buildFeatureConfig({ [ENVIRONMENT.DEV]: false }),
+ itfe: ['y9ttlj15'],
+ },
+ });
+ // Load runtime featureKit
+ return loadFeatureKit(
+ 'com.apple.apps',
+ ENVIRONMENT.DEV,
+ config,
+ logger,
+ {
+ enableToolbar: true,
+ radarConfig: {
+ component: 'ASE Web',
+ app: 'App Store',
+ build: BUILD,
+ },
+ },
+ );
+ }
+}