-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy patheventNames.ts
More file actions
481 lines (459 loc) · 15.8 KB
/
eventNames.ts
File metadata and controls
481 lines (459 loc) · 15.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
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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
/**
* Perps event property keys and values - matching dashboard requirements exactly
* Event names are defined in MetaMetrics.events.ts as the single source of truth
*/
/**
* Event property keys - ensures consistent property naming
*/
export const PERPS_EVENT_PROPERTY = {
// Common properties
TIMESTAMP: 'timestamp',
ASSET: 'asset',
DIRECTION: 'direction',
SOURCE: 'source',
TAB_NAME: 'tab_name',
LOCATION: 'location',
// Trade properties
LEVERAGE: 'leverage',
LEVERAGE_USED: 'leverage_used',
ORDER_SIZE: 'order_size',
MARGIN_USED: 'margin_used',
ORDER_TYPE: 'order_type', // lowercase per dashboard
ORDER_TIMESTAMP: 'order_timestamp',
LIMIT_PRICE: 'limit_price',
FEES: 'fees',
FEE: 'fee',
METAMASK_FEE: 'metamask_fee',
METAMASK_FEE_RATE: 'metamask_fee_rate',
DISCOUNT_PERCENTAGE: 'discount_percentage',
ESTIMATED_REWARDS: 'estimated_rewards',
ASSET_PRICE: 'asset_price',
COMPLETION_DURATION: 'completion_duration',
// Position properties
OPEN_POSITION: 'open_position',
OPEN_ORDER: 'open_order',
OPEN_POSITION_SIZE: 'open_position_size',
UNREALIZED_PNL_DOLLAR: 'unrealized_dollar_pnl',
UNREALIZED_PNL_PERCENT: 'unrealized_percent_pnl',
CLOSE_VALUE: 'close_value',
CLOSE_PERCENTAGE: 'close_percentage',
CLOSE_TYPE: 'close_type',
PERCENTAGE_CLOSED: 'percentage_closed',
PNL_DOLLAR: 'dollar_pnl',
PNL_PERCENT: 'percent_pnl',
RECEIVED_AMOUNT: 'received_amount',
// Order type variations
CURRENT_ORDER_TYPE: 'current_order_type',
SELECTED_ORDER_TYPE: 'selected_order_type',
// Funding properties
SOURCE_CHAIN: 'source_chain',
SOURCE_ASSET: 'source_asset',
SOURCE_AMOUNT: 'source_amount',
DESTINATION_AMOUNT: 'destination_amount',
NETWORK_FEE: 'network_fee',
WITHDRAWAL_AMOUNT: 'withdrawal_amount',
// Chart properties
INTERACTION_TYPE: 'interaction_type',
TIME_SERIE_SELECTED: 'time_serie_selected',
CANDLE_PERIOD: 'candle_period',
// Risk management properties
STOP_LOSS_PRICE: 'stop_loss_price',
STOP_LOSS_PERCENT: 'stop_loss_percent',
TAKE_PROFIT_PRICE: 'take_profit_price',
TAKE_PROFIT_PERCENT: 'take_profit_percent',
POSITION_SIZE: 'position_size',
POSITION_AGE: 'position_age',
LIQUIDATION_DISTANCE_OLD: 'liquidation_distance_old',
LIQUIDATION_DISTANCE_NEW: 'liquidation_distance_new',
// Notification properties
NOTIFICATION_TYPE: 'notification_type',
// Other properties
INPUT_METHOD: 'input_method', // camelCase per requirements
ACTION_TYPE: 'action_type',
SETTING_TYPE: 'setting_type',
FAILURE_REASON: 'failure_reason',
WARNING_TYPE: 'warning_type',
WARNING_MESSAGE: 'warning_message',
ERROR_TYPE: 'error_type',
ERROR_MESSAGE: 'error_message',
AB_TESTS: 'ab_tests',
COMPLETION_DURATION_TUTORIAL: 'completion_duration_tutorial',
STEPS_VIEWED: 'steps_viewed',
VIEW_OCCURRENCES: 'view_occurrences',
AMOUNT_FILLED: 'amount_filled',
REMAINING_AMOUNT: 'remaining_amount',
// Tutorial carousel navigation properties
PREVIOUS_SCREEN: 'previous_screen',
CURRENT_SCREEN: 'current_screen',
SCREEN_POSITION: 'screen_position',
TOTAL_SCREENS: 'total_screens',
NAVIGATION_METHOD: 'navigation_method',
STATUS: 'status',
SCREEN_TYPE: 'screen_type',
SCREEN_NAME: 'screen_name',
ACTION: 'action',
RETRY_ATTEMPTS: 'retry_attempts',
SHOW_BACK_BUTTON: 'show_back_button',
ATTEMPT_NUMBER: 'attempt_number',
// PnL Hero Card properties
IMAGE_SELECTED: 'image_selected',
TAB_NUMBER: 'tab_number',
// A/B testing properties (flat per test for multiple concurrent tests)
// Only include AB test properties when test is enabled (event not sent when disabled)
// Button color test (TAT-1937)
AB_TEST_BUTTON_COLOR: 'ab_test_button_color',
// Future tests: add as AB_TEST_{TEST_NAME} (no _ENABLED property needed)
// Entry point tracking properties
BUTTON_CLICKED: 'button_clicked',
BUTTON_LOCATION: 'button_location',
// Balance properties
HAS_PERP_BALANCE: 'has_perp_balance',
// Geo-blocking properties (TAT-2337: track geo-blocked withdrawals for monitoring)
IS_GEO_BLOCKED: 'is_geo_blocked',
// TP/SL differentiation properties
HAS_TAKE_PROFIT: 'has_take_profit',
HAS_STOP_LOSS: 'has_stop_loss',
TAKE_PROFIT_PERCENTAGE: 'take_profit_percentage',
STOP_LOSS_PERCENTAGE: 'stop_loss_percentage',
// Watchlist/Favorites properties
FAVORITES_COUNT: 'favorites_count',
// Scroll tracking properties
SECTION_VIEWED: 'section_viewed',
// Order value (USD $ value of the order)
ORDER_VALUE: 'order_value',
// Market category filter (for market list screen)
MARKET_CATEGORY: 'market_category',
// Pay with any token (PERPS_TRADE_TRANSACTION)
TRADE_WITH_TOKEN: 'trade_with_token',
MM_PAY_TOKEN_SELECTED: 'mm_pay_token_selected',
MM_PAY_NETWORK_SELECTED: 'mm_pay_network_selected',
// Pay-with UI (PERPS_UI_INTERACTION)
INITIAL_PAYMENT_METHOD: 'initial_payment_method',
NEW_PAYMENT_METHOD: 'new_payment_method',
} as const;
/**
* Property value constants
*/
export const PERPS_EVENT_VALUE = {
DIRECTION: {
LONG: 'long',
SHORT: 'short',
},
ORDER_TYPE: {
MARKET: 'market',
LIMIT: 'limit',
},
ORDER_TYPE_CAPITALIZED: {
MARKET: 'market',
LIMIT: 'limit',
},
INPUT_METHOD: {
SLIDER: 'slider',
KEYBOARD: 'keyboard',
PRESET: 'preset',
MANUAL: 'manual',
PERCENTAGE_BUTTON: 'percentage_button',
},
SOURCE: {
BANNER: 'banner',
NOTIFICATION: 'notification',
MAIN_ACTION_BUTTON: 'main_action_button',
POSITION_TAB: 'position_tab',
PERP_MARKETS: 'perp_markets',
DEEPLINK: 'deeplink',
TUTORIAL: 'tutorial',
TRADE_SCREEN: 'trade_screen',
HOMESCREEN_TAB: 'homescreen_tab',
PERP_ASSET_SCREEN: 'perp_asset_screen',
PERP_MARKET: 'perp_market',
PERP_MARKET_SEARCH: 'perp_market_search',
POSITION_SCREEN: 'position_screen',
TP_SL_VIEW: 'tp_sl_view',
PERPS_HOME: 'perps_home',
PERPS_TUTORIAL: 'perps_tutorial',
PERPS_HOME_EMPTY_STATE: 'perps_home_empty_state',
PERPS_ASSET_SCREEN_NO_FUNDS: 'perps_asset_screen_no_funds',
TRADE_MENU_ACTION: 'trade_menu_action',
WALLET_HOME: 'wallet_home',
HOME_SECTION: 'home_section',
TOOLTIP: 'tooltip',
MAGNIFYING_GLASS: 'magnifying_glass',
CRYPTO_BUTTON: 'crypto_button',
STOCKS_BUTTON: 'stocks_button',
CLOSE_TOAST: 'close_toast',
// Perps home section sources (for navigation tracking)
PERPS_HOME_POSITION: 'perps_home_position',
PERPS_HOME_ORDERS: 'perps_home_orders',
PERPS_HOME_WATCHLIST: 'perps_home_watchlist',
PERPS_HOME_EXPLORE_CRYPTO: 'perps_home_explore_crypto',
PERPS_HOME_EXPLORE_STOCKS: 'perps_home_explore_stocks',
PERPS_HOME_ACTIVITY: 'perps_home_activity',
// Explore/Trending page source
EXPLORE: 'explore',
// Market list tab sources
PERPS_MARKET_LIST_ALL: 'perps_market_list_all',
PERPS_MARKET_LIST_CRYPTO: 'perps_market_list_crypto',
PERPS_MARKET_LIST_STOCKS: 'perps_market_list_stocks',
// Other navigation sources
PERPS_TAB: 'perps_tab',
WALLET_MAIN_ACTION_MENU: 'wallet_main_action_menu',
PUSH_NOTIFICATION: 'push_notification',
ORDER_BOOK: 'order_book',
FULL_SCREEN_CHART: 'full_screen_chart',
STOP_LOSS_PROMPT_BANNER: 'stop_loss_prompt_banner',
// Position management sources
OPEN_POSITION: 'open_position',
POSITION_CLOSE_TOAST: 'position_close_toast',
TRADE_DETAILS: 'trade_details',
// Geo-block trigger sources (for tracking what action was blocked)
DEPOSIT_BUTTON: 'deposit_button',
WITHDRAW_BUTTON: 'withdraw_button',
TRADE_ACTION: 'trade_action',
ADD_FUNDS_ACTION: 'add_funds_action',
CANCEL_ORDER: 'cancel_order',
ASSET_DETAIL_SCREEN: 'asset_detail_screen',
MARKET_INSIGHTS: 'market_insights',
// TAT-2449: Geo-block sources for close/modify actions
CLOSE_POSITION_ACTION: 'close_position_action',
MODIFY_POSITION_ACTION: 'modify_position_action',
// Geo-block sources for order book actions
ORDER_BOOK_LONG_BUTTON: 'order_book_long_button',
ORDER_BOOK_SHORT_BUTTON: 'order_book_short_button',
ORDER_BOOK_CLOSE_BUTTON: 'order_book_close_button',
ORDER_BOOK_MODIFY_BUTTON: 'order_book_modify_button',
// Geo-block sources for position management actions
AUTO_CLOSE_ACTION: 'auto_close_action',
ADJUST_MARGIN_ACTION: 'adjust_margin_action',
STOP_LOSS_PROMPT_ADD_MARGIN: 'stop_loss_prompt_add_margin',
STOP_LOSS_PROMPT_SET_SL: 'stop_loss_prompt_set_sl',
// Geo-block sources for bulk actions
CLOSE_ALL_POSITIONS_BUTTON: 'close_all_positions_button',
CANCEL_ALL_ORDERS_BUTTON: 'cancel_all_orders_button',
},
WARNING_TYPE: {
MINIMUM_DEPOSIT: 'minimum_deposit',
MINIMUM_ORDER_SIZE: 'minimum_order_size',
INSUFFICIENT_BALANCE: 'insufficient_balance',
},
ERROR_TYPE: {
NETWORK: 'network',
APP_CRASH: 'app_crash',
BACKEND: 'backend',
VALIDATION: 'validation',
WARNING: 'warning',
},
// Standardized error message keys for PERP_ERROR events
// These should be used instead of localized strings for consistent analytics
ERROR_MESSAGE_KEY: {
ORDER_CHANGED_FROM_LIMIT_TO_MARKET: 'order_changed_from_limit_to_market',
OPEN_CROSS_MARGIN_POSITION_DETECTED: 'open_cross_margin_position_detected',
INSUFFICIENT_BALANCE: 'insufficient_balance',
ORDER_FAILED: 'order_failed',
GEO_RESTRICTION: 'geo_restriction',
MINIMUM_ORDER_SIZE: 'minimum_order_size',
MAXIMUM_LEVERAGE_EXCEEDED: 'maximum_leverage_exceeded',
PRICE_DEVIATION_TOO_HIGH: 'price_deviation_too_high',
MARKET_AT_CAPACITY: 'market_at_capacity',
NETWORK_ERROR: 'network_error',
CONNECTION_FAILED: 'connection_failed',
POSITION_UPDATE_FAILED: 'position_update_failed',
TP_SL_UPDATE_FAILED: 'tp_sl_update_failed',
MARGIN_UPDATE_FAILED: 'margin_update_failed',
UNKNOWN: 'unknown',
},
INTERACTION_TYPE: {
TAP: 'tap',
ZOOM: 'zoom',
SLIDE: 'slide',
SEARCH_CLICKED: 'search_clicked',
ORDER_TYPE_VIEWED: 'order_type_viewed',
ORDER_TYPE_SELECTED: 'order_type_selected',
/** @deprecated Use LEVERAGE_CHANGED instead for clarity */
SETTING_CHANGED: 'setting_changed',
LEVERAGE_CHANGED: 'leverage_changed',
TUTORIAL_STARTED: 'tutorial_started',
TUTORIAL_COMPLETED: 'tutorial_completed',
TUTORIAL_NAVIGATION: 'tutorial_navigation',
CANDLE_PERIOD_VIEWED: 'candle_period_viewed',
CANDLE_PERIOD_CHANGED: 'candle_period_changed',
FAVORITE_TOGGLED: 'favorite_toggled',
BUTTON_CLICKED: 'button_clicked',
// Position management interactions
CONTACT_SUPPORT: 'contact_support',
STOP_LOSS_ONE_CLICK_PROMPT: 'stop_loss_one_click_prompt',
ADD_MARGIN: 'add_margin',
REMOVE_MARGIN: 'remove_margin',
INCREASE_EXPOSURE: 'increase_exposure',
REDUCE_EXPOSURE: 'reduce_exposure',
FLIP_POSITION: 'flip_position',
// Hero card interactions
DISPLAY_HERO_CARD: 'display_hero_card',
SHARE_PNL_HERO_CARD: 'share_pnl_hero_card',
// Chart interactions
FULL_SCREEN_CHART: 'full_screen_chart',
// Pay-with interactions
PAYMENT_TOKEN_SELECTOR: 'payment_token_selector',
PAYMENT_METHOD_CHANGED: 'payment_method_changed',
// Deposit + order (pay-with token) cancel
CANCEL_TRADE_WITH_TOKEN: 'cancel_trade_with_token',
},
ACTION_TYPE: {
START_TRADING: 'start_trading',
SKIP: 'skip',
STOP_LOSS_SET: 'stop_loss_set',
TAKE_PROFIT_SET: 'take_profit_set',
ADL_LEARN_MORE: 'adl_learn_more',
LEARN_MORE: 'learn_more',
FAVORITE_MARKET: 'favorite_market',
UNFAVORITE_MARKET: 'unfavorite_market',
},
NOTIFICATION_TYPE: {
POSITION_LIQUIDATED: 'position_liquidated',
TP_EXECUTED: 'tp_executed',
SL_EXECUTED: 'sl_executed',
LIMIT_ORDER_EXECUTED: 'limit_order_executed',
},
CLOSE_TYPE: {
FULL: 'full',
PARTIAL: 'partial',
},
NAVIGATION_METHOD: {
SWIPE: 'swipe',
CONTINUE_BUTTON: 'continue_button',
PROGRESS_DOT: 'progress_dot',
},
STATUS: {
VIEWED: 'viewed',
STARTED: 'started',
COMPLETED: 'completed',
INITIATED: 'initiated',
SUBMITTED: 'submitted',
EXECUTED: 'executed',
PARTIALLY_FILLED: 'partially_filled',
FAILED: 'failed',
SUCCESS: 'success',
},
SCREEN_TYPE: {
MARKETS: 'markets',
MARKET_LIST: 'market_list',
ASSET_DETAILS: 'asset_details',
TRADING: 'trading',
/** @deprecated Use PERPS_HOME or WALLET_HOME_PERPS_TAB instead */
HOMESCREEN: 'homescreen',
PERPS_HOME: 'perps_home',
WALLET_HOME_PERPS_TAB: 'wallet_home_perps_tab',
POSITION_CLOSE: 'position_close',
LEVERAGE: 'leverage',
TUTORIAL: 'tutorial',
WITHDRAWAL: 'withdrawal',
TP_SL: 'tp_sl',
CREATE_TPSL: 'create_tpsl',
EDIT_TPSL: 'edit_tpsl',
DEPOSIT_INPUT: 'deposit_input',
DEPOSIT_REVIEW: 'deposit_review',
CLOSE_ALL_POSITIONS: 'close_all_positions',
CANCEL_ALL_ORDERS: 'cancel_all_orders',
PNL_HERO_CARD: 'pnl_hero_card',
ORDER_BOOK: 'order_book',
ERROR: 'error',
// Market list tab screen types
MARKET_LIST_ALL: 'market_list_all',
MARKET_LIST_CRYPTO: 'market_list_crypto',
MARKET_LIST_STOCKS: 'market_list_stocks',
// Additional screens
FULL_SCREEN_CHART: 'full_screen_chart',
ACTIVITY: 'activity',
INCREASE_EXPOSURE: 'increase_exposure',
ADD_MARGIN: 'add_margin',
REMOVE_MARGIN: 'remove_margin',
GEO_BLOCK_NOTIF: 'geo_block_notif',
// Deposit + order (pay-with token) cancel toast
CANCEL_TRADE_WITH_TOKEN_TOAST: 'cancel_trade_with_token_toast',
},
SETTING_TYPE: {
LEVERAGE: 'leverage',
},
SCREEN_NAME: {
CONNECTION_ERROR: 'connection_error',
PERPS_HERO_CARD: 'perps_hero_card',
PERPS_ACTIVITY_HISTORY: 'perps_activity_history',
PERPS_HOME: 'perps_home',
PERPS_MARKET_DETAILS: 'perps_market_details',
PERPS_ORDER: 'perps_order',
},
ACTION: {
CONNECTION_RETRY: 'connection_retry',
CONNECTION_GO_BACK: 'connection_go_back',
SHARE: 'share',
// Risk management actions
ADD_MARGIN: 'add_margin',
REMOVE_MARGIN: 'remove_margin',
EDIT_TP_SL: 'edit_tp_sl',
CREATE_TP_SL: 'create_tp_sl',
// TP/SL specific actions for risk management events
TP: 'tp',
SL: 'sl',
TPSL: 'tpsl',
// Trade transaction actions - differentiates new position from adding to existing
CREATE_POSITION: 'create_position',
INCREASE_EXPOSURE: 'increase_exposure',
// Flip position actions with direction specificity
FLIP_LONG_TO_SHORT: 'flip_long_to_short',
FLIP_SHORT_TO_LONG: 'flip_short_to_long',
},
// Risk management sources
RISK_MANAGEMENT_SOURCE: {
TRADE_SCREEN: 'trade_screen',
POSITION_SCREEN: 'position_screen',
STOP_LOSS_PROMPT_BANNER: 'stop_loss_prompt_banner',
},
PERPS_HISTORY_TABS: {
TRADES: 'trades',
ORDERS: 'orders',
FUNDING: 'funding',
DEPOSITS: 'deposits',
},
/** Value for mm_pay_token_selected when user pays with Perps balance (not a token) */
MM_PAY_TOKEN: {
PERPS_BALANCE: 'Perps Balance',
},
// A/B testing values
AB_TEST: {
// Test IDs
BUTTON_COLOR_TEST: 'button_color_test',
// Button color test variants
CONTROL: 'control',
MONOCHROME: 'monochrome',
},
BUTTON_CLICKED: {
DEPOSIT: 'deposit',
WITHDRAW: 'withdraw',
PERPS_HOME: 'perps_home',
TUTORIAL: 'tutorial',
TOOLTIP: 'tooltip',
MARKET_LIST: 'market_list',
OPEN_POSITION: 'open_position',
MAGNIFYING_GLASS: 'magnifying_glass',
CRYPTO: 'crypto',
STOCKS: 'stocks',
COMMODITIES: 'commodities',
FOREX: 'forex',
NEW: 'new',
GIVE_FEEDBACK: 'give_feedback',
},
BUTTON_LOCATION: {
PERPS_HOME: 'perps_home',
PERPS_TUTORIAL: 'perps_tutorial',
PERPS_HOME_EMPTY_STATE: 'perps_home_empty_state',
PERPS_ASSET_SCREEN: 'perps_asset_screen',
PERPS_TAB: 'perps_tab',
TRADE_MENU_ACTION: 'trade_menu_action',
WALLET_HOME: 'wallet_home',
MARKET_LIST: 'market_list',
SCREEN: 'screen',
TOOLTIP: 'tooltip',
PERP_MARKET_DETAILS: 'perp_market_details',
ORDER_BOOK: 'order_book',
FULL_SCREEN_CHART: 'full_screen_chart',
},
} as const;