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
21 changes: 19 additions & 2 deletions redisinsight/ui/src/pages/slowLog/SlowLogPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import InstanceHeader from 'uiSrc/components/instance-header'
import { DEFAULT_SLOWLOG_MAX_LEN } from 'uiSrc/constants'
import { DATE_FORMAT } from 'uiSrc/pages/slowLog/components/SlowLogTable/SlowLogTable'
import { convertNumberByUnits } from 'uiSrc/pages/slowLog/utils'
import { appAnalyticsInfoSelector } from 'uiSrc/slices/app/info'
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
import { ConnectionProvider, ConnectionType } from 'uiSrc/slices/interfaces'
import {
Expand All @@ -26,7 +27,7 @@ import {
slowLogConfigSelector,
slowLogSelector
} from 'uiSrc/slices/slowlog/slowlog'
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
import { sendPageViewTelemetry, sendEventTelemetry, TelemetryEvent, TelemetryPageView } from 'uiSrc/telemetry'
import { numberWithSpaces } from 'uiSrc/utils/numbers'

import { SlowLog } from 'apiSrc/modules/slow-log/models'
Expand All @@ -46,12 +47,14 @@ const countOptions: EuiSuperSelectOption<string>[] = [
]

const SlowLogPage = () => {
const { connectionType, provider } = useSelector(connectedInstanceSelector)
const { connectionType, provider, name: connectedInstanceName } = useSelector(connectedInstanceSelector)
const { data, loading, durationUnit, config } = useSelector(slowLogSelector)
const { slowlogLogSlowerThan = 0, slowlogMaxLen } = useSelector(slowLogConfigSelector)
const { identified: analyticsIdentified } = useSelector(appAnalyticsInfoSelector)
const { instanceId } = useParams<{ instanceId: string }>()

const [count, setCount] = useState<string>(DEFAULT_COUNT_VALUE)
const [isPageViewSent, setIsPageViewSent] = useState(false)

const dispatch = useDispatch()

Expand All @@ -65,6 +68,20 @@ const SlowLogPage = () => {
getSlowLogs()
}, [count])

useEffect(() => {
if (connectedInstanceName && !isPageViewSent && analyticsIdentified) {
sendPageView(instanceId)
}
}, [connectedInstanceName, isPageViewSent, analyticsIdentified])

const sendPageView = (instanceId: string) => {
sendPageViewTelemetry({
name: TelemetryPageView.SLOWLOG_PAGE,
databaseId: instanceId
})
setIsPageViewSent(true)
}

const getSlowLogs = (maxLen?: number) => {
const countToSend = (provider === ConnectionProvider.RE_CLOUD && count === MAX_COUNT_VALUE)
? (maxLen || slowlogMaxLen || DEFAULT_SLOWLOG_MAX_LEN)
Expand Down
1 change: 1 addition & 0 deletions redisinsight/ui/src/telemetry/pageViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export enum TelemetryPageView {
SETTINGS_PAGE = 'Settings',
BROWSER_PAGE = 'Browser',
WORKBENCH_PAGE = 'Workbench',
SLOWLOG_PAGE = 'Slowlog'
}