summaryrefslogtreecommitdiff
path: root/src/utils/features/runtime.ts
blob: ebb83ad8c9ac51458bb510e919ad5f764b7a517d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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,
                },
            },
        );
    }
}