-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: resolved conflicts and updated with master
- Loading branch information
Showing
29 changed files
with
528 additions
and
51 deletions.
There are no files selected for viewing
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
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
49 changes: 49 additions & 0 deletions
49
.../bot-web-ui/src/components/transaction-details/__tests__/mobile-transaction-card.spec.tsx
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,49 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import MobileTransactionCards from '../mobile-transaction-card'; | ||
|
||
jest.mock('@deriv/bot-skeleton/src/scratch/dbot', () => ({ | ||
saveRecentWorkspace: jest.fn(), | ||
unHighlightAllBlocks: jest.fn(), | ||
})); | ||
|
||
const mock_transaction_data = { | ||
barrier: '8641.67', | ||
buy_price: 11, | ||
contract_id: 211133945828, | ||
contract_type: 'CALL', | ||
currency: 'USD', | ||
date_start: '2023-6-21 06:10:20 GMT', | ||
display_name: 'Volatility 10 (1s) Index', | ||
entry_tick: '8641.67', | ||
entry_tick_time: '2023-6-21 06:10:21 GMT', | ||
exit_tick: '8641.36', | ||
exit_tick_time: '2023-6-21 06:10:22 GMT', | ||
is_completed: true, | ||
payout: 1.95, | ||
profit: -2, | ||
run_id: 'run-1687327817157', | ||
shortcode: 'CALL_1HZ10V_1.95_1687327820_1T_S0P_0', | ||
tick_count: 1, | ||
transaction_ids: { | ||
buy: 421306672788, | ||
sell: 421306674448, | ||
}, | ||
underlying: '1HZ10V', | ||
}; | ||
|
||
describe('MobileTransactionCards', () => { | ||
it('should render MobileTransactionCards', () => { | ||
render(<MobileTransactionCards transaction={mock_transaction_data} />); | ||
expect(screen.getByTestId('dt_mobile_transaction_card')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display transaction details', () => { | ||
render(<MobileTransactionCards transaction={mock_transaction_data} />); | ||
expect(screen.getByText('421306672788')).toBeInTheDocument(); | ||
expect(screen.getByText('2023-06-21 06:10:20 GMT')).toBeInTheDocument(); | ||
expect(screen.getByText('8641.67')).toBeInTheDocument(); | ||
expect(screen.getByText('11.00')).toBeInTheDocument(); | ||
expect(screen.getByText('2.00')).toBeInTheDocument(); | ||
}); | ||
}); |
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
21 changes: 21 additions & 0 deletions
21
packages/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/constants.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,21 @@ | ||
import { TFormValues } from '../types'; | ||
|
||
export const form_name = 'ce_bot_form'; | ||
export const STORED_ITEM_NOT_FOUND = 'No results found'; | ||
|
||
export enum ACTION { | ||
OPEN = 'open', | ||
CLOSE = 'close', | ||
RUN_QUICK_STRATEGY = 'run_quick_strategy', | ||
EDIT_QUICK_STRATEGY = 'edit_quick_strategy', | ||
SELECT_QUICK_STRATEGY_GUIDE = 'select_quick_strategy_guide', | ||
SWITCH_QUICK_STRATEGY_TAB = 'switch_quick_strategy_tab', | ||
} | ||
|
||
export type TFormStrategy = { | ||
form_values: TFormValues; | ||
} & TSelectedStrategy; | ||
|
||
export type TSelectedStrategy = { | ||
selected_strategy: string; | ||
}; |
87 changes: 87 additions & 0 deletions
87
...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,87 @@ | ||
import { Analytics, TEvents } from '@deriv-com/analytics'; | ||
import { ACTION, form_name, type TFormStrategy, type TSelectedStrategy } from './constants'; | ||
import { getRsStrategyType, getSubpageName, getTradeParameterData } from './utils'; | ||
|
||
export const rudderStackSendQsOpenEventFromDashboard = () => { | ||
Analytics.trackEvent('ce_bot_form', { | ||
action: ACTION.OPEN, | ||
form_name, | ||
subpage_name: getSubpageName(), | ||
subform_name: 'quick_strategy', | ||
subform_source: 'dashboard', | ||
}); | ||
}; | ||
|
||
export const rudderStackSendQsOpenEventFromBotBuilder = () => { | ||
Analytics.trackEvent('ce_bot_form', { | ||
action: ACTION.OPEN, | ||
form_name, | ||
subpage_name: getSubpageName(), | ||
subform_name: 'quick_strategy', | ||
subform_source: 'bot_builder', | ||
}); | ||
}; | ||
|
||
export const rudderStackSendQsCloseEvent = ({ | ||
quick_strategy_tab, | ||
selected_strategy, | ||
}: TEvents['ce_bot_form'] & TFormStrategy) => { | ||
Analytics.trackEvent('ce_bot_form', { | ||
action: ACTION.CLOSE, | ||
form_name, | ||
subpage_name: getSubpageName(), | ||
subform_name: 'quick_strategy', | ||
quick_strategy_tab, | ||
strategy_name: getRsStrategyType(selected_strategy), | ||
}); | ||
}; | ||
|
||
export const rudderStackSendQsRunStrategyEvent = ({ | ||
form_values, | ||
selected_strategy, | ||
}: TEvents['ce_bot_form'] & TFormStrategy) => { | ||
Analytics.trackEvent('ce_bot_form', { | ||
action: ACTION.RUN_QUICK_STRATEGY, | ||
form_name, | ||
subform_name: 'quick_strategy', | ||
...getTradeParameterData({ form_values, selected_strategy }), | ||
}); | ||
}; | ||
|
||
export const rudderStackSendQsEditStrategyEvent = ({ | ||
form_values, | ||
selected_strategy, | ||
}: TEvents['ce_bot_form'] & TFormStrategy) => { | ||
Analytics.trackEvent('ce_bot_form', { | ||
action: ACTION.EDIT_QUICK_STRATEGY, | ||
form_name, | ||
subform_name: 'quick_strategy', | ||
...getTradeParameterData({ form_values, selected_strategy }), | ||
}); | ||
}; | ||
|
||
export const rudderStackSendQsSelectedTabEvent = ({ quick_strategy_tab }: TEvents['ce_bot_form']) => { | ||
Analytics.trackEvent('ce_bot_form', { | ||
action: ACTION.SWITCH_QUICK_STRATEGY_TAB, | ||
form_name, | ||
subform_name: 'quick_strategy', | ||
quick_strategy_tab, | ||
}); | ||
}; | ||
|
||
export const rudderStackSendSelectQsStrategyGuideEvent = ({ selected_strategy }: TSelectedStrategy) => { | ||
Analytics.trackEvent('ce_bot_form', { | ||
action: ACTION.SELECT_QUICK_STRATEGY_GUIDE, | ||
form_name, | ||
subform_name: 'quick_strategy', | ||
strategy_name: getRsStrategyType(selected_strategy), | ||
}); | ||
}; | ||
|
||
export const rudderStackSendRunBotEvent = () => { | ||
Analytics.trackEvent('ce_bot_form', { | ||
action: ACTION.SELECT_QUICK_STRATEGY_GUIDE, | ||
form_name, | ||
subpage_name: getSubpageName(), | ||
}); | ||
}; |
44 changes: 44 additions & 0 deletions
44
packages/bot-web-ui/src/pages/bot-builder/quick-strategy/analytics/utils.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,44 @@ | ||
import { STRATEGIES } from '../config'; | ||
import { STORED_ITEM_NOT_FOUND, TFormStrategy } from './constants'; | ||
|
||
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_name; | ||
|
||
export const getQsActiveTabString = (tab: string) => (tab === 'TRADE_PARAMETERS' ? 'trade parameters' : 'learn more'); | ||
|
||
export const getSubpageName = () => { | ||
const pathname = window.location.hash; | ||
switch (pathname) { | ||
case 'dashboard': | ||
return 'dashboard'; | ||
case 'charts': | ||
return 'charts'; | ||
case 'tutorials': | ||
return 'tutorials'; | ||
default: | ||
return 'bot_builder'; | ||
} | ||
}; | ||
|
||
export const getTradeParameterData = ({ form_values }: TFormStrategy) => { | ||
const { symbol, tradetype, type, stake } = form_values; | ||
const stored_texts = getRsDropdownTextFromLocalStorage(); | ||
|
||
return { | ||
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, | ||
initial_stake: hasStoredText(stored_texts?.stake) ? stored_texts?.stake : stake, | ||
}; | ||
}; |
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.