Skip to content

Commit ea3693e

Browse files
refactor(condo): INFRA-917 remove tracking context (Part 2) (#5902)
* refactor(condo): INFRA-917 remove tracking context (Part 2) * fix(condo): INFRA-917 fix broken test * chore(condo): INFRA-917 sync submodules to main * chore(condo): INFRA-917 fix remaining eventName * chore(condo): INFRA-917 sync submodule
1 parent cfcc1de commit ea3693e

File tree

27 files changed

+163
-410
lines changed

27 files changed

+163
-410
lines changed

apps/callcenter

apps/condo/domains/common/components/BaseSearchInput/index.tsx

-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { colors } from '@open-condo/ui/dist/colors'
1313

1414
import Select, { CustomSelectProps } from '@condo/domains/common/components/antd/Select'
1515
import { Loader } from '@condo/domains/common/components/Loader'
16-
import { TrackingEventPropertiesType } from '@condo/domains/common/components/TrackingContext'
1716
import { isNeedToLoadNewElements } from '@condo/domains/common/utils/select.utils'
1817

1918
import { InitialValuesGetter, useInitialValueGetter } from './useInitialValueGetter'
@@ -32,8 +31,6 @@ interface ISearchInput<S> extends Omit<CustomSelectProps<S>, 'onSelect'> {
3231
initialValueGetter?: InitialValuesGetter
3332
onSelect?: (value: string, option) => void
3433
infinityScroll?: boolean
35-
eventName?: string
36-
eventProperties?: TrackingEventPropertiesType
3734
setIsMatchSelectedProperty?: Dispatch<SetStateAction<boolean>>
3835
}
3936

@@ -71,8 +68,6 @@ export const BaseSearchInput = <S extends string> (props: ISearchInput<S>) => {
7168
style,
7269
infinityScroll,
7370
value,
74-
eventName,
75-
eventProperties,
7671
loading,
7772
...restSelectProps
7873
} = props
@@ -254,8 +249,6 @@ export const BaseSearchInput = <S extends string> (props: ISearchInput<S>) => {
254249
autoClearSearchValue={false}
255250
defaultActiveFirstOption={false}
256251
style={style}
257-
eventName={eventName}
258-
eventProperties={eventProperties}
259252
loading={loading}
260253
>
261254
{options}

apps/condo/domains/common/components/GraphQlSearchInputWithCheckAll.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export type InputWithCheckAllProps = {
2323
selectProps: ComponentProps<typeof GraphQlSearchInput>
2424
checkBoxOffset?: number
2525
form: FormInstance
26-
checkBoxEventName?: string
2726
disabled?: boolean
2827
checkboxDisabled?: boolean
2928
checkboxHidden?: boolean
@@ -60,7 +59,6 @@ export const GraphQlSearchInputWithCheckAll: React.FC<InputWithCheckAllProps> =
6059
CheckAllMessage,
6160
form,
6261
checkBoxOffset,
63-
checkBoxEventName,
6462
disabled,
6563
onDataLoaded,
6664
mutationOfFormAfterCheckAll,

apps/condo/domains/common/components/Table/Filters.tsx

-16
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { FilterValue, FilterDropdownProps } from 'antd/es/table/interface'
77
import dayjs, { Dayjs } from 'dayjs'
88
import get from 'lodash/get'
99
import isArray from 'lodash/isArray'
10-
import isEmpty from 'lodash/isEmpty'
1110
import isFunction from 'lodash/isFunction'
1211
import React, { CSSProperties, useCallback, useMemo } from 'react'
1312

@@ -23,7 +22,6 @@ import { colors } from '@condo/domains/common/constants/style'
2322
import { QueryArgType } from '@condo/domains/common/utils/tables.utils'
2423

2524
import { Button } from '../Button'
26-
import { TrackingEventType, useTracking } from '../TrackingContext'
2725

2826

2927
type FilterIconType = (filtered?: boolean) => React.ReactNode
@@ -168,9 +166,6 @@ export const getTextFilterDropdown: GetTextFilterDropdownType = ({ containerStyl
168166

169167
export const getOptionFilterDropdown: GetOptionFilterDropdownType = ({ containerStyles, checkboxGroupProps } = {}) => {
170168
return ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => {
171-
const { logEvent, getEventName } = useTracking()
172-
173-
const eventName = getEventName(TrackingEventType.Checkbox)
174169

175170
const options = useMemo(() => get(checkboxGroupProps, 'options'), [])
176171

@@ -191,17 +186,6 @@ export const getOptionFilterDropdown: GetOptionFilterDropdownType = ({ container
191186
.map((option) => get(option, 'label'))
192187
.filter(Boolean)
193188
}
194-
if (!isEmpty(selectedValue)) {
195-
logEvent({
196-
eventName,
197-
eventProperties: {
198-
component: {
199-
id: checkboxGroupProps.id,
200-
value: selectedValue,
201-
},
202-
},
203-
})
204-
}
205189

206190
setSelectedKeys(values as React.Key[])
207191
confirm({ closeDropdown: false })

apps/condo/domains/common/components/Tabs.tsx

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import styled from '@emotion/styled'
22
import { Tabs } from 'antd'
3-
import React from 'react'
3+
import React, { useCallback } from 'react'
44

55
import { colors, fontSizes, shadows } from '@condo/domains/common/constants/style'
6+
import { analytics } from '@condo/domains/common/utils/analytics'
67

78
import { StarIcon } from './icons/Star'
8-
import { ITrackingComponent, TrackingEventType, useTracking } from './TrackingContext'
99

1010
const IconWrapper = styled.span`
1111
display: flex;
@@ -70,27 +70,35 @@ const TabWrapper = styled.div`
7070
}
7171
`
7272

73-
interface TabProps extends ITrackingComponent {
73+
interface TabProps {
7474
title: string
75+
tabKey: string
7576
showIcon?: boolean
7677
icon?: React.ReactNode
7778
onClick?: React.MouseEventHandler<HTMLDivElement>
7879
}
7980

8081
export const Tab: React.FC<TabProps> = ({
8182
title,
83+
tabKey,
8284
showIcon = true,
8385
icon = <StarIcon/>,
84-
eventName: propEventName,
8586
onClick,
8687
}) => {
87-
const { getTrackingWrappedCallback, getEventName } = useTracking()
88+
const onClickWrapped: React.MouseEventHandler<HTMLDivElement> = useCallback((e) => {
89+
analytics.track('change', {
90+
component: 'Tabs',
91+
location: window.location.href,
92+
activeKey: tabKey,
93+
})
8894

89-
const eventName = propEventName ? propEventName : getEventName(TrackingEventType.Click)
90-
const onClickCallback = eventName ? getTrackingWrappedCallback(eventName, {}, onClick) : onClick
95+
if (onClick) {
96+
onClick(e)
97+
}
98+
}, [])
9199

92100
return (
93-
<TabWrapper onClick={onClickCallback}>
101+
<TabWrapper onClick={onClickWrapped}>
94102
{showIcon && (
95103
<IconWrapper>
96104
{icon}

apps/condo/domains/common/components/TrackingContext.tsx

-174
This file was deleted.

apps/condo/domains/common/components/antd/Radio.tsx

+21-26
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
11
import { Radio as DefaultRadio, RadioProps } from 'antd'
2-
import get from 'lodash/get'
3-
import React from 'react'
4-
5-
import { useTracking, TrackingEventPropertiesType, TrackingEventType } from '@condo/domains/common/components/TrackingContext'
6-
7-
export interface CustomRadioProps extends RadioProps {
8-
eventName?: string
9-
eventProperties?: TrackingEventPropertiesType
10-
}
11-
12-
const Radio = (props: CustomRadioProps) => {
13-
const { eventName: propEventName, eventProperties = {}, onChange, ...restProps } = props
14-
const { getTrackingWrappedCallback, getEventName } = useTracking()
15-
16-
const eventName = propEventName ? propEventName : getEventName(TrackingEventType.Radio)
17-
const componentProperties = { ...eventProperties }
18-
19-
if (restProps.value) {
20-
componentProperties['component'] = { value: restProps.value }
21-
22-
const componentId = get(restProps, 'id')
23-
if (componentId) {
24-
componentProperties['component']['id'] = componentId
2+
import React, { useCallback } from 'react'
3+
4+
import { analytics } from '@condo/domains/common/utils/analytics'
5+
6+
/** @deprecated use Radio from "@open-condo/ui" */
7+
const Radio = (props: RadioProps) => {
8+
const { onChange, id, value, ...restProps } = props
9+
10+
const onChangeWrapped: RadioProps['onChange'] = useCallback((e) => {
11+
if (typeof value === 'string') {
12+
analytics.track('check', {
13+
component: 'Radio',
14+
location: window.location.href,
15+
id,
16+
value,
17+
})
2518
}
26-
}
2719

28-
const onChangeCallback = eventName ? getTrackingWrappedCallback(eventName, componentProperties, onChange) : onChange
20+
if (onChange) {
21+
onChange(e)
22+
}
23+
}, [])
2924

3025
return (
31-
<DefaultRadio {...restProps} onChange={onChangeCallback} />
26+
<DefaultRadio {...restProps} id={id} onChange={onChangeWrapped} />
3227
)
3328
}
3429

0 commit comments

Comments
 (0)