Skip to content

Commit ad090bb

Browse files
Merge pull request #2931 from RedisInsight/fe/feature/RI-4997-telemetry
#RI-4997 - update telemetry, add tests
2 parents 3a415ee + e93d1f0 commit ad090bb

File tree

8 files changed

+116
-20
lines changed

8 files changed

+116
-20
lines changed

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/EnablementArea.spec.tsx

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import { cleanup, mockedStore, render, screen, fireEvent, act, waitFor } from 'u
66
import { MOCK_GUIDES_ITEMS, MOCK_TUTORIALS_ITEMS, MOCK_CUSTOM_TUTORIALS_ITEMS } from 'uiSrc/constants'
77
import { EnablementAreaComponent, IEnablementAreaItem } from 'uiSrc/slices/interfaces'
88

9-
import { deleteWbCustomTutorial, uploadWbCustomTutorial } from 'uiSrc/slices/workbench/wb-custom-tutorials'
9+
import {
10+
deleteCustomTutorial,
11+
deleteWbCustomTutorial,
12+
uploadWbCustomTutorial
13+
} from 'uiSrc/slices/workbench/wb-custom-tutorials'
14+
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
1015
import EnablementArea, { Props } from './EnablementArea'
1116

1217
const mockedProps = mock<Props>()
@@ -19,6 +24,18 @@ beforeEach(() => {
1924
store.clearActions()
2025
})
2126

27+
jest.mock('uiSrc/telemetry', () => ({
28+
...jest.requireActual('uiSrc/telemetry'),
29+
sendEventTelemetry: jest.fn(),
30+
}))
31+
32+
jest.mock('uiSrc/slices/workbench/wb-custom-tutorials', () => ({
33+
...jest.requireActual('uiSrc/slices/workbench/wb-custom-tutorials'),
34+
deleteCustomTutorial: jest.fn().mockImplementation(
35+
jest.requireActual('uiSrc/slices/workbench/wb-custom-tutorials').deleteCustomTutorial
36+
)
37+
}))
38+
2239
jest.mock('uiSrc/slices/workbench/wb-guides', () => {
2340
const defaultState = jest.requireActual('uiSrc/slices/workbench/wb-guides').initialState
2441
return {
@@ -29,6 +46,11 @@ jest.mock('uiSrc/slices/workbench/wb-guides', () => {
2946
}
3047
})
3148

49+
/**
50+
* Explore Redis tests
51+
*
52+
* @group component
53+
*/
3254
describe('EnablementArea', () => {
3355
beforeEach(() => {
3456
reactRouterDom.useHistory = jest.fn().mockReturnValue({ push: jest.fn() })
@@ -171,4 +193,80 @@ describe('EnablementArea', () => {
171193
expect(screen.queryByTestId('welcome-my-tutorials')).not.toBeInTheDocument()
172194
})
173195
})
196+
197+
describe('Telemetry', () => {
198+
it('should call proper event on click create button', () => {
199+
const sendEventTelemetryMock = jest.fn();
200+
(sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock)
201+
202+
render(<EnablementArea {...instance(mockedProps)} customTutorials={MOCK_CUSTOM_TUTORIALS_ITEMS} />)
203+
204+
fireEvent.click(screen.getByTestId('open-upload-tutorial-btn'))
205+
206+
expect(sendEventTelemetry).toBeCalledWith({
207+
event: TelemetryEvent.EXPLORE_PANEL_IMPORT_CLICKED,
208+
eventData: {
209+
databaseId: 'instanceId',
210+
},
211+
});
212+
213+
(sendEventTelemetry as jest.Mock).mockRestore()
214+
})
215+
216+
it('should call proper event on submit custom tutorial', async () => {
217+
const sendEventTelemetryMock = jest.fn();
218+
(sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock)
219+
220+
render(<EnablementArea {...instance(mockedProps)} customTutorials={MOCK_CUSTOM_TUTORIALS_ITEMS} />)
221+
fireEvent.click(screen.getByTestId('open-upload-tutorial-btn'));
222+
223+
(sendEventTelemetry as jest.Mock).mockRestore()
224+
225+
await act(() => {
226+
fireEvent.change(
227+
screen.getByTestId('tutorial-link-field'),
228+
{ target: { value: 'link' } }
229+
)
230+
})
231+
232+
await act(() => {
233+
fireEvent.click(screen.getByTestId('submit-upload-tutorial-btn'))
234+
})
235+
236+
expect(sendEventTelemetry).toBeCalledWith({
237+
event: TelemetryEvent.EXPLORE_PANEL_IMPORT_SUBMITTED,
238+
eventData: {
239+
databaseId: 'instanceId',
240+
source: 'URL',
241+
},
242+
});
243+
244+
(sendEventTelemetry as jest.Mock).mockRestore()
245+
})
246+
247+
it('should call proper event on delete custom tutorial', async () => {
248+
(deleteCustomTutorial as jest.Mock).mockImplementation((_, onSuccess: () => void) => () => onSuccess?.())
249+
250+
const sendEventTelemetryMock = jest.fn();
251+
(sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock)
252+
253+
render(<EnablementArea {...instance(mockedProps)} customTutorials={MOCK_CUSTOM_TUTORIALS_ITEMS} />)
254+
await act(() => {
255+
fireEvent.click(screen.getByTestId('delete-tutorial-icon-12mfp-rem'))
256+
})
257+
258+
await act(() => {
259+
fireEvent.click(screen.getByTestId('delete-tutorial-12mfp-rem'))
260+
})
261+
262+
expect(sendEventTelemetry).toBeCalledWith({
263+
event: TelemetryEvent.EXPLORE_PANEL_TUTORIAL_DELETED,
264+
eventData: {
265+
databaseId: 'instanceId',
266+
},
267+
});
268+
269+
(sendEventTelemetry as jest.Mock).mockRestore()
270+
})
271+
})
174272
})

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/Group/Group.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const Group = (props: Props) => {
5858
e.stopPropagation()
5959
onCreate?.()
6060
sendEventTelemetry({
61-
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_IMPORT_CLICKED,
61+
event: TelemetryEvent.EXPLORE_PANEL_IMPORT_CLICKED,
6262
eventData: {
6363
databaseId: instanceId,
6464
}

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/InternalPage/InternalPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const InternalPage = (props: Props) => {
8383

8484
const sendEventClickExternalLinkTelemetry = (link: string = '') => {
8585
sendEventTelemetry({
86-
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_LINK_CLICKED,
86+
event: TelemetryEvent.EXPLORE_PANEL_LINK_CLICKED,
8787
eventData: {
8888
path,
8989
link,

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/Navigation/Navigation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const Navigation = (props: Props) => {
5757
}
5858

5959
sendEventTelemetry({
60-
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_IMPORT_SUBMITTED,
60+
event: TelemetryEvent.EXPLORE_PANEL_IMPORT_SUBMITTED,
6161
eventData: {
6262
databaseId: instanceId,
6363
source: file ? 'Upload' : 'URL'
@@ -73,7 +73,7 @@ const Navigation = (props: Props) => {
7373
const onDeleteCustomTutorial = (id: string) => {
7474
dispatch(deleteCustomTutorial(id, () => {
7575
sendEventTelemetry({
76-
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_TUTORIAL_DELETED,
76+
event: TelemetryEvent.EXPLORE_PANEL_TUTORIAL_DELETED,
7777
eventData: {
7878
databaseId: instanceId,
7979
}

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/RedisUploadButton/RedisUploadButton.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('RedisUploadButton', () => {
7373
fireEvent.click(screen.getByTestId('upload-data-bulk-btn'))
7474

7575
expect(sendEventTelemetry).toBeCalledWith({
76-
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_CLICKED,
76+
event: TelemetryEvent.EXPLORE_PANEL_DATA_UPLOAD_CLICKED,
7777
eventData: {
7878
databaseId: 'databaseId'
7979
}
@@ -84,7 +84,7 @@ describe('RedisUploadButton', () => {
8484
fireEvent.click(screen.getByTestId('upload-data-bulk-apply-btn'))
8585

8686
expect(sendEventTelemetry).toBeCalledWith({
87-
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_SUBMITTED,
87+
event: TelemetryEvent.EXPLORE_PANEL_DATA_UPLOAD_SUBMITTED,
8888
eventData: {
8989
databaseId: 'databaseId'
9090
}

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/RedisUploadButton/RedisUploadButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const RedisUploadButton = ({ label, path }: Props) => {
3232
const openPopover = () => {
3333
if (!isPopoverOpen) {
3434
sendEventTelemetry({
35-
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_CLICKED,
35+
event: TelemetryEvent.EXPLORE_PANEL_DATA_UPLOAD_CLICKED,
3636
eventData: {
3737
databaseId: instanceId
3838
}
@@ -46,7 +46,7 @@ const RedisUploadButton = ({ label, path }: Props) => {
4646
setIsPopoverOpen(false)
4747
dispatch(uploadDataBulkAction(instanceId, path))
4848
sendEventTelemetry({
49-
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_SUBMITTED,
49+
event: TelemetryEvent.EXPLORE_PANEL_DATA_UPLOAD_SUBMITTED,
5050
eventData: {
5151
databaseId: instanceId
5252
}

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementAreaWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const EnablementAreaWrapper = () => {
3333

3434
const onOpenInternalPage = ({ path, manifestPath }: IInternalPage) => {
3535
sendEventTelemetry({
36-
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_GUIDE_OPENED,
36+
event: TelemetryEvent.EXPLORE_PANEL_TUTORIAL_OPENED,
3737
eventData: {
3838
path,
3939
section: getTutorialSection(manifestPath),

redisinsight/ui/src/telemetry/events.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ export enum TelemetryEvent {
107107
STRING_LOAD_ALL_CLICKED = 'STRING_LOAD_ALL_CLICKED',
108108
STRING_DOWNLOAD_VALUE_CLICKED = 'STRING_DOWNLOAD_VALUE_CLICKED',
109109

110-
WORKBENCH_ENABLEMENT_AREA_GUIDE_OPENED = 'WORKBENCH_ENABLEMENT_AREA_GUIDE_OPENED',
111-
WORKBENCH_ENABLEMENT_AREA_LINK_CLICKED = 'WORKBENCH_ENABLEMENT_AREA_LINK_CLICKED',
112110
WORKBENCH_COMMAND_SUBMITTED = 'WORKBENCH_COMMAND_SUBMITTED',
113111

114112
WORKBENCH_COMMAND_COPIED = 'WORKBENCH_COMMAND_COPIED',
@@ -123,13 +121,6 @@ export enum TelemetryEvent {
123121
WORKBENCH_NON_REDIS_EDITOR_CANCELLED = 'WORKBENCH_NON_REDIS_EDITOR_CANCELLED',
124122
WORKBENCH_NON_REDIS_EDITOR_SAVED = 'WORKBENCH_NON_REDIS_EDITOR_SAVED',
125123
WORKBENCH_MODE_CHANGED = 'WORKBENCH_MODE_CHANGED',
126-
WORKBENCH_ENABLEMENT_AREA_IMPORT_CLICKED = 'WORKBENCH_ENABLEMENT_AREA_IMPORT_CLICKED',
127-
WORKBENCH_ENABLEMENT_AREA_IMPORT_SUBMITTED = 'WORKBENCH_ENABLEMENT_AREA_IMPORT_SUBMITTED',
128-
WORKBENCH_ENABLEMENT_AREA_TUTORIAL_LINK_CHANGED = 'WORKBENCH_ENABLEMENT_AREA_TUTORIAL_LINK_CHANGED',
129-
WORKBENCH_ENABLEMENT_AREA_TUTORIAL_DELETED = 'WORKBENCH_ENABLEMENT_AREA_TUTORIAL_DELETED',
130-
EXPLORE_PANEL_CREATE_TUTORIAL_LINK_CLICKED = 'EXPLORE_PANEL_CREATE_TUTORIAL_LINK_CLICKED',
131-
WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_CLICKED = 'WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_CLICKED',
132-
WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_SUBMITTED = 'WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_SUBMITTED',
133124
WORKBENCH_CLEAR_RESULT_CLICKED = 'WORKBENCH_CLEAR_RESULT_CLICKED',
134125
WORKBENCH_CLEAR_ALL_RESULTS_CLICKED = 'WORKBENCH_CLEAR_ALL_RESULTS_CLICKED',
135126

@@ -251,8 +242,15 @@ export enum TelemetryEvent {
251242

252243
EXPLORE_PANEL_COMMAND_COPIED = 'EXPLORE_PANEL_COMMAND_COPIED',
253244
EXPLORE_PANEL_COMMAND_RUN_CLICKED = 'EXPLORE_PANEL_COMMAND_RUN_CLICKED',
254-
EXPLORE_PANEL_COMMAND_RUN_CONFIRMED = 'EXPLORE_PANEL_COMMAND_RUN_CONFIRMED',
255245
EXPLORE_PANEL_DATABASE_CHANGE_CLICKED = 'EXPLORE_PANEL_DATABASE_CHANGE_CLICKED',
246+
EXPLORE_PANEL_IMPORT_CLICKED = 'EXPLORE_PANEL_IMPORT_CLICKED',
247+
EXPLORE_PANEL_IMPORT_SUBMITTED = 'EXPLORE_PANEL_IMPORT_SUBMITTED',
248+
EXPLORE_PANEL_TUTORIAL_DELETED = 'EXPLORE_PANEL_TUTORIAL_DELETED',
249+
EXPLORE_PANEL_TUTORIAL_OPENED = 'EXPLORE_PANEL_TUTORIAL_OPENED',
250+
EXPLORE_PANEL_LINK_CLICKED = 'EXPLORE_PANEL_LINK_CLICKED',
251+
EXPLORE_PANEL_CREATE_TUTORIAL_LINK_CLICKED = 'EXPLORE_PANEL_CREATE_TUTORIAL_LINK_CLICKED',
252+
EXPLORE_PANEL_DATA_UPLOAD_CLICKED = 'EXPLORE_PANEL_DATA_UPLOAD_CLICKED',
253+
EXPLORE_PANEL_DATA_UPLOAD_SUBMITTED = 'EXPLORE_PANEL_DATA_UPLOAD_SUBMITTED',
256254

257255
CAPABILITY_POPOVER_DISPLAYED = 'CAPABILITY_POPOVER_DISPLAYED',
258256

0 commit comments

Comments
 (0)