Skip to content

Commit 04854c2

Browse files
author
Artem
committed
Merge branch 'feature/RI-4399-beta_features' into be/feature/RI-4489-beta_features
2 parents 481f357 + b236a5d commit 04854c2

File tree

6 files changed

+36
-10
lines changed

6 files changed

+36
-10
lines changed

redisinsight/ui/src/components/config/Config.spec.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import { cloneDeep } from 'lodash'
33
import { BuildType } from 'uiSrc/constants/env'
44
import { localStorageService } from 'uiSrc/services'
5-
import { setFeaturesToHighlight, setOnboarding } from 'uiSrc/slices/app/features'
5+
import { getFeatureFlags, setFeaturesToHighlight, setOnboarding } from 'uiSrc/slices/app/features'
66
import { getNotifications } from 'uiSrc/slices/app/notifications'
77
import { render, mockedStore, cleanup, MOCKED_HIGHLIGHTING_FEATURES } from 'uiSrc/utils/test-utils'
88

@@ -63,6 +63,7 @@ describe('Config', () => {
6363
getNotifications(),
6464
getWBGuides(),
6565
getWBTutorials(),
66+
getFeatureFlags(),
6667
getUserConfigSettings(),
6768
]
6869
expect(store.getActions()).toEqual([...afterRenderActions])
@@ -95,6 +96,7 @@ describe('Config', () => {
9596
getNotifications(),
9697
getWBGuides(),
9798
getWBTutorials(),
99+
getFeatureFlags(),
98100
getUserConfigSettings(),
99101
setSettingsPopupState(true),
100102
]

redisinsight/ui/src/telemetry/checkAnalytics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ import store from 'uiSrc/slices/store'
55
export const checkIsAnalyticsGranted = () =>
66
!!get(store.getState(), 'user.settings.config.agreements.analytics', false)
77

8+
export const getInfoServer = () => get(store.getState(), 'app.info.server', {})
89
export const getAppType = () => get(store.getState(), 'app.info.server.appType')

redisinsight/ui/src/telemetry/interfaces.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ export interface ITelemetryIdentify {
88

99
export interface ITelemetryService {
1010
initialize(): Promise<void>
11-
pageView(name: string, appType: string, databaseId?: string): Promise<void>
11+
pageView(
12+
name: string,
13+
params: {
14+
buildType?: string
15+
controlNumber?: number
16+
controlGroup?: string
17+
databaseId?: string
18+
}
19+
): Promise<void>
1220
identify(opts: ITelemetryIdentify): Promise<void>
1321
event(opts: ITelemetryEvent): Promise<void>
1422
anonymousId: string

redisinsight/ui/src/telemetry/segment.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@ export class SegmentTelemetryService implements ITelemetryService {
5151
return this._anonymousId
5252
}
5353

54-
async pageView(name: string, appType: string, databaseId?: string): Promise<void> {
54+
async pageView(
55+
name: string,
56+
properties: object
57+
): Promise<void> {
5558
return new Promise((resolve, reject) => {
5659
try {
5760
const pageInfo = this._getPageInfo()
5861
const { page = {} } = { ...pageInfo }
59-
window.analytics.page(name, { databaseId, buildType: appType, ...page }, {
62+
window.analytics.page(name, { ...properties, ...page }, {
6063
context: {
6164
ip: '0.0.0.0',
6265
...pageInfo

redisinsight/ui/src/telemetry/telemetryUtils.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { localStorageService } from 'uiSrc/services'
1010
import { ApiEndpoints, BrowserStorageItem, KeyTypes, StreamViews } from 'uiSrc/constants'
1111
import { KeyViewType } from 'uiSrc/slices/interfaces/keys'
1212
import { StreamViewType } from 'uiSrc/slices/interfaces/stream'
13-
import { checkIsAnalyticsGranted, getAppType } from 'uiSrc/telemetry/checkAnalytics'
13+
import { checkIsAnalyticsGranted, getInfoServer } from 'uiSrc/telemetry/checkAnalytics'
1414
import { AdditionalRedisModule } from 'apiSrc/modules/database/models/additional.redis.module'
1515
import {
1616
ITelemetrySendEvent,
@@ -60,13 +60,15 @@ const sendEventTelemetry = (payload: ITelemetrySendEvent) => {
6060
const isAnalyticsGranted = checkIsAnalyticsGranted()
6161
setAnonymousId(isAnalyticsGranted)
6262

63-
const appType = getAppType()
63+
const { appType: buildType, controlNumber, controlGroup } = getInfoServer() as Record<string, any>
6464

6565
if (isAnalyticsGranted || nonTracking) {
6666
return telemetryService?.event({
6767
event,
6868
properties: {
69-
buildType: appType,
69+
buildType,
70+
controlNumber,
71+
controlGroup,
7072
...eventData,
7173
},
7274
})
@@ -86,10 +88,19 @@ const sendPageViewTelemetry = (payload: ITelemetrySendPageView) => {
8688

8789
const isAnalyticsGranted = checkIsAnalyticsGranted()
8890
setAnonymousId(isAnalyticsGranted)
89-
const appType = getAppType()
91+
92+
const { appType: buildType, controlNumber, controlGroup } = getInfoServer() as Record<string, any>
9093

9194
if (isAnalyticsGranted || nonTracking) {
92-
telemetryService?.pageView(name, appType, databaseId)
95+
telemetryService?.pageView(
96+
name,
97+
{
98+
buildType,
99+
controlNumber,
100+
controlGroup,
101+
databaseId
102+
}
103+
)
93104
}
94105
}
95106

redisinsight/ui/src/utils/test-utils.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ jest.mock(
216216
'uiSrc/telemetry/checkAnalytics',
217217
() => ({
218218
checkIsAnalyticsGranted: jest.fn(),
219-
getAppType: jest.fn()
219+
getAppType: jest.fn(),
220+
getInfoServer: jest.fn().mockReturnValue({}),
220221
})
221222
)
222223

0 commit comments

Comments
 (0)