forked from artsy/eigen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
features.ts
339 lines (324 loc) · 10.6 KB
/
features.ts
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
import { useToast } from "app/Components/Toast/toastHook"
import { echoLaunchJson } from "app/utils/jsonFiles"
import { GlobalStore } from "../GlobalStore"
interface FeatureDescriptorCommonTypes {
/** Provide a short description for the Dev Menu. */
readonly description?: string
/** Whether or not to show the feature flag in the Dev Menu. Consider also providing a description. */
readonly showInDevMenu?: boolean
}
export interface FeatureDescriptorReadyForRelease {
/**
* Set readyForRelease to `true` when the feature is ready to be exposed outside of dev mode.
* If an echo flag key is specified, the echo flag's value will be used after this
* is set to `true`.
*/
readonly readyForRelease: true
/**
* Provide an echo feature flag key to allow this feature to be toggled globally via echo.
* Make sure to add the flag to echo before setting this value. Then run `./scripts/update-echo`.
*/
readonly echoFlagKey: string
}
interface FeatureDescriptorNotReadyForRelease {
/**
* Set readyForRelease to `false` when the feature is still in progress.
*/
readonly readyForRelease: false
readonly echoFlagKey?: string
}
export type FeatureDescriptor = (
| FeatureDescriptorReadyForRelease
| FeatureDescriptorNotReadyForRelease
) &
FeatureDescriptorCommonTypes
// Helper function to get good typings and intellisense
function defineFeatures<T extends string>(featureMap: {
readonly [featureName in T]: FeatureDescriptor
}) {
return featureMap
}
export type FeatureName = keyof typeof features
export const features = defineFeatures({
AROptionsPriceTransparency: {
readyForRelease: true,
echoFlagKey: "AROptionsPriceTransparency",
description: "Price Transparency",
},
AROptionsLotConditionReport: {
readyForRelease: true,
echoFlagKey: "AROptionsLotConditionReport",
},
AREnableOrderHistoryOption: {
readyForRelease: true,
echoFlagKey: "AREnableOrderHistoryOption",
description: "Enable Order History in settings",
},
AREnableSavedAddresses: {
readyForRelease: false,
description: "Enable Saved Addresses",
},
AREnableTrove: {
readyForRelease: true,
description: "Enable Trove in homepage",
echoFlagKey: "AREnableTrove",
},
AREnableShowsRail: {
readyForRelease: true,
description: "Enable Shows in homepage",
echoFlagKey: "AREnableShowsRail",
},
ARShowNetworkUnavailableModal: {
readyForRelease: true,
description: "Enable network unavailable modal",
echoFlagKey: "ARShowNetworkUnavailableModal",
},
ARGoogleAuth: {
readyForRelease: true,
description: "Enable Google authentication",
echoFlagKey: "ARGoogleAuth",
},
AREnableExampleExperiments: {
// we can remove this as soon as we have a real experiment on Unleash
readyForRelease: false,
description: "Show example Unleash experiments",
},
AREnableQueriesPrefetching: {
readyForRelease: true,
description: "Enable query prefetching",
echoFlagKey: "AREnableQueriesPrefetching",
},
ARAllowLinkSocialAccountsOnSignUp: {
readyForRelease: true,
description: "Allow linking of social accounts on sign up",
echoFlagKey: "ARAllowLinkSocialAccountsOnSignUp",
},
AREnableImageSearch: {
readyForRelease: false,
description: "Enable search with image",
showInDevMenu: true,
},
AREnableMyCollectionSearchBar: {
readyForRelease: true,
description: "Enable My Collection search bar",
echoFlagKey: "AREnableMyCollectionSearchBar",
},
AREnablePlaceholderLayoutAnimation: {
readyForRelease: true,
description: "Enable placeholder layout animation",
echoFlagKey: "AREnablePlaceholderLayoutAnimation",
},
ARDarkModeSupport: {
readyForRelease: false,
description: "Support dark mode",
},
ARShowRequestPriceEstimateBanner: {
readyForRelease: true,
description: "Show request price estimate banner",
echoFlagKey: "ARShowRequestPriceEstimateBanner",
},
ARShowMyCollectionDemandIndexHints: {
readyForRelease: true,
description: "Show demand index hints",
echoFlagKey: "ARShowMyCollectionDemandIndexHints",
},
AREnablePriceEstimateRange: {
readyForRelease: false,
description: "Enable My Collection Price Estimate Range",
showInDevMenu: false,
},
AREnableHomeScreenArtworkRecommendations: {
readyForRelease: true,
description: "Enable Home Screen Artwork Recommendations",
echoFlagKey: "AREnableHomeScreenArtworkRecommendations",
},
AREnableMapScreen: {
readyForRelease: false,
description: "Enable Crossplatform Map Screen",
showInDevMenu: true,
},
AREnableAuctionShareButton: {
readyForRelease: true,
description: "Show share button in auction screen",
echoFlagKey: "AREnableAuctionShareButton",
},
AREnableNewOpaqueImageComponent: {
readyForRelease: true,
description: "Enable New Image Component",
showInDevMenu: true,
echoFlagKey: "AREnableNewOpaqueImageComponent",
},
AREnableConversationalBuyNow: {
readyForRelease: true,
description: "Conversational Buy Now",
echoFlagKey: "AREnableConversationalBuyNow",
},
AREnableMyCollectionInsights: {
readyForRelease: true,
description: "Enable My Collection insights tab",
echoFlagKey: "AREnableMyCollectionInsights",
},
AREnableArtworksFromNonArtsyArtists: {
readyForRelease: false,
description: "Enable My Collection artworks from non-Artsy artists",
showInDevMenu: true,
echoFlagKey: "AREnableArtworksFromNonArtsyArtists",
},
AREnableArtworksConnectionForAuction: {
readyForRelease: true,
description: "Use artworksConnection for Auction screen",
echoFlagKey: "AREnableArtworksConnectionForAuction",
},
AREnableActivity: {
readyForRelease: true,
description: "Enable Activity",
showInDevMenu: true,
echoFlagKey: "AREnableActivity",
},
AREnableMyCollectionHFOnboarding: {
readyForRelease: true,
description: "Enable My Collection home feed onboarding",
showInDevMenu: true,
echoFlagKey: "AREnableMyCollectionHFOnboarding",
},
AREnableCollectionsInOnboarding: {
readyForRelease: true,
description: "Replace genes with collections in onboarding",
echoFlagKey: "AREnableCollectionsInOnboarding",
},
AREnableNewRequestPriceEstimateLogic: {
description: "Enable new request price estimate logic",
showInDevMenu: true,
readyForRelease: true,
echoFlagKey: "AREnableNewRequestPriceEstimateLogic",
},
ARReorderSWAArtworkSubmissionFlow: {
description: "Reorder SWA Artwork submission flow",
showInDevMenu: true,
readyForRelease: true,
echoFlagKey: "ARReorderSWAArtworkSubmissionFlow",
},
ARArtworkRedesingPhase2: {
description: "Enable redesigned artwork page (phase 2)",
showInDevMenu: true,
readyForRelease: true,
echoFlagKey: "ARArtworkRedesingPhase2",
},
AREnablePanOnStaticHeader: {
description: "Enable Scroll/Pan on StaticHeader",
showInDevMenu: true,
readyForRelease: false,
},
AREnableSearchDiscoveryContentIOS: {
description: "Display discovery content on Search tab on iOS",
showInDevMenu: true,
readyForRelease: true,
echoFlagKey: "AREnableSearchDiscoveryContentIOS",
},
AREnableSearchDiscoveryContentAndroid: {
description: "Display discovery content on Search tab on Android",
showInDevMenu: true,
readyForRelease: true,
echoFlagKey: "AREnableSearchDiscoveryContentAndroid",
},
AREnforceLargeNewWorksRail: {
description: "Enforce large new works rail",
showInDevMenu: true,
readyForRelease: false,
},
AREnableArtworkGridSaveIcon: {
description: "Enable artwork grid save icon",
showInDevMenu: true,
readyForRelease: true,
echoFlagKey: "AREnableArtworkGridSaveIcon",
},
AREnableAndroidImagesGallery: {
description: "Enable images gallery on Android",
showInDevMenu: true,
readyForRelease: false,
},
AREnableLargeArtworkRailSaveIcon: {
description: "Enable save icon for large artwork rails",
showInDevMenu: true,
readyForRelease: true,
echoFlagKey: "AREnableLargeArtworkRailSaveIcon",
},
AREnableConsignmentInquiryFlow: {
description: "Enable Sell With Artsy Inquiry",
showInDevMenu: true,
readyForRelease: true,
echoFlagKey: "AREnableConsignmentInquiryFlow",
},
})
export interface DevToggleDescriptor {
/**
* Provide a short description for the Dev Menu.
*/
readonly description: string
/**
* Provide some action/thunk to run when the toggle value is changed.
*/
readonly onChange?: (value: boolean, { toast }: { toast: ReturnType<typeof useToast> }) => void
}
// Helper function to get good typings and intellisense
const defineDevToggles = <T extends string>(devToggleMap: {
readonly [devToggleName in T]: DevToggleDescriptor
}) => devToggleMap
export type DevToggleName = keyof typeof devToggles
export const devToggles = defineDevToggles({
DTShowQuickAccessInfo: {
description: "Quick Access Info",
},
DTDisableEchoRemoteFetch: {
description: "Disable fetching remote echo",
onChange: (value, { toast }) => {
if (value) {
GlobalStore.actions.artsyPrefs.echo.setEchoState(echoLaunchJson())
toast.show("Loaded bundled echo config", "middle")
} else {
GlobalStore.actions.artsyPrefs.echo.fetchRemoteEcho()
toast.show("Fetched remote echo config", "middle")
}
},
},
DTShowAnalyticsVisualiser: {
description: "Analytics visualiser",
},
DTShowNavigationVisualiser: {
description: "Navigation visualiser",
},
DTEasyMyCollectionArtworkCreation: {
description: "MyCollection artworks easy add",
},
DTMyCollectionDeleteAllArtworks: {
description: "MyCollection delete all artworks",
},
DTShowWebviewIndicator: {
description: "Webview indicator",
},
DTShowInstagramShot: {
description: "Instagram viewshot debug",
},
DTCaptureExceptionsInSentryOnDev: {
description: "Capture exceptions in Sentry on DEV",
},
DTFPSCounter: {
description: "FPS counter",
},
DTUseProductionUnleash: {
description: "Use Production Unleash",
},
DTShowErrorInLoadFailureView: {
description: "Show error in load failure view",
},
DTEnableNewImageLabel: {
description: "Show a label on new OpaqueImageView",
},
})
export const isDevToggle = (name: FeatureName | DevToggleName): name is DevToggleName => {
return Object.keys(devToggles).includes(name)
}
type Assert<T, U extends T> = U
// If you mouse-over the name of the type below, you should be able to see the key that needs renaming!
export type _ThereIsAKeyThatIsCommonInFeaturesAndDevToggles_PleaseRename_MouseOverToSeeTheNaughtyKey =
Assert<never, keyof (typeof features | typeof devToggles)>