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!

sessions time notation support

Blue Mouse1cee6385cb48
diff --git a/app/pages/Project/View/ViewProject.tsx b/app/pages/Project/View/ViewProject.tsx
index ef3d263bd..eb2be9329 100644
--- a/app/pages/Project/View/ViewProject.tsx
+++ b/app/pages/Project/View/ViewProject.tsx
@@ -576,7 +576,8 @@ const ViewProject = ({
// similar to panelsData but using for performance tab
const [panelsDataPerf, setPanelsDataPerf] = useState<any>({})
// timeFormat is a time format for chart
- const timeFormat = useMemo(() => user.timeFormat || TimeFormat['12-hour'], [user])
+ // @ts-expect-error
+ const timeFormat = useMemo<'12-hour' | '24-hour'>(() => user.timeFormat || TimeFormat['12-hour'], [user])
// ref, size using for logic with responsive chart
const [ref, size] = useSize() as any
// rotateXAxias using for logic with responsive chart
@@ -4022,7 +4023,7 @@ const ViewProject = ({
/>
{sessionsLoading && _isEmpty(sessions) && <Loader />}
{!sessionsLoading && _isEmpty(sessions) && <NoEvents filters={filters} resetFilters={resetFilters} />}
- <Sessions sessions={sessions} onClick={loadSession} />
+ <Sessions sessions={sessions} onClick={loadSession} timeFormat={timeFormat} />
{canLoadMoreSessions && (
<button
type='button'
@@ -4065,7 +4066,7 @@ const ViewProject = ({
chartType={chartType}
dataNames={dataNames}
/>
- <Pageflow pages={activeSession?.pages} />
+ <Pageflow pages={activeSession?.pages} timeFormat={timeFormat} />
</>
)}
{activeTab === PROJECT_TABS.errors && !activeEID && (
diff --git a/app/pages/Project/View/components/Pageflow.tsx b/app/pages/Project/View/components/Pageflow.tsx
index 7642d72df..dd99b5ff9 100644
--- a/app/pages/Project/View/components/Pageflow.tsx
+++ b/app/pages/Project/View/components/Pageflow.tsx
@@ -10,9 +10,10 @@ interface IPageflow {
value: string
created: string
}[]
+ timeFormat: '12-hour' | '24-hour'
}
-export const Pageflow = ({ pages }: IPageflow) => {
+export const Pageflow = ({ pages, timeFormat }: IPageflow) => {
const {
t,
i18n: { language },
@@ -27,6 +28,7 @@ export const Pageflow = ({ pages }: IPageflow) => {
month: 'short',
hour: 'numeric',
minute: 'numeric',
+ hourCycle: timeFormat === '12-hour' ? 'h12' : 'h23',
})
return (
diff --git a/app/pages/Project/View/components/Sessions.tsx b/app/pages/Project/View/components/Sessions.tsx
index bc3375559..6ff6cae39 100644
--- a/app/pages/Project/View/components/Sessions.tsx
+++ b/app/pages/Project/View/components/Sessions.tsx
@@ -11,11 +11,13 @@ import CCRow from './CCRow'
interface ISessions {
sessions: ISession[]
onClick: (psid: string) => void
+ timeFormat: '12-hour' | '24-hour'
}
interface ISessionComponent {
session: ISession
onClick: (psid: string) => void
+ timeFormat: '12-hour' | '24-hour'
}
const Separator = () => (
@@ -24,7 +26,7 @@ const Separator = () => (
</svg>
)
-const Session = ({ session, onClick }: ISessionComponent) => {
+const Session = ({ session, onClick, timeFormat }: ISessionComponent) => {
const {
t,
i18n: { language },
@@ -35,6 +37,7 @@ const Session = ({ session, onClick }: ISessionComponent) => {
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
+ hourCycle: timeFormat === '12-hour' ? 'h12' : 'h23',
})
const psidUrl = new URL(window.location.href)
@@ -84,7 +87,7 @@ const Session = ({ session, onClick }: ISessionComponent) => {
)
}
-export const Sessions: React.FC<ISessions> = ({ sessions, onClick }) => {
+export const Sessions: React.FC<ISessions> = ({ sessions, onClick, timeFormat }) => {
return (
<ClientOnly
fallback={
@@ -96,7 +99,7 @@ export const Sessions: React.FC<ISessions> = ({ sessions, onClick }) => {
{() => (
<ul className='mt-4'>
{_map(sessions, (session) => (
- <Session key={session.psid} session={session} onClick={onClick} />
+ <Session key={session.psid} session={session} onClick={onClick} timeFormat={timeFormat} />
))}
</ul>
)}