-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeatureFlags.ts
More file actions
396 lines (345 loc) · 10.9 KB
/
featureFlags.ts
File metadata and controls
396 lines (345 loc) · 10.9 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
import { parseEnvBoolean, parseOrgIds } from "utils/envUtils";
// Few pre-defined org-ids for configuring feature flags on production
// NOTE: The production org-ids must be read from environment variables
const ORG_ID = {
EKOSTORE: Number(process.env.NEXT_PUBLIC_ORG_IDS_EKOSTORE),
EKOTESTS: parseOrgIds(process.env.NEXT_PUBLIC_ORG_IDS_EKOTESTS),
SBIKIOSK: Number(process.env.NEXT_PUBLIC_ORG_IDS_SBIKIOSK),
AI_TEST: parseOrgIds(process.env.NEXT_PUBLIC_ORG_IDS_AI_TEST),
};
/**
* Note: This file is used to enable or disable features in the application.
* Can be used to enable or disable features based on user roles or environment.
*
* To add a feature-flag, add a new entry in the `FeatureFlags` object below.
* The key should be the name of the feature-flag (eg: "CHAT").
*
* To check for a feature-flag, use the "useFeatureFlag" hook.
* @example
* import { useFeatureFlag } from "hooks";
* const [isFeatureEnabled] = useFeatureFlag("FEATURE_NAME");
* const [isNotFeatureEnabled] = useFeatureFlag("!FEATURE_NAME"); // To check for "feature not enabled"
*/
export const FeatureFlags: Record<string, FeatureFlagType> = {
// ------------------------------------------------------------------------
// MARK: 🚩Dev Flags
// Put all in-development flags in this section.
// Assisted Full Onboarding
ASSISTED_FULL_ONBOARDING: {
enabled: true,
envConstraints: {
development: {
forOrgId: [3],
},
staging: {
forOrgId: [3],
},
production: {
forOrgId: [3],
},
},
},
// KYC Verification
KYC_VERIFICATION: {
enabled: true,
envConstraints: {
development: {
forOrgId: [3, 26],
},
staging: {
forOrgId: [26],
},
production: {
forOrgId: [420],
},
},
},
// Eko Shield
// TODO: Deprecate the usage of this flag across the project.
EKO_SHIELD: {
enabled: true,
},
VERIFICATION_WORKFLOW_BUILDER: {
enabled: true,
forEnv: ["development"],
},
// TODO: Update this feature flag on role basis instead of org-id basis after the role-based access control (RBAC) is implemented.
DEMO_ACCOUNT: {
enabled: true,
forAdminOnly: true,
envConstraints: {
development: {
forOrgId: [26],
},
staging: {
forOrgId: [26],
},
production: {
forOrgId: [420],
},
},
},
// Inventory Management for (Super)Distributors
INVENTORY_MANAGEMENT_FOR_SUBNETWORK: {
enabled: true,
forUserType: [1], // 7 = SuperDistributor
forEnv: ["development"],
},
// Custom theme support (paid tier)
CUSTOM_THEME_CREATOR: {
enabled: true,
forEnv: ["development"],
},
// Feature to show a custom Landing Page that can be fully configured by Admins.
CMS_LANDING_PAGE: {
enabled: true,
forEnv: ["development"],
},
// Eloka Gateway for redirection-based transaction processing.
ELOKA_GATEWAY: {
enabled: true,
forEnv: ["development"],
},
// ------------------------------------------------------------------------
// MARK: 🚩BETA Flags
// Feature Enabled only for certain orgs/users in production
// Put all UAT/Beta testing flags in this section.
// Feature to Raise Generic Issues (from Top-Right Menu)...
RAISE_ISSUE_GENERIC: {
enabled: true,
forAdminOnly: true, // TODO: Enable for all users
requiredFeatures: ["RAISE_ISSUE"],
},
// [MASTER FLAG] Experimental AI Features
// Disabling this will disable all other AI-related features.
AI_MASTER_FLAG: {
enabled: true,
forAdminOnly: true,
// forEnv: ["development"],
envConstraints: {
development: {
forOrgId: [3],
},
staging: {
forOrgId: [3],
},
production: {
forOrgId: [...ORG_ID.EKOTESTS, ...ORG_ID.AI_TEST], // 306=Kunal Chand, 186=HI TECH RECHARGE SOLUTION, 10=RAMSON TECHNOVATIONS PVT LTD, 344=PROWESS FINTECH PRIVATE LIMITED, 331=AJ ENTERPRISES
},
},
},
// Experimental LLM conversational UI for financial transactions and queries.
AI_CHATBOT: {
enabled: true,
forAdminOnly: true,
requiredFeatures: ["AI_MASTER_FLAG"],
},
// Feature to initiate AI Text Chatbot popup from KBar.
// It is only allowed if the AI_MASTER_FLAG feature is also enabled.
AI_CHATBOT_KBAR: {
enabled: true,
forAdminOnly: true,
requiredFeatures: ["AI_CHATBOT"],
},
// Feature to show AI Text Chatbot on Home or Dashboard page.
// It is only allowed if the AI_MASTER_FLAG feature is also enabled.
AI_CHATBOT_HOME: {
enabled: true,
forAdminOnly: true,
requiredFeatures: ["AI_CHATBOT"],
},
// Feature to enable AI Voice Chat.
// It is only allowed if the AI_MASTER_FLAG feature is also enabled.
AI_VOICEBOT: {
enabled: true,
forAdminOnly: true,
forEnv: ["development", "staging"],
requiredFeatures: ["AI_MASTER_FLAG"],
},
// Feature to enable AI Copilot.
AI_COPILOT: {
enabled: true,
forAdminOnly: true,
forEnv: ["development"],
requiredFeatures: ["AI_MASTER_FLAG"],
},
// ------------------------------------------------------------------------
// MARK: 🚩Production Flags
// Put all production flags (visible to all relevant users) in this section.
// Show Admin-like (business) dashboard to other sub-network owners like (Super)Distributor
ADMIN_DASHBOARD_FOR_SUBNETWORK: {
enabled: true,
forUserType: [1, 4, 7], // 1 = Dist, 7 = SuperDistributor, 4 = FOS
},
// Show Admin Network pages to sub-network users
ADMIN_NETWORK_PAGES_FOR_SUBNETWORK: {
enabled: true,
forUserType: [1, 4, 7], // 1 = Dist, 7 = SuperDistributor, 4 = FOS
},
// Open ChatGPT Agent in new tab
// To answer Admin's queries related to Eloka products and features.
CHATGPT_AGENT_LINK: {
enabled: true,
},
// Custom Flag for collapsable(compact) Sidebar (Left-Menu)
COMPACT_SIDEBAR: {
enabled: true,
},
// Custom flag for enabling Real Time Network Transactions for Admins
NETWORK_STATEMENT: {
enabled: true,
forAdminOnly: true,
},
// Feature for Admins to toggle services for their network (Business Settings > Enable/Disable Services)
TOGGLE_SERVICES: {
enabled: true,
forAdminOnly: true,
},
// Option to expand an issue in query-center to show detailed options and perform operations such as: Add Comment, Escalate, Close, etc.
QUERY_CENTER_DETAILED_OPTIONS: {
enabled: true,
forAdminOnly: true,
},
// Feature to show Tree-view in Network Management.
NETWORK_TREE_VIEW: {
enabled: true,
},
// Basic Landing Page customization where Admins can upload a custom image.
// This flag is to show the image on the landing/login page.
CMS_IMAGE_THEME: {
enabled: true,
},
// MANUALLY CONFIGURE CUSTOM IMAGE FOR LANDING/LOGIN PAGE...
// This flag is to show the image-upload option to Admins for configuring the landing page
// where the request goes to the DevOps team for manual configuration.
// TODO: Remove this after we are able to auto-upload images on file server for configuring the landing page (CMS).
MANUAL_LANDING_PAGE_IMAGE_SETUP: {
enabled: true,
forAdminOnly: true,
},
// Feature to Raise Issues (Generic + Trxn History)...
RAISE_ISSUE: {
enabled: !parseEnvBoolean(process.env.NEXT_PUBLIC_HIDE_RAISE_ISSUE),
},
// Custom flag for enabling raise issue only for SBI Kiosk _Agents_
RAISE_ISSUE_GENERIC_SBIKIOSK: {
enabled: true,
requiredFeatures: ["RAISE_ISSUE"],
envConstraints: {
development: {
forOrgId: [1],
},
production: {
forOrgId: [ORG_ID.SBIKIOSK],
},
},
},
// Theme selection from predefined themes (free tier)
THEME_PICKER: {
enabled: true,
},
// Face detector for images, videos, and live streams.
FACE_DETECTOR: {
enabled: true,
},
// TSP Bank Account Support (Multi-wallet) – Show bank balance and statement for TSP Bank Accounts.
// This is used for making payments from bank accounts using UPI and other payment methods,
// directly from the user's own bank account instead of their e-wallet).
TSP_BANK: {
enabled: true,
},
// ------------------------------------------------------------------------
// MARK: 🧪Test-Only Flags
// Put all experimental or developer testing-only flags in this section.
// Face detector for images, videos, and live streams.
TEXT_CLASSIFIER: {
enabled: true,
forEnv: ["development"],
},
// Expression editor for generating custom expressions using a GUI.
// To be used by developers only for inserting custom expressions
// in interaction-framework configuration database.
EXPRESSION_EDITOR: {
enabled: true,
forEnv: ["development"],
},
// A test page ("/test" or "/admin/test") to quickly check
// components, hooks, etc, during the development.
// Note: DO NOT CHANGE. ONLY FOR DEVELOPMENT ENVIRONMENT.
TEST_PAGE: {
enabled: true,
forEnv: ["development"], // DO NOT CHANGE
},
};
// ------------------------------------------------------------------------
// MARK: ⚙️ Types
// Type definition for environments
type EnvTypes = "development" | "staging" | "production" | string;
// Type definition for specific constraints for each envoirnment
type EnvConstraints = {
/**
* List of org-ids for which the feature is enabled.
* If the list is empty, the feature is enabled for all orgs.
* Example: [1, 2, 3]
*/
forOrgId?: number[];
/**
* List of user-IDs for which the feature is enabled.
* If the list is empty, the feature is enabled for all users.
* Example: ["123", "456", "789"]
*/
forUserId?: string[];
};
/**
* Type definition for a feature flag configuration.
*/
export type FeatureFlagType = {
/**
* Whether the feature is enabled or not.
* If false, the feature will not be available in the application.
* If true, the feature will be available in the application, based on other conditions.
* Default: false
*/
enabled: boolean;
/**
* List of environments for which the feature is enabled.
* If the list is empty, the feature is enabled for all environments.
* Possible values: "development", "staging", "production"
* Note: The environment is read from process.env.NEXT_PUBLIC_ENV
*/
forEnv?: EnvTypes[];
/**
* List of user-types for which the feature is enabled.
* If the list is empty, the feature is enabled for all user-types.
* Example: [1, 2, 3]
*/
forUserType?: number[];
/**
* List of user-IDs for which the feature is enabled.
* If the list is empty, the feature is enabled for all users.
* Example: ["123", "456", "789"]
*/
// forUserId?: string[];
/**
* List of roles for which the feature is enabled.
* If the list is empty, then roles have no effect on the availability of the feature.
*/
forRoles?: string[];
/**
* Whether the feature is enabled for Admin only.
* If true, the feature is enabled only for Admin users.
* Default: false
*/
forAdminOnly?: boolean;
/**
* Specific constraints for each environment.
*/
envConstraints?: Record<EnvTypes, EnvConstraints>;
/**
* An array of feature_flags that are required for this feature to be enabled.
* If any of the required features are not enabled, this feature will not be available.
* Each feature flagmust be one of the keys in the FeatureFlags object.
* Example: ["FEATURE_A", "FEATURE_B"]
*/
requiredFeatures?: (keyof typeof FeatureFlags)[];
};