Skip to content

Commit c990bce

Browse files
Merge pull request #2749 from RedisInsight/be/feature/RI-5094_telemetry
#RI-5094 - add telemetry in user properties
2 parents 8c55936 + 0300d17 commit c990bce

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AppType } from 'src/modules/server/models/server';
1010
import { SettingsService } from 'src/modules/settings/settings.service';
1111
import {
1212
AnalyticsService,
13+
Telemetry,
1314
NON_TRACKING_ANONYMOUS_ID,
1415
} from './analytics.service';
1516

@@ -95,6 +96,11 @@ describe('AnalyticsService', () => {
9596
anonymousId: mockAnonymousId,
9697
integrations: { Amplitude: { session_id: sessionId } },
9798
event: TelemetryEvents.ApplicationStarted,
99+
context: {
100+
traits: {
101+
telemetry: Telemetry.Enabled,
102+
},
103+
},
98104
properties: {
99105
anonymousId: mockAnonymousId,
100106
buildType: AppType.Electron,
@@ -128,6 +134,11 @@ describe('AnalyticsService', () => {
128134
anonymousId: NON_TRACKING_ANONYMOUS_ID,
129135
integrations: { Amplitude: { session_id: sessionId } },
130136
event: TelemetryEvents.ApplicationStarted,
137+
context: {
138+
traits: {
139+
telemetry: Telemetry.Disabled,
140+
},
141+
},
131142
properties: {
132143
anonymousId: mockAnonymousId,
133144
buildType: AppType.Electron,
@@ -150,6 +161,11 @@ describe('AnalyticsService', () => {
150161
anonymousId: mockAnonymousId,
151162
integrations: { Amplitude: { session_id: sessionId } },
152163
event: TelemetryEvents.ApplicationStarted,
164+
context: {
165+
traits: {
166+
telemetry: Telemetry.Enabled,
167+
},
168+
},
153169
properties: {
154170
anonymousId: mockAnonymousId,
155171
buildType: AppType.Electron,
@@ -186,6 +202,11 @@ describe('AnalyticsService', () => {
186202
anonymousId: mockAnonymousId,
187203
integrations: { Amplitude: { session_id: sessionId } },
188204
name: TelemetryEvents.ApplicationStarted,
205+
context: {
206+
traits: {
207+
telemetry: Telemetry.Enabled,
208+
},
209+
},
189210
properties: {
190211
anonymousId: mockAnonymousId,
191212
buildType: AppType.Electron,
@@ -219,6 +240,11 @@ describe('AnalyticsService', () => {
219240
anonymousId: NON_TRACKING_ANONYMOUS_ID,
220241
integrations: { Amplitude: { session_id: sessionId } },
221242
name: TelemetryEvents.ApplicationStarted,
243+
context: {
244+
traits: {
245+
telemetry: Telemetry.Disabled,
246+
},
247+
},
222248
properties: {
223249
anonymousId: mockAnonymousId,
224250
buildType: AppType.Electron,
@@ -241,6 +267,11 @@ describe('AnalyticsService', () => {
241267
anonymousId: mockAnonymousId,
242268
integrations: { Amplitude: { session_id: sessionId } },
243269
name: TelemetryEvents.ApplicationStarted,
270+
context: {
271+
traits: {
272+
telemetry: Telemetry.Enabled,
273+
},
274+
},
244275
properties: {
245276
anonymousId: mockAnonymousId,
246277
buildType: AppType.Electron,

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export interface ITelemetryInitEvent {
2424
appVersion: string;
2525
}
2626

27+
export enum Telemetry {
28+
Enabled = 'enabled',
29+
Disabled = 'disabled',
30+
}
31+
2732
@Injectable()
2833
export class AnalyticsService {
2934
private anonymousId: string = NON_TRACKING_ANONYMOUS_ID;
@@ -83,6 +88,11 @@ export class AnalyticsService {
8388
anonymousId: !isAnalyticsGranted && nonTracking ? NON_TRACKING_ANONYMOUS_ID : this.anonymousId,
8489
integrations: { Amplitude: { session_id: this.sessionId } },
8590
event,
91+
context: {
92+
traits: {
93+
telemetry: isAnalyticsGranted ? Telemetry.Enabled : Telemetry.Disabled,
94+
}
95+
},
8696
properties: {
8797
...eventData,
8898
anonymousId: this.anonymousId,
@@ -116,6 +126,11 @@ export class AnalyticsService {
116126
name: event,
117127
anonymousId: !isAnalyticsGranted && nonTracking ? NON_TRACKING_ANONYMOUS_ID : this.anonymousId,
118128
integrations: { Amplitude: { session_id: this.sessionId } },
129+
context: {
130+
traits: {
131+
telemetry: isAnalyticsGranted ? Telemetry.Enabled : Telemetry.Disabled,
132+
}
133+
},
119134
properties: {
120135
...eventData,
121136
anonymousId: this.anonymousId,

0 commit comments

Comments
 (0)