/ src / utils / features / runtime.ts
runtime.ts
 1  import {
 2      buildFeatureConfig,
 3      buildRuntimeFeatureKitConfig,
 4      ENVIRONMENT,
 5      loadFeatureKit,
 6      type OnyxFeatures,
 7  } from '@amp/web-apps-featurekit';
 8  import type { LoggerFactory } from '@amp/web-apps-logger';
 9  import { BUILD } from '~/config/build';
10  
11  export async function setupRuntimeFeatures(
12      logger: LoggerFactory,
13  ): Promise<OnyxFeatures | void> {
14      // load featureKit only for internal builds
15      if (import.meta.env.APP_SCOPE === 'internal' || import.meta.env.DEV) {
16          const features = await import('./consts');
17  
18          // Build FeatureKit Config with overrides
19          const config = buildRuntimeFeatureKitConfig(features, {
20              [features.__FF_SHOW_RADAR]: buildFeatureConfig({
21                  [ENVIRONMENT.DEV]: true,
22              }),
23              [features.__FF_ARYA]: {
24                  ...buildFeatureConfig({ [ENVIRONMENT.DEV]: false }),
25                  itfe: ['y9ttlj15'],
26              },
27          });
28          // Load runtime featureKit
29          return loadFeatureKit(
30              'com.apple.apps',
31              ENVIRONMENT.DEV,
32              config,
33              logger,
34              {
35                  enableToolbar: true,
36                  radarConfig: {
37                      component: 'ASE Web',
38                      app: 'App Store',
39                      build: BUILD,
40                  },
41              },
42          );
43      }
44  }