Skip to content

📈 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!

fix: Build the drawer range in the selected dashboard timezone

Blue Mousecbb950f1616f
diff --git a/web/app/pages/Project/View/ViewProject.helpers.tsx b/web/app/pages/Project/View/ViewProject.helpers.tsx
index 6e3212fe3..a2f22e56f 100644
--- a/web/app/pages/Project/View/ViewProject.helpers.tsx
+++ b/web/app/pages/Project/View/ViewProject.helpers.tsx
@@ -601,6 +601,7 @@ const getSettings = (
period?: string,
timezone?: string,
onDataPointClick?: (d: { x: Date; index: number }) => void,
+ dataPointClickLabel?: string,
): ChartOptions => {
const xAxisSize = _size(chart.x)
@@ -909,7 +910,7 @@ const getSettings = (
},
).join(
'',
- )}${onDataPointClick ? `<li class='pt-1 mt-1 border-t border-gray-200 dark:border-slate-700/80 text-[10px] text-gray-400 dark:text-slate-500'>Click to explore sessions</li>` : ''}</ul>`
+ )}${onDataPointClick ? `<li class='pt-1 mt-1 border-t border-gray-200 dark:border-slate-700/80 text-[10px] text-gray-400 dark:text-slate-500'>${dataPointClickLabel}</li>` : ''}</ul>`
}
// Get dates from first item
@@ -1004,7 +1005,7 @@ const getSettings = (
<ul class='bg-gray-50 dark:text-gray-50 dark:bg-slate-900 rounded-md ring-1 ring-black/10 px-2 py-1 text-xs md:text-sm max-h-[250px] md:max-h-[350px] overflow-y-auto shadow-md z-50'>
${currentSection}
${compareSection}
- ${onDataPointClick ? `<li class='pt-1 mt-1 border-t border-gray-200 dark:border-slate-700/80 text-[10px] text-gray-400 dark:text-slate-500'>Click to explore sessions</li>` : ''}
+ ${onDataPointClick ? `<li class='pt-1 mt-1 border-t border-gray-200 dark:border-slate-700/80 text-[10px] text-gray-400 dark:text-slate-500'>${dataPointClickLabel}</li>` : ''}
</ul>`
},
},
diff --git a/web/app/pages/Project/tabs/Traffic/TrafficChart.tsx b/web/app/pages/Project/tabs/Traffic/TrafficChart.tsx
index 8210e8301..b5731b987 100644
--- a/web/app/pages/Project/tabs/Traffic/TrafficChart.tsx
+++ b/web/app/pages/Project/tabs/Traffic/TrafficChart.tsx
@@ -1,5 +1,6 @@
import { ChartOptions } from 'billboard.js'
import React, { useMemo } from 'react'
+import { useTranslation } from 'react-i18next'
import { Annotation } from '~/lib/models/Project'
@@ -45,6 +46,13 @@ export const TrafficChart = ({
timezone,
onDataPointClick,
}: TrafficChartProps) => {
+ const { t } = useTranslation()
+
+ const dataPointClickLabel = useMemo(
+ () => (onDataPointClick ? t('project.exploreSessions') : undefined),
+ [onDataPointClick, t],
+ )
+
const options: ChartOptions = useMemo(() => {
return getSettings(
chartData,
@@ -62,6 +70,7 @@ export const TrafficChart = ({
period,
timezone,
onDataPointClick,
+ dataPointClickLabel,
)
}, [
chartData,
@@ -79,6 +88,7 @@ export const TrafficChart = ({
period,
timezone,
onDataPointClick,
+ dataPointClickLabel,
])
const deps = useMemo(
diff --git a/web/app/pages/Project/tabs/Traffic/TrafficView.tsx b/web/app/pages/Project/tabs/Traffic/TrafficView.tsx
index d7c4174dc..812c57bf8 100644
--- a/web/app/pages/Project/tabs/Traffic/TrafficView.tsx
+++ b/web/app/pages/Project/tabs/Traffic/TrafficView.tsx
@@ -1,5 +1,7 @@
import cx from 'clsx'
import dayjs from 'dayjs'
+import utc from 'dayjs/plugin/utc'
+import timezonePlugin from 'dayjs/plugin/timezone'
import _filter from 'lodash/filter'
import _includes from 'lodash/includes'
import _isEmpty from 'lodash/isEmpty'
@@ -100,6 +102,9 @@ import { groupRefEntries } from '~/utils/referrers'
import { LoaderView } from '../../View/components/LoaderView'
import { ChartTypeSwitcher } from '../../View/components/ChartTypeSwitcher'
+dayjs.extend(utc)
+dayjs.extend(timezonePlugin)
+
const InteractiveMap = lazy(
() => import('~/pages/Project/View/components/InteractiveMap'),
)
@@ -336,7 +341,7 @@ const TrafficViewInner = ({
const handleDataPointClick = useCallback(
(d: { x: Date; index: number }) => {
- const date = dayjs(d.x)
+ const date = dayjs(d.x).tz(timezone)
let from: string
let to: string
let label: string
@@ -376,7 +381,7 @@ const TrafficViewInner = ({
setSessionsDrawer({ from, to, label })
},
- [timeBucket, timeFormat],
+ [timeBucket, timeFormat, timezone],
)
const panelsData: PanelsData = useMemo(() => {
@@ -1487,7 +1492,7 @@ const TrafficViewInner = ({
onExploreSessions={
contextMenu.date
? () => {
- const date = dayjs(contextMenu.date, 'YYYY-MM-DD')
+ const date = dayjs.tz(contextMenu.date, 'YYYY-MM-DD', timezone)
if (!date.isValid()) return
setSessionsDrawer({