Skip to content

Commit f3d8b95

Browse files
#RI-2976-add slowlog page telemetry event (#702)
1 parent 68b0e03 commit f3d8b95

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

redisinsight/ui/src/pages/slowLog/SlowLogPage.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import InstanceHeader from 'uiSrc/components/instance-header'
1717
import { DEFAULT_SLOWLOG_MAX_LEN } from 'uiSrc/constants'
1818
import { DATE_FORMAT } from 'uiSrc/pages/slowLog/components/SlowLogTable/SlowLogTable'
1919
import { convertNumberByUnits } from 'uiSrc/pages/slowLog/utils'
20+
import { appAnalyticsInfoSelector } from 'uiSrc/slices/app/info'
2021
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
2122
import { ConnectionProvider, ConnectionType } from 'uiSrc/slices/interfaces'
2223
import {
@@ -26,7 +27,7 @@ import {
2627
slowLogConfigSelector,
2728
slowLogSelector
2829
} from 'uiSrc/slices/slowlog/slowlog'
29-
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
30+
import { sendPageViewTelemetry, sendEventTelemetry, TelemetryEvent, TelemetryPageView } from 'uiSrc/telemetry'
3031
import { numberWithSpaces } from 'uiSrc/utils/numbers'
3132

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

4849
const SlowLogPage = () => {
49-
const { connectionType, provider } = useSelector(connectedInstanceSelector)
50+
const { connectionType, provider, name: connectedInstanceName } = useSelector(connectedInstanceSelector)
5051
const { data, loading, durationUnit, config } = useSelector(slowLogSelector)
5152
const { slowlogLogSlowerThan = 0, slowlogMaxLen } = useSelector(slowLogConfigSelector)
53+
const { identified: analyticsIdentified } = useSelector(appAnalyticsInfoSelector)
5254
const { instanceId } = useParams<{ instanceId: string }>()
5355

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

5659
const dispatch = useDispatch()
5760

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

71+
useEffect(() => {
72+
if (connectedInstanceName && !isPageViewSent && analyticsIdentified) {
73+
sendPageView(instanceId)
74+
}
75+
}, [connectedInstanceName, isPageViewSent, analyticsIdentified])
76+
77+
const sendPageView = (instanceId: string) => {
78+
sendPageViewTelemetry({
79+
name: TelemetryPageView.SLOWLOG_PAGE,
80+
databaseId: instanceId
81+
})
82+
setIsPageViewSent(true)
83+
}
84+
6885
const getSlowLogs = (maxLen?: number) => {
6986
const countToSend = (provider === ConnectionProvider.RE_CLOUD && count === MAX_COUNT_VALUE)
7087
? (maxLen || slowlogMaxLen || DEFAULT_SLOWLOG_MAX_LEN)

redisinsight/ui/src/telemetry/pageViews.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export enum TelemetryPageView {
44
SETTINGS_PAGE = 'Settings',
55
BROWSER_PAGE = 'Browser',
66
WORKBENCH_PAGE = 'Workbench',
7+
SLOWLOG_PAGE = 'Slowlog'
78
}

0 commit comments

Comments
 (0)