* start moving ui to redux tlk * remove unused reducer * changes for gdpr and site types * ui: migrating duck/roles to mobx * ui: drop unreferenced types * ui: drop unreferenced types * ui: move player slice reducer to mobx family * ui: move assignments to issueReportingStore.ts * remove issues store * some fixes after issues store * remove errors reducer, drop old components * finish removing errors reducer * start moving integrations state to mobx * change(ui): funnel duck cleanup * change(ui): custom fields * change(ui): customMetrics cleanup * change(ui): customMetrics cleanup * change(ui): duck/filters minor cleanup * change(ui): duck/filters cleanup * change(ui): duck/customMetrics cleanup and upgrades * fix integrations service, fix babel config to >.25 + not ie * refactoring integrations reducers etc WIP * finish removing integrations state * some fixes for integrated check * start of projects refactoring * move api and "few" files to new project store * new batch for site -> projects * fix setid context * move all critical components, drop site duck * remove all duck/site refs, remove old components * fixup for SessionTags.tsx, remove duck/sources (?) * move session store * init sessionstore outside of context * fix userfilter * replace simple actions for session store * sessions sotre * Rtm temp (#2597) * change(ui): duck/search wip * change(ui): duck/search wip * change(ui): duck/search wip * change(ui): duck/searchLive wip * change(ui): duck/searchLive wip * change(ui): duck/searchLive wip * change(ui): duck/searchLive wip * change(ui): search states * change(ui): search states * change(ui): search states * change(ui): fix savedSearch store * change(ui): fix savedSearch store * some fixes for session connector * change(ui): fix savedSearch store * change(ui): fix searchLive * change(ui): fix searchLive * fixes for session replay * change(ui): bookmark fetch * last components for sessions * add fetchautoplaylist * finish session reducer, remove deleted reducers * change(ui): fix the search fetch * change(ui): fix the search fetch * fix integrations call ctx * ensure ctx for sessionstore * fix(ui): checking for latest sessions path * start removing user reducer * removing user reducer pt2... * finish user store * remove rand log * fix crashes * tinkering workflow file for tracker test * making sure prefetched sessions work properly * fix conflict * fix router redirects during loading --------- Co-authored-by: Shekar Siri <sshekarsiri@gmail.com>
75 lines
3 KiB
TypeScript
75 lines
3 KiB
TypeScript
import React from 'react'
|
|
import { useStore } from 'App/mstore'
|
|
import { observer } from 'mobx-react-lite'
|
|
import ClickMapRenderer from 'App/components/Session/Player/ClickMapRenderer'
|
|
import { NoContent, Icon } from 'App/components/ui'
|
|
|
|
function ClickMapCard() {
|
|
const [customSession, setCustomSession] = React.useState<any>(null)
|
|
const { metricStore, dashboardStore, sessionStore } = useStore();
|
|
const fetchInsights = sessionStore.fetchInsights
|
|
const insights = sessionStore.insights
|
|
const onMarkerClick = (s: string, innerText: string) => {
|
|
metricStore.changeClickMapSearch(s, innerText)
|
|
}
|
|
const mapUrl = metricStore.instance.series[0].filter.filters[0].value[0]
|
|
const sessionId = metricStore.instance.data.sessionId
|
|
|
|
React.useEffect(() => {
|
|
return () => setCustomSession(null)
|
|
}, [])
|
|
|
|
React.useEffect(() => {
|
|
if (metricStore.instance.data.domURL && sessionId && sessionId !== customSession?.sessionId) {
|
|
setCustomSession(null)
|
|
setTimeout(() => {
|
|
setCustomSession(metricStore.instance.data)
|
|
}, 100)
|
|
}
|
|
}, [metricStore.instance, sessionId])
|
|
|
|
React.useEffect(() => {
|
|
const rangeValue = dashboardStore.drillDownPeriod.rangeValue
|
|
const startDate = dashboardStore.drillDownPeriod.start
|
|
const endDate = dashboardStore.drillDownPeriod.end
|
|
void fetchInsights({ url: mapUrl || '/', startDate, endDate, rangeValue, clickRage: metricStore.clickMapFilter })
|
|
}, [dashboardStore.drillDownPeriod.start, dashboardStore.drillDownPeriod.end, dashboardStore.drillDownPeriod.rangeValue, metricStore.clickMapFilter])
|
|
|
|
if (!metricStore.instance.data.domURL || insights.size === 0) {
|
|
return (
|
|
<NoContent
|
|
style={{ minHeight: 220 }}
|
|
title={
|
|
<div className="flex items-center relative">
|
|
<Icon name="info-circle" className="mr-2" size="14" />
|
|
No data available for the selected period.
|
|
</div>
|
|
}
|
|
show={true}
|
|
/>
|
|
)
|
|
}
|
|
|
|
if (!metricStore.instance.data?.sessionId || !customSession) {
|
|
return <div className="py-2">Loading session</div>
|
|
}
|
|
|
|
const jumpToEvent = metricStore.instance.data.events.find((evt: Record<string, any>) => {
|
|
if (mapUrl) return evt.path.includes(mapUrl)
|
|
return evt
|
|
}) || { timestamp: metricStore.instance.data.startTs }
|
|
const ts = jumpToEvent.timestamp ?? metricStore.instance.data.startTs
|
|
const domTime = jumpToEvent.domBuildingTime ?? 0
|
|
const jumpTimestamp = (ts - metricStore.instance.data.startTs) + domTime + 99 // 99ms safety margin to give some time for the DOM to load
|
|
return (
|
|
<div id="clickmap-render">
|
|
<ClickMapRenderer
|
|
session={customSession}
|
|
jumpTimestamp={jumpTimestamp}
|
|
onMarkerClick={onMarkerClick}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default observer(ClickMapCard)
|