Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { cleanup, mockedStore, render, screen, fireEvent, act, waitFor } from 'u
import { MOCK_GUIDES_ITEMS, MOCK_TUTORIALS_ITEMS, MOCK_CUSTOM_TUTORIALS_ITEMS } from 'uiSrc/constants'
import { EnablementAreaComponent, IEnablementAreaItem } from 'uiSrc/slices/interfaces'

import { deleteWbCustomTutorial, uploadWbCustomTutorial } from 'uiSrc/slices/workbench/wb-custom-tutorials'
import {
deleteCustomTutorial,
deleteWbCustomTutorial,
uploadWbCustomTutorial
} from 'uiSrc/slices/workbench/wb-custom-tutorials'
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
import EnablementArea, { Props } from './EnablementArea'

const mockedProps = mock<Props>()
Expand All @@ -19,6 +24,18 @@ beforeEach(() => {
store.clearActions()
})

jest.mock('uiSrc/telemetry', () => ({
...jest.requireActual('uiSrc/telemetry'),
sendEventTelemetry: jest.fn(),
}))

jest.mock('uiSrc/slices/workbench/wb-custom-tutorials', () => ({
...jest.requireActual('uiSrc/slices/workbench/wb-custom-tutorials'),
deleteCustomTutorial: jest.fn().mockImplementation(
jest.requireActual('uiSrc/slices/workbench/wb-custom-tutorials').deleteCustomTutorial
)
}))

jest.mock('uiSrc/slices/workbench/wb-guides', () => {
const defaultState = jest.requireActual('uiSrc/slices/workbench/wb-guides').initialState
return {
Expand All @@ -29,6 +46,11 @@ jest.mock('uiSrc/slices/workbench/wb-guides', () => {
}
})

/**
* Explore Redis tests
*
* @group component
*/
describe('EnablementArea', () => {
beforeEach(() => {
reactRouterDom.useHistory = jest.fn().mockReturnValue({ push: jest.fn() })
Expand Down Expand Up @@ -171,4 +193,80 @@ describe('EnablementArea', () => {
expect(screen.queryByTestId('welcome-my-tutorials')).not.toBeInTheDocument()
})
})

describe('Telemetry', () => {
it('should call proper event on click create button', () => {
const sendEventTelemetryMock = jest.fn();
(sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock)

render(<EnablementArea {...instance(mockedProps)} customTutorials={MOCK_CUSTOM_TUTORIALS_ITEMS} />)

fireEvent.click(screen.getByTestId('open-upload-tutorial-btn'))

expect(sendEventTelemetry).toBeCalledWith({
event: TelemetryEvent.EXPLORE_PANEL_IMPORT_CLICKED,
eventData: {
databaseId: 'instanceId',
},
});

(sendEventTelemetry as jest.Mock).mockRestore()
})

it('should call proper event on submit custom tutorial', async () => {
const sendEventTelemetryMock = jest.fn();
(sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock)

render(<EnablementArea {...instance(mockedProps)} customTutorials={MOCK_CUSTOM_TUTORIALS_ITEMS} />)
fireEvent.click(screen.getByTestId('open-upload-tutorial-btn'));

(sendEventTelemetry as jest.Mock).mockRestore()

await act(() => {
fireEvent.change(
screen.getByTestId('tutorial-link-field'),
{ target: { value: 'link' } }
)
})

await act(() => {
fireEvent.click(screen.getByTestId('submit-upload-tutorial-btn'))
})

expect(sendEventTelemetry).toBeCalledWith({
event: TelemetryEvent.EXPLORE_PANEL_IMPORT_SUBMITTED,
eventData: {
databaseId: 'instanceId',
source: 'URL',
},
});

(sendEventTelemetry as jest.Mock).mockRestore()
})

it('should call proper event on delete custom tutorial', async () => {
(deleteCustomTutorial as jest.Mock).mockImplementation((_, onSuccess: () => void) => () => onSuccess?.())

const sendEventTelemetryMock = jest.fn();
(sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock)

render(<EnablementArea {...instance(mockedProps)} customTutorials={MOCK_CUSTOM_TUTORIALS_ITEMS} />)
await act(() => {
fireEvent.click(screen.getByTestId('delete-tutorial-icon-12mfp-rem'))
})

await act(() => {
fireEvent.click(screen.getByTestId('delete-tutorial-12mfp-rem'))
})

expect(sendEventTelemetry).toBeCalledWith({
event: TelemetryEvent.EXPLORE_PANEL_TUTORIAL_DELETED,
eventData: {
databaseId: 'instanceId',
},
});

(sendEventTelemetry as jest.Mock).mockRestore()
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Group = (props: Props) => {
e.stopPropagation()
onCreate?.()
sendEventTelemetry({
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_IMPORT_CLICKED,
event: TelemetryEvent.EXPLORE_PANEL_IMPORT_CLICKED,
eventData: {
databaseId: instanceId,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const InternalPage = (props: Props) => {

const sendEventClickExternalLinkTelemetry = (link: string = '') => {
sendEventTelemetry({
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_LINK_CLICKED,
event: TelemetryEvent.EXPLORE_PANEL_LINK_CLICKED,
eventData: {
path,
link,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const Navigation = (props: Props) => {
}

sendEventTelemetry({
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_IMPORT_SUBMITTED,
event: TelemetryEvent.EXPLORE_PANEL_IMPORT_SUBMITTED,
eventData: {
databaseId: instanceId,
source: file ? 'Upload' : 'URL'
Expand All @@ -73,7 +73,7 @@ const Navigation = (props: Props) => {
const onDeleteCustomTutorial = (id: string) => {
dispatch(deleteCustomTutorial(id, () => {
sendEventTelemetry({
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_TUTORIAL_DELETED,
event: TelemetryEvent.EXPLORE_PANEL_TUTORIAL_DELETED,
eventData: {
databaseId: instanceId,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('RedisUploadButton', () => {
fireEvent.click(screen.getByTestId('upload-data-bulk-btn'))

expect(sendEventTelemetry).toBeCalledWith({
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_CLICKED,
event: TelemetryEvent.EXPLORE_PANEL_DATA_UPLOAD_CLICKED,
eventData: {
databaseId: 'databaseId'
}
Expand All @@ -84,7 +84,7 @@ describe('RedisUploadButton', () => {
fireEvent.click(screen.getByTestId('upload-data-bulk-apply-btn'))

expect(sendEventTelemetry).toBeCalledWith({
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_SUBMITTED,
event: TelemetryEvent.EXPLORE_PANEL_DATA_UPLOAD_SUBMITTED,
eventData: {
databaseId: 'databaseId'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const RedisUploadButton = ({ label, path }: Props) => {
const openPopover = () => {
if (!isPopoverOpen) {
sendEventTelemetry({
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_CLICKED,
event: TelemetryEvent.EXPLORE_PANEL_DATA_UPLOAD_CLICKED,
eventData: {
databaseId: instanceId
}
Expand All @@ -46,7 +46,7 @@ const RedisUploadButton = ({ label, path }: Props) => {
setIsPopoverOpen(false)
dispatch(uploadDataBulkAction(instanceId, path))
sendEventTelemetry({
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_SUBMITTED,
event: TelemetryEvent.EXPLORE_PANEL_DATA_UPLOAD_SUBMITTED,
eventData: {
databaseId: instanceId
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const EnablementAreaWrapper = () => {

const onOpenInternalPage = ({ path, manifestPath }: IInternalPage) => {
sendEventTelemetry({
event: TelemetryEvent.WORKBENCH_ENABLEMENT_AREA_GUIDE_OPENED,
event: TelemetryEvent.EXPLORE_PANEL_TUTORIAL_OPENED,
eventData: {
path,
section: getTutorialSection(manifestPath),
Expand Down
18 changes: 8 additions & 10 deletions redisinsight/ui/src/telemetry/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ export enum TelemetryEvent {
STRING_LOAD_ALL_CLICKED = 'STRING_LOAD_ALL_CLICKED',
STRING_DOWNLOAD_VALUE_CLICKED = 'STRING_DOWNLOAD_VALUE_CLICKED',

WORKBENCH_ENABLEMENT_AREA_GUIDE_OPENED = 'WORKBENCH_ENABLEMENT_AREA_GUIDE_OPENED',
WORKBENCH_ENABLEMENT_AREA_LINK_CLICKED = 'WORKBENCH_ENABLEMENT_AREA_LINK_CLICKED',
WORKBENCH_COMMAND_SUBMITTED = 'WORKBENCH_COMMAND_SUBMITTED',

WORKBENCH_COMMAND_COPIED = 'WORKBENCH_COMMAND_COPIED',
Expand All @@ -123,13 +121,6 @@ export enum TelemetryEvent {
WORKBENCH_NON_REDIS_EDITOR_CANCELLED = 'WORKBENCH_NON_REDIS_EDITOR_CANCELLED',
WORKBENCH_NON_REDIS_EDITOR_SAVED = 'WORKBENCH_NON_REDIS_EDITOR_SAVED',
WORKBENCH_MODE_CHANGED = 'WORKBENCH_MODE_CHANGED',
WORKBENCH_ENABLEMENT_AREA_IMPORT_CLICKED = 'WORKBENCH_ENABLEMENT_AREA_IMPORT_CLICKED',
WORKBENCH_ENABLEMENT_AREA_IMPORT_SUBMITTED = 'WORKBENCH_ENABLEMENT_AREA_IMPORT_SUBMITTED',
WORKBENCH_ENABLEMENT_AREA_TUTORIAL_LINK_CHANGED = 'WORKBENCH_ENABLEMENT_AREA_TUTORIAL_LINK_CHANGED',
WORKBENCH_ENABLEMENT_AREA_TUTORIAL_DELETED = 'WORKBENCH_ENABLEMENT_AREA_TUTORIAL_DELETED',
EXPLORE_PANEL_CREATE_TUTORIAL_LINK_CLICKED = 'EXPLORE_PANEL_CREATE_TUTORIAL_LINK_CLICKED',
WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_CLICKED = 'WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_CLICKED',
WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_SUBMITTED = 'WORKBENCH_ENABLEMENT_AREA_DATA_UPLOAD_SUBMITTED',
WORKBENCH_CLEAR_RESULT_CLICKED = 'WORKBENCH_CLEAR_RESULT_CLICKED',
WORKBENCH_CLEAR_ALL_RESULTS_CLICKED = 'WORKBENCH_CLEAR_ALL_RESULTS_CLICKED',

Expand Down Expand Up @@ -251,8 +242,15 @@ export enum TelemetryEvent {

EXPLORE_PANEL_COMMAND_COPIED = 'EXPLORE_PANEL_COMMAND_COPIED',
EXPLORE_PANEL_COMMAND_RUN_CLICKED = 'EXPLORE_PANEL_COMMAND_RUN_CLICKED',
EXPLORE_PANEL_COMMAND_RUN_CONFIRMED = 'EXPLORE_PANEL_COMMAND_RUN_CONFIRMED',
EXPLORE_PANEL_DATABASE_CHANGE_CLICKED = 'EXPLORE_PANEL_DATABASE_CHANGE_CLICKED',
EXPLORE_PANEL_IMPORT_CLICKED = 'EXPLORE_PANEL_IMPORT_CLICKED',
EXPLORE_PANEL_IMPORT_SUBMITTED = 'EXPLORE_PANEL_IMPORT_SUBMITTED',
EXPLORE_PANEL_TUTORIAL_DELETED = 'EXPLORE_PANEL_TUTORIAL_DELETED',
EXPLORE_PANEL_TUTORIAL_OPENED = 'EXPLORE_PANEL_TUTORIAL_OPENED',
EXPLORE_PANEL_LINK_CLICKED = 'EXPLORE_PANEL_LINK_CLICKED',
EXPLORE_PANEL_CREATE_TUTORIAL_LINK_CLICKED = 'EXPLORE_PANEL_CREATE_TUTORIAL_LINK_CLICKED',
EXPLORE_PANEL_DATA_UPLOAD_CLICKED = 'EXPLORE_PANEL_DATA_UPLOAD_CLICKED',
EXPLORE_PANEL_DATA_UPLOAD_SUBMITTED = 'EXPLORE_PANEL_DATA_UPLOAD_SUBMITTED',

CAPABILITY_POPOVER_DISPLAYED = 'CAPABILITY_POPOVER_DISPLAYED',

Expand Down