📈 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 getSettingsUptime
Blue Mouse4dc4bc950b19
diff --git a/app/pages/Project/View/ViewProject.helpers.tsx b/app/pages/Project/View/ViewProject.helpers.tsxindex 0456bf1c4..4eedc222c 100644--- a/app/pages/Project/View/ViewProject.helpers.tsx+++ b/app/pages/Project/View/ViewProject.helpers.tsx@@ -232,7 +232,8 @@ const getColumns = ([key: string]: string[]},) => {- const { views, bounce, viewsPerUnique, unique, trendlines, sessionDuration, occurrences } = activeChartMetrics+ const { views, bounce, viewsPerUnique, unique, trendlines, sessionDuration, occurrences, avgResponseTime } =+ activeChartMetricsconst columns: any[] = [['x', ..._map(chart.x, (el) => dayjs(el).toDate())]]@@ -255,6 +256,10 @@ const getColumns = (}}+ if (avgResponseTime) {+ columns.push(['avgResponseTime', ...chart.avgResponseTime])+ }+if (views) {columns.push(['total', ...chart.visits])if (trendlines) {@@ -939,7 +944,6 @@ const getSettingsSession = (}}-// function to get the settings and data for the error details chartconst getSettingsError = (chart: any,timeBucket: string,@@ -1065,7 +1069,6 @@ const getSettingsError = (}}-// function to get the settings and data for the funnels chartconst getSettingsFunnels = (funnel: IAnalyticsFunnel[], totalPageviews: number, t: typeof i18next.t): ChartOptions => {const values = _map(funnel, (step) => {if (_startsWith(step.value, '/')) {@@ -1208,6 +1211,130 @@ const getSettingsFunnels = (funnel: IAnalyticsFunnel[], totalPageviews: number,}}+const getSettingsUptime = (+ chart: any,+ timeBucket: string,+ timeFormat: string,+ rotateXAxis: boolean,+ chartType: string,+): ChartOptions => {+ const xAxisSize = _size(chart.x)++ const columns = getColumns(chart, { avgResponseTime: true }, {})++ let regionStart++ if (xAxisSize > 1) {+ regionStart = dayjs(chart.x[xAxisSize - 2]).toDate()+ } else {+ regionStart = dayjs(chart.x[xAxisSize - 1]).toDate()+ }++ return {+ data: {+ x: 'x',+ columns,+ types: {+ avgResponseTime: chartType === chartTypes.line ? area() : bar(),+ },+ colors: {+ avgResponseTime: '#709775',+ },+ regions: {+ avgResponseTime: [+ {+ // @ts-expect-error+ start: regionStart,+ style: {+ dasharray: '6 2',+ },+ },+ ],+ },+ },+ transition: {+ duration: 500,+ },+ resize: {+ auto: true,+ timer: false,+ },+ axis: {+ x: {+ clipPath: false,+ tick: {+ fit: true,+ rotate: rotateXAxis ? 45 : 0,+ // @ts-expect-error+ format:+ timeFormat === TimeFormat['24-hour']+ ? (x: string) => d3.timeFormat(tbsFormatMapper24h[timeBucket])(x)+ : (x: string) => d3.timeFormat(tbsFormatMapper[timeBucket])(x),+ },+ localtime: timeFormat === TimeFormat['24-hour'],+ type: 'timeseries',+ },+ y: {+ tick: {+ format: (d: number) => nFormatter(d, 1),+ },+ show: true,+ inner: true,+ },+ },+ tooltip: {+ contents: (item: any, _: any, __: any, color: any) => {+ return `<ul class='bg-gray-100 dark:text-gray-50 dark:bg-slate-800 rounded-md shadow-md px-3 py-1'>+ <li class='font-semibold'>${+ timeFormat === TimeFormat['24-hour']+ ? d3.timeFormat(tbsFormatMapperTooltip24h[timeBucket])(item[0].x)+ : d3.timeFormat(tbsFormatMapperTooltip[timeBucket])(item[0].x)+ }</li>+ <hr class='border-gray-200 dark:border-gray-600' />+ ${_map(+ item,+ (el: { id: string; index: number; name: string; value: string; x: Date }) => `+ <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(el.id)}></div>+ <span>${el.name}</span>+ </div>+ <span class='pl-4'>${el.value}</span>+ </li>+ `,+ ).join('')}`+ },+ },+ point:+ chartType === chartTypes.bar+ ? {}+ : {+ focus: {+ only: xAxisSize > 1,+ },+ pattern: ['circle'],+ r: 2,+ },+ legend: {+ item: {+ tile: {+ type: 'circle',+ width: 10,+ r: 3,+ },+ },+ hide: ['uniqueCompare', 'totalCompare', 'bounceCompare', 'sessionDurationCompare'],+ },+ area: {+ linearGradient: true,+ },+ bar: {+ linearGradient: true,+ },+ bindto: '#avgResponseUptimeChart',+ }+}+const perfomanceChartCompare = ['dnsCompare','tlsCompare',@@ -1636,4 +1763,5 @@ export {CHART_MEASURES_MAPPING_PERF,getSettingsError,ERROR_FILTERS_MAPPING,+ getSettingsUptime,}