From ec2aabf8779fa0efe6f19ad46c676ac090fab3c1 Mon Sep 17 00:00:00 2001 From: sylenien Date: Fri, 23 Dec 2022 11:22:18 +0100 Subject: [PATCH] change(ui): some more changes to chec clickmap, clickrage subtype --- .../ClickMapCard/ClickMapCard.tsx | 45 ++++++++++++++++--- .../components/WidgetChart/WidgetChart.tsx | 2 +- .../components/WidgetForm/WidgetForm.tsx | 21 ++++++++- frontend/app/components/Session/WebPlayer.tsx | 18 +------- .../shared/Filters/FilterList/FilterList.tsx | 2 +- frontend/app/player/web/Screen/Screen.ts | 20 +++++---- frontend/app/types/filter/filterType.ts | 2 +- 7 files changed, 75 insertions(+), 35 deletions(-) diff --git a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/ClickMapCard/ClickMapCard.tsx b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/ClickMapCard/ClickMapCard.tsx index 8c187e10c..1e3f4b078 100644 --- a/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/ClickMapCard/ClickMapCard.tsx +++ b/frontend/app/components/Dashboard/Widgets/CustomMetricsWidgets/ClickMapCard/ClickMapCard.tsx @@ -4,9 +4,18 @@ import { observer } from 'mobx-react-lite' import WebPlayer from 'App/components/Session/WebPlayer' import { connect } from 'react-redux' import { setCustomSession } from 'App/duck/sessions' +import Period, { LAST_30_DAYS } from "Types/app/period"; +import { fetchInsights } from 'Duck/sessions'; -function ClickMapCard({ setCustomSession, visitedEvents }: any) { - const { metricStore } = useStore(); +function ClickMapCard({ + setCustomSession, + visitedEvents, + insights, + fetchInsights, + insightsFilters, + host, +}: any) { + const { metricStore, dashboardStore } = useStore(); const onMarkerClick = (s: string, innerText: string) => { metricStore.changeClickMapSearch(s, innerText) } @@ -15,9 +24,26 @@ function ClickMapCard({ setCustomSession, visitedEvents }: any) { if (metricStore.instance.data.mobsUrl) { setCustomSession(metricStore.instance.data) } - }, [metricStore.instance.data.mobsUrl]) + }, [metricStore.instance]) - if (!metricStore.instance.data?.mobsUrl) return
No Data for selected period or URL.
+ React.useEffect(() => { + if (visitedEvents.length) { + const urlOptions = visitedEvents.map(({ url, host }: any) => ({ label: url, value: url, host })) + const url = insightsFilters.url ? insightsFilters.url : host + urlOptions[0].value; + // @ts-ignore + // const { startDate, endDate, rangeValue } = Period({ rangeName: LAST_30_DAYS }).toJSON() + const rangeValue = dashboardStore.drillDownPeriod.rangeValue + const startDate = dashboardStore.drillDownPeriod.start + const endDate = dashboardStore.drillDownPeriod.end + fetchInsights({ ...insightsFilters, url, startDate, endDate, rangeValue }) + } + }, [visitedEvents]) + + if (!metricStore.instance.data.mobsUrl || insights.size === 0) { + return ( +
No Data for selected period or URL.
+ ) + } if (!visitedEvents || !visitedEvents.length) { return
Loading session
} @@ -28,6 +54,7 @@ function ClickMapCard({ setCustomSession, visitedEvents }: any) { return evt }) const jumpTimestamp = (jumpToEvent.timestamp - metricStore.instance.data.startTs) + jumpToEvent.domBuildingTime + return (
({ visitedEvents: state.getIn(['sessions', 'visitedEvents']) }), - { setCustomSession }) + (state: any) => ({ + insightsFilters: state.getIn(['sessions', 'insightFilters']), + visitedEvents: state.getIn(['sessions', 'visitedEvents']), + insights: state.getIn(['sessions', 'insights']), + host: state.getIn(['sessions', 'host']), + }), + { setCustomSession, fetchInsights } +) (observer(ClickMapCard)) diff --git a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx index 01faed546..ab6a34042 100644 --- a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx +++ b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx @@ -90,7 +90,7 @@ function WidgetChart(props: Props) { const timestmaps = drillDownPeriod.toTimestamps(); const payload = isWidget ? { ...params } : { ...metricParams, ...timestmaps, ...metric.toJson() }; debounceRequest(metric, payload, isWidget, !isWidget ? drillDownPeriod : period); - }, [drillDownPeriod, period, depsString, _metric.page, metric.metricType, metric.metricOf, metric.viewType]); + }, [drillDownPeriod, period, depsString, _metric.page, metric.metricType, metric.metricOf, metric.viewType, metric.metricValue]); const renderChart = () => { diff --git a/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx b/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx index 4460f69a2..11aacfc73 100644 --- a/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx +++ b/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx @@ -41,6 +41,7 @@ function WidgetForm(props: Props) { const cannotSaveFunnel = isFunnel && (!metric.series[0] || eventsLength <= 1); const writeOption = ({ value, name }: any) => { + console.log(name, value) value = Array.isArray(value) ? value : value.value; const obj: any = { [name]: value }; @@ -67,9 +68,12 @@ function WidgetForm(props: Props) { obj['metricOf'] = tableOptions[0].value; obj['viewType'] = 'table'; } + if (metric.metricType === CLICKMAP && value !== CLICKMAP) { + metric.series[0].filter.removeFilter(0) + } if (value === CLICKMAP) { obj['viewType'] = 'chart'; - + obj['metricValue'] = 'clicks' if (metric.series[0].filter.filters.length < 1) { metric.series[0].filter.addFilter({ ...clickmapFilter, @@ -90,7 +94,7 @@ function WidgetForm(props: Props) { console.error(e) } } - metricStore.save(metric, dashboardId).then((metric: any) => { + metricStore.save(metric).then((metric: any) => { if (wasCreating) { if (parseInt(dashboardId) > 0) { history.replace(withSiteId(dashboardMetricDetails(dashboardId, metric.metricId), siteId)); @@ -173,6 +177,19 @@ function WidgetForm(props: Props) { /> )} + + {metric.metricType === CLICKMAP && ( + <> + showing +