Skip to content

Commit 7ea931c

Browse files
authored
Merge pull request #2754 from devtron-labs/chore/ga-events
feat: add ga events in resource browser
2 parents 9a56102 + 6b02312 commit 7ea931c

File tree

26 files changed

+263
-199
lines changed

26 files changed

+263
-199
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.15.0-pre-4",
7+
"@devtron-labs/devtron-fe-common-lib": "1.15.0-pre-5",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/assets/icons/ic-world.svg

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/components/CIPipelineN/CIPipeline.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import {
4949
FloatingVariablesSuggestions,
5050
TriggerType,
5151
DeleteCINodeButton,
52+
handleAnalyticsEvent,
5253
} from '@devtron-labs/devtron-fe-common-lib'
5354
import Tippy from '@tippyjs/react'
5455
import {
@@ -541,6 +542,11 @@ export default function CIPipeline({
541542
handleClose()
542543
}
543544

545+
const handleAdvancedOptions = () => {
546+
setIsAdvanced(true)
547+
handleAnalyticsEvent({category: 'CI Pipeline', action: 'DA_BUILD_ADVANCED'})
548+
}
549+
544550
const renderSecondaryButton = () => {
545551
if (ciPipelineId) {
546552
const canDeletePipeline = connectCDPipelines === 0 && ciPipeline.linkedCount === 0
@@ -582,9 +588,7 @@ export default function CIPipeline({
582588
type="button"
583589
data-testid="create-build-pipeline-advanced-options-button"
584590
className="cta cta--workflow cancel mr-16 flex"
585-
onClick={() => {
586-
setIsAdvanced(true)
587-
}}
591+
onClick={handleAdvancedOptions}
588592
>
589593
Advanced options
590594
{mandatoryPluginData && (!mandatoryPluginData.isValidPre || !mandatoryPluginData.isValidPost) && (

src/components/ClusterNodes/ClusterTerminal.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
ComponentSizeType,
2424
get,
2525
getIsRequestAborted,
26+
handleAnalyticsEvent,
2627
NodeTaintType,
2728
noop,
2829
OptionType,
@@ -642,7 +643,13 @@ const ClusterTerminal = ({
642643
}
643644

644645
const toggleScreenView = (): void => {
645-
setFullScreen(!isFullScreen)
646+
if (!isFullScreen) {
647+
handleAnalyticsEvent({
648+
category: 'Cluster Terminal',
649+
action: 'RB_TERMINAL_FULLSCREEN',
650+
})
651+
}
652+
setFullScreen((prev) => !prev)
646653
}
647654

648655
const selectEventsTab = (): void => {

src/components/Jobs/JobDetails/JobDetails.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
import React, { Suspense, useCallback, useEffect, useRef, useState } from 'react'
18-
import ReactGA from 'react-ga4'
1918
import {
2019
generatePath,
2120
Redirect,
@@ -37,14 +36,15 @@ import {
3736
TabProps,
3837
TabGroup,
3938
URLS as CommonURLS,
39+
handleAnalyticsEvent,
4040
} from '@devtron-labs/devtron-fe-common-lib'
4141
import AppConfig from '../../../Pages/Applications/DevtronApps/Details/AppConfigurations/AppConfig'
4242
import Overview from '../../app/Overview/Overview'
4343
import CIDetails from '../../app/details/cIDetails/CIDetails'
4444
import TriggerView from '../../app/details/triggerView/TriggerView'
4545
import { getAppMetaInfo } from '../../app/service'
4646
import { AppMetaInfo } from '../../app/types'
47-
import { ErrorBoundary, trackByGAEvent } from '../../common'
47+
import { ErrorBoundary } from '../../common'
4848
import { ReactComponent as Settings } from '../../../assets/icons/ic-settings.svg'
4949
import { AppSelector } from '../../AppSelector'
5050
import '../../app/details/appDetails/appDetails.scss'
@@ -122,7 +122,7 @@ const JobHeader = ({ jobName }: { jobName: string }) => {
122122
}
123123

124124
function handleEventClick(event) {
125-
trackByGAEvent('Job', event.currentTarget.dataset.action)
125+
handleAnalyticsEvent({ category: 'Job', action: event.currentTarget.dataset.action })
126126
onClickTabPreventDefault(event, 'active')
127127
}
128128

@@ -135,10 +135,9 @@ const JobHeader = ({ jobName }: { jobName: string }) => {
135135
const tab = currentPathname.current.replace(match.url, '').split('/')[1]
136136
const newUrl = generatePath(match.path, { appId: value })
137137
history.push(`${newUrl}/${tab}`)
138-
ReactGA.event({
138+
handleAnalyticsEvent({
139139
category: 'Job Selector',
140140
action: 'Job Selection Changed',
141-
label: tab,
142141
})
143142
},
144143
[location.pathname],

src/components/Jobs/JobList/JobListView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import {
2222
DEFAULT_BASE_PAGE_SIZE,
2323
Pagination,
2424
SortableTableHeaderCell,
25+
handleAnalyticsEvent,
2526
} from '@devtron-labs/devtron-fe-common-lib'
2627
import { Link, useHistory, useLocation } from 'react-router-dom'
27-
import { trackByGAEvent } from '../../common'
2828
import { ReactComponent as Edit } from '../../../assets/icons/ic-settings.svg'
2929
import { ReactComponent as JobIcon } from '../../../assets/icons/ic-job-node.svg'
3030
import { ReactComponent as Arrow } from '../../../assets/icons/ic-dropdown-filled.svg'
@@ -52,7 +52,7 @@ export default function JobListView(props: JobListViewProps) {
5252
const handleEditJob = (event): void => {
5353
event.stopPropagation()
5454
event.preventDefault()
55-
trackByGAEvent('Job List', event.currentTarget.dataset.action)
55+
handleAnalyticsEvent({ category: 'Job List', action: event.currentTarget.dataset.action })
5656
props.handleEditJob(event.currentTarget.dataset.key)
5757
}
5858

src/components/ResourceBrowser/PageHeader.buttons.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
import React, { useState } from 'react'
1818
import { generatePath, Route, useHistory } from 'react-router-dom'
1919

20-
import { Button, ButtonComponentType, ComponentSizeType, useMainContext } from '@devtron-labs/devtron-fe-common-lib'
20+
import {
21+
Button,
22+
ButtonComponentType,
23+
ComponentSizeType,
24+
handleAnalyticsEvent,
25+
useMainContext,
26+
} from '@devtron-labs/devtron-fe-common-lib'
2127

2228
import CreateCluster from '@Pages/GlobalConfigurations/ClustersAndEnvironments/CreateCluster/CreateCluster.component'
2329
import {
@@ -33,7 +39,13 @@ import { CreateResourceButtonType, CreateResourceType } from './Types'
3339
export const CreateResourceButton: React.FC<CreateResourceButtonType> = ({ clusterId, closeModal }) => {
3440
const [showModal, setShowModal] = useState(false)
3541

36-
const handleModalOpen = () => setShowModal(true)
42+
const handleCreateResource = () => {
43+
setShowModal(true)
44+
handleAnalyticsEvent({
45+
category: 'RB Create Resource',
46+
action: 'RB_CREATE_RESOURCE',
47+
})
48+
}
3749

3850
const handleModalClose = () => {
3951
setShowModal(false)
@@ -44,7 +56,7 @@ export const CreateResourceButton: React.FC<CreateResourceButtonType> = ({ clust
4456
<>
4557
<Button
4658
dataTestId="create-resource"
47-
onClick={handleModalOpen}
59+
onClick={handleCreateResource}
4860
text="Create resource"
4961
startIcon={<Add />}
5062
size={ComponentSizeType.small}

src/components/ResourceBrowser/ResourceList/CreateResource.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
import React, { useEffect, useState } from 'react'
1818

1919
import {
20+
Button,
21+
ButtonStyleType,
22+
ButtonVariantType,
2023
CodeEditor,
2124
createNewResource,
2225
CreateResourceDTO,
2326
Drawer,
2427
GenericEmptyState,
28+
handleAnalyticsEvent,
2529
InfoBlock,
26-
Progressing,
2730
showError,
2831
useRegisterShortcut,
2932
} from '@devtron-labs/devtron-fe-common-lib'
@@ -68,6 +71,10 @@ export const CreateResource: React.FC<CreateResourceType> = ({ closePopup, clust
6871
}
6972

7073
const onSave = async (): Promise<void> => {
74+
handleAnalyticsEvent({
75+
category: 'RB Create Resource',
76+
action: 'RB_CREATE_RESOURCE_APPLY',
77+
})
7178
try {
7279
setLoader(true)
7380
const resourceListPayload: CreateResourcePayload = {
@@ -90,18 +97,21 @@ export const CreateResource: React.FC<CreateResourceType> = ({ closePopup, clust
9097
if (showCodeEditorView) {
9198
return (
9299
<div className="dc__border-top flex right p-16">
93-
<button className="cta cancel h-36 lh-36 mr-12" type="button" disabled={loader} onClick={onClose}>
94-
{CREATE_RESOURCE_MODAL_MESSAGING.actionButtonText.cancel}
95-
</button>
96-
<button
97-
type="button"
98-
className="cta h-36 lh-36"
99-
disabled={loader || !resourceYAML}
100+
<Button
101+
dataTestId="cancel-create-resource"
102+
text={CREATE_RESOURCE_MODAL_MESSAGING.actionButtonText.cancel}
103+
disabled={loader}
104+
onClick={onClose}
105+
variant={ButtonVariantType.secondary}
106+
style={ButtonStyleType.neutral}
107+
/>
108+
<Button
109+
dataTestId="create-kubernetes-resource-button"
110+
text={CREATE_RESOURCE_MODAL_MESSAGING.actionButtonText.apply}
111+
disabled={!resourceYAML}
100112
onClick={onSave}
101-
data-testid="create-kubernetes-resource-button"
102-
>
103-
{loader ? <Progressing /> : CREATE_RESOURCE_MODAL_MESSAGING.actionButtonText.apply}
104-
</button>
113+
isLoading={loader}
114+
/>
105115
</div>
106116
)
107117
}

src/components/ResourceBrowser/ResourceList/ResourceFilterOptions.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ const ResourceFilterOptions = ({
7676
setShowFilterModal(true)
7777
}
7878

79+
const handleCloseFilterModal = () => {
80+
setShowFilterModal(false)
81+
}
82+
7983
useEffect(() => {
8084
if (registerShortcut && isOpen) {
8185
registerShortcut({ keys: ['R'], callback: handleInputShortcut })
@@ -154,7 +158,8 @@ const ResourceFilterOptions = ({
154158
clusterName={selectedCluster?.label || ''}
155159
updateTabUrl={updateK8sResourceTab}
156160
showModal={showFilterModal}
157-
setShowModal={setShowFilterModal}
161+
handleShowFilterModal={handleShowFilterModal}
162+
handleCloseFilterModal={handleCloseFilterModal}
158163
/>
159164
)}
160165
<SelectPicker

src/components/ResourceBrowser/ResourceList/ResourceList.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
DynamicTabType,
2525
ErrorScreenManager,
2626
getResourceGroupListRaw,
27+
handleAnalyticsEvent,
2728
InitTabType,
2829
noop,
2930
useAsync,
@@ -282,6 +283,10 @@ const ResourceList = () => {
282283
}, [location.pathname])
283284

284285
const onClusterChange = (selected: ClusterOptionType) => {
286+
handleAnalyticsEvent({
287+
category: 'Resource Browser',
288+
action: 'RB_CLUSTER_SWITCH_CLUSTER',
289+
})
285290
if (selected.value === selectedCluster?.value) {
286291
return
287292
}

0 commit comments

Comments
 (0)