Skip to content

Commit 66b78d3

Browse files
committed
merge main into dependabot alerts
2 parents 1da6d6f + ae82d66 commit 66b78d3

File tree

25 files changed

+192
-65
lines changed

25 files changed

+192
-65
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"word-wrap": "1.2.4",
8383
"electron-builder/app-builder-lib/@electron/universal/dir-compare/minimatch": "^3.0.5",
8484
"**/semver": "^7.5.2",
85-
"rawproto/protobufjs": "^7.2.4"
85+
"rawproto/protobufjs": "^7.2.5"
8686
},
8787
"devDependencies": {
8888
"@babel/preset-env": "^7.23.2",

redisinsight/api/data/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
{
1111
"path": "search",
12-
"modules": ["search"]
12+
"modules": ["search", "searchlight", "ft", "ftl"]
1313
}
1414
]
1515
}

redisinsight/api/src/__mocks__/bulk-actions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,5 @@ export const mockBulkActionsAnalytics = () => ({
9292
sendActionStopped: jest.fn(),
9393
sendActionSucceed: jest.fn(),
9494
sendActionFailed: jest.fn(),
95+
sendImportSamplesUploaded: jest.fn(),
9596
});

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export enum TelemetryEvents {
7878
BulkActionsStopped = 'BULK_ACTIONS_STOPPED',
7979
BulkActionsSucceed = 'BULK_ACTIONS_SUCCEED',
8080
BulkActionsFailed = 'BULK_ACTIONS_FAILED',
81+
ImportSamplesUploaded = 'IMPORT_SAMPLES_UPLOADED',
8182

8283
// Feature
8384
FeatureFlagConfigUpdated = 'FEATURE_FLAG_CONFIG_UPDATED',

redisinsight/api/src/modules/analytics/telemetry.base.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { isString } from 'lodash';
22
import { EventEmitter2 } from '@nestjs/event-emitter';
3-
import { HttpException } from '@nestjs/common';
3+
import { HttpException, Injectable } from '@nestjs/common';
44
import { AppAnalyticsEvents } from 'src/constants';
55

6+
@Injectable()
67
export abstract class TelemetryBaseService {
78
constructor(
89
protected readonly eventEmitter: EventEmitter2,

redisinsight/api/src/modules/bulk-actions/bulk-actions.analytics.spec.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,48 @@ describe('BulkActionsAnalytics', () => {
223223
expect(sendFailedEventSpy).not.toHaveBeenCalled();
224224
});
225225
});
226+
227+
describe('sendImportSamplesUploaded', () => {
228+
it('should emit event when action succeed (without progress)', () => {
229+
service.sendImportSamplesUploaded(mockBulkActionOverview);
230+
231+
expect(sendEventSpy).toHaveBeenCalledWith(
232+
TelemetryEvents.ImportSamplesUploaded,
233+
{
234+
databaseId: mockBulkActionOverview.databaseId,
235+
action: mockBulkActionOverview.type,
236+
duration: mockBulkActionOverview.duration,
237+
summary: {
238+
processed: mockBulkActionOverview.summary.processed,
239+
processedRange: '0 - 5 000',
240+
succeed: mockBulkActionOverview.summary.succeed,
241+
succeedRange: '0 - 5 000',
242+
failed: mockBulkActionOverview.summary.failed,
243+
failedRange: '0 - 5 000',
244+
},
245+
},
246+
);
247+
});
248+
it('should emit event when action succeed without filter and summary', () => {
249+
service.sendImportSamplesUploaded({
250+
...mockBulkActionOverview,
251+
filter: undefined,
252+
summary: undefined,
253+
});
254+
255+
expect(sendEventSpy).toHaveBeenCalledWith(
256+
TelemetryEvents.ImportSamplesUploaded,
257+
{
258+
databaseId: mockBulkActionOverview.databaseId,
259+
action: mockBulkActionOverview.type,
260+
duration: mockBulkActionOverview.duration,
261+
summary: {},
262+
},
263+
);
264+
});
265+
it('should not emit event in case of an error and should not fail', () => {
266+
service.sendImportSamplesUploaded(undefined);
267+
expect(sendEventSpy).not.toHaveBeenCalled();
268+
});
269+
});
226270
});

redisinsight/api/src/modules/bulk-actions/bulk-actions.analytics.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,27 @@ export class BulkActionsAnalytics extends TelemetryBaseService {
105105
// continue regardless of error
106106
}
107107
}
108+
109+
sendImportSamplesUploaded(overview: IBulkActionOverview): void {
110+
try {
111+
this.sendEvent(
112+
TelemetryEvents.ImportSamplesUploaded,
113+
{
114+
databaseId: overview.databaseId,
115+
action: overview.type,
116+
duration: overview.duration,
117+
summary: {
118+
processed: overview.summary?.processed,
119+
processedRange: getRangeForNumber(overview.summary?.processed, BULK_ACTIONS_BREAKPOINTS),
120+
succeed: overview.summary?.succeed,
121+
succeedRange: getRangeForNumber(overview.summary?.succeed, BULK_ACTIONS_BREAKPOINTS),
122+
failed: overview.summary?.failed,
123+
failedRange: getRangeForNumber(overview.summary?.failed, BULK_ACTIONS_BREAKPOINTS),
124+
},
125+
},
126+
);
127+
} catch (e) {
128+
// continue regardless of error
129+
}
130+
}
108131
}

redisinsight/api/src/modules/bulk-actions/bulk-import.service.spec.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,60 @@ describe('BulkImportService', () => {
346346
expect(spy).toHaveBeenCalledWith(mockClientMetadata, mockCombinedStream);
347347
});
348348

349+
it('should import default data for search module', async () => {
350+
mockedFs.readFileSync.mockImplementationOnce(() => Buffer.from(JSON.stringify({
351+
files: [
352+
{
353+
path: 'some-path',
354+
modules: ['search', 'searchlight', 'ft', 'ftl'],
355+
},
356+
],
357+
})));
358+
359+
mockedFs.createReadStream.mockImplementationOnce(() => new fs.ReadStream());
360+
deviceService.get.mockResolvedValue({
361+
...mockDatabase,
362+
modules: [{
363+
name: 'search',
364+
version: 999999,
365+
semanticVersion: '99.99.99',
366+
}],
367+
});
368+
369+
await service.importDefaultData(mockClientMetadata);
370+
371+
expect(mockCombinedStream.append).toHaveBeenCalledTimes(2);
372+
expect(spy).toHaveBeenCalledTimes(1);
373+
expect(spy).toHaveBeenCalledWith(mockClientMetadata, mockCombinedStream);
374+
});
375+
376+
it('should import default data for searchlight module', async () => {
377+
mockedFs.readFileSync.mockImplementationOnce(() => Buffer.from(JSON.stringify({
378+
files: [
379+
{
380+
path: 'some-path',
381+
modules: ['search', 'searchlight', 'ft', 'ftl'],
382+
},
383+
],
384+
})));
385+
386+
mockedFs.createReadStream.mockImplementationOnce(() => new fs.ReadStream());
387+
deviceService.get.mockResolvedValue({
388+
...mockDatabase,
389+
modules: [{
390+
name: 'searchlight',
391+
version: 999999,
392+
semanticVersion: '99.99.99',
393+
}],
394+
});
395+
396+
await service.importDefaultData(mockClientMetadata);
397+
398+
expect(mockCombinedStream.append).toHaveBeenCalledTimes(2);
399+
expect(spy).toHaveBeenCalledTimes(1);
400+
expect(spy).toHaveBeenCalledWith(mockClientMetadata, mockCombinedStream);
401+
});
402+
349403
it('should import default data for core module only', async () => {
350404
mockedFs.readFileSync.mockImplementationOnce(() => Buffer.from(JSON.stringify(mockDefaultDataManifest)));
351405
mockedFs.createReadStream.mockImplementationOnce(() => new fs.ReadStream());

redisinsight/api/src/modules/bulk-actions/bulk-import.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ export class BulkImportService {
212212
commandsStream.append('\r\n');
213213
});
214214

215-
return this.import(clientMetadata, commandsStream);
215+
const result = await this.import(clientMetadata, commandsStream);
216+
217+
this.analytics.sendImportSamplesUploaded(result);
218+
219+
return result;
216220
} catch (e) {
217221
this.logger.error('Unable to process an import file path from tutorial', e);
218222
throw new InternalServerErrorException(ERROR_MESSAGES.COMMON_DEFAULT_IMPORT_ERROR);

redisinsight/ui/src/components/messages/filter-not-available/FilterNotAvailable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const FilterNotAvailable = ({ onClose } : { onClose?: () => void }) => {
4747
<>
4848
<EuiText color="subdued">
4949
Create a free Redis Stack database that supports filtering and extends
50-
the core capabilities of open-source Redis.
50+
the core capabilities of your Redis.
5151
</EuiText>
5252
<EuiSpacer size="l" />
5353
<div className={styles.linksWrapper}>

0 commit comments

Comments
 (0)