Skip to content

Commit 465741d

Browse files
committed
#RI-4861 - Optimize the number of API calls
1 parent f18d065 commit 465741d

File tree

11 files changed

+5
-162
lines changed

11 files changed

+5
-162
lines changed

redisinsight/api/config/default.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export default {
212212
url: process.env.RI_FEATURES_CONFIG_URL
213213
// eslint-disable-next-line max-len
214214
|| 'https://raw.githubusercontent.com/RedisInsight/RedisInsight/main/redisinsight/api/config/features-config.json',
215-
syncInterval: parseInt(process.env.RI_FEATURES_CONFIG_SYNC_INTERVAL, 10) || 1_000 * 60 * 60 * 4, // 4h
215+
syncInterval: parseInt(process.env.RI_FEATURES_CONFIG_SYNC_INTERVAL, 10) || 1_000 * 60 * 60 * 24, // 24h
216216
},
217217
cloud: {
218218
apiUrl: process.env.RI_CLOUD_API_URL || 'https://app-sm.k8s-cloudapi.sm-qa.qa.redislabs.com/api/v1',

redisinsight/api/src/constants/telemetry-events.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export enum TelemetryEvents {
1313
RedisInstanceDeleted = 'CONFIG_DATABASES_DATABASE_DELETED',
1414
RedisInstanceEditedByUser = 'CONFIG_DATABASES_DATABASE_EDITED_BY_USER',
1515
RedisInstanceConnectionFailed = 'DATABASE_CONNECTION_FAILED',
16-
RedisInstanceListReceived = 'CONFIG_DATABASES_DATABASE_LIST_DISPLAYED',
1716

1817
// Databases import
1918
DatabaseImportParseFailed = 'CONFIG_DATABASES_REDIS_IMPORT_PARSE_FAILED',

redisinsight/api/src/modules/database/database.analytics.spec.ts

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,54 +30,6 @@ describe('DatabaseAnalytics', () => {
3030
sendFailedEventSpy = jest.spyOn(service as any, 'sendFailedEvent');
3131
});
3232

33-
describe('sendInstanceListReceivedEvent', () => {
34-
it('should emit event with one db in the list', () => {
35-
service.sendInstanceListReceivedEvent([mockDatabaseWithTlsAuth]);
36-
37-
expect(sendEventSpy).toHaveBeenCalledWith(
38-
TelemetryEvents.RedisInstanceListReceived,
39-
{
40-
numberOfDatabases: 1,
41-
},
42-
);
43-
});
44-
it('should emit event with several dbs in the list', () => {
45-
service.sendInstanceListReceivedEvent([
46-
mockDatabaseWithTlsAuth,
47-
mockDatabaseWithTlsAuth,
48-
mockDatabaseWithTlsAuth,
49-
]);
50-
51-
expect(sendEventSpy).toHaveBeenCalledWith(
52-
TelemetryEvents.RedisInstanceListReceived,
53-
{
54-
numberOfDatabases: 3,
55-
},
56-
);
57-
});
58-
it('should emit event with several empty in the list', () => {
59-
service.sendInstanceListReceivedEvent([]);
60-
61-
expect(sendEventSpy).toHaveBeenCalledWith(
62-
TelemetryEvents.RedisInstanceListReceived,
63-
{
64-
numberOfDatabases: 0,
65-
},
66-
);
67-
});
68-
it('should emit event with additional data', () => {
69-
service.sendInstanceListReceivedEvent([], { data: 'data' });
70-
71-
expect(sendEventSpy).toHaveBeenCalledWith(
72-
TelemetryEvents.RedisInstanceListReceived,
73-
{
74-
numberOfDatabases: 0,
75-
data: 'data',
76-
},
77-
);
78-
});
79-
});
80-
8133
describe('sendInstanceAddedEvent', () => {
8234
it('should emit event with enabled tls and sni, and ssh', () => {
8335
service.sendInstanceAddedEvent({

redisinsight/api/src/modules/database/database.analytics.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,6 @@ export class DatabaseAnalytics extends TelemetryBaseService {
1313
super(eventEmitter);
1414
}
1515

16-
sendInstanceListReceivedEvent(
17-
databases: Database[],
18-
additionalData: object = {},
19-
): void {
20-
try {
21-
this.sendEvent(
22-
TelemetryEvents.RedisInstanceListReceived,
23-
{
24-
numberOfDatabases: databases.length,
25-
...additionalData,
26-
},
27-
);
28-
} catch (e) {
29-
// continue regardless of error
30-
}
31-
}
32-
3316
sendConnectionFailedEvent(instance: Database, exception: HttpException): void {
3417
this.sendFailedEvent(
3518
TelemetryEvents.RedisInstanceConnectionFailed,

redisinsight/api/src/modules/database/database.service.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,10 @@ describe('DatabaseService', () => {
9797
it('should return databases and send analytics event', async () => {
9898
databaseRepository.list.mockResolvedValue([mockDatabase, mockDatabase]);
9999
expect(await service.list()).toEqual([mockDatabase, mockDatabase]);
100-
expect(analytics.sendInstanceListReceivedEvent).toHaveBeenCalledWith([mockDatabase, mockDatabase]);
101100
});
102101
it('should throw InternalServerErrorException?', async () => {
103102
databaseRepository.list.mockRejectedValueOnce(new Error());
104103
await expect(service.list()).rejects.toThrow(InternalServerErrorException);
105-
expect(analytics.sendInstanceListReceivedEvent).not.toHaveBeenCalled();
106104
});
107105
});
108106

redisinsight/api/src/modules/database/database.service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ export class DatabaseService {
6363
async list(): Promise<Database[]> {
6464
try {
6565
this.logger.log('Getting databases list');
66-
const result = await this.repository.list();
67-
this.analytics.sendInstanceListReceivedEvent(result);
68-
return result;
66+
return await this.repository.list();
6967
} catch (e) {
7068
this.logger.error('Failed to get database instance list.', e);
7169
throw new InternalServerErrorException();

redisinsight/ui/src/pages/browser/components/key-details-header/KeyDetailsHeader.tsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { initialKeyInfo, keysSelector, selectedKeyDataSelector, selectedKeySelec
3434
import { streamSelector } from 'uiSrc/slices/browser/stream'
3535
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
3636
import { RedisResponseBuffer } from 'uiSrc/slices/interfaces'
37-
import { getBasedOnViewTypeEvent, getRefreshEventData, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
37+
import { getBasedOnViewTypeEvent, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
3838
import {
3939
formatBytes,
4040
formatLongName,
@@ -208,25 +208,7 @@ const KeyDetailsHeader = ({
208208
})
209209
}
210210

211-
const handleRefreshKey = (enableAutoRefresh: boolean) => {
212-
if (!enableAutoRefresh) {
213-
const eventData = getRefreshEventData(
214-
{
215-
databaseId: instanceId,
216-
keyType: type
217-
},
218-
type,
219-
streamViewType
220-
)
221-
sendEventTelemetry({
222-
event: getBasedOnViewTypeEvent(
223-
viewType,
224-
TelemetryEvent.BROWSER_KEY_DETAILS_REFRESH_CLICKED,
225-
TelemetryEvent.TREE_VIEW_KEY_DETAILS_REFRESH_CLICKED
226-
),
227-
eventData
228-
})
229-
}
211+
const handleRefreshKey = () => {
230212
onRefresh(keyBuffer, type)
231213
}
232214

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,7 @@ const KeysHeader = (props: Props) => {
116116
height: '36px !important',
117117
}
118118

119-
const handleRefreshKeys = (enableAutoRefresh: boolean) => {
120-
if (!enableAutoRefresh) {
121-
sendEventTelemetry({
122-
event: getBasedOnViewTypeEvent(
123-
viewType,
124-
TelemetryEvent.BROWSER_KEY_LIST_REFRESH_CLICKED,
125-
TelemetryEvent.TREE_VIEW_KEY_LIST_REFRESH_CLICKED
126-
),
127-
eventData: {
128-
databaseId: instanceId
129-
}
130-
})
131-
}
119+
const handleRefreshKeys = () => {
132120
dispatch(fetchKeys(
133121
{
134122
searchMode,

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -562,21 +562,6 @@ export function fetchPatternKeysAction(
562562
}
563563
})
564564
}
565-
if (!type && !match && cursor === '0') {
566-
sendEventTelemetry({
567-
event: getBasedOnViewTypeEvent(
568-
state.browser.keys?.viewType,
569-
TelemetryEvent.BROWSER_KEYS_SCANNED,
570-
TelemetryEvent.TREE_VIEW_KEYS_SCANNED
571-
),
572-
eventData: {
573-
databaseId: state.connections.instances?.connectedInstance?.id,
574-
databaseSize: data[0].total,
575-
numberOfKeysScanned: data[0].scanned,
576-
scanCount: count,
577-
}
578-
})
579-
}
580565
onSuccess?.(data)
581566
}
582567
} catch (error) {
@@ -879,18 +864,6 @@ export function deleteSelectedKeyAction(
879864
)
880865

881866
if (isStatusSuccessful(status)) {
882-
sendEventTelemetry({
883-
event: getBasedOnViewTypeEvent(
884-
state.browser.keys?.viewType,
885-
TelemetryEvent.BROWSER_KEYS_DELETED,
886-
TelemetryEvent.TREE_VIEW_KEYS_DELETED
887-
),
888-
eventData: {
889-
databaseId: state.connections.instances?.connectedInstance?.id,
890-
numberOfDeletedKeys: 1,
891-
source: 'keyValue',
892-
}
893-
})
894867
dispatch(deleteSelectedKeySuccess())
895868
dispatch<any>(deleteKeyFromList(key))
896869
onSuccessAction?.()
@@ -926,18 +899,6 @@ export function deleteKeyAction(
926899
)
927900

928901
if (isStatusSuccessful(status)) {
929-
sendEventTelemetry({
930-
event: getBasedOnViewTypeEvent(
931-
state.browser.keys?.viewType,
932-
TelemetryEvent.BROWSER_KEYS_DELETED,
933-
TelemetryEvent.TREE_VIEW_KEYS_DELETED
934-
),
935-
eventData: {
936-
databaseId: state.connections.instances?.connectedInstance?.id,
937-
numberOfDeletedKeys: 1,
938-
source: 'keyList',
939-
}
940-
})
941902
dispatch(deleteKeySuccess())
942903
dispatch<any>(deleteKeyFromList(key))
943904
onSuccessAction?.()

redisinsight/ui/src/telemetry/events.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ export enum TelemetryEvent {
4444
BROWSER_KEY_BULK_ACTIONS_BUTTON_CLICKED = 'BROWSER_KEY_BULK_ACTIONS_BUTTON_CLICKED',
4545
BROWSER_KEY_ADD_CANCELLED = 'BROWSER_KEY_ADD_CANCELLED',
4646
BROWSER_KEY_DELETE_CLICKED = 'BROWSER_KEY_DELETE_CLICKED',
47-
BROWSER_KEY_LIST_REFRESH_CLICKED = 'BROWSER_KEY_LIST_REFRESH_CLICKED',
48-
BROWSER_KEY_DETAILS_REFRESH_CLICKED = 'BROWSER_KEY_DETAILS_REFRESH_CLICKED',
4947
BROWSER_KEY_VALUE_REMOVE_CLICKED = 'BROWSER_KEY_VALUE_REMOVE_CLICKED',
5048
BROWSER_KEY_ADD_VALUE_CLICKED = 'BROWSER_KEY_ADD_VALUE_CLICKED',
5149
BROWSER_KEY_ADD_VALUE_CANCELLED = 'BROWSER_KEY_ADD_VALUE_CANCELLED',
@@ -58,12 +56,10 @@ export enum TelemetryEvent {
5856
BROWSER_KEY_VALUE_ADDED = 'BROWSER_KEY_VALUE_ADDED',
5957
BROWSER_KEY_VALUE_REMOVED = 'BROWSER_KEY_VALUE_REMOVED',
6058
BROWSER_KEY_VALUE_EDITED = 'BROWSER_KEY_VALUE_EDITED',
61-
BROWSER_KEYS_DELETED = 'BROWSER_KEYS_DELETED',
6259
BROWSER_JSON_PROPERTY_EDITED = 'BROWSER_JSON_PROPERTY_EDITED',
6360
BROWSER_JSON_PROPERTY_DELETED = 'BROWSER_JSON_PROPERTY_DELETED',
6461
BROWSER_JSON_PROPERTY_ADDED = 'BROWSER_JSON_PROPERTY_ADDED',
6562
BROWSER_JSON_VALUE_IMPORT_CLICKED = 'BROWSER_JSON_VALUE_IMPORT_CLICKED',
66-
BROWSER_KEYS_SCANNED = 'BROWSER_KEYS_SCANNED',
6763
BROWSER_KEYS_ADDITIONALLY_SCANNED = 'BROWSER_KEYS_ADDITIONALLY_SCANNED',
6864
BROWSER_KEYS_SCANNED_WITH_FILTER_ENABLED = 'BROWSER_KEYS_SCANNED_WITH_FILTER_ENABLED',
6965
BROWSER_KEY_LIST_AUTO_REFRESH_ENABLED = 'BROWSER_KEY_LIST_AUTO_REFRESH_ENABLED',
@@ -150,19 +146,15 @@ export enum TelemetryEvent {
150146
TREE_VIEW_KEY_VALUE_ADDED = 'TREE_VIEW_KEY_VALUE_ADDED',
151147
TREE_VIEW_KEY_VALUE_REMOVE_CLICKED = 'TREE_VIEW_KEY_VALUE_REMOVE_CLICKED',
152148
TREE_VIEW_KEY_DELETE_CLICKED = 'TREE_VIEW_KEY_DELETE_CLICKED',
153-
TREE_VIEW_KEY_LIST_REFRESH_CLICKED = 'TREE_VIEW_KEY_LIST_REFRESH_CLICKED',
154-
TREE_VIEW_KEY_DETAILS_REFRESH_CLICKED = 'TREE_VIEW_KEY_DETAILS_REFRESH_CLICKED',
155149
TREE_VIEW_KEY_VALUE_REMOVED = 'TREE_VIEW_KEY_VALUE_REMOVED',
156150
TREE_VIEW_KEY_VALUE_EDITED = 'TREE_VIEW_KEY_VALUE_EDITED',
157-
TREE_VIEW_KEYS_DELETED = 'TREE_VIEW_KEYS_DELETED',
158151
TREE_VIEW_KEY_COPIED = 'TREE_VIEW_KEY_COPIED',
159152
TREE_VIEW_JSON_KEY_EXPANDED = 'TREE_VIEW_JSON_KEY_EXPANDED',
160153
TREE_VIEW_JSON_KEY_COLLAPSED = 'TREE_VIEW_JSON_KEY_COLLAPSED',
161154
TREE_VIEW_JSON_PROPERTY_EDITED = 'TREE_VIEW_JSON_PROPERTY_EDITED',
162155
TREE_VIEW_JSON_PROPERTY_DELETED = 'TREE_VIEW_JSON_PROPERTY_DELETED',
163156
TREE_VIEW_JSON_PROPERTY_ADDED = 'TREE_VIEW_JSON_PROPERTY_ADDED',
164157
TREE_VIEW_KEYS_SCANNED_WITH_FILTER_ENABLED = 'TREE_VIEW_KEYS_SCANNED_WITH_FILTER_ENABLED',
165-
TREE_VIEW_KEYS_SCANNED = 'TREE_VIEW_KEYS_SCANNED',
166158
TREE_VIEW_KEYS_ADDITIONALLY_SCANNED = 'TREE_VIEW_KEYS_ADDITIONALLY_SCANNED',
167159
TREE_VIEW_DELIMITER_CHANGED = 'TREE_VIEW_DELIMITER_CHANGED',
168160
TREE_VIEW_KEY_ADDED = 'TREE_VIEW_KEY_ADDED',

0 commit comments

Comments
 (0)