Skip to content

Commit 20f1724

Browse files
Merge pull request #2471 from RedisInsight/feature/RI-4842_add_appVersion_to_all_telemetry_events
#RI-4842 - Add application version to all telemetry events
2 parents 1af95b4 + a12777b commit 20f1724

File tree

7 files changed

+20
-5
lines changed

7 files changed

+20
-5
lines changed

redisinsight/api/src/__mocks__/feature.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const mockFeaturesConfigId = '1';
1717
export const mockFeaturesConfigVersion = defaultConfig.version + 0.111;
1818
export const mockControlNumber = 7.68;
1919
export const mockControlGroup = '7';
20+
export const mockAppVersion = '2.1.0';
2021

2122
export const mockFeaturesConfigJson = {
2223
version: mockFeaturesConfigVersion,

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Test, TestingModule } from '@nestjs/testing';
22
import {
33
mockAppSettings,
4-
mockAppSettingsWithoutPermissions, mockControlGroup, mockControlNumber,
4+
mockAppSettingsWithoutPermissions, mockAppVersion, mockControlGroup, mockControlNumber,
55
mockSettingsService,
66
MockType,
77
} from 'src/__mocks__';
@@ -59,6 +59,7 @@ describe('AnalyticsService', () => {
5959
appType: AppType.Electron,
6060
controlNumber: mockControlNumber,
6161
controlGroup: mockControlGroup,
62+
appVersion: mockAppVersion,
6263
});
6364

6465
const anonymousId = service.getAnonymousId();
@@ -76,6 +77,7 @@ describe('AnalyticsService', () => {
7677
appType: AppType.Electron,
7778
controlNumber: mockControlNumber,
7879
controlGroup: mockControlGroup,
80+
appVersion: mockAppVersion,
7981
});
8082
});
8183
it('should send event with anonymousId if permission are granted', async () => {
@@ -95,6 +97,7 @@ describe('AnalyticsService', () => {
9597
buildType: AppType.Electron,
9698
controlNumber: mockControlNumber,
9799
controlGroup: mockControlGroup,
100+
appVersion: mockAppVersion,
98101
},
99102
});
100103
});
@@ -126,6 +129,7 @@ describe('AnalyticsService', () => {
126129
buildType: AppType.Electron,
127130
controlNumber: mockControlNumber,
128131
controlGroup: mockControlGroup,
132+
appVersion: mockAppVersion,
129133
},
130134
});
131135
});

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface ITelemetryInitEvent {
2121
appType: string;
2222
controlNumber: number;
2323
controlGroup: string;
24+
appVersion: string;
2425
}
2526

2627
@Injectable()
@@ -35,6 +36,8 @@ export class AnalyticsService {
3536

3637
private controlGroup: string = '-1';
3738

39+
private appVersion: string = '2.0.0';
40+
3841
private analytics;
3942

4043
constructor(
@@ -48,12 +51,13 @@ export class AnalyticsService {
4851
@OnEvent(AppAnalyticsEvents.Initialize)
4952
public initialize(payload: ITelemetryInitEvent) {
5053
const {
51-
anonymousId, sessionId, appType, controlNumber, controlGroup,
54+
anonymousId, sessionId, appType, controlNumber, controlGroup, appVersion,
5255
} = payload;
5356
this.sessionId = sessionId;
5457
this.anonymousId = anonymousId;
5558
this.appType = appType;
5659
this.controlGroup = controlGroup;
60+
this.appVersion = appVersion;
5761
this.controlNumber = controlNumber;
5862
this.analytics = new Analytics(ANALYTICS_CONFIG.writeKey, {
5963
flushInterval: ANALYTICS_CONFIG.flushInterval,
@@ -87,6 +91,7 @@ export class AnalyticsService {
8791
buildType: this.appType,
8892
controlNumber: this.controlNumber,
8993
controlGroup: this.controlGroup,
94+
appVersion: this.appVersion,
9095
},
9196
});
9297
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ describe('ServerService', () => {
9090
anonymousId: mockServer.id,
9191
sessionId,
9292
appType: SERVER_CONFIG.buildType,
93+
appVersion: SERVER_CONFIG.appVersion,
9394
controlNumber: mockControlNumber,
9495
controlGroup: mockControlGroup,
9596
},

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class ServerService implements OnApplicationBootstrap {
5252
anonymousId: server.id,
5353
sessionId: this.sessionId,
5454
appType: ServerService.getAppType(SERVER_CONFIG.buildType),
55+
appVersion: SERVER_CONFIG.appVersion,
5556
...(await this.featuresConfigService.getControlInfo()),
5657
});
5758

redisinsight/ui/src/telemetry/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface ITelemetryService {
1414
buildType?: string
1515
controlNumber?: number
1616
controlGroup?: string
17+
appVersion?: string
1718
databaseId?: string
1819
}
1920
): Promise<void>

redisinsight/ui/src/telemetry/telemetryUtils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const sendEventTelemetry = (payload: ITelemetrySendEvent) => {
6161
const isAnalyticsGranted = checkIsAnalyticsGranted()
6262
setAnonymousId(isAnalyticsGranted)
6363

64-
const { appType: buildType, controlNumber, controlGroup } = getInfoServer() as Record<string, any>
64+
const { appType: buildType, controlNumber, controlGroup, appVersion } = getInfoServer() as Record<string, any>
6565

6666
if (isAnalyticsGranted || nonTracking) {
6767
return telemetryService?.event({
@@ -70,6 +70,7 @@ const sendEventTelemetry = (payload: ITelemetrySendEvent) => {
7070
buildType,
7171
controlNumber,
7272
controlGroup,
73+
appVersion,
7374
...eventData,
7475
},
7576
})
@@ -90,7 +91,7 @@ const sendPageViewTelemetry = (payload: ITelemetrySendPageView) => {
9091
const isAnalyticsGranted = checkIsAnalyticsGranted()
9192
setAnonymousId(isAnalyticsGranted)
9293

93-
const { appType: buildType, controlNumber, controlGroup } = getInfoServer() as Record<string, any>
94+
const { appType: buildType, controlNumber, controlGroup, appVersion } = getInfoServer() as Record<string, any>
9495

9596
if (isAnalyticsGranted || nonTracking) {
9697
telemetryService?.pageView(
@@ -99,7 +100,8 @@ const sendPageViewTelemetry = (payload: ITelemetrySendPageView) => {
99100
buildType,
100101
controlNumber,
101102
controlGroup,
102-
databaseId
103+
appVersion,
104+
databaseId,
103105
}
104106
)
105107
}

0 commit comments

Comments
 (0)