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 project session recency localization

Blue Mouse366dae7e824c
diff --git a/backend/apps/community/src/analytics/analytics.service.ts b/backend/apps/community/src/analytics/analytics.service.ts
index 09d1e952d..98364e567 100644
--- a/backend/apps/community/src/analytics/analytics.service.ts
+++ b/backend/apps/community/src/analytics/analytics.service.ts
@@ -6713,7 +6713,7 @@ export class AnalyticsService {
AND profileId = {profileId:String}
AND psid IS NOT NULL
AND toString(psid) IN {psids:Array(String)}
- AND created BETWEEN {groupFrom:DateTime} AND {groupTo:DateTime}
+ AND created BETWEEN {groupFrom:String} AND {groupTo:String}
)
)
diff --git a/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx b/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx
index 84e4740d3..64809ad8d 100644
--- a/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx
+++ b/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx
@@ -111,8 +111,8 @@ interface PlatformPart {
const getOnlineStatus = (lastSeen: string | undefined): OnlineStatus => {
if (!lastSeen) return 'offline'
- const now = dayjs()
- const lastSeenTime = dayjs(lastSeen)
+ const now = dayjs.utc()
+ const lastSeenTime = dayjs.utc(lastSeen)
const minutesAgo = now.diff(lastSeenTime, 'minute')
if (minutesAgo < ONLINE_THRESHOLD_MINUTES) {
@@ -154,17 +154,19 @@ const formatVersionLabel = (name: string | null, version: string | null) => {
}
const getSessionDuration = (session: ProfileSession) => {
- if (session.sdur && session.sdur > 0) {
+ if (session.sdur != null) {
return session.sdur
}
- const pages = session.pages || []
- if (pages.length < 2) {
+ const interactionPages = (session.pages || []).filter(
+ ({ type }) => type !== 'sale' && type !== 'refund',
+ )
+ if (interactionPages.length < 2) {
return 0
}
- const first = dayjs.utc(pages[0].created)
- const last = dayjs.utc(pages[pages.length - 1].created)
+ const first = dayjs.utc(interactionPages[0].created)
+ const last = dayjs.utc(interactionPages[interactionPages.length - 1].created)
if (!first.isValid() || !last.isValid()) {
return 0
}
@@ -599,7 +601,7 @@ export const ProfileDetails = ({
)
const lastSeenAgo = useMemo(
- () => (details?.lastSeen ? dayjs(details.lastSeen).fromNow() : ''),
+ () => (details?.lastSeen ? dayjs.utc(details.lastSeen).fromNow(true) : ''),
[details?.lastSeen],
)
diff --git a/web/app/pages/Project/tabs/Profiles/Profiles.tsx b/web/app/pages/Project/tabs/Profiles/Profiles.tsx
index 57fa62596..a1c918a9c 100644
--- a/web/app/pages/Project/tabs/Profiles/Profiles.tsx
+++ b/web/app/pages/Project/tabs/Profiles/Profiles.tsx
@@ -89,7 +89,7 @@ const ProfileRow = ({ profile, timeFormat }: ProfileRowProps) => {
)
const lastSeenAgo = useMemo(
- () => dayjs(profile.lastSeen).fromNow(),
+ () => dayjs(profile.lastSeen).fromNow(true),
[profile.lastSeen],
)
diff --git a/web/app/pages/Project/tabs/Sessions/SessionDetailView.tsx b/web/app/pages/Project/tabs/Sessions/SessionDetailView.tsx
index 61dc3ac16..900a303a6 100644
--- a/web/app/pages/Project/tabs/Sessions/SessionDetailView.tsx
+++ b/web/app/pages/Project/tabs/Sessions/SessionDetailView.tsx
@@ -307,7 +307,7 @@ export const SessionDetailView = ({
const lastSeenLabel = lastSeenTime
? lastSeenTime === 'now'
? t('project.online')
- : t('project.lastSeenAgo', { time: `${lastSeenTime} ago` })
+ : t('project.lastSeenAgo', { time: lastSeenTime })
: t('project.endOfSession')
const isRecentlyActive =
!details.isLive &&
diff --git a/web/app/pages/Project/tabs/Sessions/Sessions.tsx b/web/app/pages/Project/tabs/Sessions/Sessions.tsx
index 4052624b7..b3a534d8e 100644
--- a/web/app/pages/Project/tabs/Sessions/Sessions.tsx
+++ b/web/app/pages/Project/tabs/Sessions/Sessions.tsx
@@ -169,7 +169,7 @@ export const Session = ({
)
const lastActivityAgo = useMemo(
- () => dayjs(session.lastActivity).fromNow(),
+ () => dayjs(session.lastActivity).fromNow(true),
[session.lastActivity],
)
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index b240aaf1c..c14040982 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -1854,7 +1854,7 @@
"sessionNew": "New",
"sessionReturn": "Return",
"online": "Online",
- "lastSeenAgo": "Last seen {{time}}",
+ "lastSeenAgo": "Last seen {{time}} ago",
"searchUsers": "Search users...",
"sessions": "Sessions",
"xSessions": "{{x}} sessions",