-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Rudderstack quick strategy update events (#13194)
* chore: Rudderstack quick strategy update events * chore: add role to span icon for accessibility * chore: add tabindex and onkeydown * chore: update test case
- Loading branch information
1 parent
0e8eb10
commit f717142
Showing
12 changed files
with
256 additions
and
74 deletions.
There are no files selected for viewing
116 changes: 116 additions & 0 deletions
116
...s/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/rudderstack-quick-strategy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { Analytics, TEvents } from '@deriv-com/analytics'; | ||
import { TFormValues } from '../types'; | ||
|
||
const form_name = 'ce_bot_quick_strategy_form'; | ||
|
||
enum ACTION { | ||
OPEN = 'open', | ||
CLOSE = 'close', | ||
CHOOSE_STRATEGY_TYPE = 'choose_strategy_type', | ||
SWITCH_STRATEGY_MODE = 'switch_strategy_mode', | ||
RUN_STRATEGY = 'run_strategy', | ||
EDIT_STRATEGY = 'edit_strategy', | ||
} | ||
|
||
enum DURATION_TYPE_MAP { | ||
t = 'ticks', | ||
s = 'seconds', | ||
m = 'minutes', | ||
h = 'hours', | ||
d = 'days', | ||
} | ||
|
||
const generateParamterData = (form_values: TFormValues) => { | ||
['action', 'purchase'].forEach(property => { | ||
delete form_values[property]; | ||
}); | ||
const { symbol, tradetype, type, durationtype, duration, ...rest } = form_values; | ||
const duration_type = DURATION_TYPE_MAP[durationtype ?? 't']; | ||
|
||
return { | ||
trade_parameters: { | ||
asset_type: symbol, | ||
trade_type: tradetype, | ||
purchase_condition: type, | ||
duration_type, | ||
duration_value: duration, | ||
}, | ||
varied_parameters: { | ||
...rest, | ||
}, | ||
}; | ||
}; | ||
|
||
export const rudderStackSendQsOpenEvent = () => { | ||
Analytics.trackEvent('ce_bot_quick_strategy_form', { | ||
action: ACTION.OPEN, | ||
form_name, | ||
form_source: 'ce_bot_builder_form', | ||
}); | ||
}; | ||
|
||
export const rudderStackSendQsCloseEvent = ({ | ||
strategy_switcher_mode, | ||
strategy_type, | ||
form_values, | ||
}: TEvents['ce_bot_quick_strategy_form'] & { | ||
form_values: TFormValues; | ||
}) => { | ||
Analytics.trackEvent('ce_bot_quick_strategy_form', { | ||
action: ACTION.CLOSE, | ||
form_name, | ||
strategy_type, | ||
strategy_switcher_mode, | ||
...generateParamterData(form_values), | ||
}); | ||
}; | ||
|
||
export const rudderStackSendQsRunStrategyEvent = ({ | ||
strategy_switcher_mode, | ||
strategy_type, | ||
form_values, | ||
}: TEvents['ce_bot_quick_strategy_form'] & { | ||
form_values: TFormValues; | ||
}) => { | ||
Analytics.trackEvent('ce_bot_quick_strategy_form', { | ||
action: ACTION.RUN_STRATEGY, | ||
form_name, | ||
strategy_type, | ||
strategy_switcher_mode, | ||
...generateParamterData(form_values), | ||
}); | ||
}; | ||
|
||
export const rudderStackSendQsEditStrategyEvent = ({ | ||
strategy_switcher_mode, | ||
strategy_type, | ||
form_values, | ||
}: TEvents['ce_bot_quick_strategy_form'] & { | ||
form_values: TFormValues; | ||
}) => { | ||
Analytics.trackEvent('ce_bot_quick_strategy_form', { | ||
action: ACTION.EDIT_STRATEGY, | ||
form_name, | ||
strategy_type, | ||
strategy_switcher_mode, | ||
...generateParamterData(form_values), | ||
}); | ||
}; | ||
|
||
export const rudderStackSendQsStrategyChangeEvent = ({ strategy_type }: TEvents['ce_bot_quick_strategy_form']) => { | ||
Analytics.trackEvent('ce_bot_quick_strategy_form', { | ||
action: ACTION.CHOOSE_STRATEGY_TYPE, | ||
form_name, | ||
strategy_type, | ||
}); | ||
}; | ||
|
||
export const rudderStackSendQsSelectedTabEvent = ({ | ||
strategy_switcher_mode, | ||
}: TEvents['ce_bot_quick_strategy_form']) => { | ||
Analytics.trackEvent('ce_bot_quick_strategy_form', { | ||
action: ACTION.SWITCH_STRATEGY_MODE, | ||
form_name, | ||
strategy_switcher_mode, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.