Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions backend/apps/cloud/src/analytics/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,8 @@ export class AnalyticsService {
WITH analytics_counts AS (
SELECT
count(*) AS all,
count(DISTINCT psid) AS unique
count(DISTINCT psid) AS unique,
count(DISTINCT profileId) AS users
FROM analytics
WHERE
pid = {pid:FixedString(12)}
Expand Down Expand Up @@ -1765,17 +1766,20 @@ export class AnalyticsService {
current: {
all: data[0].all,
unique: data[0].unique,
users: data[0].users,
bounceRate,
sdur: data[0].sdur,
},
previous: {
all: 0,
unique: 0,
users: 0,
bounceRate: 0,
sdur: 0,
},
change: data[0].all,
uniqueChange: data[0].unique,
usersChange: data[0].users,
bounceRateChange: bounceRate,
sdurChange: data[0].sdur,
customEVFilterApplied,
Expand All @@ -1798,7 +1802,8 @@ export class AnalyticsService {
SELECT
1 AS sortOrder,
count(*) AS all,
count(DISTINCT psid) AS unique
count(DISTINCT psid) AS unique,
count(DISTINCT profileId) AS users
FROM analytics
WHERE
pid = {pid:FixedString(12)}
Expand Down Expand Up @@ -1828,7 +1833,8 @@ export class AnalyticsService {
SELECT
2 AS sortOrder,
count(*) AS all,
count(DISTINCT psid) AS unique
count(DISTINCT psid) AS unique,
count(DISTINCT profileId) AS users
FROM analytics
WHERE
pid = {pid:FixedString(12)}
Expand Down Expand Up @@ -1913,17 +1919,20 @@ export class AnalyticsService {
current: {
all: currentPeriod.all,
unique: currentPeriod.unique,
users: currentPeriod.users,
sdur: currentPeriod.sdur || 0,
bounceRate,
},
previous: {
all: previousPeriod.all,
unique: previousPeriod.unique,
users: previousPeriod.users,
sdur: previousPeriod.sdur || 0,
bounceRate: prevBounceRate,
},
change: currentPeriod.all - previousPeriod.all,
uniqueChange: currentPeriod.unique - previousPeriod.unique,
usersChange: currentPeriod.users - previousPeriod.users,
bounceRateChange: (bounceRate - prevBounceRate) * -1,
sdurChange: currentPeriod.sdur - previousPeriod.sdur,
customEVFilterApplied,
Expand Down
3 changes: 3 additions & 0 deletions backend/apps/cloud/src/analytics/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface TrafficCHResponse {
export interface BirdseyeCHResponse {
all: number
unique: number
users: number
sdur: number
}

Expand Down Expand Up @@ -134,6 +135,7 @@ export interface IGetFunnel {
interface IOverallPeriodStats {
all: number
unique: number
users: number
bounceRate: number
sdur: number
}
Expand Down Expand Up @@ -169,6 +171,7 @@ interface IOverallObject {
previous: IOverallPeriodStats
change: number
uniqueChange?: number
usersChange?: number
bounceRateChange?: number
sdurChange?: number
}
Expand Down
15 changes: 12 additions & 3 deletions backend/apps/community/src/analytics/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,8 @@ export class AnalyticsService {
WITH analytics_counts AS (
SELECT
count(*) AS all,
count(DISTINCT psid) AS unique
count(DISTINCT psid) AS unique,
count(DISTINCT profileId) AS users
FROM analytics
WHERE
pid = {pid:FixedString(12)}
Expand Down Expand Up @@ -1569,17 +1570,20 @@ export class AnalyticsService {
current: {
all: data[0].all,
unique: data[0].unique,
users: data[0].users,
bounceRate,
sdur: data[0].sdur,
},
previous: {
all: 0,
unique: 0,
users: 0,
bounceRate: 0,
sdur: 0,
},
change: data[0].all,
uniqueChange: data[0].unique,
usersChange: data[0].users,
bounceRateChange: bounceRate,
sdurChange: data[0].sdur,
customEVFilterApplied,
Expand All @@ -1602,7 +1606,8 @@ export class AnalyticsService {
SELECT
1 AS sortOrder,
count(*) AS all,
count(DISTINCT psid) AS unique
count(DISTINCT psid) AS unique,
count(DISTINCT profileId) AS users
FROM analytics
WHERE
pid = {pid:FixedString(12)}
Expand Down Expand Up @@ -1632,7 +1637,8 @@ export class AnalyticsService {
SELECT
2 AS sortOrder,
count(*) AS all,
count(DISTINCT psid) AS unique
count(DISTINCT psid) AS unique,
count(DISTINCT profileId) AS users
FROM analytics
WHERE
pid = {pid:FixedString(12)}
Expand Down Expand Up @@ -1717,17 +1723,20 @@ export class AnalyticsService {
current: {
all: currentPeriod.all,
unique: currentPeriod.unique,
users: currentPeriod.users,
sdur: currentPeriod.sdur || 0,
bounceRate,
},
previous: {
all: previousPeriod.all,
unique: previousPeriod.unique,
users: previousPeriod.users,
sdur: previousPeriod.sdur || 0,
bounceRate: prevBounceRate,
},
change: currentPeriod.all - previousPeriod.all,
uniqueChange: currentPeriod.unique - previousPeriod.unique,
usersChange: currentPeriod.users - previousPeriod.users,
bounceRateChange: (bounceRate - prevBounceRate) * -1,
sdurChange: currentPeriod.sdur - previousPeriod.sdur,
customEVFilterApplied,
Expand Down
3 changes: 3 additions & 0 deletions backend/apps/community/src/analytics/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ export interface IGetFunnel {
export interface BirdseyeCHResponse {
all: number
unique: number
users: number
sdur: number
}

interface IOverallPeriodStats {
all: number
unique: number
users: number
bounceRate: number
sdur: number
}
Expand All @@ -159,6 +161,7 @@ interface IOverallObject {
previous: IOverallPeriodStats
change: number
uniqueChange?: number
usersChange?: number
bounceRateChange?: number
sdurChange?: number
}
Expand Down
2 changes: 2 additions & 0 deletions web/app/lib/models/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Organisation, Role } from './Organisation'
interface OverallPeriodStats {
all: number
unique?: number
users?: number
bounceRate?: number
sdur?: number
}
Expand All @@ -12,6 +13,7 @@ export interface OverallObject {
previous: OverallPeriodStats
change: number
uniqueChange?: number
usersChange?: number
bounceRateChange?: number
sdurChange?: number
customEVFilterApplied?: boolean
Expand Down
4 changes: 2 additions & 2 deletions web/app/pages/Project/View/ViewProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ const ViewProjectContent = () => {
return [
{
id: CHART_METRICS_MAPPING.unique,
label: t('dashboard.unique'),
label: t('dashboard.sessions'),
active: activeChartMetrics[CHART_METRICS_MAPPING.unique],
},
{
Expand Down Expand Up @@ -1415,7 +1415,7 @@ const ViewProjectContent = () => {

const dataNames = useMemo(
() => ({
unique: t('project.unique'),
unique: t('dashboard.sessions'),
total: t('project.total'),
pageviews: t('project.pageviews'),
customEvents: t('project.customEvents'),
Expand Down
12 changes: 11 additions & 1 deletion web/app/pages/Project/View/components/MetricCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,14 @@ export const MetricCards = memo(({ overall, overallCompare, activePeriodCompare
const { t } = useTranslation('common')

let uniqueChange = overall.uniqueChange
let usersChange = overall.usersChange
let allChange = overall.change
let bounceRateChange = overall.bounceRateChange
let sdurChange = overall.sdurChange

if (!_isEmpty(overallCompare) && activePeriodCompare !== 'previous') {
uniqueChange = (overall.current?.unique as number) - (overallCompare?.current?.unique as number)
usersChange = (overall.current?.users as number) - (overallCompare?.current?.users as number)
allChange = (overall.current?.all as number) - (overallCompare?.current?.all as number)
bounceRateChange = ((overall.current?.bounceRate as number) - (overallCompare.current?.bounceRate as number)) * -1
sdurChange = (overall.current?.sdur as number) - (overallCompare?.current?.sdur as number)
Expand All @@ -208,7 +210,15 @@ export const MetricCards = memo(({ overall, overallCompare, activePeriodCompare
return (
<>
<MetricCard
label={t('dashboard.unique')}
label={t('dashboard.users')}
value={overall.current?.users}
change={usersChange}
type='percent'
goodChangeDirection='down'
valueMapper={(value, type) => `${type === 'badge' && value > 0 ? '+' : ''}${nFormatter(value, 1)}`}
/>
<MetricCard
label={t('dashboard.sessions')}
value={overall.current?.unique}
change={uniqueChange}
type='percent'
Expand Down
2 changes: 1 addition & 1 deletion web/app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ const AnalyticsLivePreview = () => {
<div className='mb-3 flex items-center justify-between'>
<div className='flex gap-3'>
{[
{ l: t('dashboard.unique'), v: 471 },
{ l: t('dashboard.sessions'), v: 471 },
{ l: t('dashboard.pageviews'), v: 994 },
{ l: t('dashboard.bounceRate'), v: '28.5%' },
].map((k) => (
Expand Down
2 changes: 1 addition & 1 deletion web/app/ui/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Input = ({
{
'text-red-900 placeholder-red-300 ring-red-600': isError,
'ring-gray-300 dark:ring-slate-800/50': !isError,
'cursor-text': disabled,
'cursor-not-allowed bg-gray-100 text-gray-500 dark:bg-slate-700 dark:text-gray-400': disabled,
'pr-10': isPassword,
},
classes?.input,
Expand Down
2 changes: 1 addition & 1 deletion web/app/ui/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Textarea = ({
{
'text-red-900 placeholder-red-300 ring-red-600': isError,
'ring-gray-300 dark:ring-slate-800/50': !isError,
'cursor-text': disabled,
'cursor-not-allowed bg-gray-100 text-gray-500 dark:bg-slate-700 dark:text-gray-400': disabled,
},
classes?.textarea,
)}
Expand Down
5 changes: 2 additions & 3 deletions web/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
"firstSeen": "First seen",
"lastSeen": "Last seen",
"atFile": "At {{filename}}, line {{lineno}}, column {{colno}}",
"unique": "Unique views",
"users": "Users",
"createdAt": "Created at",
"inc": "Increased by",
"dec": "Descreased by",
Expand Down Expand Up @@ -1008,7 +1008,7 @@
"noSessionDetails": "No session details",
"noSessionDesc": "We could not find a session with the specified session ID.",
"showAll": "Show all views",
"trendlineUnique": "Unique visitors trendline",
"trendlineUnique": "Sessions trendline",
"backToFunnels": "Back to funnels list",
"backToSessions": "Back to sessions list",
"backToUsers": "Back to users list",
Expand Down Expand Up @@ -1125,7 +1125,6 @@
"conflictMetric": "The metric you selected conflicts with an already selected one",
"prev": "Previous",
"next": "Next",
"unique": "Unique visitors",
"results": "Results",
"total": "Total page views",
"pageviews": "Pageviews",
Expand Down