diff --git a/packages/bot-web-ui/src/pages/bot-builder/bot-builder.tsx b/packages/bot-web-ui/src/pages/bot-builder/bot-builder.tsx index 6797ccf74a91..f26e9e8f5465 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/bot-builder.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/bot-builder.tsx @@ -2,10 +2,8 @@ import React from 'react'; import classNames from 'classnames'; import { useRemoteConfig } from '@deriv/api'; import { observer, useStore } from '@deriv/stores'; -import { Analytics } from '@deriv-com/analytics'; import { botNotification } from 'Components/bot-notification/bot-notification'; import { notification_message } from 'Components/bot-notification/bot-notification-utils'; -import { DBOT_TABS } from 'Constants/bot-contents'; import initDatadogLogs from 'Utils/datadog-logs'; import LoadModal from '../../components/load-modal'; import { useDBotStore } from '../../stores/useDBotStore'; @@ -31,24 +29,6 @@ const BotBuilder = observer(() => { window.is_datadog_logging_enabled = remote_config_data.tracking_datadog; // This will be used in the middleware inside of bot-skeleton to check if datadog is enabled before logging }, [remote_config_data.tracking_datadog]); - React.useEffect(() => { - const is_bot_builder = active_tab === DBOT_TABS.BOT_BUILDER; - if (is_bot_builder) { - Analytics.trackEvent('ce_bot_builder_form', { - action: 'open', - form_source: 'ce_bot_builder_form', - }); - } - return () => { - if (is_bot_builder) { - Analytics.trackEvent('ce_bot_builder_form', { - action: 'close', - form_source: 'ce_bot_builder_form', - }); - } - }; - }, [active_tab]); - React.useEffect(() => { onMount(); return () => onUnmount(); diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/constants.ts b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/constants.ts deleted file mode 100644 index e12f9daa74a8..000000000000 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/constants.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { TFormValues } from '../types'; - -export const form_name = 'ce_bot_quick_strategy_form'; -export const STORED_ITEM_NOT_FOUND = 'No results found'; -export const LABEL = 'label'; -export const LAST_DIGIT_PREDICTION_TRADE_TYPES = ['matchesdiffers', 'overunder']; -export const UNNECESSARY_KEYS = ['action', 'purchase']; - -export 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', - CHANGE_PARAMETER_VALUE = 'change_parameter_value', - INFO_POPUP_OPEN = 'info_popup_open', - LOSS_THRESHOLD_WARNING_POPUP = 'loss_threshold_warning_popup', - LEARN_MORE_EXPANSION = 'learn_more_expansion', - LEARN_MORE_COLLAPSE = 'learn_more_collapse', -} - -export enum DURATION_TYPE_MAP { - t = 'ticks', - s = 'seconds', - m = 'minutes', - h = 'hours', - d = 'days', -} - -export enum PARAMETER_TYPE_MAP { - symbol = 'asset_type', - tradetype = 'trade_type', - type = 'purchase_condition', - stake = 'initial_stake', - profit = 'profit_threshold', - loss = 'loss_threshold', - size = 'size', - unit = 'unit', - max_stake = 'max_stake', - durationtype = 'duration_type', - duration = 'duration_value', - last_digit_prediction = 'last_digit_prediction', -} - -export enum LOSS_THRESHOLD_WARNING_POPUP_CTA { - edit_the_amount = 'edit_the_amount', - yes_continue = 'yes_continue', -} - -export type TFormStrategy = { - form_values: TFormValues; -} & TSelectedStrategy; - -export type TSelectedStrategy = { - selected_strategy: string; -}; diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/rudderstack-quick-strategy.ts b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/rudderstack-quick-strategy.ts deleted file mode 100644 index 42269e7a8fb8..000000000000 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/rudderstack-quick-strategy.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { Analytics, TEvents } from '@deriv-com/analytics'; -import { TDurationType } from '../types'; -import { - ACTION, - DURATION_TYPE_MAP, - form_name, - PARAMETER_TYPE_MAP, - type TFormStrategy, - type TSelectedStrategy, -} from './constants'; -import { getRsStrategyType, getTradeParameterData } from './utils'; - -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, - selected_strategy, - form_values, -}: TEvents['ce_bot_quick_strategy_form'] & TFormStrategy) => { - Analytics.trackEvent('ce_bot_quick_strategy_form', { - action: ACTION.CLOSE, - form_name, - strategy_type: getRsStrategyType(selected_strategy), - strategy_switcher_mode, - ...getTradeParameterData({ form_values, selected_strategy }), - }); -}; - -export const rudderStackSendQsRunStrategyEvent = ({ - strategy_switcher_mode, - selected_strategy, - form_values, -}: TEvents['ce_bot_quick_strategy_form'] & TFormStrategy) => { - Analytics.trackEvent('ce_bot_quick_strategy_form', { - action: ACTION.RUN_STRATEGY, - form_name, - strategy_type: getRsStrategyType(selected_strategy), - strategy_switcher_mode, - ...getTradeParameterData({ form_values, selected_strategy }), - }); -}; - -export const rudderStackSendQsEditStrategyEvent = ({ - strategy_switcher_mode, - selected_strategy, - form_values, -}: TEvents['ce_bot_quick_strategy_form'] & TFormStrategy) => { - Analytics.trackEvent('ce_bot_quick_strategy_form', { - action: ACTION.EDIT_STRATEGY, - form_name, - strategy_type: getRsStrategyType(selected_strategy), - strategy_switcher_mode, - ...getTradeParameterData({ form_values, selected_strategy }), - }); -}; - -export const rudderStackSendQsStrategyChangeEvent = ({ selected_strategy }: TSelectedStrategy) => { - Analytics.trackEvent('ce_bot_quick_strategy_form', { - action: ACTION.CHOOSE_STRATEGY_TYPE, - form_name, - strategy_type: getRsStrategyType(selected_strategy), - }); -}; - -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, - }); -}; - -export const rudderStackSendQsParameterChangeEvent = ({ - parameter_type, - parameter_value, - parameter_field_type, - manual_parameter_input, - plus_minus_push, -}: TEvents['ce_bot_quick_strategy_form']) => { - let modified_parameter_value = parameter_value; - if (parameter_type === 'durationtype') { - const tmp_value = parameter_value as TDurationType; - modified_parameter_value = DURATION_TYPE_MAP[tmp_value ?? 't']; - } - Analytics.trackEvent('ce_bot_quick_strategy_form', { - action: ACTION.CHANGE_PARAMETER_VALUE, - form_name, - parameter_type: PARAMETER_TYPE_MAP[parameter_type as keyof typeof PARAMETER_TYPE_MAP] ?? parameter_type, - parameter_value: modified_parameter_value, - parameter_field_type, - plus_minus_push, - manual_parameter_input, - }); -}; - -export const rudderStackSendQsInfoPopupEvent = ({ parameter_type }: TEvents['ce_bot_quick_strategy_form']) => { - Analytics.trackEvent('ce_bot_quick_strategy_form', { - action: ACTION.INFO_POPUP_OPEN, - form_name, - parameter_type, - }); -}; - -export const rudderStackSendQsLossThresholdWarningEvent = ({ - dont_show_checkbox, - cta_name, -}: TEvents['ce_bot_quick_strategy_form']) => { - Analytics.trackEvent('ce_bot_quick_strategy_form', { - action: ACTION.LOSS_THRESHOLD_WARNING_POPUP, - form_name, - dont_show_checkbox, - cta_name, - }); -}; - -export const rudderStackSendQsLearnMoreExpansionEvent = ({ - selected_strategy, - learn_more_title, -}: TEvents['ce_bot_quick_strategy_form'] & TSelectedStrategy) => { - Analytics.trackEvent('ce_bot_quick_strategy_form', { - action: ACTION.LEARN_MORE_EXPANSION, - form_name, - strategy_type: getRsStrategyType(selected_strategy), - learn_more_title, - }); -}; - -export const rudderStackSendQsLearnMoreCollapseEvent = ({ - selected_strategy, - learn_more_title, -}: TEvents['ce_bot_quick_strategy_form'] & TSelectedStrategy) => { - Analytics.trackEvent('ce_bot_quick_strategy_form', { - action: ACTION.LEARN_MORE_COLLAPSE, - form_name, - strategy_type: getRsStrategyType(selected_strategy), - learn_more_title, - }); -}; diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/utils.ts b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/utils.ts deleted file mode 100644 index 27aa007a4dc8..000000000000 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/utils.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { STRATEGIES } from '../config'; -import { TFormData } from '../types'; -import { - DURATION_TYPE_MAP, - LABEL, - LAST_DIGIT_PREDICTION_TRADE_TYPES, - PARAMETER_TYPE_MAP, - STORED_ITEM_NOT_FOUND, - TFormStrategy, - UNNECESSARY_KEYS, -} from './constants'; - -export const setRsDropdownTextToLocalStorage = (text: string, name: string) => { - try { - const current_analytics_data = JSON.parse(localStorage?.getItem('qs-analytics') ?? '{}'); - const new_analytics_data = { - ...current_analytics_data, - [name]: text, - }; - localStorage?.setItem('qs-analytics', JSON.stringify(new_analytics_data)); - } catch (error) { - // eslint-disable-next-line no-console - console.error('Rudderstack: unable to set dropdown text'); - } -}; - -export const getRsDropdownTextFromLocalStorage = () => { - try { - return JSON.parse(localStorage?.getItem('qs-analytics') ?? '{}'); - } catch (error) { - // eslint-disable-next-line no-console - console.error('Rudderstack: unable to get dropdown text'); - return {}; - } -}; - -const hasStoredText = (parameter: string) => parameter && parameter !== STORED_ITEM_NOT_FOUND; - -export const getRsStrategyType = (selected_strategy: string) => STRATEGIES[selected_strategy]?.rs_strategy_type; - -export const getQsActiveTabString = (tab: string) => (tab === 'TRADE_PARAMETERS' ? 'trade parameters' : 'learn more'); - -const getVariedParametersData = (form_values: TFormData, selected_strategy: string) => { - const variable_fields = STRATEGIES[selected_strategy]?.fields[1]; - let varied_parameters = {}; - variable_fields?.forEach(field => { - if (field.type !== LABEL) { - const field_name = PARAMETER_TYPE_MAP[field.name as keyof typeof PARAMETER_TYPE_MAP] ?? field.name; - varied_parameters = { - ...varied_parameters, - [field_name]: field.name ? form_values[field.name] : '', - }; - } - }); - return varied_parameters; -}; - -export const getTradeParameterData = ({ form_values, selected_strategy }: TFormStrategy) => { - UNNECESSARY_KEYS.forEach(key => { - delete form_values[key]; - }); - const { symbol, tradetype, type, durationtype, duration, last_digit_prediction, ...other_params } = form_values; - const duration_type = DURATION_TYPE_MAP[durationtype ?? 't']; - const varied_parameters = getVariedParametersData(other_params, selected_strategy); - const has_last_digit_prediction = - LAST_DIGIT_PREDICTION_TRADE_TYPES.includes(tradetype ?? '') && last_digit_prediction; - const stored_texts = getRsDropdownTextFromLocalStorage(); - - return { - trade_parameters: { - asset_type: hasStoredText(stored_texts?.symbol) ? stored_texts.symbol : symbol, - trade_type: hasStoredText(stored_texts?.tradetype) ? stored_texts?.tradetype : tradetype, - purchase_condition: hasStoredText(stored_texts?.type) ? stored_texts?.type : type, - duration_type, - duration_value: duration, - last_digit_prediction: has_last_digit_prediction ? last_digit_prediction : undefined, - }, - varied_parameters: { - ...varied_parameters, - }, - }; -}; diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/form-wrappers/desktop-form-wrapper.tsx b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/form-wrappers/desktop-form-wrapper.tsx index f4697eee0ef1..ac93166a2cc1 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/form-wrappers/desktop-form-wrapper.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/form-wrappers/desktop-form-wrapper.tsx @@ -6,13 +6,6 @@ import Icon from '@deriv/components/src/components/icon/icon'; import { observer } from '@deriv/stores'; import { localize } from '@deriv/translations'; import { useDBotStore } from 'Stores/useDBotStore'; -import { - rudderStackSendQsEditStrategyEvent, - rudderStackSendQsRunStrategyEvent, - rudderStackSendQsSelectedTabEvent, - rudderStackSendQsStrategyChangeEvent, -} from '../analytics/rudderstack-quick-strategy'; -import { getQsActiveTabString } from '../analytics/utils'; import { STRATEGIES } from '../config'; import { TFormValues } from '../types'; import FormTabs from './form-tabs'; @@ -28,7 +21,7 @@ type TDesktopFormWrapper = { const FormWrapper: React.FC = observer(({ children, onClickClose, active_tab_ref }) => { const [activeTab, setActiveTab] = React.useState('TRADE_PARAMETERS'); - const { submitForm, isValid, setFieldValue, validateForm, values } = useFormikContext(); + const { submitForm, isValid, setFieldValue, validateForm } = useFormikContext(); const { quick_strategy } = useDBotStore(); const { selected_strategy, setSelectedStrategy } = quick_strategy; const strategy = STRATEGIES[selected_strategy as keyof typeof STRATEGIES]; @@ -41,30 +34,18 @@ const FormWrapper: React.FC = observer(({ children, onClick const onChangeStrategy = (strategy: string) => { setSelectedStrategy(strategy); setActiveTab('TRADE_PARAMETERS'); - rudderStackSendQsStrategyChangeEvent({ selected_strategy }); }; const handleTabChange = (tab: string) => { setActiveTab(tab); - rudderStackSendQsSelectedTabEvent({ strategy_switcher_mode: getQsActiveTabString(tab) }); }; const onEdit = async () => { - rudderStackSendQsEditStrategyEvent({ - form_values: values, - selected_strategy, - strategy_switcher_mode: getQsActiveTabString(activeTab), - }); await setFieldValue('action', 'EDIT'); submitForm(); }; const onRun = () => { - rudderStackSendQsRunStrategyEvent({ - form_values: values, - selected_strategy, - strategy_switcher_mode: getQsActiveTabString(activeTab), - }); handleSubmit(); }; diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/form-wrappers/mobile-form-wrapper.tsx b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/form-wrappers/mobile-form-wrapper.tsx index 3b757488dc53..43b1e1ef11a5 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/form-wrappers/mobile-form-wrapper.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/form-wrappers/mobile-form-wrapper.tsx @@ -5,12 +5,6 @@ import { Button, SelectNative, Text, ThemedScrollbars } from '@deriv/components' import { observer } from '@deriv/stores'; import { localize } from '@deriv/translations'; import { useDBotStore } from 'Stores/useDBotStore'; -import { - rudderStackSendQsRunStrategyEvent, - rudderStackSendQsSelectedTabEvent, - rudderStackSendQsStrategyChangeEvent, -} from '../analytics/rudderstack-quick-strategy'; -import { getQsActiveTabString } from '../analytics/utils'; import { STRATEGIES } from '../config'; import { TFormValues } from '../types'; import FormTabs from './form-tabs'; @@ -25,7 +19,7 @@ type TMobileFormWrapper = { const MobileFormWrapper: React.FC = observer(({ children, active_tab_ref }) => { const [active_tab, setActiveTab] = React.useState('TRADE_PARAMETERS'); - const { isValid, validateForm, values } = useFormikContext(); + const { isValid, validateForm } = useFormikContext(); const { quick_strategy } = useDBotStore(); const { selected_strategy, setSelectedStrategy } = quick_strategy; const { handleSubmit } = useQsSubmitHandler(); @@ -38,22 +32,13 @@ const MobileFormWrapper: React.FC = observer(({ children, ac const onChangeStrategy = (strategy: string) => { setSelectedStrategy(strategy); setActiveTab('TRADE_PARAMETERS'); - rudderStackSendQsStrategyChangeEvent({ - selected_strategy, - }); }; const handleTabChange = (tab: string) => { setActiveTab(tab); - rudderStackSendQsSelectedTabEvent({ strategy_switcher_mode: getQsActiveTabString(tab) }); }; const onRun = () => { - rudderStackSendQsRunStrategyEvent({ - form_values: values, - selected_strategy, - strategy_switcher_mode: getQsActiveTabString(active_tab), - }); handleSubmit(); }; diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-checkbox.tsx b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-checkbox.tsx index 1a00329694d3..b4ba7a363f48 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-checkbox.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-checkbox.tsx @@ -2,7 +2,6 @@ import React from 'react'; import classNames from 'classnames'; import { Field, FieldProps, useFormikContext } from 'formik'; import { Checkbox, Popover } from '@deriv/components'; -import { rudderStackSendQsParameterChangeEvent } from '../analytics/rudderstack-quick-strategy'; import { TFormData } from '../types'; type TQSCheckbox = { @@ -17,11 +16,6 @@ const QSCheckbox: React.FC = ({ name, label, description, attached const { values, setFieldValue, validateForm } = useFormikContext(); const handleChange = () => { - rudderStackSendQsParameterChangeEvent({ - parameter_type: name, - parameter_value: !values?.[name], - parameter_field_type: 'checkbox', - }); setFieldValue(name, !values?.[name]).finally(() => { validateForm(); }); diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-input-label.tsx b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-input-label.tsx index 5a5ab48e33a3..f02a93baa740 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-input-label.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-input-label.tsx @@ -1,7 +1,5 @@ import React from 'react'; import { Popover, Text } from '@deriv/components'; -import { observer } from '@deriv/stores'; -import { rudderStackSendQsInfoPopupEvent } from '../analytics/rudderstack-quick-strategy'; type TQSInputLabel = { children?: React.ReactNode; @@ -9,13 +7,7 @@ type TQSInputLabel = { description?: string; }; -const QSInputLabel: React.FC = observer(({ label, description }) => { - const sendEventToRudderstack = () => { - rudderStackSendQsInfoPopupEvent({ - parameter_type: label, - }); - }; - +const QSInputLabel: React.FC = ({ label, description }) => { return (
@@ -23,17 +15,11 @@ const QSInputLabel: React.FC = observer(({ label, description }) {label} - +
); -}); +}; export default QSInputLabel; diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-input.tsx b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-input.tsx index 53c15090ab9a..12fa8718c5d0 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-input.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/inputs/qs-input.tsx @@ -1,12 +1,9 @@ import React, { MouseEvent } from 'react'; import classNames from 'classnames'; import { Field, FieldProps, useFormikContext } from 'formik'; -import debounce from 'lodash.debounce'; import { Input, Popover } from '@deriv/components'; import { observer, useStore } from '@deriv/stores'; -import { DEBOUNCE_INTERVAL_TIME } from 'Constants/bot-contents'; import { useDBotStore } from 'Stores/useDBotStore'; -import { rudderStackSendQsParameterChangeEvent } from '../analytics/rudderstack-quick-strategy'; type TQSInput = { name: string; @@ -31,41 +28,17 @@ const QSInput: React.FC = observer( const { setFieldValue, setFieldTouched } = useFormikContext(); const is_number = type === 'number'; - // eslint-disable-next-line react-hooks/exhaustive-deps - const debounceInputChange = React.useCallback( - // Need the useCallback to stop the debounce function from being recreated on every render - debounce(rudderStackSendQsParameterChangeEvent, DEBOUNCE_INTERVAL_TIME, { - trailing: true, - leading: false, - }), - [] - ); - const handleButtonInputChange = (e: MouseEvent, value: string) => { e?.preventDefault(); onChange(name, value); setFieldTouched(name, true, true); setFieldValue(name, value); - debounceInputChange({ - parameter_type: name, - parameter_value: value, - parameter_field_type: 'number', - manual_parameter_input: 'no', - plus_minus_push: 'yes', - }); }; const handleOnChange = (e: React.ChangeEvent) => { const input_value = e.target.value; const value = is_number ? Number(input_value) : input_value; onChange(name, value); - debounceInputChange({ - parameter_type: name, - parameter_value: value, - parameter_field_type: 'number', - manual_parameter_input: 'yes', - plus_minus_push: 'no', - }); }; return ( diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/parts/loss-threshold-warning-dialog.tsx b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/parts/loss-threshold-warning-dialog.tsx index f23082bf7e54..59f4e2f39244 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/parts/loss-threshold-warning-dialog.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/parts/loss-threshold-warning-dialog.tsx @@ -3,8 +3,6 @@ import { Checkbox, Dialog } from '@deriv/components'; import { observer } from '@deriv/stores'; import { Localize, localize } from '@deriv/translations'; import { useDBotStore } from 'Stores/useDBotStore'; -import { LOSS_THRESHOLD_WARNING_POPUP_CTA } from '../analytics/constants'; -import { rudderStackSendQsLossThresholdWarningEvent } from '../analytics/rudderstack-quick-strategy'; import useQsSubmitHandler from '../form-wrappers/useQsSubmitHandler'; import './loss-threshold-warning-dialog.scss'; @@ -16,25 +14,16 @@ const LossThresholdWarningDialog = observer(() => { quick_strategy; const { proceedFormSubmission } = useQsSubmitHandler(); - const rudderStackEventHandler = (action: keyof typeof LOSS_THRESHOLD_WARNING_POPUP_CTA) => { - rudderStackSendQsLossThresholdWarningEvent({ - dont_show_checkbox: !localStorage?.getItem('qs-dont-show-loss-threshold-warning') ? 'no' : 'yes', - cta_name: action, - }); - }; - const handleAmountEdit = () => { setLossThresholdWarningData({ show: false, highlight_field: ['loss'], }); - rudderStackEventHandler(LOSS_THRESHOLD_WARNING_POPUP_CTA.edit_the_amount); }; const handleContinueBot = () => { initializeLossThresholdWarningData(); proceedFormSubmission(); - rudderStackEventHandler(LOSS_THRESHOLD_WARNING_POPUP_CTA.yes_continue); }; const handleDontShowAgain = () => { diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/quick-strategy.tsx b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/quick-strategy.tsx index 0c0b32c51061..a97fae8d6349 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/quick-strategy.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/quick-strategy.tsx @@ -6,13 +6,12 @@ import { MobileFullPageModal, Modal } from '@deriv/components'; import { observer, useStore } from '@deriv/stores'; import { localize } from '@deriv/translations'; import { useDBotStore } from 'Stores/useDBotStore'; -import { rudderStackSendQsCloseEvent } from './analytics/rudderstack-quick-strategy'; import DesktopFormWrapper from './form-wrappers/desktop-form-wrapper'; import MobileFormWrapper from './form-wrappers/mobile-form-wrapper'; import LossThresholdWarningDialog from './parts/loss-threshold-warning-dialog'; import { STRATEGIES } from './config'; import Form from './form'; -import { TConfigItem, TFormData, TFormValues } from './types'; +import { TConfigItem, TFormData } from './types'; import './quick-strategy.scss'; type TFormikWrapper = { @@ -182,24 +181,11 @@ const QuickStrategy = observer(() => { const { quick_strategy } = useDBotStore(); const { ui } = useStore(); const { is_mobile } = ui; - const { is_open, setFormVisibility, form_data, selected_strategy } = quick_strategy; + const { is_open, setFormVisibility } = quick_strategy; const active_tab_ref = useRef(null); - const sendRudderStackQsFormCloseData = () => { - const active_tab = - active_tab_ref.current?.querySelector('.active')?.textContent?.toLowerCase() === 'learn more' - ? 'learn more' - : 'trade parameters'; - rudderStackSendQsCloseEvent({ - strategy_switcher_mode: active_tab, - selected_strategy, - form_values: form_data as TFormValues, - }); - }; - const handleClose = () => { - sendRudderStackQsFormCloseData(); setFormVisibility(false); }; diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/contract-type.tsx b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/contract-type.tsx index 752bcd6125b0..209cd2ac7af4 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/contract-type.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/contract-type.tsx @@ -6,8 +6,6 @@ import { Autocomplete, Text } from '@deriv/components'; import { TItem } from '@deriv/components/src/components/dropdown-list'; import { observer, useStore } from '@deriv/stores'; import { useDBotStore } from 'Stores/useDBotStore'; -import { rudderStackSendQsParameterChangeEvent } from '../analytics/rudderstack-quick-strategy'; -import { setRsDropdownTextToLocalStorage } from '../analytics/utils'; import { TApiHelpersInstance, TDropdownItems, TFormData } from '../types'; type TContractTypes = { @@ -36,10 +34,6 @@ const ContractTypes: React.FC = observer(({ name }) => { setFieldValue?.(name, categories?.[0]?.value); setValue(name, categories?.[0]?.value); validateForm(); - setRsDropdownTextToLocalStorage(categories?.[0]?.text, name); - } else { - const curzrent_selected = categories?.find(contract => contract.value === selected); - setRsDropdownTextToLocalStorage(curzrent_selected?.text ?? '', name); } }; getContractTypes(); @@ -47,15 +41,9 @@ const ContractTypes: React.FC = observer(({ name }) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [symbol, tradetype, selected]); - const handleChange = (value: string, text: string) => { + const handleChange = (value: string) => { setFieldValue?.(name, value); setValue(name, value); - rudderStackSendQsParameterChangeEvent({ - parameter_type: name, - parameter_value: text, - parameter_field_type: 'dropdown', - }); - setRsDropdownTextToLocalStorage(text, name); }; const key = `qs-contract-type-${name}`; @@ -77,7 +65,7 @@ const ContractTypes: React.FC = observer(({ name }) => { 'qs__form__field__list__item--active': is_active, })} onClick={() => { - handleChange(item?.value, item?.text); + handleChange(item?.value); }} > @@ -100,9 +88,9 @@ const ContractTypes: React.FC = observer(({ name }) => { value={selected_item?.text || ''} list_items={list} onItemSelection={(item: TItem) => { - const { value, text } = item as TDropdownItems; + const { value } = item as TDropdownItems; if (value) { - handleChange(value, text); + handleChange(value); } }} /> diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/duration-type.tsx b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/duration-type.tsx index 983650d4d4e7..e4e366429865 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/duration-type.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/duration-type.tsx @@ -5,7 +5,6 @@ import { ApiHelpers } from '@deriv/bot-skeleton'; import { Autocomplete } from '@deriv/components'; import { TItem } from '@deriv/components/src/components/dropdown-list'; import { useDBotStore } from 'Stores/useDBotStore'; -import { rudderStackSendQsParameterChangeEvent } from '../analytics/rudderstack-quick-strategy'; import { TApiHelpersInstance, TDurationUnitItem, TFormData } from '../types'; type TDurationUnit = { @@ -83,11 +82,6 @@ const DurationUnit: React.FC = ({ attached }: TDurationUnit) => { validateForm(); }); setValue('duration', min); - rudderStackSendQsParameterChangeEvent({ - parameter_type: 'durationtype', - parameter_value: value, - parameter_field_type: 'dropdown', - }); } }} /> diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/symbol.tsx b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/symbol.tsx index 99f79c93efc4..b9bbcff1ae47 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/symbol.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/symbol.tsx @@ -5,8 +5,6 @@ import { Autocomplete, Icon, Text } from '@deriv/components'; import { TItem } from '@deriv/components/src/components/dropdown-list'; import { useStore } from '@deriv/stores'; import { useDBotStore } from 'Stores/useDBotStore'; -import { rudderStackSendQsParameterChangeEvent } from '../analytics/rudderstack-quick-strategy'; -import { setRsDropdownTextToLocalStorage } from '../analytics/utils'; import { TFormData } from '../types'; type TSymbol = { @@ -63,10 +61,6 @@ const SymbolSelect: React.FC = () => { if (!has_symbol) { setFieldValue('symbol', symbols?.[0]?.value); setValue('symbol', symbols?.[0]?.value); - setRsDropdownTextToLocalStorage(symbols?.[0]?.text, 'symbol'); - } else { - const selected_item = symbols?.find(symbol => symbol?.value === values?.symbol); - setRsDropdownTextToLocalStorage(selected_item?.text ?? '', 'symbol'); } // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -91,16 +85,10 @@ const SymbolSelect: React.FC = () => { const handleItemSelection = (item: TItem) => { if (item) { - const { value, text } = item as TSymbol; + const { value } = item as TSymbol; setFieldValue('symbol', value); setValue('symbol', value); setIsInputStarted(false); - rudderStackSendQsParameterChangeEvent({ - parameter_type: 'symbol', - parameter_value: text, - parameter_field_type: 'dropdown', - }); - setRsDropdownTextToLocalStorage(text, 'symbol'); } }; diff --git a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/trade-type.tsx b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/trade-type.tsx index 207cdc951771..d2260e549d35 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/trade-type.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/quick-strategy/selects/trade-type.tsx @@ -5,8 +5,6 @@ import { ApiHelpers } from '@deriv/bot-skeleton'; import { Autocomplete, IconTradeTypes, Text } from '@deriv/components'; import { TItem } from '@deriv/components/src/components/dropdown-list'; import { useDBotStore } from 'Stores/useDBotStore'; -import { rudderStackSendQsParameterChangeEvent } from '../analytics/rudderstack-quick-strategy'; -import { setRsDropdownTextToLocalStorage } from '../analytics/utils'; import { TApiHelpersInstance, TFormData, TTradeType } from '../types'; type TTradeTypeOption = { @@ -51,10 +49,6 @@ const TradeTypeSelect: React.FC = () => { await setFieldValue?.('tradetype', trade_types?.[0].value || ''); await validateForm(); setValue('tradetype', trade_types?.[0].value); - setRsDropdownTextToLocalStorage(trade_types?.[0]?.text, 'tradetype'); - } else { - const selected_item = trade_types?.find(trade_types => trade_types?.value === selected); - setRsDropdownTextToLocalStorage(selected_item?.text ?? '', 'tradetype'); } }; debounce(async () => { @@ -96,12 +90,6 @@ const TradeTypeSelect: React.FC = () => { if (value && text) { setFieldValue?.('tradetype', value); setValue('tradetype', value); - rudderStackSendQsParameterChangeEvent({ - parameter_type: 'tradetype', - parameter_value: text, - parameter_field_type: 'dropdown', - }); - setRsDropdownTextToLocalStorage(text, 'tradetype'); } }} leading_icon={ diff --git a/packages/bot-web-ui/src/pages/bot-builder/toolbar/__tests__/workspace-group.spec.tsx b/packages/bot-web-ui/src/pages/bot-builder/toolbar/__tests__/workspace-group.spec.tsx index 8525d9b113b9..8c6bdbfe456b 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/toolbar/__tests__/workspace-group.spec.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/toolbar/__tests__/workspace-group.spec.tsx @@ -12,22 +12,48 @@ jest.mock('@deriv/bot-skeleton/src/scratch/dbot', () => ({ unHighlightAllBlocks: jest.fn(), })); +const mockOnResetClick = jest.fn(); +const mockOnSortClick = jest.fn(); +const mockOnUndoClick = jest.fn(); +const mockOnZoomInOutClick = jest.fn(); +const mockToggleLoadModal = jest.fn(); +const mockToggleSaveModal = jest.fn(); + describe('WorkspaceGroup', () => { let wrapper: ({ children }: { children: JSX.Element }) => JSX.Element; - const mock_props = { - has_redo_stack: true, - has_undo_stack: true, - onResetClick: jest.fn(), - onSortClick: jest.fn(), - onUndoClick: jest.fn(), - onZoomInOutClick: jest.fn(), - toggleLoadModal: jest.fn(), - toggleSaveModal: jest.fn(), - }; beforeAll(() => { const mock_store = mockStore({}); - const mock_DBot_store = mockDBotStore(mock_store, mock_ws); + let mock_DBot_store = mockDBotStore(mock_store, mock_ws); + mock_DBot_store = { + ...mock_DBot_store, + toolbar: { + ...mock_DBot_store.toolbar, + has_redo_stack: true, + has_undo_stack: true, + onResetClick: mockOnResetClick, + onSortClick: mockOnSortClick, + onUndoClick: mockOnUndoClick, + onZoomInOutClick: mockOnZoomInOutClick, + }, + save_modal: { + ...mock_DBot_store.save_modal, + toggleSaveModal: mockToggleSaveModal, + }, + load_modal: { + ...mock_DBot_store.load_modal, + toggleLoadModal: mockToggleLoadModal, + preview_workspace: null, + selected_strategy: { + id: '', + name: '', + save_type: '', + timestamp: 0, + xml: '', + }, + tab_name: '', + }, + }; wrapper = ({ children }: { children: JSX.Element }) => ( @@ -39,81 +65,81 @@ describe('WorkspaceGroup', () => { }); it('should render WorkspaceGroup', () => { - render(, { + render(, { wrapper, }); expect(screen.getByTestId('dt_toolbar_group_btn')).toBeInTheDocument(); }); it('should call reset function on clicking reset icon', () => { - render(, { + render(, { wrapper, }); const reset_button = screen.getByTestId('dt_toolbar_reset_button'); userEvent.click(reset_button); - expect(mock_props.onResetClick).toBeCalledTimes(1); + expect(mockOnResetClick).toBeCalledTimes(1); }); it('should call toggleLoadModal function on clicking import icon', () => { - render(, { + render(, { wrapper, }); const import_button = screen.getByTestId('dt_toolbar_import_button'); userEvent.click(import_button); - expect(mock_props.toggleLoadModal).toBeCalledTimes(1); + expect(mockToggleLoadModal).toBeCalledTimes(1); }); it('should call toggleSaveModal function on clicking save icon', () => { - render(, { + render(, { wrapper, }); const save_button = screen.getByTestId('dt_toolbar_save_button'); userEvent.click(save_button); - expect(mock_props.toggleSaveModal).toBeCalledTimes(1); + expect(mockToggleSaveModal).toBeCalledTimes(1); }); it('should call onSortClick function on clicking sort icon', () => { - render(, { + render(, { wrapper, }); const sort_button = screen.getByTestId('dt_toolbar_sort_button'); userEvent.click(sort_button); - expect(mock_props.onSortClick).toBeCalledTimes(1); + expect(mockOnSortClick).toBeCalledTimes(1); }); it('should call onUndoClick function with false on clicking undo icon', () => { - render(, { + render(, { wrapper, }); const undo_button = screen.getByTestId('dt_toolbar_undo_button'); userEvent.click(undo_button); - expect(mock_props.onUndoClick).toBeCalledWith(false); + expect(mockOnUndoClick).toBeCalledWith(false); }); it('should call onUndoClick function with true on clicking redo icon', () => { - render(, { + render(, { wrapper, }); const undo_button = screen.getByTestId('dt_toolbar_redo_button'); userEvent.click(undo_button); - expect(mock_props.onUndoClick).toBeCalledWith(true); + expect(mockOnUndoClick).toBeCalledWith(true); }); it('should call onZoomInOutClick function with true on clicking zoomIn icon', () => { - render(, { + render(, { wrapper, }); const zoom_button = screen.getByTestId('dt_toolbar_zoom_in_button'); userEvent.click(zoom_button); - expect(mock_props.onZoomInOutClick).toBeCalledWith(true); + expect(mockOnZoomInOutClick).toBeCalledWith(true); }); it('should call onZoomInOutClick function with false on clicking zoomOut icon', () => { - render(, { + render(, { wrapper, }); const zoom_button = screen.getByTestId('dt_toolbar_zoom_out_button'); userEvent.click(zoom_button); - expect(mock_props.onZoomInOutClick).toBeCalledWith(false); + expect(mockOnZoomInOutClick).toBeCalledWith(false); }); }); diff --git a/packages/bot-web-ui/src/pages/bot-builder/toolbar/toolbar.tsx b/packages/bot-web-ui/src/pages/bot-builder/toolbar/toolbar.tsx index a551cab83213..7b23cadaf1e6 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/toolbar/toolbar.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/toolbar/toolbar.tsx @@ -3,36 +3,21 @@ import { Dialog } from '@deriv/components'; import { observer, useStore } from '@deriv/stores'; import { Localize, localize } from '@deriv/translations'; import { useDBotStore } from 'Stores/useDBotStore'; -import { rudderStackSendQsOpenEvent } from '../quick-strategy/analytics/rudderstack-quick-strategy'; import ToolbarButton from './toolbar-button'; import WorkspaceGroup from './workspace-group'; const Toolbar = observer(() => { - const { run_panel, save_modal, load_modal, toolbar, quick_strategy } = useDBotStore(); + const { run_panel, toolbar, quick_strategy } = useDBotStore(); const { ui: { is_mobile }, } = useStore(); - const { - has_redo_stack, - has_undo_stack, - is_dialog_open, - closeResetDialog, - onResetOkButtonClick: onOkButtonClick, - onResetClick, - onSortClick, - onUndoClick, - onZoomInOutClick, - } = toolbar; - const { toggleSaveModal } = save_modal; - const { toggleLoadModal } = load_modal; + const { is_dialog_open, closeResetDialog, onResetOkButtonClick: onOkButtonClick } = toolbar; const { is_running } = run_panel; const { setFormVisibility } = quick_strategy; const confirm_button_text = is_running ? localize('Yes') : localize('OK'); const cancel_button_text = is_running ? localize('No') : localize('Cancel'); const handleQuickStrategyOpen = () => { setFormVisibility(true); - // send to rs if quick strategy is opened from bot builder (mobile) - rudderStackSendQsOpenEvent(); }; return ( @@ -47,16 +32,7 @@ const Toolbar = observer(() => { button_text={localize('Quick strategy')} /> )} - + void; - onSortClick: () => void; - onUndoClick: (param?: boolean) => void; - onZoomInOutClick: (param?: boolean) => void; - toggleLoadModal: () => void; - toggleSaveModal: () => void; -}; +const WorkspaceGroup = observer(() => { + const { dashboard, toolbar, load_modal, save_modal } = useDBotStore(); + const { setPreviewOnPopup, setChartModalVisibility, setTradingViewModalVisibility } = dashboard; + const { has_redo_stack, has_undo_stack, onResetClick, onSortClick, onUndoClick, onZoomInOutClick } = toolbar; + const { toggleSaveModal } = save_modal; + const { toggleLoadModal } = load_modal; -const WorkspaceGroup = observer( - ({ - has_redo_stack, - has_undo_stack, - onResetClick, - onSortClick, - onUndoClick, - onZoomInOutClick, - toggleLoadModal, - toggleSaveModal, - }: TWorkspaceGroup) => { - const { dashboard } = useDBotStore(); - const { setPreviewOnPopup, setChartModalVisibility, setTradingViewModalVisibility } = dashboard; - - return ( -
- - { - setPreviewOnPopup(true); - toggleLoadModal(); - }} - /> - - - -
- setChartModalVisibility()} - /> - - - setTradingViewModalVisibility()} - /> - -
- onUndoClick(/* redo */ false)} - /> - onUndoClick(/* redo */ true)} - /> + return ( +
+ + { + setPreviewOnPopup(true); + toggleLoadModal(); + }} + /> + + +
onZoomInOutClick(/* in */ true)} + popover_message={localize('Charts')} + icon='IcChartsTabDbot' + icon_id='db-toolbar__charts-button' + action={() => setChartModalVisibility()} /> + + onZoomInOutClick(/* in */ false)} + popover_message={localize('Trading View Chart')} + icon='IcTradingViewChart' + icon_id='db-toolbar__tradingview-button' + action={() => setTradingViewModalVisibility()} /> -
- ); - } -); +
+
+ onUndoClick(/* redo */ false)} + /> + onUndoClick(/* redo */ true)} + /> +
+ onZoomInOutClick(/* in */ true)} + /> + onZoomInOutClick(/* in */ false)} + /> +
+ ); +}); export default WorkspaceGroup; diff --git a/packages/bot-web-ui/src/pages/bot-builder/toolbox/search-box/search-icon.tsx b/packages/bot-web-ui/src/pages/bot-builder/toolbox/search-box/search-icon.tsx index 02e1c5caa98e..5e92e57f83a2 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/toolbox/search-box/search-icon.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/toolbox/search-box/search-icon.tsx @@ -1,7 +1,5 @@ import React from 'react'; import { Icon } from '@deriv/components'; -import debounce from 'lodash.debounce'; -import { Analytics } from '@deriv-com/analytics'; import { observer } from '@deriv/stores'; type TSearchIcon = { @@ -11,18 +9,6 @@ type TSearchIcon = { }; const SearchIcon = observer(({ search, is_search_loading, onClick }: TSearchIcon) => { - React.useEffect(() => { - //this is to check after keup on bot-builder page form sent even to rudderstack - debounce(() => { - if (search && !is_search_loading) { - Analytics.trackEvent('ce_bot_builder_form', { - search_string: search, - action: 'search', - }); - } - }, 2000)(); - }, [is_search_loading]); - if (!search) return ; if (is_search_loading) return
; return ; diff --git a/packages/bot-web-ui/src/pages/bot-builder/toolbox/toolbox.tsx b/packages/bot-web-ui/src/pages/bot-builder/toolbox/toolbox.tsx index 66c6c962dd75..6f7c462b3bc7 100644 --- a/packages/bot-web-ui/src/pages/bot-builder/toolbox/toolbox.tsx +++ b/packages/bot-web-ui/src/pages/bot-builder/toolbox/toolbox.tsx @@ -4,7 +4,6 @@ import { Icon, Text } from '@deriv/components'; import { observer, useStore } from '@deriv/stores'; import { localize } from '@deriv/translations'; import { useDBotStore } from '../../../stores/useDBotStore'; -import { rudderStackSendQsOpenEvent } from '../quick-strategy/analytics/rudderstack-quick-strategy'; import ToolbarButton from '../toolbar/toolbar-button'; import SearchBox from './search-box'; import { ToolboxItems } from './toolbox-items'; @@ -37,12 +36,11 @@ const Toolbox = observer(() => { React.useEffect(() => { onMount(toolbox_ref); return () => onUnmount(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const handleQuickStrategyOpen = () => { setFormVisibility(true); - // send to rs if quick strategy is opened from bot builder (desktop) - rudderStackSendQsOpenEvent(); }; if (!is_mobile) { diff --git a/packages/bot-web-ui/src/pages/dashboard/analytics/rudderstack-dashboard.ts b/packages/bot-web-ui/src/pages/dashboard/analytics/rudderstack-dashboard.ts deleted file mode 100644 index fe9d4bb8e210..000000000000 --- a/packages/bot-web-ui/src/pages/dashboard/analytics/rudderstack-dashboard.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { Analytics, TEvents } from '@deriv-com/analytics'; - -const form_name = 'ce_bot_dashboard_form'; -const form_source = 'ce_bot_dashboard_form'; - -enum ACTION { - OPEN = 'open', - CLOSE = 'close', - CHOOSE_YOUR_BOT = 'choose_your_bot', - EDIT_YOUR_BOT = 'edit_your_bot', - SAVE_YOUR_BOT = 'save_your_bot', - DELETE_YOUR_BOT = 'delete_your_bot', - PUSH_OPEN_BUTTON = 'push_open_button', - CHOOSE_SHORTCUT = 'choose_shortcut', - PUSH_USER_GUIDE = 'push_user_guide', -} - -export const rudderstackDashboardOpen = ({ - bot_name, - preview_mode, - bot_last_modified_time, -}: TEvents['ce_bot_dashboard_form']) => { - Analytics.trackEvent('ce_bot_dashboard_form', { - action: ACTION.OPEN, - form_source, - form_name, - bot_name, - preview_mode, - bot_last_modified_time, - }); -}; - -export const rudderstackDashboardClose = ({ - bot_name, - preview_mode, - bot_last_modified_time, -}: TEvents['ce_bot_dashboard_form']) => { - Analytics.trackEvent('ce_bot_dashboard_form', { - action: ACTION.OPEN, - form_source, - form_name, - bot_name, - preview_mode, - bot_last_modified_time, - }); -}; - -export const rudderstackDashboardChooseYourBot = ({ - bot_name, - bot_last_modified_time, -}: TEvents['ce_bot_dashboard_form']) => { - Analytics.trackEvent('ce_bot_dashboard_form', { - action: ACTION.CHOOSE_YOUR_BOT, - form_name, - bot_name, - bot_last_modified_time, - }); -}; - -export const rudderstackDashboardEditYourBot = ({ bot_name }: TEvents['ce_bot_dashboard_form']) => { - Analytics.trackEvent('ce_bot_dashboard_form', { - action: ACTION.EDIT_YOUR_BOT, - form_name, - bot_name, - }); -}; - -export const rudderstackDashboardSaveYourBot = ({ - bot_name, - bot_last_modified_time, - bot_status, -}: TEvents['ce_bot_dashboard_form']) => { - Analytics.trackEvent('ce_bot_dashboard_form', { - action: ACTION.SAVE_YOUR_BOT, - form_name, - bot_name, - bot_last_modified_time, - bot_status, - }); -}; - -export const rudderstackDashboardDeleteYourBot = ({ - bot_name, - delete_popup_respond, -}: TEvents['ce_bot_dashboard_form']) => { - Analytics.trackEvent('ce_bot_dashboard_form', { - action: ACTION.DELETE_YOUR_BOT, - bot_name, - delete_popup_respond, - }); -}; - -export const rudderstackDashboardOpenButton = () => { - Analytics.trackEvent('ce_bot_dashboard_form', { - action: ACTION.PUSH_OPEN_BUTTON, - form_name, - form_source, - }); -}; - -export const rudderstackDashboardChooseShortcut = ({ shortcut_name }: TEvents['ce_bot_dashboard_form']) => { - Analytics.trackEvent('ce_bot_dashboard_form', { - action: ACTION.CHOOSE_SHORTCUT, - form_name, - form_source, - shortcut_name, - }); -}; - -export const rudderstackDashboardUserGuide = () => { - Analytics.trackEvent('ce_bot_dashboard_form', { - action: ACTION.PUSH_USER_GUIDE, - form_name, - form_source, - }); -}; diff --git a/packages/bot-web-ui/src/pages/dashboard/cards.tsx b/packages/bot-web-ui/src/pages/dashboard/cards.tsx index 5fe971fac013..eb2ff00f4f54 100644 --- a/packages/bot-web-ui/src/pages/dashboard/cards.tsx +++ b/packages/bot-web-ui/src/pages/dashboard/cards.tsx @@ -4,12 +4,9 @@ import classNames from 'classnames'; import { DesktopWrapper, Dialog, Icon, MobileFullPageModal, MobileWrapper, Text } from '@deriv/components'; import { observer } from '@deriv/stores'; import { localize } from '@deriv/translations'; -import { Analytics } from '@deriv-com/analytics'; import { NOTIFICATION_TYPE } from 'Components/bot-notification/bot-notification-utils'; import { DBOT_TABS } from 'Constants/bot-contents'; import { useDBotStore } from 'Stores/useDBotStore'; -import { rudderStackSendQsOpenEvent } from '../bot-builder/quick-strategy/analytics/rudderstack-quick-strategy'; -import { rudderstackDashboardChooseShortcut } from './analytics/rudderstack-dashboard'; import GoogleDrive from './load-bot-preview/google-drive'; import Recent from './load-bot-preview/recent'; @@ -40,20 +37,6 @@ const Cards = observer(({ is_mobile, has_dashboard_strategies }: TCardProps) => const { handleFileChange, loadFileFromLocal } = load_modal; const { setFormVisibility } = quick_strategy; - //this is to check on click of which icon the user has come to bot builder - const sentToRudderStackTabChange = (type: string) => { - Analytics.trackEvent('ce_bot_builder_form', { - shortcut_name: type, - form_source: 'bot_dashboard_form-shortcut', - action: 'choose_shortcut', - }); - }; - - const sendToRudderStackOnQuickStrategyIconClick = () => { - // send to rs if quick strategy is opened from dashbaord - rudderStackSendQsOpenEvent(); - }; - const [is_file_supported, setIsFileSupported] = React.useState(true); const file_input_ref = React.useRef(null); @@ -86,7 +69,6 @@ const Cards = observer(({ is_mobile, has_dashboard_strategies }: TCardProps) => content: localize('Bot Builder'), method: () => { setActiveTab(DBOT_TABS.BOT_BUILDER); - sentToRudderStackTabChange('bot-builder'); }, }, { @@ -96,8 +78,6 @@ const Cards = observer(({ is_mobile, has_dashboard_strategies }: TCardProps) => method: () => { setActiveTab(DBOT_TABS.BOT_BUILDER); setFormVisibility(true); - sentToRudderStackTabChange('quick-strategy'); - sendToRudderStackOnQuickStrategyIconClick(); }, }, ]; @@ -116,7 +96,7 @@ const Cards = observer(({ is_mobile, has_dashboard_strategies }: TCardProps) => id='tab__dashboard__table__tiles' > {actions.map(icons => { - const { icon, content, method, type } = icons; + const { icon, content, method } = icons; return (
id={icon} onClick={() => { method(); - rudderstackDashboardChooseShortcut({ shortcut_name: type }); }} /> @@ -188,6 +167,7 @@ const Cards = observer(({ is_mobile, has_dashboard_strategies }: TCardProps) =>
), + // eslint-disable-next-line react-hooks/exhaustive-deps [is_dialog_open, has_dashboard_strategies] ); }); diff --git a/packages/bot-web-ui/src/pages/dashboard/dashboard.tsx b/packages/bot-web-ui/src/pages/dashboard/dashboard.tsx index 7100054252d5..dd286892e491 100644 --- a/packages/bot-web-ui/src/pages/dashboard/dashboard.tsx +++ b/packages/bot-web-ui/src/pages/dashboard/dashboard.tsx @@ -5,7 +5,6 @@ import { observer, useStore } from '@deriv/stores'; import { localize } from '@deriv/translations'; import { useDBotStore } from 'Stores/useDBotStore'; import OnboardTourHandler from '../tutorials/dbot-tours/onboarding-tour'; -import { rudderstackDashboardClose, rudderstackDashboardOpen } from './analytics/rudderstack-dashboard'; import Local from './load-bot-preview/local'; import Cards from './cards'; import InfoPanel from './info-panel'; @@ -22,26 +21,6 @@ const DashboardComponent = observer(({ handleTabChange }: TMobileIconGuide) => { const { setActiveTabTutorial, active_tab, active_tour } = dashboard; const has_dashboard_strategies = !!dashboard_strategies?.length; const { is_mobile } = ui; - const get_first_strategy_info = React.useRef(false); - - React.useEffect(() => { - if (!get_first_strategy_info.current) { - //on dashbord umount fire close event for rudderstack - get_first_strategy_info.current = true; - rudderstackDashboardOpen({ - bot_name: dashboard_strategies?.[0]?.name, - preview_mode: dashboard_strategies?.length ? 'yes' : 'no', - bot_last_modified_time: dashboard_strategies?.[0]?.timestamp, - }); - } - return () => { - rudderstackDashboardClose({ - bot_name: dashboard_strategies?.[0]?.name, - preview_mode: dashboard_strategies?.length ? 'yes' : 'no', - bot_last_modified_time: dashboard_strategies?.[0]?.timestamp, - }); - }; - }, []); return ( diff --git a/packages/bot-web-ui/src/pages/dashboard/load-bot-preview/delete-dialog.tsx b/packages/bot-web-ui/src/pages/dashboard/load-bot-preview/delete-dialog.tsx index 99617b2f22d4..da68ce22df77 100644 --- a/packages/bot-web-ui/src/pages/dashboard/load-bot-preview/delete-dialog.tsx +++ b/packages/bot-web-ui/src/pages/dashboard/load-bot-preview/delete-dialog.tsx @@ -8,7 +8,6 @@ import { localize } from '@deriv/translations'; import { NOTIFICATION_TYPE } from 'Components/bot-notification/bot-notification-utils'; import { TStrategy } from 'Types'; import { useDBotStore } from 'Stores/useDBotStore'; -import { rudderstackDashboardDeleteYourBot } from '../analytics/rudderstack-dashboard'; const DeleteDialog = observer(() => { const { load_modal, dashboard } = useDBotStore(); @@ -55,21 +54,12 @@ const DeleteDialog = observer(() => { (strategy_from_workspace: TStrategy) => strategy_from_workspace.id !== strategy_id ); setDashboardStrategies(updated_workspaces); + // TODO: Need to move this to skeleton localForage.setItem('saved_workspaces', LZString.compress(JSON.stringify(updated_workspaces))); await resetStrategiesAfterDelete(strategy_id, updated_workspaces); onToggleDeleteDialog(false); }; - const onHandleChange = (type: string, param: boolean) => { - if (type === 'confirm') { - removeBotStrategy(selected_strategy_id); - rudderstackDashboardDeleteYourBot({ delete_popup_respond: 'yes' }); - } else { - rudderstackDashboardDeleteYourBot({ delete_popup_respond: 'no' }); - } - onToggleDeleteDialog(param); - }; - return (
{ is_visible={is_delete_modal_open} confirm_button_text={localize('Yes, delete')} onConfirm={() => { - onHandleChange('confirm', false); + removeBotStrategy(selected_strategy_id); + onToggleDeleteDialog(false); setOpenSettings(NOTIFICATION_TYPE.BOT_DELETE); }} cancel_button_text={localize('No')} onCancel={() => { - onHandleChange('cancel', false); + onToggleDeleteDialog(false); }} is_mobile_full_width={false} className={'dc-dialog__delete-strategy--delete'} diff --git a/packages/bot-web-ui/src/pages/dashboard/load-bot-preview/local.tsx b/packages/bot-web-ui/src/pages/dashboard/load-bot-preview/local.tsx index 06b1e641d71c..db962f12d3cc 100644 --- a/packages/bot-web-ui/src/pages/dashboard/load-bot-preview/local.tsx +++ b/packages/bot-web-ui/src/pages/dashboard/load-bot-preview/local.tsx @@ -3,10 +3,8 @@ import classNames from 'classnames'; import { Dialog, MobileWrapper } from '@deriv/components'; import { observer, useStore } from '@deriv/stores'; import { Localize, localize } from '@deriv/translations'; -import { Analytics } from '@deriv-com/analytics'; import { DBOT_TABS } from 'Constants/bot-contents'; import { useDBotStore } from 'Stores/useDBotStore'; -import { rudderstackDashboardOpenButton } from '../analytics/rudderstack-dashboard'; import BotPreview from './bot-preview'; import './index.scss'; @@ -20,14 +18,6 @@ const LocalComponent = observer(() => { const el_ref = React.useRef(null); const has_strategies = !!dashboard_strategies?.length; - const sendToRudderStackForOpenButton = () => { - //this is to track from which open button user has come to bot builder tab - Analytics.trackEvent('ce_bot_builder_form', { - action: 'open', - form_source: 'bot_dashboard_form_open', - }); - }; - React.useEffect(() => { if (el_ref.current?.children.length === 3) { el_ref?.current?.removeChild(el_ref?.current?.children[1]); @@ -38,8 +28,6 @@ const LocalComponent = observer(() => {