Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion redisinsight/ui/src/components/config/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
setAnalyticsIdentified,
} from 'uiSrc/slices/app/info'

import { checkIsAnalyticsGranted, getTelemetryService } from 'uiSrc/telemetry'
import { getTelemetryService } from 'uiSrc/telemetry'
import { checkIsAnalyticsGranted } from 'uiSrc/telemetry/checkAnalytics'
import { setFavicon, isDifferentConsentsExists } from 'uiSrc/utils'
import { fetchUnsupportedCliCommandsAction } from 'uiSrc/slices/cli/cli-settings'
import { fetchRedisCommandsInfo } from 'uiSrc/slices/app/redis-commands'
Expand Down
2 changes: 1 addition & 1 deletion redisinsight/ui/src/slices/tests/browser/stream.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from 'apiSrc/modules/browser/dto/stream.dto'
import { AxiosError } from 'axios'
import { cloneDeep, omit } from 'lodash'
import { cleanup, initialStateDefault, mockedStore, } from 'uiSrc/utils/test-utils'
import successMessages from 'uiSrc/components/notifications/success-messages'
import { SortOrder } from 'uiSrc/constants'
import { apiService } from 'uiSrc/services'
Expand Down Expand Up @@ -71,7 +72,6 @@ import reducer, {
deleteMessageFromList
} from 'uiSrc/slices/browser/stream'
import { StreamViewType } from 'uiSrc/slices/interfaces/stream'
import { cleanup, initialStateDefault, mockedStore, } from 'uiSrc/utils/test-utils'
import { addErrorNotification, addMessageNotification } from '../../app/notifications'

jest.mock('uiSrc/services')
Expand Down
6 changes: 6 additions & 0 deletions redisinsight/ui/src/telemetry/checkAnalytics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { get } from 'lodash'
import store from 'uiSrc/slices/store'

// Check is user give access to collect his events
export const checkIsAnalyticsGranted = () =>
!!get(store.getState(), 'user.settings.config.agreements.analytics', false)
7 changes: 1 addition & 6 deletions redisinsight/ui/src/telemetry/telemetryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
* Telemetry and analytics module.
* This module abstracts the exact service/framework used for tracking usage.
*/
import { get } from 'lodash'
import isGlob from 'is-glob'
import * as jsonpath from 'jsonpath'
import { Nullable } from 'uiSrc/utils'
import store from 'uiSrc/slices/store'
import { localStorageService } from 'uiSrc/services'
import { ApiEndpoints, BrowserStorageItem, KeyTypes } from 'uiSrc/constants'
import { KeyViewType } from 'uiSrc/slices/interfaces/keys'
import { checkIsAnalyticsGranted } from 'uiSrc/telemetry/checkAnalytics'
import { ITelemetrySendEvent, ITelemetrySendPageView, ITelemetryService, MatchType } from './interfaces'
import { TelemetryEvent } from './events'
import { NON_TRACKING_ANONYMOUS_ID, SegmentTelemetryService } from './segment'
Expand All @@ -29,10 +28,6 @@ const getTelemetryService = (apiKey: string): ITelemetryService => {
return telemetryService
}

// Check is user give access to collect his events
const checkIsAnalyticsGranted = () =>
!!get(store.getState(), 'user.settings.config.agreements.analytics', false)

// Telemetry doesn't watch on sending anonymousId like arg of function. Only look at localStorage
const setAnonymousId = (isAnalyticsGranted: boolean) => {
const anonymousId = isAnalyticsGranted
Expand Down
7 changes: 7 additions & 0 deletions redisinsight/ui/src/utils/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ jest.mock(
() => ({ children }) => children({ height: 600, width: 600 })
)

jest.mock(
'uiSrc/telemetry/checkAnalytics',
() => ({
checkIsAnalyticsGranted: jest.fn()
})
)

export const localStorageMock = {
getItem: jest.fn(),
setItem: jest.fn(),
Expand Down