@@ -17,16 +17,17 @@ import InstanceHeader from 'uiSrc/components/instance-header'
17
17
import { DEFAULT_SLOWLOG_MAX_LEN } from 'uiSrc/constants'
18
18
import { DATE_FORMAT } from 'uiSrc/pages/slowLog/components/SlowLogTable/SlowLogTable'
19
19
import { convertNumberByUnits } from 'uiSrc/pages/slowLog/utils'
20
+ import { appAnalyticsInfoSelector } from 'uiSrc/slices/app/info'
20
21
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
21
- import { ConnectionProvider , ConnectionType } from 'uiSrc/slices/interfaces'
22
+ import { ConnectionType } from 'uiSrc/slices/interfaces'
22
23
import {
23
24
clearSlowLogAction ,
24
25
fetchSlowLogsAction ,
25
26
getSlowLogConfigAction ,
26
27
slowLogConfigSelector ,
27
28
slowLogSelector
28
29
} from 'uiSrc/slices/slowlog/slowlog'
29
- import { sendEventTelemetry , TelemetryEvent } from 'uiSrc/telemetry'
30
+ import { sendPageViewTelemetry , sendEventTelemetry , TelemetryEvent , TelemetryPageView } from 'uiSrc/telemetry'
30
31
import { numberWithSpaces } from 'uiSrc/utils/numbers'
31
32
32
33
import { SlowLog } from 'apiSrc/modules/slow-log/models'
@@ -46,12 +47,14 @@ const countOptions: EuiSuperSelectOption<string>[] = [
46
47
]
47
48
48
49
const SlowLogPage = ( ) => {
49
- const { connectionType, provider } = useSelector ( connectedInstanceSelector )
50
+ const { connectionType, name : connectedInstanceName } = useSelector ( connectedInstanceSelector )
50
51
const { data, loading, durationUnit, config } = useSelector ( slowLogSelector )
51
52
const { slowlogLogSlowerThan = 0 , slowlogMaxLen } = useSelector ( slowLogConfigSelector )
53
+ const { identified : analyticsIdentified } = useSelector ( appAnalyticsInfoSelector )
52
54
const { instanceId } = useParams < { instanceId : string } > ( )
53
55
54
56
const [ count , setCount ] = useState < string > ( DEFAULT_COUNT_VALUE )
57
+ const [ isPageViewSent , setIsPageViewSent ] = useState ( false )
55
58
56
59
const dispatch = useDispatch ( )
57
60
@@ -65,8 +68,22 @@ const SlowLogPage = () => {
65
68
getSlowLogs ( )
66
69
} , [ count ] )
67
70
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
+
68
85
const getSlowLogs = ( maxLen ?: number ) => {
69
- const countToSend = ( provider === ConnectionProvider . RE_CLOUD && count === MAX_COUNT_VALUE )
86
+ const countToSend = count === MAX_COUNT_VALUE
70
87
? ( maxLen || slowlogMaxLen || DEFAULT_SLOWLOG_MAX_LEN )
71
88
: toNumber ( count )
72
89
0 commit comments