-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathabTestConfig.ts
More file actions
341 lines (295 loc) · 10.8 KB
/
Copy pathabTestConfig.ts
File metadata and controls
341 lines (295 loc) · 10.8 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
import { EVENT_NAME } from '../../../core/Analytics/MetaMetrics.events';
import type { ABTestAnalyticsMapping } from '../../../util/analytics/abTestAnalytics.types';
import { createActiveABTestAssignment } from '../../../util/analytics/activeABTestAssignments';
import type { TransactionActiveAbTestEntry } from '../../../util/transactions/transaction-active-ab-test-attribution-registry';
// ─── Hub Page Discovery Tabs ────────────────────────────────────────────────
/**
* LaunchDarkly / remote flag key. Pattern: `{team}{TICKET}Abtest{Name}` — keep in
* sync with the flag in LD (team `core`, ticket MCU-589).
*/
export const HUB_PAGE_DISCOVERY_TABS_AB_KEY =
'coreMCU589AbtestHubPageDiscoveryTabs';
export enum HubPageDiscoveryTabsVariant {
Control = 'control',
Treatment = 'treatment',
}
interface HubPageDiscoveryTabsVariantConfig {
discoveryTabsEnabled: boolean;
}
export const HUB_PAGE_DISCOVERY_TABS_VARIANTS: Record<
HubPageDiscoveryTabsVariant,
HubPageDiscoveryTabsVariantConfig
> = {
[HubPageDiscoveryTabsVariant.Control]: { discoveryTabsEnabled: false },
[HubPageDiscoveryTabsVariant.Treatment]: { discoveryTabsEnabled: true },
};
export const HUB_PAGE_DISCOVERY_TABS_AB_TEST_ANALYTICS_MAPPING: ABTestAnalyticsMapping =
{
flagKey: HUB_PAGE_DISCOVERY_TABS_AB_KEY,
validVariants: Object.values(HubPageDiscoveryTabsVariant),
eventNames: [EVENT_NAME.HOME_VIEWED],
};
// ─── Trending Sections ───────────────────────────────────────────────────────
/**
* LaunchDarkly / remote flag key. Pattern: `{team}{TICKET}Abtest{Name}` — keep in
* sync with the flag in LD (team `home`, ticket TMCU-470).
*/
export const HOMEPAGE_TRENDING_SECTIONS_AB_KEY =
'homeTMCU470AbtestTrendingSections';
/**
* Builds `active_ab_tests` entries for swap / perps / predict Transaction Added
* when the homepage trending-sections experiment assignment is active.
*/
export function getHomepageTrendingSectionsTransactionActiveAbTests(
isAssignmentActive: boolean,
variantName: string,
): TransactionActiveAbTestEntry[] | undefined {
if (!isAssignmentActive) {
return undefined;
}
return [
createActiveABTestAssignment(
HOMEPAGE_TRENDING_SECTIONS_AB_KEY,
variantName,
),
];
}
export enum HomepageTrendingSectionsVariant {
Control = 'control',
TrendingSections = 'trendingSections',
}
export const HOMEPAGE_TRENDING_SECTIONS_VARIANTS: Record<
HomepageTrendingSectionsVariant,
{ separateTrending: boolean }
> = {
[HomepageTrendingSectionsVariant.Control]: { separateTrending: false },
[HomepageTrendingSectionsVariant.TrendingSections]: {
separateTrending: true,
},
};
export const HOMEPAGE_TRENDING_SECTIONS_AB_TEST_ANALYTICS_MAPPING: ABTestAnalyticsMapping =
{
flagKey: HOMEPAGE_TRENDING_SECTIONS_AB_KEY,
validVariants: Object.values(HomepageTrendingSectionsVariant),
eventNames: [EVENT_NAME.HOME_VIEWED],
};
// ─── Homepage Perps empty state — Explore-style pills (TMCU-725) ─────────────
/**
* LaunchDarkly / remote flag key. Pattern: `{team}{TICKET}Abtest{Name}` — keep in
* sync with the flag in LD (team `home`, ticket TMCU-725).
*/
export const HOMEPAGE_PERPS_PILLS_EMPTY_AB_KEY =
'homeTMCU725AbtestHomepagePerpsPillsEmptyState';
export enum HomepagePerpsPillsEmptyVariant {
Control = 'control',
Treatment = 'treatment',
}
interface HomepagePerpsPillsEmptyVariantConfig {
/** When true, users with no open positions/orders see Explore Perps Movers pills. */
showExplorePillsWhenEmpty: boolean;
}
export const HOMEPAGE_PERPS_PILLS_EMPTY_VARIANTS: Record<
HomepagePerpsPillsEmptyVariant,
HomepagePerpsPillsEmptyVariantConfig
> = {
[HomepagePerpsPillsEmptyVariant.Control]: {
showExplorePillsWhenEmpty: false,
},
[HomepagePerpsPillsEmptyVariant.Treatment]: {
showExplorePillsWhenEmpty: true,
},
};
/**
* Shared third argument for `useABTest` on this experiment (exposure +
* consistent variation labels).
*/
export const HOMEPAGE_PERPS_PILLS_EMPTY_AB_TEST_EXPOSURE_OPTIONS = {
experimentName: 'Homepage Perps empty state pills',
variationNames: {
control: 'Tile carousel empty state',
treatment: 'Explore Perps Movers pills empty state',
},
} as const;
/**
* Builds `active_ab_tests` entries for perps transaction flows when the user is
* on the homepage perps **empty** surface and the flag assignment is active.
*/
export function getHomepagePerpsPillsEmptyTransactionActiveAbTests(
isAssignmentActive: boolean,
variantName: string,
): TransactionActiveAbTestEntry[] | undefined {
if (!isAssignmentActive) {
return undefined;
}
return [
createActiveABTestAssignment(
HOMEPAGE_PERPS_PILLS_EMPTY_AB_KEY,
variantName,
),
];
}
/** Must match `HomeSectionNames.PERPS` in `useHomeViewedEvent` (avoid importing here — circular deps). */
const HOMEPAGE_SECTION_NAME_PERPS = 'perps' as const;
/** `Home Viewed` — homepage perps slot with empty-surface experiment exposure. */
export const HOMEPAGE_PERPS_PILLS_EMPTY_AB_TEST_HOME_VIEWED_MAPPING: ABTestAnalyticsMapping =
{
flagKey: HOMEPAGE_PERPS_PILLS_EMPTY_AB_KEY,
validVariants: Object.values(HomepagePerpsPillsEmptyVariant),
eventNames: [EVENT_NAME.HOME_VIEWED],
injectWhenPropertiesMatch: {
section_name: HOMEPAGE_SECTION_NAME_PERPS,
is_empty: true,
},
};
// ─── Predict positions empty state (wallet Predict section layout) ──────────
/**
* LaunchDarkly / remote flag key. Pattern: `{team}{TICKET}Abtest{Name}` — keep in
* sync with the flag in LD (team `core`, ticket MCU-747).
*/
export const PREDICT_POSITIONS_EMPTY_STATE_AB_KEY =
'coreMCU747AbtestPredictPositionsEmptyState';
export enum PredictPositionsEmptyStateVariant {
Control = 'control',
Treatment = 'treatment',
}
export const PREDICT_POSITIONS_EMPTY_STATE_VARIANTS = {
control: { layout: 'carousel' as const },
treatment: { layout: 'list' as const },
};
export const PREDICT_EMPTY_STATE_CTA_NAMES = {
EXPLORE_FEATURED: 'explore_featured',
BROWSE_CATEGORY: 'browse_category',
} as const;
export type PredictEmptyStateCtaName =
(typeof PREDICT_EMPTY_STATE_CTA_NAMES)[keyof typeof PREDICT_EMPTY_STATE_CTA_NAMES];
export function getPredictPositionsEmptyStateActiveAbTests(
isAssignmentActive: boolean,
variantName: string,
): TransactionActiveAbTestEntry[] | undefined {
if (!isAssignmentActive) {
return undefined;
}
return [
createActiveABTestAssignment(
PREDICT_POSITIONS_EMPTY_STATE_AB_KEY,
variantName,
),
];
}
// Backward-compatible aliases for the existing hook/component names.
export const PREDICT_HOMEPAGE_DISCOVERY_AB_KEY =
PREDICT_POSITIONS_EMPTY_STATE_AB_KEY;
export const PREDICT_HOMEPAGE_DISCOVERY_VARIANTS =
PREDICT_POSITIONS_EMPTY_STATE_VARIANTS;
// ─── Homepage discovery pills (TMCU-926) ─────────────────────────────────────
/**
* LaunchDarkly / remote flag key. Pattern: `{team}{TICKET}Abtest{Name}` — keep in
* sync with the flag in LD (team `home`, ticket TMCU-926).
*/
export const HOMEPAGE_DISCOVERY_PILLS_AB_KEY =
'homeTMCU926AbtestDiscoveryPills';
export enum HomepageDiscoveryPillsVariant {
Control = 'control',
GrayIcons = 'grayIcons',
ColorIcons = 'colorIcons',
}
export type HomepageDiscoveryPillIconStyle = 'gray' | 'color';
interface HomepageDiscoveryPillsVariantConfig {
showPills: boolean;
iconStyle: HomepageDiscoveryPillIconStyle | null;
}
export const HOMEPAGE_DISCOVERY_PILLS_VARIANTS: Record<
HomepageDiscoveryPillsVariant,
HomepageDiscoveryPillsVariantConfig
> = {
[HomepageDiscoveryPillsVariant.Control]: {
showPills: false,
iconStyle: null,
},
[HomepageDiscoveryPillsVariant.GrayIcons]: {
showPills: true,
iconStyle: 'gray',
},
[HomepageDiscoveryPillsVariant.ColorIcons]: {
showPills: true,
iconStyle: 'color',
},
};
export const HOMEPAGE_DISCOVERY_PILLS_AB_TEST_EXPOSURE_OPTIONS = {
experimentName: 'Homepage discovery pills',
variationNames: {
control: 'Current homepage without discovery pills',
grayIcons: 'Discovery pills with gray icons',
colorIcons: 'Discovery pills with color icons',
},
} as const;
export const HOMEPAGE_DISCOVERY_PILLS_AB_TEST_ANALYTICS_MAPPING: ABTestAnalyticsMapping =
{
flagKey: HOMEPAGE_DISCOVERY_PILLS_AB_KEY,
validVariants: Object.values(HomepageDiscoveryPillsVariant),
eventNames: [EVENT_NAME.HOME_VIEWED],
};
/**
* Builds `active_ab_tests` entries for swap / perps / predict transaction flows
* when the homepage discovery-pills experiment assignment is active.
*/
export function getHomepageDiscoveryPillsTransactionActiveAbTests(
isAssignmentActive: boolean,
variantName: string,
): TransactionActiveAbTestEntry[] | undefined {
if (!isAssignmentActive) {
return undefined;
}
return [
createActiveABTestAssignment(HOMEPAGE_DISCOVERY_PILLS_AB_KEY, variantName),
];
}
// ─── Homepage action buttons 2×4 grid (TMCU-1103) ────────────────────────────
/**
* LaunchDarkly / remote flag key. Pattern: `{team}{TICKET}Abtest{Name}` — keep in
* sync with the flag in LD (team `home`, ticket TMCU-1103).
*/
export const HOMEPAGE_ACTION_BUTTONS_GRID_AB_KEY =
'homeTMCU1103AbtestActionButtonsGrid';
export enum HomepageActionButtonsGridVariant {
Control = 'control',
Row1Top = 'row1Top',
Row2Top = 'row2Top',
}
export type HomepageActionButtonsGridRowOrder = 'row1Top' | 'row2Top';
type HomepageActionButtonsGridVariantConfig =
| { layout: 'fourSquare' }
| {
layout: 'eightCircular';
rowOrder: HomepageActionButtonsGridRowOrder;
};
export const HOMEPAGE_ACTION_BUTTONS_GRID_VARIANTS: Record<
HomepageActionButtonsGridVariant,
HomepageActionButtonsGridVariantConfig
> = {
[HomepageActionButtonsGridVariant.Control]: {
layout: 'fourSquare',
},
[HomepageActionButtonsGridVariant.Row1Top]: {
layout: 'eightCircular',
rowOrder: 'row1Top',
},
[HomepageActionButtonsGridVariant.Row2Top]: {
layout: 'eightCircular',
rowOrder: 'row2Top',
},
};
export const HOMEPAGE_ACTION_BUTTONS_GRID_AB_TEST_EXPOSURE_OPTIONS = {
experimentName: 'Homepage action buttons 2x4 grid',
variationNames: {
control: '4 square action buttons',
row1Top: '8 circular buttons, Row 1 top',
row2Top: '8 circular buttons, Row 2 top',
},
} as const;
export const HOMEPAGE_ACTION_BUTTONS_GRID_AB_TEST_ANALYTICS_MAPPING: ABTestAnalyticsMapping =
{
flagKey: HOMEPAGE_ACTION_BUTTONS_GRID_AB_KEY,
validVariants: Object.values(HomepageActionButtonsGridVariant),
eventNames: [EVENT_NAME.HOME_VIEWED, EVENT_NAME.ACTION_BUTTON_CLICKED],
};