📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
add export with csv for perfomence and fix bug, refactoring
kruzhambus5c1b7ae4825f
diff --git a/src/pages/Project/View/ViewProject.helpers.jsx b/src/pages/Project/View/ViewProject.helpers.jsxindex 09a155db2..7d18a5ba1 100644--- a/src/pages/Project/View/ViewProject.helpers.jsx+++ b/src/pages/Project/View/ViewProject.helpers.jsx@@ -198,27 +198,6 @@ const getColumns = (chart, activeChartMetrics) => {return columns}-// // Network-// // @ts-ignore-// dns: perf.domainLookupEnd - perf.domainLookupStart, // DNS Resolution-// // @ts-ignore-// tls: perf.secureConnectionStart ? perf.requestStart - perf.secureConnectionStart : 0, // TLS Setup; checking if secureConnectionStart is not 0 (it's 0 for non-https websites)-// // @ts-ignore-// conn: perf.secureConnectionStart ? perf.secureConnectionStart - perf.connectStart : perf.connectEnd - perf.connectStart, // Connection time-// // @ts-ignore-// response: perf.responseEnd - perf.responseStart, // Response Time (Download)--// // Frontend-// // @ts-ignore-// render: perf.domComplete - perf.domContentLoadedEventEnd, // Browser rendering the HTML time-// // @ts-ignore-// dom_load: perf.domContentLoadedEventEnd - perf.responseEnd, // DOM loading timing-// // @ts-ignore-// page_load: perf.loadEventStart, // Page load time--// // Backend-// // @ts-ignore-// ttfb: perf.responseStart - perf.requestStart,const getColumnsPerf = (chart, activeChartMetrics) => {const columns = [diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsxindex d54fb5c42..3fb90909a 100644--- a/src/pages/Project/View/ViewProject.jsx+++ b/src/pages/Project/View/ViewProject.jsx@@ -33,7 +33,7 @@ import Title from 'components/Title'import EventsRunningOutBanner from 'components/EventsRunningOutBanner'import {tbPeriodPairs, getProjectCacheKey, LIVE_VISITORS_UPDATE_INTERVAL, DEFAULT_TIMEZONE, CDN_URL, isDevelopment,- timeBucketToDays, getProjectCacheCustomKey, roleViewer, MAX_MONTHS_IN_PAST, MAX_MONTHS_IN_PAST_FREE,+ timeBucketToDays, getProjectCacheCustomKey, roleViewer, MAX_MONTHS_IN_PAST, MAX_MONTHS_IN_PAST_FREE, PROJECT_TABS,} from 'redux/constants'import Button from 'ui/Button'import Loader from 'ui/Loader'@@ -271,12 +271,13 @@ const ViewProject = ({// eslint-disable-next-line react-hooks/exhaustive-depsconst switchActiveChartMetric = useCallback(_debounce((pairID) => {- if (activeTab === tabs[1].id) {+ if (activeTab === PROJECT_TABS.performance) {setActiveChartMetricsPerf(pairID)+ console.log(pairID)} else {setActiveChartMetrics(prev => ({ ...prev, [pairID]: !prev[pairID] }))}- }, 0), [])+ }, 0), [activeTab])const onErrorLoading = () => {showError(t('project.noExist'))@@ -372,7 +373,7 @@ const ViewProject = ({customs,})- if (activeTab === tabs[0].id) {+ if (activeTab === PROJECT_TABS.traffic) {if (!_isEmpty(mainChart)) {mainChart.destroy()}@@ -400,7 +401,7 @@ const ViewProject = ({data: dataPerf.params,})- if (activeTab === tabs[1].id) {+ if (activeTab === PROJECT_TABS.performance) {if (!_isEmpty(mainChart)) {mainChart.destroy()}@@ -427,10 +428,8 @@ const ViewProject = ({// temp solution just to see if it worksuseEffect(() => {- if (activeTab === tabs[1].id) {- console.log(chartDataPerf)+ if (activeTab === PROJECT_TABS.performance) {if (!_isEmpty(chartDataPerf)) {- console.log('asd1')const applyRegions = !_includes(noRegionPeriods, activePeriod.period)const bbSettings = getSettingsPerf(chartDataPerf, timeBucket, activeChartMetricsPerf, applyRegions)setMainChart(() => {@@ -440,7 +439,6 @@ const ViewProject = ({})}} else if (!_isEmpty(chartData)) {- console.log('asd2')const applyRegions = !_includes(noRegionPeriods, activePeriod.period)const bbSettings = getSettings(chartData, timeBucket, activeChartMetrics, applyRegions)setMainChart(() => {@@ -542,7 +540,7 @@ const ViewProject = ({}useEffect(() => {- if (activeTab === tabs[0].id) {+ if (activeTab === PROJECT_TABS.traffic) {if (!isLoading && !_isEmpty(chartData) && !_isEmpty(mainChart)) {mainChart.data.names(dataNames)@@ -994,7 +992,15 @@ const ViewProject = ({const exportTypes = [{ label: t('project.asImage'), onClick: exportAsImageHandler },- { label: t('project.asCSV'), onClick: () => onCSVExportClick(panelsData, id, tnMapping, language) },+ {+ label: t('project.asCSV'),+ onClick: () => {+ if (activeTab === PROJECT_TABS.performance) {+ return onCSVExportClick(panelsDataPerf, id, tnMapping, language)+ }+ return onCSVExportClick(panelsData, id, tnMapping, language)+ },+ },]if (!isLoading) {@@ -1020,8 +1026,8 @@ const ViewProject = ({labelExtractor={(item) => item.label}onSelect={(label) => {const selected = _find(tabs, (tab) => tab.label === label)- setActiveTab(selected.id)setProjectTab(selected.id)+ setActiveTab(selected.id)}}title={activeTabLabel}/>@@ -1150,7 +1156,7 @@ const ViewProject = ({</div></div><div className='flex flex-row flex-wrap items-center justify-center md:justify-end h-10 mt-16 md:mt-5 mb-4'>- {activeTab === tabs[0].id ? (+ {activeTab === PROJECT_TABS.traffic ? (!isPanelsDataEmpty && (<Dropdownitems={chartMetrics}@@ -1345,7 +1351,7 @@ const ViewProject = ({</div></div>)}- {activeTab === tabs[1].id && (+ {activeTab === PROJECT_TABS.performance && (<div className={cx('pt-4 md:pt-0', { hidden: isPanelsDataEmpty || analyticsLoading })}><divclassName={cx('h-80', {@@ -1373,7 +1379,7 @@ const ViewProject = ({const panelName = tnMapping[type]const panelIcon = panelIconMapping[type]const customTabs = _filter(customPanelTabs, tab => tab.panelID === type)- console.log(panelsDataPerf)+if (type === 'cc') {return (<Paneldiff --git a/src/pages/Project/View/components/InteractiveMap.jsx b/src/pages/Project/View/components/InteractiveMap.jsxindex 8aa947ca6..8e26716b2 100644--- a/src/pages/Project/View/components/InteractiveMap.jsx+++ b/src/pages/Project/View/components/InteractiveMap.jsx@@ -4,7 +4,7 @@ import _map from 'lodash/map'import { useTranslation } from 'react-i18next'import PropTypes from 'prop-types'import countries from 'utils/isoCountries'-import { projectTabs } from 'redux/constants'+import { PROJECT_TABS } from 'redux/constants'import countriesList from 'utils/countries'import { useSelector } from 'react-redux'@@ -36,7 +36,7 @@ const InteractiveMap = ({ data, onClickCountry, total }) => {<pathkey={index}id={index}- className={projectTabs.traffic === projectTab+ className={PROJECT_TABS.traffic === projectTab? cx({'hover:opacity-90': perc > 0,'fill-[#cfd1d4] dark:fill-[#465d7e46]': perc === 0,diff --git a/src/redux/constants/index.js b/src/redux/constants/index.jsindex eb4cd9519..0b6b20008 100644--- a/src/redux/constants/index.js+++ b/src/redux/constants/index.js@@ -194,7 +194,7 @@ export const tabsForDashboard = [},]-export const projectTabs = {+export const PROJECT_TABS = {traffic: 'traffic',performance: 'performance',}diff --git a/src/redux/reducers/ui/projects.js b/src/redux/reducers/ui/projects.jsindex 8249462b6..f6ac3a126 100644--- a/src/redux/reducers/ui/projects.js+++ b/src/redux/reducers/ui/projects.js@@ -2,7 +2,7 @@ import { types } from 'redux/actions/ui/types'import _filter from 'lodash/filter'import _findIndex from 'lodash/findIndex'import _map from 'lodash/map'-import { tabForOwnedProject, projectTabs } from 'redux/constants'+import { tabForOwnedProject, PROJECT_TABS } from 'redux/constants'import { setItem, getItem } from 'utils/localstorage'const getInitialState = () => {@@ -18,7 +18,7 @@ const getInitialState = () => {dashboardPaginationPage: 1,dashboardPaginationPageShared: 1,dashboardTabs: getItem('dashboardTabs') || tabForOwnedProject,- projectTab: projectTabs.traffic,+ projectTab: PROJECT_TABS.traffic,}}