Skip to content

Commit

Permalink
Merge pull request #1608 from maryia-deriv/maryia/CRO-624/update-rudd…
Browse files Browse the repository at this point in the history
…erstack-events-for-chart

[DTRA] Maryia/CRO-624/Update state change events used for Rudderstack tracking in Indicators, Chart Types modals and Markets dropdown
  • Loading branch information
balakrishna-deriv authored Jun 13, 2024
2 parents 6e490df + 1c7ee3b commit ea931e1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 26 deletions.
2 changes: 0 additions & 2 deletions src/Constant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,6 @@ export const Languages = [

export const STATE = {
CHART_INTERVAL_CHANGE: 'CHART_INTERVAL_CHANGE',
CHART_MODE_TOGGLE: 'CHART_MODE_TOGGLE',
CHART_TYPE_CHANGE: 'CHART_TYPE_CHANGE',
FAVORITE_MARKETS_TOGGLE: 'FAVORITE_MARKETS_TOGGLE',
INDICATOR_ADDED: 'INDICATOR_ADDED',
Expand All @@ -2131,7 +2130,6 @@ export const STATE = {
INITIAL: 'INITIAL',
MARKET_SEARCH: 'MARKET_SEARCH',
MARKET_STATE_CHANGE: 'MARKET_STATE_CHANGE',
MARKETS_LIST_TOGGLE: 'MARKETS_LIST_TOGGLE',
READY: 'READY',
SCROLL_TO_LEFT: 'SCROLL_TO_LEFT',
SYMBOL_CHANGE: 'SYMBOL_CHANGE',
Expand Down
11 changes: 8 additions & 3 deletions src/components/StudyLegend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const TabularDisplayActivePanel = ({
clearAll,
isMobile,
}: TabularDisplayActivePanelProps) => (
<React.Fragment>
<>
<div className='sc-studies__panel__head'>
<p>
{isMobile
Expand All @@ -183,7 +183,7 @@ const TabularDisplayActivePanel = ({
<div className='sc-studies__panel__content sc-studies__panel__content--active'>
<IndicatorList items={items} onDeleteItem={onDeleteItem} onEditItem={onEditItem} />
</div>
</React.Fragment>
</>
);

const TabularDisplay = ({
Expand Down Expand Up @@ -307,6 +307,11 @@ const StudyLegend = ({ portalNodeId }: TStudyLegendProps) => {
});
};

const handleClearAll = () => {
deleteAll();
state.stateChange(STATE.INDICATORS_CLEAR_ALL);
};

return (
<Menu
store={menuStore}
Expand Down Expand Up @@ -397,7 +402,7 @@ const StudyLegend = ({ portalNodeId }: TStudyLegendProps) => {
handleStateChange(item.flutter_chart_id, STATE.INDICATOR_INFO_TOGGLE, { is_info_open: true });
}}
activeItems={activeItems}
clearAll={deleteAll}
clearAll={handleClearAll}
searchQuery={searchQuery}
isMobile={isMobile}
maxAllowedItem={maxAllowedItem}
Expand Down
20 changes: 2 additions & 18 deletions src/store/MenuStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { action, computed, observable, reaction, makeObservable } from 'mobx';
import { ChartTypes, Intervals, STATE } from 'src/Constant';
import { getTimeIntervalName } from 'src/utils';
import { STATE } from 'src/Constant';
import MainStore from '.';
import Context from '../components/ui/Context';
import DialogStore from './DialogStore';
Expand Down Expand Up @@ -57,22 +56,7 @@ export default class MenuStore {
this.setOpen(!this.open);
}
handleDialogStatus() {
if (this.route === 'chart-mode') {
const chart_type_name = ChartTypes.find(type => type.id === this.mainStore.chartType.type.id)?.text ?? '';
this.mainStore.state.stateChange(STATE.CHART_MODE_TOGGLE, {
is_open: this.open,
chart_type_name:
this.mainStore.chartType.type.id === 'colored_bar'
? chart_type_name
: chart_type_name.toLowerCase(),
time_interval_name: getTimeIntervalName(this.mainStore.state.granularity, Intervals),
});
} else if (this.route === 'chart-title') {
this.mainStore.state.stateChange(STATE.MARKETS_LIST_TOGGLE, {
is_open: this.open,
symbol: this.mainStore.chart.currentActiveSymbol?.symbol,
});
} else if (this.route === 'indicators') {
if (this.route === 'indicators') {
this.mainStore.state.stateChange(STATE.INDICATORS_MODAL_TOGGLE, {
is_open: this.open,
});
Expand Down
5 changes: 2 additions & 3 deletions src/store/StudyLegendStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ export default class StudyLegendStore {
get searchedItems() {
return [...getIndicatorsTree()]
.map(category => {
category.foundItems = (category.items.filter(
category.foundItems = category.items.filter(
item => item.name.toLowerCase().indexOf(this.filterText.toLowerCase().trim()) !== -1
) as unknown) as TActiveItem[];
) as unknown as TActiveItem[];
return category;
})
.filter(category => category.foundItems?.length);
Expand Down Expand Up @@ -359,7 +359,6 @@ export default class StudyLegendStore {
this.activeItems = [];
window.flutterChart?.indicators.clearIndicators();
this.mainStore.state.saveLayout();
this.mainStore.state.stateChange(STATE.INDICATORS_CLEAR_ALL);
}

onSelectTab(tabIndex: number) {
Expand Down

0 comments on commit ea931e1

Please sign in to comment.