Skip to content

Commit 6e034e9

Browse files
RI-2722-fix filtered events (#539)
* RI-2722-fix filtered events
1 parent 8e99e04 commit 6e034e9

File tree

8 files changed

+37
-10
lines changed

8 files changed

+37
-10
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"@types/express": "^4.17.3",
143143
"@types/html-entities": "^1.3.4",
144144
"@types/ioredis": "^4.26.0",
145+
"@types/is-glob": "^4.0.2",
145146
"@types/jest": "^26.0.15",
146147
"@types/lodash": "^4.14.171",
147148
"@types/node": "14.14.10",

redisinsight/ui/src/slices/hash.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { cloneDeep, remove, isNull } from 'lodash'
33
import { apiService } from 'uiSrc/services'
44
import { ApiEndpoints, KeyTypes } from 'uiSrc/constants'
55
import { getApiErrorMessage, getUrl, isStatusSuccessful } from 'uiSrc/utils'
6-
import { getBasedOnViewTypeEvent, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
6+
import { getBasedOnViewTypeEvent, getMatchType, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
77
import { SCAN_COUNT_DEFAULT } from 'uiSrc/constants/api'
88
import successMessages from 'uiSrc/components/notifications/success-messages'
99
import {
@@ -209,6 +209,7 @@ export function fetchHashFields(
209209
)
210210

211211
if (isStatusSuccessful(status)) {
212+
const matchValue = getMatchType(match)
212213
sendEventTelemetry({
213214
event: getBasedOnViewTypeEvent(
214215
state.browser.keys?.viewType,
@@ -218,10 +219,11 @@ export function fetchHashFields(
218219
eventData: {
219220
databaseId: state.connections.instances?.connectedInstance?.id,
220221
keyType: KeyTypes.Hash,
221-
match: 'EXACT_VALUE_NAME',
222+
match: matchValue,
222223
length: data.total,
223224
}
224225
})
226+
225227
dispatch(loadHashFieldsSuccess(data))
226228
dispatch(updateSelectedKeyRefreshTime(Date.now()))
227229
}

redisinsight/ui/src/slices/keys.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
isStatusSuccessful,
1313
} from 'uiSrc/utils'
1414
import { DEFAULT_SEARCH_MATCH, SCAN_COUNT_DEFAULT } from 'uiSrc/constants/api'
15-
import { getBasedOnViewTypeEvent, sendEventTelemetry, TelemetryEvent, getAdditionalAddedEventData } from 'uiSrc/telemetry'
15+
import { getBasedOnViewTypeEvent, sendEventTelemetry, TelemetryEvent, getAdditionalAddedEventData, getMatchType } from 'uiSrc/telemetry'
1616
import successMessages from 'uiSrc/components/notifications/success-messages'
1717
import {
1818
CreateListWithExpireDto,
@@ -390,6 +390,10 @@ export function fetchKeys(cursor: string, count: number, onSuccess?: () => void,
390390
})
391391
)
392392
if (!!type || !!match) {
393+
let matchValue = '*'
394+
if (match !== '*' && !!match) {
395+
matchValue = getMatchType(match)
396+
}
393397
sendEventTelemetry({
394398
event: getBasedOnViewTypeEvent(
395399
state.browser.keys?.viewType,
@@ -399,7 +403,7 @@ export function fetchKeys(cursor: string, count: number, onSuccess?: () => void,
399403
eventData: {
400404
databaseId: state.connections.instances?.connectedInstance?.id,
401405
keyType: type,
402-
match: 'EXACT KEY NAME',
406+
match: matchValue,
403407
databaseSize: data[0].total,
404408
numberOfKeysScanned: data[0].scanned,
405409
scanCount: count,

redisinsight/ui/src/slices/set.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { remove } from 'lodash'
44
import { apiService } from 'uiSrc/services'
55
import { ApiEndpoints, KeyTypes } from 'uiSrc/constants'
66
import { getApiErrorMessage, getUrl, isStatusSuccessful } from 'uiSrc/utils'
7-
import { getBasedOnViewTypeEvent, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
7+
import { getBasedOnViewTypeEvent, sendEventTelemetry, TelemetryEvent, getMatchType } from 'uiSrc/telemetry'
88
import {
99
AddMembersToSetDto,
1010
GetSetMembersResponse,
@@ -170,6 +170,7 @@ export function fetchSetMembers(
170170
)
171171

172172
if (isStatusSuccessful(status)) {
173+
const matchValue = getMatchType(match)
173174
sendEventTelemetry({
174175
event: getBasedOnViewTypeEvent(
175176
state.browser.keys?.viewType,
@@ -179,7 +180,7 @@ export function fetchSetMembers(
179180
eventData: {
180181
databaseId: state.connections.instances?.connectedInstance?.id,
181182
keyType: KeyTypes.Set,
182-
match: 'EXACT_VALUE_NAME',
183+
match: matchValue,
183184
length: data.total,
184185
}
185186
})

redisinsight/ui/src/slices/zset.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createSlice } from '@reduxjs/toolkit'
44
import { apiService } from 'uiSrc/services'
55
import { ApiEndpoints, SortOrder, KeyTypes } from 'uiSrc/constants'
66
import { getApiErrorMessage, getUrl, isStatusSuccessful } from 'uiSrc/utils'
7-
import { getBasedOnViewTypeEvent, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
7+
import { getBasedOnViewTypeEvent, sendEventTelemetry, TelemetryEvent, getMatchType } from 'uiSrc/telemetry'
88
import { StateZset } from 'uiSrc/slices/interfaces/zset'
99
import successMessages from 'uiSrc/components/notifications/success-messages'
1010
import {
@@ -447,6 +447,7 @@ export function fetchSearchZSetMembers(
447447
)
448448

449449
if (isStatusSuccessful(status)) {
450+
const matchValue = getMatchType(match)
450451
sendEventTelemetry({
451452
event: getBasedOnViewTypeEvent(
452453
state.browser.keys?.viewType,
@@ -456,7 +457,7 @@ export function fetchSearchZSetMembers(
456457
eventData: {
457458
databaseId: state.connections.instances?.connectedInstance?.id,
458459
keyType: KeyTypes.ZSet,
459-
match: 'EXACT_VALUE_NAME',
460+
match: matchValue,
460461
length: data.total,
461462
}
462463
})

redisinsight/ui/src/telemetry/interfaces.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ export interface ITelemetryEvent {
2929
event: TelemetryEvent;
3030
properties?: object;
3131
}
32+
33+
export enum MatchType {
34+
EXACT_VALUE_NAME = 'EXACT_VALUE_NAME',
35+
PATTERN = 'PATTERN'
36+
}

redisinsight/ui/src/telemetry/telemetryUtils.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
* This module abstracts the exact service/framework used for tracking usage.
44
*/
55
import { get } from 'lodash'
6+
import isGlob from 'is-glob'
67
import * as jsonpath from 'jsonpath'
78
import { Nullable } from 'uiSrc/utils'
89
import store from 'uiSrc/slices/store'
910
import { localStorageService } from 'uiSrc/services'
1011
import { ApiEndpoints, BrowserStorageItem, KeyTypes } from 'uiSrc/constants'
1112
import { KeyViewType } from 'uiSrc/slices/interfaces/keys'
12-
import { ITelemetrySendEvent, ITelemetrySendPageView, ITelemetryService } from './interfaces'
13+
import { ITelemetrySendEvent, ITelemetrySendPageView, ITelemetryService, MatchType } from './interfaces'
1314
import { TelemetryEvent } from './events'
1415
import { NON_TRACKING_ANONYMOUS_ID, SegmentTelemetryService } from './segment'
1516

@@ -156,12 +157,19 @@ const getAdditionalAddedEventData = (endpoint: ApiEndpoints, data: any) => {
156157
}
157158
}
158159

160+
const getMatchType = (match: string): MatchType => (
161+
!isGlob(match, { strict: false })
162+
? MatchType.EXACT_VALUE_NAME
163+
: MatchType.PATTERN
164+
)
165+
159166
export {
160167
getTelemetryService,
161168
sendEventTelemetry,
162169
sendPageViewTelemetry,
163170
checkIsAnalyticsGranted,
164171
getBasedOnViewTypeEvent,
165172
getJsonPathLevel,
166-
getAdditionalAddedEventData
173+
getAdditionalAddedEventData,
174+
getMatchType
167175
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,6 +2161,11 @@
21612161
dependencies:
21622162
"@types/node" "*"
21632163

2164+
"@types/is-glob@^4.0.2":
2165+
version "4.0.2"
2166+
resolved "https://registry.yarnpkg.com/@types/is-glob/-/is-glob-4.0.2.tgz#c243dd0d09eac2992130142419ff2308ffd988bf"
2167+
integrity sha512-4j5G9Y5jljDSICQ1R2f/Rcyoj6DZmYGneny+p/cDkjep0rkqNg0W73Ty0bVjMUTZgLXHf8oiMjg1XC3CDwCz+g==
2168+
21642169
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
21652170
version "2.0.3"
21662171
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz#4ba8ddb720221f432e443bd5f9117fd22cfd4762"

0 commit comments

Comments
 (0)