📈 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: New chart perfomence to billboard js
kruzhambus8133cbdf1f74
diff --git a/src/pages/Project/View/ViewProject.container.jsx b/src/pages/Project/View/ViewProject.container.jsxindex d0c7c2109..33966843c 100644--- a/src/pages/Project/View/ViewProject.container.jsx+++ b/src/pages/Project/View/ViewProject.container.jsx@@ -46,6 +46,9 @@ const mapDispatchToProps = (dispatch) => ({setProjectViewPrefs: (pid, period, timeBucket, rangeDate) => {dispatch(UIActions.setProjectViewPrefs(pid, period, timeBucket, rangeDate))},+ setProjectCachePerf: (pid, data, key) => {+ dispatch(UIActions.setProjectCachePerf(pid, data, key))+ },setPublicProject: (project) => {dispatch(UIActions.setPublicProject(project))},diff --git a/src/pages/Project/View/ViewProject.helpers.jsx b/src/pages/Project/View/ViewProject.helpers.jsxindex ddbde7ad5..09a155db2 100644--- a/src/pages/Project/View/ViewProject.helpers.jsx+++ b/src/pages/Project/View/ViewProject.helpers.jsx@@ -134,6 +134,21 @@ const CHART_METRICS_MAPPING = {sessionDuration: 'sessionDuration',}+const CHART_METRICS_MAPPING_PERF = {+ full: 'full',+ network: 'network',+ frontend: 'frontend',+ backend: 'backend',+ dns: 'dns',+ tls: 'tls',+ conn: 'conn',+ response: 'response',+ render: 'render',+ dom_load: 'dom_load',+ page_load: 'page_load',+ ttfb: 'ttfb',+}+// function to filter the data for the chartconst getColumns = (chart, activeChartMetrics) => {const {@@ -183,6 +198,97 @@ 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 = [+ ['x', ..._map(chart.x, el => dayjs(el).toDate())],+ ]+ console.log(activeChartMetrics)+ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.full) {+ columns.push(['dns', ...chart.dns])+ columns.push(['tls', ...chart.tls])+ columns.push(['conn', ...chart.conn])+ columns.push(['response', ...chart.response])+ columns.push(['render', ...chart.render])+ columns.push(['dom_load', ...chart.domLoad])+ columns.push(['page_load', ...chart.pageLoad])+ columns.push(['ttfb', ...chart.ttfb])+ }++ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.network) {+ columns.push(['dns', ...chart.dns])+ columns.push(['tls', ...chart.tls])+ columns.push(['conn', ...chart.conn])+ columns.push(['response', ...chart.response])+ }++ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.frontend) {+ columns.push(['render', ...chart.render])+ columns.push(['dom_load', ...chart.domLoad])+ columns.push(['page_load', ...chart.pageLoad])+ }++ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.backend) {+ columns.push(['ttfb', ...chart.ttfb])+ }++ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.dns) {+ columns.push(['dns', ...chart.dns])+ }++ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.tls) {+ columns.push(['tls', ...chart.tls])+ }++ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.conn) {+ columns.push(['conn', ...chart.conn])+ }++ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.response) {+ columns.push(['response', ...chart.response])+ }++ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.render) {+ columns.push(['render', ...chart.render])+ }++ // eslint-disable-next-line camelcase+ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.dom_load) {+ columns.push(['dom_load', ...chart.domLoad])+ }++ // eslint-disable-next-line camelcase+ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.page_load) {+ columns.push(['page_load', ...chart.pageLoad])+ }++ if (activeChartMetrics === CHART_METRICS_MAPPING_PERF.ttfb) {+ columns.push(['ttfb', ...chart.ttfb])+ }++ return columns+}// setting the default values for the time period dropdownconst noRegionPeriods = ['custom', 'yesterday']@@ -327,6 +433,183 @@ const getSettings = (chart, timeBucket, activeChartMetrics, applyRegions) => {}}+const getSettingsPerf = (chart, timeBucket, activeChartMetrics, applyRegions) => {+ const xAxisSize = _size(chart.x)++ let regions++ if (applyRegions) {+ let regionStart++ if (xAxisSize > 1) {+ regionStart = dayjs(chart.x[xAxisSize - 2]).toDate()+ } else {+ regionStart = dayjs(chart.x[xAxisSize - 1]).toDate()+ }++ regions = {+ dns: [+ {+ start: regionStart,+ style: {+ dasharray: '6 2',+ },+ },+ ],+ tls: [+ {+ start: regionStart,+ style: {+ dasharray: '6 2',+ },+ },+ ],+ conn: [+ {+ start: regionStart,+ style: {+ dasharray: '6 2',+ },+ },+ ],+ response: [+ {+ start: regionStart,+ style: {+ dasharray: '6 2',+ },+ },+ ],+ render: [+ {+ start: regionStart,+ style: {+ dasharray: '6 2',+ },+ },+ ],+ dom_load: [+ {+ start: regionStart,+ style: {+ dasharray: '6 2',+ },+ },+ ],+ page_load: [+ {+ start: regionStart,+ style: {+ dasharray: '6 2',+ },+ },+ ],+ ttfb: [+ {+ start: regionStart,+ style: {+ dasharray: '6 2',+ },+ },+ ],+ }+ }++ return {+ data: {+ x: 'x',+ xFormat: tbsFormatMapper[timeBucket],+ columns: getColumnsPerf(chart, activeChartMetrics),+ types: {+ dns: area(),+ tls: area(),+ conn: area(),+ response: area(),+ render: area(),+ dom_load: area(),+ page_load: area(),+ ttfb: area(),+ },+ colors: {+ dns: '#F56565',+ tls: '#ED8936',+ conn: '#ECC94B',+ response: '#48BB78',+ render: '#4299E1',+ dom_load: '#667EEA',+ page_load: '#9F7AEA',+ ttfb: '#ED64A6',+ },+ // names: {+ // dns: 'DNS',+ // tls: 'TLS',+ // conn: 'Conn',+ // response: 'Response',+ // render: 'Render',+ // dom_load: 'DOM Load',+ // page_load: 'Page Load',+ // ttfb: 'TTFB',+ // },+ regions,+ },+ axis: {+ x: {+ type: 'timeseries',+ tick: {+ format: tbsFormatMapper[timeBucket],+ },+ },+ y: {+ tick: {+ format: (d) => `${d} ms`,+ },+ },+ },+ tooltip: {+ format: {+ title: (x) => d3.timeFormat(tbsFormatMapper[timeBucket])(x),+ },+ contents: {+ template: `+ <ul class='bg-gray-100 dark:text-gray-50 dark:bg-gray-700 rounded-md shadow-md px-3 py-1'>+ <li class='font-semibold'>{=TITLE}</li>+ <hr class='border-gray-200 dark:border-gray-600' />+ {{+ <li class='flex justify-between'>+ <div class='flex justify-items-start'>+ <div class='w-3 h-3 rounded-sm mt-1.5 mr-2' style=background-color:{=COLOR}></div>+ <span>{=NAME}</span>+ </div>+ <span class='pl-4'>{=VALUE}</span>+ </li>+ }}+ </ul>`,+ },+ },+ point: {+ focus: {+ only: xAxisSize > 1,+ },+ pattern: [+ 'circle',+ ],+ r: 3,+ },+ legend: {+ usePoint: true,+ item: {+ tile: {+ width: 10,+ },+ },+ },+ area: {+ linearGradient: true,+ },+ bindto: '#dataChart',+ }+}+const validTimeBacket = ['hour', 'day', 'week', 'month']const validPeriods = ['custom', 'today', 'yesterday', '1d', '7d', '4w', '3M', '12M', '24M']const paidPeriods = ['12M', '24M']@@ -368,5 +651,5 @@ const getFormatDate = (date) => {}export {- iconClassName, getFormatDate, panelIconMapping, typeNameMapping, validFilters, validPeriods, validTimeBacket, paidPeriods, noRegionPeriods, getSettings, getExportFilename, getColumns, onCSVExportClick, CHART_METRICS_MAPPING,+ iconClassName, getFormatDate, panelIconMapping, typeNameMapping, validFilters, validPeriods, validTimeBacket, paidPeriods, noRegionPeriods, getSettings, getExportFilename, getColumns, onCSVExportClick, CHART_METRICS_MAPPING, CHART_METRICS_MAPPING_PERF, getColumnsPerf, getSettingsPerf,}diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsxindex 44bf4ea13..756c8ab69 100644--- a/src/pages/Project/View/ViewProject.jsx+++ b/src/pages/Project/View/ViewProject.jsx@@ -51,7 +51,7 @@ import {} from './Panels'import {onCSVExportClick, getFormatDate, panelIconMapping, typeNameMapping, validFilters, validPeriods,- validTimeBacket, paidPeriods, noRegionPeriods, getSettings, getColumns, CHART_METRICS_MAPPING,+ validTimeBacket, paidPeriods, noRegionPeriods, getSettings, getColumns, CHART_METRICS_MAPPING, CHART_METRICS_MAPPING_PERF, getColumnsPerf, getSettingsPerf,} from './ViewProject.helpers'import CCRow from './components/CCRow'import RefRow from './components/RefRow'@@ -63,7 +63,7 @@ const DEFAULT_TAB = 'traffic'const ViewProject = ({projects, isLoading: _isLoading, showError, cache, setProjectCache, projectViewPrefs, setProjectViewPrefs, setPublicProject,- setLiveStatsForProject, authenticated, timezone, user, sharedProjects, isPaidTierUsed, extensions, generateAlert,+ setLiveStatsForProject, authenticated, timezone, user, sharedProjects, isPaidTierUsed, extensions, generateAlert, setProjectCachePerf,}) => {const { t, i18n: { language } } = useTranslation('common')const [periodPairs, setPeriodPairs] = useState(tbPeriodPairs(t))@@ -100,6 +100,7 @@ const ViewProject = ({[CHART_METRICS_MAPPING.viewsPerUnique]: false,[CHART_METRICS_MAPPING.trendlines]: false,})+ const [activeChartMetricsPerf, setActiveChartMetricsPerf] = useState(CHART_METRICS_MAPPING_PERF.full)const [sessionDurationAVG, setSessionDurationAVG] = useState(null)const checkIfAllMetricsAreDisabled = useMemo(() => !_some(activeChartMetrics, (value) => value), [activeChartMetrics])const [filters, setFilters] = useState([])@@ -113,7 +114,10 @@ const ViewProject = ({const [dateRange, setDateRange] = useState(localStorageDateRange ? [new Date(localStorageDateRange[0]), new Date(localStorageDateRange[1])] : null)const [activeTab, setActiveTab] = useState(DEFAULT_TAB)+ const [chartDataPerf, setChartDataPerf] = useState({})+ const [isPanelsDataEmptyPerf, setIsPanelsDataEmptyPerf] = useState(false)const [perfData, setPerfData] = useState({})+ const [panelsDataPerf, setPanelsDataPerf] = useState({})const tabs = useMemo(() => {return [@@ -173,6 +177,71 @@ const ViewProject = ({]}, [t, activeChartMetrics])+ const chartMetricsPerf = useMemo(() => {+ return [+ {+ id: CHART_METRICS_MAPPING_PERF.full,+ label: t('dashboard.fullPageLoad'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.full),+ },+ {+ id: CHART_METRICS_MAPPING_PERF.network,+ label: t('dashboard.network'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.network),+ },+ {+ id: CHART_METRICS_MAPPING_PERF.frontend,+ label: t('dashboard.frontend'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.frontend),+ },+ {+ id: CHART_METRICS_MAPPING_PERF.backend,+ label: t('dashboard.backend'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.backend),+ },+ {+ id: CHART_METRICS_MAPPING_PERF.dns,+ label: t('dashboard.dns'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.dns),+ },+ {+ id: CHART_METRICS_MAPPING_PERF.tls,+ label: t('dashboard.tls'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.tls),+ },+ {+ id: CHART_METRICS_MAPPING_PERF.conn,+ label: t('dashboard.conn'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.conn),+ },+ {+ id: CHART_METRICS_MAPPING_PERF.response,+ label: t('dashboard.response'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.response),+ },+ {+ id: CHART_METRICS_MAPPING_PERF.render,+ label: t('dashboard.render'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.render),+ },+ {+ id: CHART_METRICS_MAPPING_PERF.dom_load,+ label: t('dashboard.domLoad'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.dom_load),+ },+ {+ id: CHART_METRICS_MAPPING_PERF.page_load,+ label: t('dashboard.pageLoad'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.page_load),+ },+ {+ id: CHART_METRICS_MAPPING_PERF.ttfb,+ label: t('dashboard.ttfb'),+ active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.ttfb),+ },+ ]+ }, [t, activeChartMetricsPerf])+const dataNames = useMemo(() => {return {unique: t('project.unique'),@@ -185,9 +254,30 @@ const ViewProject = ({}}, [t])+ const dataNamesPerf = useMemo(() => {+ return {+ full: t('dashboard.fullPageLoad'),+ network: t('dashboard.network'),+ frontend: t('dashboard.frontend'),+ backend: t('dashboard.backend'),+ dns: t('dashboard.dns'),+ tls: t('dashboard.tls'),+ conn: t('dashboard.conn'),+ response: t('dashboard.response'),+ render: t('dashboard.render'),+ dom_load: t('dashboard.domLoad'),+ page_load: t('dashboard.pageLoad'),+ ttfb: t('dashboard.ttfb'),+ }+ }, [t])+// eslint-disable-next-line react-hooks/exhaustive-depsconst switchActiveChartMetric = useCallback(_debounce((pairID) => {- setActiveChartMetrics(prev => ({ ...prev, [pairID]: !prev[pairID] }))+ if (activeTab === tabs[1].id) {+ setActiveChartMetricsPerf(pairID)+ } else {+ setActiveChartMetrics(prev => ({ ...prev, [pairID]: !prev[pairID] }))+ }}, 0), [])const onErrorLoading = () => {@@ -204,6 +294,7 @@ const ViewProject = ({setDataLoading(true)try {let data+ let dataPerflet keylet fromlet to@@ -221,10 +312,13 @@ const ViewProject = ({} else {if (period === 'custom' && dateRange) {data = await getProjectData(id, timeBucket, '', newFilters || filters, from, to, timezone)+ dataPerf = await getPerfData(id, timeBucket, '', filters, from, to, timezone)} else {data = await getProjectData(id, timeBucket, period, newFilters || filters, '', '', timezone)+ dataPerf = await getPerfData(id, timeBucket, period, filters, '', '', timezone)}+ setProjectCachePerf(id, dataPerf || {}, key)setProjectCache(id, data || {}, key)}@@ -277,18 +371,50 @@ const ViewProject = ({customs,})- if (!_isEmpty(mainChart)) {- mainChart.destroy()+ if (activeTab === tabs[0].id) {+ if (!_isEmpty(mainChart)) {+ mainChart.destroy()+ }++ setMainChart(() => {+ const generete = bb.generate(bbSettings)+ generete.data.names(dataNames)+ return generete+ })}- setMainChart(() => {- const generete = bb.generate(bbSettings)- generete.data.names(dataNames)- return generete- })setIsPanelsDataEmpty(false)}+ if (_isEmpty(dataPerf)) {+ setIsPanelsDataEmptyPerf(true)+ } else {+ const { chart: chartPerf } = dataPerf+ const applyRegions = !_includes(noRegionPeriods, activePeriod.period)+ const bbSettings = getSettings(chartPerf, timeBucket, activeChartMetricsPerf, applyRegions)+ setChartDataPerf(chartPerf)+ setPerfData(dataPerf)++ setPanelsDataPerf({+ types: _keys(dataPerf.params),+ data: dataPerf.params,+ })++ if (activeTab === tabs[1].id) {+ if (!_isEmpty(mainChart)) {+ mainChart.destroy()+ }++ setMainChart(() => {+ const generete = bb.generate(bbSettings)+ generete.data.names(dataNames)+ return generete+ })+ }++ setIsPanelsDataEmptyPerf(false)+ }+setAnalyticsLoading(false)setDataLoading(false)} catch (e) {@@ -301,42 +427,30 @@ const ViewProject = ({// temp solution just to see if it worksuseEffect(() => {- if (activeTab !== 'performance') {- setPerfData({})- return- }-- const loadPerfData = async () => {- try {- let data- let key- let from- let to-- if (dateRange) {- from = getFormatDate(dateRange[0])- to = getFormatDate(dateRange[1])- key = getProjectCacheCustomKey(from, to, timeBucket)- } else {- key = getProjectCacheKey(period, timeBucket)- }-- if (period === 'custom' && dateRange) {- data = await getPerfData(id, timeBucket, '', filters, from, to, timezone)- } else {- data = await getPerfData(id, timeBucket, period, filters, '', '', timezone)- }- setPerfData(data)- } catch (e) {- console.error('[ERROR](loadPerfData) Loading performance data failed')- console.error(e)+ if (activeTab === tabs[1].id) {+ console.log(chartDataPerf)+ if (!_isEmpty(chartDataPerf)) {+ console.log('asd1')+ const applyRegions = !_includes(noRegionPeriods, activePeriod.period)+ const bbSettings = getSettingsPerf(chartDataPerf, timeBucket, activeChartMetricsPerf, applyRegions)+ setMainChart(() => {+ const generete = bb.generate(bbSettings)+ generete.data.names(dataNamesPerf)+ return generete+ })}+ } else if (!_isEmpty(chartData)) {+ console.log('asd2')+ const applyRegions = !_includes(noRegionPeriods, activePeriod.period)+ const bbSettings = getSettings(chartData, timeBucket, activeChartMetrics, applyRegions)+ setMainChart(() => {+ const generete = bb.generate(bbSettings)+ generete.data.names(dataNames)+ return generete+ })}-- loadPerfData()- }, [activeTab, id, period, timeBucket, timezone, dateRange, filters])-- console.log(perfData)+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [activeTab, chartData, chartDataPerf, activeChartMetrics, activeChartMetricsPerf, timeBucket])// this funtion is used for requesting the data from the API when the filter is changedconst filterHandler = (column, filter, isExclusive = false) => {@@ -428,64 +542,74 @@ const ViewProject = ({}useEffect(() => {- if (!isLoading && !_isEmpty(chartData) && !_isEmpty(mainChart)) {- mainChart.data.names(dataNames)+ if (activeTab === tabs[0].id) {+ if (!isLoading && !_isEmpty(chartData) && !_isEmpty(mainChart)) {+ mainChart.data.names(dataNames)- if (activeChartMetrics.views || activeChartMetrics.unique || activeChartMetrics.viewsPerUnique || activeChartMetrics.trendlines) {- mainChart.load({- columns: getColumns(chartData, activeChartMetrics),- })- }+ if (activeChartMetrics.views || activeChartMetrics.unique || activeChartMetrics.viewsPerUnique || activeChartMetrics.trendlines) {+ mainChart.load({+ columns: getColumns(chartData, activeChartMetrics),+ })+ }- if (activeChartMetrics.bounce || activeChartMetrics.sessionDuration) {- const applyRegions = !_includes(noRegionPeriods, activePeriod.period)- const bbSettings = getSettings(chartData, timeBucket, activeChartMetrics, applyRegions)+ if (activeChartMetrics.bounce || activeChartMetrics.sessionDuration) {+ const applyRegions = !_includes(noRegionPeriods, activePeriod.period)+ const bbSettings = getSettings(chartData, timeBucket, activeChartMetrics, applyRegions)- if (!_isEmpty(mainChart)) {- mainChart.destroy()+ if (!_isEmpty(mainChart)) {+ mainChart.destroy()+ }++ setMainChart(() => {+ const generete = bb.generate(bbSettings)+ generete.data.names(dataNames)+ return generete+ })}- setMainChart(() => {- const generete = bb.generate(bbSettings)- generete.data.names(dataNames)- return generete- })- }+ if (!activeChartMetrics.bounce || !activeChartMetrics.sessionDuration) {+ const applyRegions = !_includes(noRegionPeriods, activePeriod.period)+ const bbSettings = getSettings(chartData, timeBucket, activeChartMetrics, applyRegions)- if (!activeChartMetrics.bounce || !activeChartMetrics.sessionDuration) {- const applyRegions = !_includes(noRegionPeriods, activePeriod.period)- const bbSettings = getSettings(chartData, timeBucket, activeChartMetrics, applyRegions)+ if (!_isEmpty(mainChart)) {+ mainChart.destroy()+ }- if (!_isEmpty(mainChart)) {- mainChart.destroy()+ setMainChart(() => {+ const generete = bb.generate(bbSettings)+ generete.data.names(dataNames)+ return generete+ })}- setMainChart(() => {- const generete = bb.generate(bbSettings)- generete.data.names(dataNames)- return generete- })- }+ if (!activeChartMetrics.views) {+ mainChart.unload({+ ids: 'total',+ })+ }- if (!activeChartMetrics.views) {- mainChart.unload({- ids: 'total',- })- }+ if (!activeChartMetrics.unique) {+ mainChart.unload({+ ids: 'unique',+ })+ }- if (!activeChartMetrics.unique) {- mainChart.unload({- ids: 'unique',- })+ if (!activeChartMetrics.viewsPerUnique) {+ mainChart.unload({+ ids: 'viewsPerUnique',+ })+ }}+ } else if (!isLoading && !_isEmpty(chartDataPerf) && !_isEmpty(mainChart)) {+ mainChart.data.names(dataNames)- if (!activeChartMetrics.viewsPerUnique) {- mainChart.unload({- ids: 'viewsPerUnique',+ if (activeChartMetricsPerf) {+ mainChart.load({+ columns: getColumnsPerf(chartDataPerf, activeChartMetricsPerf),})}}- }, [isLoading, activeChartMetrics, chartData]) // eslint-disable-line+ }, [isLoading, activeChartMetrics, chartData, chartDataPerf, activeChartMetricsPerf]) // eslint-disable-line// Initialising Swetrix SDK instanceuseEffect(() => {@@ -1024,24 +1148,27 @@ const ViewProject = ({<div className='flex flex-row flex-wrap items-center justify-center md:justify-end h-10 mt-16 md:mt-5 mb-4'>{!isPanelsDataEmpty && (<Dropdown- items={chartMetrics}+ items={activeTab === tabs[0].id ? chartMetrics : chartMetricsPerf}title={t('project.metricVis')}labelExtractor={(pair) => {const {label, id: pairID, active, conflicts,} = pair- const conflicted = isConflicted(conflicts)+ if (activeTab === tabs[0].id) {+ const conflicted = isConflicted(conflicts)- return (- <Checkbox- className={cx({ hidden: isPanelsDataEmpty || analyticsLoading })}- label={label}- disabled={conflicted}- id={pairID}- checked={active}- />- )+ return (+ <Checkbox+ className={cx({ hidden: isPanelsDataEmpty || analyticsLoading })}+ label={label}+ disabled={conflicted}+ id={pairID}+ checked={active}+ />+ )+ }+ return label}}keyExtractor={(pair) => pair.id}onSelect={({ id: pairID, conflicts }) => {diff --git a/src/redux/actions/ui/index.js b/src/redux/actions/ui/index.jsindex b71ddbe67..4f4768fa5 100644--- a/src/redux/actions/ui/index.js+++ b/src/redux/actions/ui/index.js@@ -118,6 +118,13 @@ const setProjectCache = (pid, data, key) => ({},})+const setProjectCachePerf = (pid, data, key) => ({+ type: types.SET_PROJECT_CACHE_PERF,+ payload: {+ pid, data, key,+ },+})+const deleteProjectCache = (pid, period, timeBucket) => ({type: types.DELETE_PROJECT_CACHE,payload: {@@ -125,6 +132,13 @@ const deleteProjectCache = (pid, period, timeBucket) => ({},})+const deleteProjectCachePerf = (pid, period, timeBucket) => ({+ type: types.DELETE_PROJECT_CACHE_PERF,+ payload: {+ pid, period, timeBucket,+ },+})+const setProjectViewPrefs = (pid, period, timeBucket, rangeDate) => ({type: types.SET_PROJECT_VIEW_PREFS,payload: {@@ -210,6 +224,8 @@ const UIActions = {loadExtensions,setLastBlogPost,setThemeType,+ setProjectCachePerf,+ deleteProjectCachePerf,}export default UIActionsdiff --git a/src/redux/actions/ui/types.js b/src/redux/actions/ui/types.jsindex c2611042d..c363c2a97 100644--- a/src/redux/actions/ui/types.js+++ b/src/redux/actions/ui/types.js@@ -26,4 +26,6 @@ export const types = {LOAD_SHARED_PROJECTS: 'UI_LOAD_SHARED_PROJECTS',SET_DASHBOARD_TABS: 'UI_SET_DASHBOARD_TABS',SET_THEME_TYPE: 'UI_SET_THEME_TYPE',+ SET_PROJECT_CACHE_PERF: 'UI_SET_PROJECT_CACHE_PERF',+ DELETE_PROJECT_CACHE_PERF: 'UI_DELETE_PROJECT_CACHE_PERF',}diff --git a/src/redux/reducers/ui/cache.js b/src/redux/reducers/ui/cache.jsindex 9ed316a9f..e1b3fa6a2 100644--- a/src/redux/reducers/ui/cache.js+++ b/src/redux/reducers/ui/cache.js@@ -25,6 +25,8 @@ const getInitialState = () => {// example: { 'FSMaC9V4HFLA': { '4wday': { }, '7dhour': { } } }analytics: {},+ analyticsPerf: {},+// { pid: { period: '7d', timeBucket: 'day' }, ... }projectViewPrefs: getInitialViewPrefs(),}@@ -93,6 +95,48 @@ const cacheReducer = (state = getInitialState(), { type, payload }) => {}}+ case types.SET_PROJECT_CACHE_PERF: {+ const { pid, data, key } = payload++ return {+ ...state,+ analyticsPerf: {+ ...state.analyticsPerf,+ [pid]: {+ ...state.analyticsPerf[pid],+ [key]: data,+ },+ },+ }+ }++ case types.DELETE_PROJECT_CACHE_PERF: {+ const { pid, period, timeBucket } = payload+ const key = getProjectCacheKey(period, timeBucket)++ if (_isEmpty(period) || _isEmpty(timeBucket)) {+ if (_isEmpty(pid)) {+ return {+ ...state,+ analyticsPerf: {},+ }+ }++ return {+ ...state,+ analyticsPerf: _filter(state.analyticsPerf, (project) => project !== pid),+ }+ }++ return {+ ...state,+ analyticsPerf: {+ ...state.analyticsPerf,+ [pid]: _filter(state.analyticsPerf[pid], (ckey) => ckey !== key),+ },+ }+ }+default:return state}