Skip to content

Commit 662ef1e

Browse files
authored
Merge pull request #1368 from RedisInsight/fe/feature/RI-3716_Redisearch_telemetry
#RI-3716 - Cover Search capability with telemetry
2 parents 3917d2e + 048ade0 commit 662ef1e

File tree

7 files changed

+59
-12
lines changed

7 files changed

+59
-12
lines changed

redisinsight/ui/src/pages/browser/components/browser-right-panel/BrowserRightPanel.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ const BrowserRightPanel = (props: Props) => {
6969
sendEventTelemetry({
7070
event: TelemetryEvent.SEARCH_INDEX_ADD_CANCELLED,
7171
eventData: {
72-
databaseId: instanceId
72+
databaseId: instanceId,
73+
view: viewType,
7374
}
7475
})
7576
}
@@ -140,7 +141,10 @@ const BrowserRightPanel = (props: Props) => {
140141
/>
141142
)}
142143
{isCreateIndexPanelOpen && every([!isAddKeyPanelOpen, !isBulkActionsPanelOpen], Boolean) && (
143-
<CreateRedisearchIndex onClosePanel={onCloseRedisearchPanel} />
144+
<CreateRedisearchIndex
145+
onCreateIndex={closePanel}
146+
onClosePanel={onCloseRedisearchPanel}
147+
/>
144148
)}
145149
</>
146150
)

redisinsight/ui/src/pages/browser/components/create-redisearch-index/CreateRedisearchIndex.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import Divider from 'uiSrc/components/divider/Divider'
2020
import AddItemsActions from 'uiSrc/pages/browser/components/add-items-actions/AddItemsActions'
2121
import { createIndexStateSelector, createRedisearchIndexAction } from 'uiSrc/slices/browser/redisearch'
2222
import { stringToBuffer } from 'uiSrc/utils'
23+
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
24+
import { keysSelector } from 'uiSrc/slices/browser/keys'
25+
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
2326
import { CreateRedisearchIndexDto } from 'apiSrc/modules/browser/dto/redisearch'
2427

2528
import { FIELD_TYPE_OPTIONS, KEY_TYPE_OPTIONS, RedisearchIndexKeyType } from './constants'
@@ -28,6 +31,7 @@ import styles from './styles.module.scss'
2831

2932
export interface Props {
3033
onClosePanel: () => void
34+
onCreateIndex: () => void
3135
}
3236

3337
const keyTypeOptions = KEY_TYPE_OPTIONS.map((item) => {
@@ -49,8 +53,10 @@ const fieldTypeOptions = FIELD_TYPE_OPTIONS.map(({ value, text }) => ({
4953

5054
const initialFieldValue = (id = 0) => ({ id, identifier: '', fieldType: fieldTypeOptions[0].value })
5155

52-
const CreateRedisearchIndex = ({ onClosePanel }: Props) => {
56+
const CreateRedisearchIndex = ({ onClosePanel, onCreateIndex }: Props) => {
57+
const { viewType } = useSelector(keysSelector)
5358
const { loading } = useSelector(createIndexStateSelector)
59+
const { id: instanceId } = useSelector(connectedInstanceSelector)
5460

5561
const [keyTypeSelected, setKeyTypeSelected] = useState<RedisearchIndexKeyType>(keyTypeOptions[0].value)
5662
const [prefixes, setPrefixes] = useState<EuiComboBoxOptionOption[]>([])
@@ -97,7 +103,22 @@ const CreateRedisearchIndex = ({ onClosePanel }: Props) => {
97103
}))
98104
}
99105

100-
dispatch(createRedisearchIndexAction(data, onClosePanel))
106+
dispatch(createRedisearchIndexAction(data, onSuccess))
107+
}
108+
109+
const onSuccess = (data: CreateRedisearchIndexDto) => {
110+
sendEventTelemetry({
111+
event: TelemetryEvent.SEARCH_INDEX_ADDED,
112+
eventData: {
113+
databaseId: instanceId,
114+
view: viewType,
115+
dataType: data.type,
116+
countOfPrefixes: data.prefixes?.length || 0,
117+
countOfFieldNames: data.fields?.length || 0,
118+
}
119+
})
120+
121+
onCreateIndex()
101122
}
102123

103124
const isClearDisabled = (item: any): boolean => fields.length === 1 && !(item.identifier.length)

redisinsight/ui/src/pages/browser/components/create-redisearch-index/CreateRedisearchIndexWrapper.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import styles from './styles.module.scss'
1515

1616
export interface Props {
1717
onClosePanel: () => void
18+
onCreateIndex: () => void
1819
}
1920

20-
const CreateRedisearchIndexWrapper = ({ onClosePanel }: Props) => (
21+
const CreateRedisearchIndexWrapper = ({ onClosePanel, onCreateIndex }: Props) => (
2122
<div className={styles.page} data-testid="create-index-panel">
2223
<EuiFlexGroup
2324
justifyContent="center"
@@ -60,7 +61,10 @@ const CreateRedisearchIndexWrapper = ({ onClosePanel }: Props) => (
6061
</EuiText>
6162
</EuiFlexItem>
6263
</div>
63-
<CreateRedisearchIndex onClosePanel={onClosePanel} />
64+
<CreateRedisearchIndex
65+
onCreateIndex={onCreateIndex}
66+
onClosePanel={onClosePanel}
67+
/>
6468
</EuiFlexGroup>
6569
</div>
6670
)

redisinsight/ui/src/pages/browser/components/keys-header/KeysHeader.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ const KeysHeader = (props: Props) => {
249249
eventData: {
250250
databaseId: instanceId,
251251
previous: searchMode,
252-
current: mode
252+
current: mode,
253+
view: viewType,
253254
}
254255
})
255256
}

redisinsight/ui/src/pages/browser/components/redisearch-key-list/RediSearchIndexesList.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ const RediSearchIndexesList = (props: Props) => {
8282
sendEventTelemetry({
8383
event: TelemetryEvent.SEARCH_INDEX_ADD_BUTTON_CLICKED,
8484
eventData: {
85-
databaseId: instanceId
85+
databaseId: instanceId,
86+
view: viewType,
8687
}
8788
})
8889

@@ -100,10 +101,11 @@ const RediSearchIndexesList = (props: Props) => {
100101
))
101102

102103
sendEventTelemetry({
103-
event: TelemetryEvent.SEARCH_INDEX_ADD_BUTTON_CLICKED,
104+
event: TelemetryEvent.SEARCH_INDEX_CHANGED,
104105
eventData: {
105106
databaseId: instanceId,
106-
totalNumberOfIndexes: list.length
107+
totalNumberOfIndexes: list.length,
108+
view: viewType,
107109
}
108110
})
109111
}

redisinsight/ui/src/slices/browser/redisearch.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { bufferToString, getApiErrorMessage, getUrl, isEqualBuffers, isStatusSuc
99
import { DEFAULT_SEARCH_MATCH } from 'uiSrc/constants/api'
1010
import { IKeyPropTypes } from 'uiSrc/constants/prop-types/keys'
1111
import ApiErrors from 'uiSrc/constants/apiErrors'
12+
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
1213

1314
import { GetKeysWithDetailsResponse } from 'apiSrc/modules/browser/dto'
1415
import { CreateRedisearchIndexDto, ListRedisearchIndexesResponse } from 'apiSrc/modules/browser/dto/redisearch'
@@ -249,6 +250,18 @@ export function fetchRedisearchKeysAction(
249250

250251
if (isStatusSuccessful(status)) {
251252
dispatch(loadKeysSuccess([data, !!query]))
253+
254+
if (query) {
255+
sendEventTelemetry({
256+
event: TelemetryEvent.SEARCH_KEYS_SEARCHED,
257+
eventData: {
258+
view: state.browser.keys?.viewType,
259+
databaseId: state.connections.instances?.connectedInstance?.id,
260+
scanCount: data.scanned,
261+
}
262+
})
263+
}
264+
252265
onSuccess?.(data)
253266
}
254267
} catch (_err) {
@@ -351,7 +364,7 @@ export function fetchRedisearchListAction(
351364
}
352365
export function createRedisearchIndexAction(
353366
data: CreateRedisearchIndexDto,
354-
onSuccess?: () => void,
367+
onSuccess?: (data: CreateRedisearchIndexDto) => void,
355368
onFailed?: () => void,
356369
) {
357370
return async (dispatch: AppDispatch, stateInit: () => RootState) => {
@@ -377,7 +390,7 @@ export function createRedisearchIndexAction(
377390
dispatch(createIndexSuccess())
378391
dispatch(addMessageNotification(successMessages.CREATE_INDEX()))
379392
dispatch(fetchRedisearchListAction())
380-
onSuccess?.()
393+
onSuccess?.(data)
381394
}
382395
} catch (_err) {
383396
const error = _err as AxiosError

redisinsight/ui/src/telemetry/events.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,6 @@ export enum TelemetryEvent {
192192
SEARCH_INDEX_CHANGED = 'SEARCH_INDEX_CHANGED',
193193
SEARCH_INDEX_ADD_BUTTON_CLICKED = 'SEARCH_INDEX_ADD_BUTTON_CLICKED',
194194
SEARCH_INDEX_ADD_CANCELLED = 'SEARCH_INDEX_ADD_CANCELLED',
195+
SEARCH_KEYS_SEARCHED = 'SEARCH_KEYS_SEARCHED',
196+
SEARCH_INDEX_ADDED = 'SEARCH_INDEX_ADDED',
195197
}

0 commit comments

Comments
 (0)