Skip to content

Commit 3fc0c18

Browse files
#RI-2542,RI-3093,RI-3092 (#794)
* #RI-2542,RI-3093,RI-3092
1 parent 222759d commit 3fc0c18

File tree

11 files changed

+63
-29
lines changed

11 files changed

+63
-29
lines changed

redisinsight/ui/src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ export * from './mocks/mock-tutorials'
2121
export * from './socketErrors'
2222
export * from './browser'
2323
export * from './durationUnits'
24+
export * from './streamViews'
2425
export { ApiEndpoints, BrowserStorageItem, ApiStatusCode, apiErrors }
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { StreamViewType } from 'uiSrc/slices/interfaces/stream'
2+
3+
export const StreamViews = Object.freeze({
4+
[StreamViewType.Data]: 'entries',
5+
[StreamViewType.Groups]: 'consumer_groups',
6+
[StreamViewType.Consumers]: 'consumers',
7+
[StreamViewType.Messages]: 'pending_messages_list'
8+
})

redisinsight/ui/src/pages/browser/components/key-details-header/KeyDetailsHeader.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { AddCommonFieldsFormConfig } from 'uiSrc/pages/browser/components/add-ke
2424
import { keysSelector, selectedKeyDataSelector, selectedKeySelector } from 'uiSrc/slices/browser/keys'
2525
import { streamSelector } from 'uiSrc/slices/browser/stream'
2626
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
27-
import { getBasedOnViewTypeEvent, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
27+
import { getBasedOnViewTypeEvent, getRefreshEventData, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
2828
import { formatBytes, formatNameShort, MAX_TTL_NUMBER, replaceSpaces, validateTTLNumber } from 'uiSrc/utils'
2929
import AutoRefresh from '../auto-refresh'
3030

@@ -182,16 +182,21 @@ const KeyDetailsHeader = ({
182182

183183
const handleRefreshKey = (enableAutoRefresh: boolean) => {
184184
if (!enableAutoRefresh) {
185+
const eventData = getRefreshEventData(
186+
{
187+
databaseId: instanceId,
188+
keyType: type
189+
},
190+
type,
191+
streamViewType
192+
)
185193
sendEventTelemetry({
186194
event: getBasedOnViewTypeEvent(
187195
viewType,
188196
TelemetryEvent.BROWSER_KEY_DETAILS_REFRESH_CLICKED,
189197
TelemetryEvent.TREE_VIEW_KEY_DETAILS_REFRESH_CLICKED
190198
),
191-
eventData: {
192-
databaseId: instanceId,
193-
keyType: type
194-
}
199+
eventData
195200
})
196201
}
197202
onRefresh(key, type)

redisinsight/ui/src/pages/browser/components/key-details/KeyDetails/KeyDetails.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,19 @@ const KeyDetails = ({ ...props }: Props) => {
7979
const openAddItemPanel = () => {
8080
setIsRemoveItemPanelOpen(false)
8181
setIsAddItemPanelOpen(true)
82-
sendEventTelemetry({
83-
event: getBasedOnViewTypeEvent(
84-
viewType,
85-
TelemetryEvent.BROWSER_KEY_ADD_VALUE_CLICKED,
86-
TelemetryEvent.TREE_VIEW_KEY_ADD_VALUE_CLICKED
87-
),
88-
eventData: {
89-
databaseId: instanceId,
90-
keyType: selectedKeyType
91-
}
92-
})
82+
if (!STREAM_ADD_GROUP_VIEW_TYPES.includes(streamViewType)) {
83+
sendEventTelemetry({
84+
event: getBasedOnViewTypeEvent(
85+
viewType,
86+
TelemetryEvent.BROWSER_KEY_ADD_VALUE_CLICKED,
87+
TelemetryEvent.TREE_VIEW_KEY_ADD_VALUE_CLICKED
88+
),
89+
eventData: {
90+
databaseId: instanceId,
91+
keyType: selectedKeyType
92+
}
93+
})
94+
}
9395
}
9496

9597
const openRemoveItemPanel = () => {
@@ -98,7 +100,7 @@ const KeyDetails = ({ ...props }: Props) => {
98100
}
99101

100102
const closeAddItemPanel = (isCancelled?: boolean) => {
101-
if (isCancelled && isAddItemPanelOpen) {
103+
if (isCancelled && isAddItemPanelOpen && !STREAM_ADD_GROUP_VIEW_TYPES.includes(streamViewType)) {
102104
sendEventTelemetry({
103105
event: getBasedOnViewTypeEvent(
104106
viewType,

redisinsight/ui/src/pages/pubSub/components/messages-list/EmptyMessagesList/EmptyMessagesList.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ describe('EmptyMessagesList', () => {
1919
expect(queryByTestId('empty-messages-list-cluster')).toBeInTheDocument()
2020
})
2121

22-
it('should render cluster info for Cluster connection type', () => {
22+
it(' not render cluster info for Cluster connection type', () => {
2323
const { queryByTestId } = render(
24-
<EmptyMessagesList isSpublishNotSupported />
24+
<EmptyMessagesList connectionType={ConnectionType.Cluster} isSpublishNotSupported={false} />
2525
)
2626

27-
expect(queryByTestId('empty-messages-list-cluster')).toBeInTheDocument()
27+
expect(queryByTestId('empty-messages-list-cluster')).not.toBeInTheDocument()
2828
})
2929

3030
it('should not render cluster info for Cluster connection type', () => {
3131
const { queryByTestId } = render(
32-
<EmptyMessagesList isSpublishNotSupported={false} />
32+
<EmptyMessagesList connectionType={ConnectionType.Standalone} isSpublishNotSupported />
3333
)
3434

3535
expect(queryByTestId('empty-messages-list-cluster')).not.toBeInTheDocument()

redisinsight/ui/src/pages/pubSub/components/messages-list/EmptyMessagesList/EmptyMessagesList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const EmptyMessagesList = ({ connectionType, isSpublishNotSupported }: Props) =>
2222
<EuiIcon type="alert" className={styles.alertIcon} />
2323
Running in production may decrease performance and memory available
2424
</EuiText>
25-
{(connectionType === ConnectionType.Cluster || isSpublishNotSupported) && (
25+
{(connectionType === ConnectionType.Cluster && isSpublishNotSupported) && (
2626
<>
2727
<div className={styles.separator} />
2828
<EuiText className={styles.cluster} data-testid="empty-messages-list-cluster">

redisinsight/ui/src/telemetry/checkAnalytics.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ import store from 'uiSrc/slices/store'
44
// Check is user give access to collect his events
55
export const checkIsAnalyticsGranted = () =>
66
!!get(store.getState(), 'user.settings.config.agreements.analytics', false)
7+
8+
export const getAppType = () => get(store.getState(), 'app.info.server.appType')

redisinsight/ui/src/telemetry/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface ITelemetryIdentify {
77

88
export interface ITelemetryService {
99
initialize(): Promise<void>;
10-
pageView(name: string, databaseId?: string): Promise<void>;
10+
pageView(name: string, appType: string, databaseId?: string): Promise<void>;
1111
identify(opts: ITelemetryIdentify): Promise<void>;
1212
event(opts: ITelemetryEvent): Promise<void>;
1313
anonymousId: string;

redisinsight/ui/src/telemetry/segment.ts

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

54-
async pageView(name: string, databaseId?: string): Promise<void> {
54+
async pageView(name: string, appType: string, databaseId?: string): Promise<void> {
5555
return new Promise((resolve, reject) => {
5656
try {
5757
const pageInfo = this._getPageInfo()
5858
const { page = {} } = { ...pageInfo }
59-
window.analytics.page(name, { databaseId, ...page }, {
59+
window.analytics.page(name, { databaseId, buildType: appType, ...page }, {
6060
context: {
6161
ip: '0.0.0.0',
6262
...pageInfo

redisinsight/ui/src/telemetry/telemetryUtils.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import isGlob from 'is-glob'
66
import * as jsonpath from 'jsonpath'
77
import { Nullable } from 'uiSrc/utils'
88
import { localStorageService } from 'uiSrc/services'
9-
import { ApiEndpoints, BrowserStorageItem, KeyTypes } from 'uiSrc/constants'
9+
import { ApiEndpoints, BrowserStorageItem, KeyTypes, StreamViews } from 'uiSrc/constants'
1010
import { KeyViewType } from 'uiSrc/slices/interfaces/keys'
11-
import { checkIsAnalyticsGranted } from 'uiSrc/telemetry/checkAnalytics'
11+
import { StreamViewType } from 'uiSrc/slices/interfaces/stream'
12+
import { checkIsAnalyticsGranted, getAppType } from 'uiSrc/telemetry/checkAnalytics'
1213
import { ITelemetrySendEvent, ITelemetrySendPageView, ITelemetryService, MatchType } from './interfaces'
1314
import { TelemetryEvent } from './events'
1415
import { NON_TRACKING_ANONYMOUS_ID, SegmentTelemetryService } from './segment'
@@ -50,10 +51,13 @@ const sendEventTelemetry = (payload: ITelemetrySendEvent) => {
5051
const isAnalyticsGranted = checkIsAnalyticsGranted()
5152
setAnonymousId(isAnalyticsGranted)
5253

54+
const appType = getAppType()
55+
5356
if (isAnalyticsGranted || nonTracking) {
5457
telemetryService?.event({
5558
event,
5659
properties: {
60+
buildType: appType,
5761
...eventData,
5862
},
5963
})
@@ -72,9 +76,10 @@ const sendPageViewTelemetry = (payload: ITelemetrySendPageView) => {
7276

7377
const isAnalyticsGranted = checkIsAnalyticsGranted()
7478
setAnonymousId(isAnalyticsGranted)
79+
const appType = getAppType()
7580

7681
if (isAnalyticsGranted || nonTracking) {
77-
telemetryService?.pageView(name, databaseId)
82+
telemetryService?.pageView(name, appType, databaseId)
7883
}
7984
}
8085

@@ -164,6 +169,16 @@ const getMatchType = (match: string): MatchType => (
164169
: MatchType.PATTERN
165170
)
166171

172+
export const getRefreshEventData = (eventData: any, type: string, streamViewType?: StreamViewType) => {
173+
if (type === KeyTypes.Stream) {
174+
return {
175+
...eventData,
176+
streamView: StreamViews[streamViewType!]
177+
}
178+
}
179+
return eventData
180+
}
181+
167182
export {
168183
getTelemetryService,
169184
sendEventTelemetry,

0 commit comments

Comments
 (0)