Skip to content

Commit 906099d

Browse files
author
Artyom Podymov
committed
fix pr comments
1 parent 5fe2699 commit 906099d

File tree

2 files changed

+22
-31
lines changed

2 files changed

+22
-31
lines changed

redisinsight/api/src/modules/cli/services/cli-analytics/cli-analytics.service.spec.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('CliAnalyticsService', () => {
4242

4343
describe('sendCliClientCreatedEvent', () => {
4444
it('should emit CliClientCreated event', () => {
45-
service.sendClientCreatedEvent(instanceId, 'cli', { data: 'Some data' });
45+
service.sendClientCreatedEvent(instanceId, AppTool.CLI, { data: 'Some data' });
4646

4747
expect(sendEventMethod).toHaveBeenCalledWith(
4848
`CLI_${TelemetryEvents.ClientCreated}`,
@@ -66,7 +66,7 @@ describe('CliAnalyticsService', () => {
6666

6767
describe('sendCliClientCreationFailedEvent', () => {
6868
it('should emit CliClientCreationFailed event', () => {
69-
service.sendClientCreationFailedEvent(instanceId, 'cli', httpException, { data: 'Some data' });
69+
service.sendClientCreationFailedEvent(instanceId, AppTool.CLI, httpException, { data: 'Some data' });
7070

7171
expect(sendFailedEventMethod).toHaveBeenCalledWith(
7272
`CLI_${TelemetryEvents.ClientCreationFailed}`,
@@ -78,7 +78,7 @@ describe('CliAnalyticsService', () => {
7878
);
7979
});
8080
it('should emit CliClientCreationFailed event without additional data', () => {
81-
service.sendClientCreationFailedEvent(instanceId, 'cli', httpException);
81+
service.sendClientCreationFailedEvent(instanceId, AppTool.CLI, httpException);
8282

8383
expect(sendFailedEventMethod).toHaveBeenCalledWith(
8484
`CLI_${TelemetryEvents.ClientCreationFailed}`,
@@ -92,7 +92,7 @@ describe('CliAnalyticsService', () => {
9292

9393
describe('sendCliClientRecreatedEvent', () => {
9494
it('should emit CliClientRecreated event', () => {
95-
service.sendClientRecreatedEvent(instanceId, 'cli', { data: 'Some data' });
95+
service.sendClientRecreatedEvent(instanceId, AppTool.CLI, { data: 'Some data' });
9696

9797
expect(sendEventMethod).toHaveBeenCalledWith(
9898
`CLI_${TelemetryEvents.ClientRecreated}`,
@@ -103,7 +103,7 @@ describe('CliAnalyticsService', () => {
103103
);
104104
});
105105
it('should emit CliClientRecreated event without additional data', () => {
106-
service.sendClientRecreatedEvent(instanceId, 'cli');
106+
service.sendClientRecreatedEvent(instanceId, AppTool.CLI);
107107

108108
expect(sendEventMethod).toHaveBeenCalledWith(
109109
`CLI_${TelemetryEvents.ClientRecreated}`,
@@ -116,7 +116,7 @@ describe('CliAnalyticsService', () => {
116116

117117
describe('sendCliClientDeletedEvent', () => {
118118
it('should emit CliClientDeleted event', () => {
119-
service.sendClientDeletedEvent(1, instanceId, 'cli', { data: 'Some data' });
119+
service.sendClientDeletedEvent(1, instanceId, AppTool.CLI, { data: 'Some data' });
120120

121121
expect(sendEventMethod).toHaveBeenCalledWith(
122122
`CLI_${TelemetryEvents.ClientDeleted}`,
@@ -127,7 +127,7 @@ describe('CliAnalyticsService', () => {
127127
);
128128
});
129129
it('should emit CliClientDeleted event without additional data', () => {
130-
service.sendClientDeletedEvent(1, instanceId, 'cli');
130+
service.sendClientDeletedEvent(1, instanceId, AppTool.CLI);
131131

132132
expect(sendEventMethod).toHaveBeenCalledWith(
133133
`CLI_${TelemetryEvents.ClientDeleted}`,
@@ -137,22 +137,22 @@ describe('CliAnalyticsService', () => {
137137
);
138138
});
139139
it('should not emit event', () => {
140-
service.sendClientDeletedEvent(0, instanceId, 'cli');
140+
service.sendClientDeletedEvent(0, instanceId, AppTool.CLI);
141141

142142
expect(sendEventMethod).not.toHaveBeenCalled();
143143
});
144144
it('should not emit event on invalid input values', () => {
145145
const input: any = {};
146-
service.sendClientDeletedEvent(input, instanceId, 'cli');
146+
service.sendClientDeletedEvent(input, instanceId, AppTool.CLI);
147147

148-
expect(() => service.sendClientDeletedEvent(input, instanceId, 'cli')).not.toThrow();
148+
expect(() => service.sendClientDeletedEvent(input, instanceId, AppTool.CLI)).not.toThrow();
149149
expect(sendEventMethod).not.toHaveBeenCalled();
150150
});
151151
});
152152

153153
describe('sendCliCommandExecutedEvent', () => {
154154
it('should emit CliCommandExecuted event', () => {
155-
service.sendCommandExecutedEvent(instanceId, 'cli', { command: 'info' });
155+
service.sendCommandExecutedEvent(instanceId, AppTool.CLI, { command: 'info' });
156156

157157
expect(sendEventMethod).toHaveBeenCalledWith(
158158
`CLI_${TelemetryEvents.CommandExecuted}`,
@@ -163,7 +163,7 @@ describe('CliAnalyticsService', () => {
163163
);
164164
});
165165
it('should emit CliCommandExecuted event without additional data', () => {
166-
service.sendCommandExecutedEvent(instanceId, 'cli');
166+
service.sendCommandExecutedEvent(instanceId, AppTool.CLI);
167167

168168
expect(sendEventMethod).toHaveBeenCalledWith(
169169
`CLI_${TelemetryEvents.CommandExecuted}`,
@@ -208,7 +208,7 @@ describe('CliAnalyticsService', () => {
208208

209209
describe('sendCliCommandErrorEvent', () => {
210210
it('should emit CliCommandError event', () => {
211-
service.sendCommandErrorEvent(instanceId, 'cli', redisReplyError, { data: 'Some data' });
211+
service.sendCommandErrorEvent(instanceId, AppTool.CLI, redisReplyError, { data: 'Some data' });
212212

213213
expect(sendEventMethod).toHaveBeenCalledWith(
214214
`CLI_${TelemetryEvents.CommandErrorReceived}`,
@@ -221,7 +221,7 @@ describe('CliAnalyticsService', () => {
221221
);
222222
});
223223
it('should emit CliCommandError event without additional data', () => {
224-
service.sendCommandErrorEvent(instanceId, 'cli', redisReplyError);
224+
service.sendCommandErrorEvent(instanceId, AppTool.CLI, redisReplyError);
225225

226226
expect(sendEventMethod).toHaveBeenCalledWith(
227227
`CLI_${TelemetryEvents.CommandErrorReceived}`,
@@ -234,7 +234,7 @@ describe('CliAnalyticsService', () => {
234234
});
235235
it('should emit event for custom error', () => {
236236
const error: any = CliParsingError;
237-
service.sendCommandErrorEvent(instanceId, 'cli', error);
237+
service.sendCommandErrorEvent(instanceId, AppTool.CLI, error);
238238

239239
expect(sendEventMethod).toHaveBeenCalledWith(
240240
`CLI_${TelemetryEvents.CommandErrorReceived}`,
@@ -248,7 +248,7 @@ describe('CliAnalyticsService', () => {
248248

249249
describe('sendCliClientCreationFailedEvent', () => {
250250
it('should emit CliConnectionError event', () => {
251-
service.sendConnectionErrorEvent(instanceId, 'cli', httpException, { data: 'Some data' });
251+
service.sendConnectionErrorEvent(instanceId, AppTool.CLI, httpException, { data: 'Some data' });
252252

253253
expect(sendFailedEventMethod).toHaveBeenCalledWith(
254254
`CLI_${TelemetryEvents.ClientConnectionError}`,
@@ -260,7 +260,7 @@ describe('CliAnalyticsService', () => {
260260
);
261261
});
262262
it('should emit CliConnectionError event without additional data', () => {
263-
service.sendConnectionErrorEvent(instanceId, 'cli', httpException);
263+
service.sendConnectionErrorEvent(instanceId, AppTool.CLI, httpException);
264264

265265
expect(sendFailedEventMethod).toHaveBeenCalledWith(
266266
`CLI_${TelemetryEvents.ClientConnectionError}`,
@@ -281,7 +281,7 @@ describe('CliAnalyticsService', () => {
281281
status: CommandExecutionStatus.Success,
282282
};
283283

284-
service.sendClusterCommandExecutedEvent(instanceId, 'cli', nodExecResult, { command: 'sadd' });
284+
service.sendClusterCommandExecutedEvent(instanceId, AppTool.CLI, nodExecResult, { command: 'sadd' });
285285

286286
expect(sendEventMethod).toHaveBeenCalledWith(
287287
`CLI_${TelemetryEvents.ClusterNodeCommandExecuted}`,
@@ -300,7 +300,7 @@ describe('CliAnalyticsService', () => {
300300
status: CommandExecutionStatus.Fail,
301301
};
302302

303-
service.sendClusterCommandExecutedEvent(instanceId, 'cli', nodExecResult);
303+
service.sendClusterCommandExecutedEvent(instanceId, AppTool.CLI, nodExecResult);
304304

305305
expect(sendEventMethod).toHaveBeenCalledWith(
306306
`CLI_${TelemetryEvents.CommandErrorReceived}`,
@@ -320,7 +320,7 @@ describe('CliAnalyticsService', () => {
320320
status: CommandExecutionStatus.Fail,
321321
};
322322

323-
service.sendClusterCommandExecutedEvent(instanceId, 'cli', nodExecResult);
323+
service.sendClusterCommandExecutedEvent(instanceId, AppTool.CLI, nodExecResult);
324324

325325
expect(sendEventMethod).toHaveBeenCalledWith(
326326
`CLI_${TelemetryEvents.CommandErrorReceived}`,
@@ -337,7 +337,7 @@ describe('CliAnalyticsService', () => {
337337
port: 7002,
338338
status: 'undefined status',
339339
};
340-
service.sendClusterCommandExecutedEvent(instanceId, 'cli', nodExecResult);
340+
service.sendClusterCommandExecutedEvent(instanceId, AppTool.CLI, nodExecResult);
341341

342342
expect(sendEventMethod).not.toHaveBeenCalled();
343343
});

redisinsight/api/src/modules/cli/services/cli-analytics/cli-analytics.service.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,6 @@ export class CliAnalyticsService extends TelemetryBaseService {
161161
}
162162

163163
private getNamespaceEvent(event: TelemetryEvents, namespace: string = AppTool.CLI): string {
164-
switch (namespace.toLowerCase()) {
165-
case 'workbench': {
166-
return `WORKBENCH_${event}`;
167-
}
168-
case 'cli': {
169-
return `CLI_${event}`;
170-
}
171-
default:
172-
return `CLI_${event}`;
173-
}
164+
return namespace.toLowerCase() === 'workbench' ? `WORKBENCH_${event}` : `CLI_${event}`;
174165
}
175166
}

0 commit comments

Comments
 (0)