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: Opening sessions with custom events in them in the profile inspector may case page to crash

Blue Mouse8fb7cfc76629
diff --git a/backend/apps/cloud/src/analytics/analytics.service.ts b/backend/apps/cloud/src/analytics/analytics.service.ts
index 5a156d097..64d386e00 100644
--- a/backend/apps/cloud/src/analytics/analytics.service.ts
+++ b/backend/apps/cloud/src/analytics/analytics.service.ts
@@ -6736,9 +6736,11 @@ export class AnalyticsService {
}))
: undefined
- // For sale and refund events, extract amount and currency from metadata
+ // For monetary events, extract amount and currency from metadata
if (
- (page.type === 'sale' || page.type === 'refund') &&
+ (page.type === 'sale' ||
+ page.type === 'subscription' ||
+ page.type === 'refund') &&
processedMetadata
) {
const amountEntry = processedMetadata.find((m) => m.key === 'amount')
diff --git a/backend/apps/cloud/src/analytics/interfaces/index.ts b/backend/apps/cloud/src/analytics/interfaces/index.ts
index 55938e04d..89dc8a18a 100644
--- a/backend/apps/cloud/src/analytics/interfaces/index.ts
+++ b/backend/apps/cloud/src/analytics/interfaces/index.ts
@@ -209,7 +209,7 @@ export interface IOverallPerformance {
}
export interface IPageflow {
- type: 'pageview' | 'event' | 'error' | 'sale' | 'refund'
+ type: 'pageview' | 'event' | 'error' | 'sale' | 'subscription' | 'refund'
value: string
created: string
psid?: string
diff --git a/web/app/api/api.server.ts b/web/app/api/api.server.ts
index c4ba053b8..32c0bab14 100644
--- a/web/app/api/api.server.ts
+++ b/web/app/api/api.server.ts
@@ -1174,7 +1174,7 @@ export async function getGoalSessionsServer(
}
interface PageflowItem {
- type: 'pageview' | 'event' | 'error' | 'sale' | 'refund'
+ type: 'pageview' | 'event' | 'error' | 'sale' | 'subscription' | 'refund'
value: string
created: string
metadata?: { key: string; value: string }[]
diff --git a/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx b/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx
index 857207603..5187780b7 100644
--- a/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx
+++ b/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx
@@ -57,7 +57,7 @@ const RECENTLY_ACTIVE_THRESHOLD_MINUTES = 30
type OnlineStatus = 'online' | 'recently_active' | 'offline'
interface PageflowItem {
- type: 'pageview' | 'event' | 'error' | 'sale' | 'refund'
+ type: 'pageview' | 'event' | 'error' | 'sale' | 'subscription' | 'refund'
value: string
created: string
metadata?: { key: string; value: string }[]
@@ -160,7 +160,8 @@ const getSessionDuration = (session: ProfileSession) => {
}
const interactionPages = (session.pages || []).filter(
- ({ type }) => type !== 'sale' && type !== 'refund',
+ ({ type }) =>
+ type !== 'sale' && type !== 'subscription' && type !== 'refund',
)
if (interactionPages.length < 2) {
return 0
diff --git a/web/app/pages/Project/tabs/Sessions/Pageflow.tsx b/web/app/pages/Project/tabs/Sessions/Pageflow.tsx
index 7b8fd7bc4..1f7318bf0 100644
--- a/web/app/pages/Project/tabs/Sessions/Pageflow.tsx
+++ b/web/app/pages/Project/tabs/Sessions/Pageflow.tsx
@@ -13,6 +13,7 @@ import {
FileTextIcon,
CursorClickIcon,
ArrowCounterClockwiseIcon,
+ ArrowsClockwiseIcon,
TagIcon,
ClockIcon,
ClockCounterClockwiseIcon,
@@ -37,6 +38,7 @@ export type PageflowEventType =
| 'event'
| 'error'
| 'sale'
+ | 'subscription'
| 'refund'
export interface PageflowEvent {
@@ -80,6 +82,7 @@ export const PAGEFLOW_ICON_BY_TYPE: Record<
event: CursorClickIcon,
error: WarningIcon,
sale: CurrencyDollarIcon,
+ subscription: ArrowsClockwiseIcon,
refund: ArrowCounterClockwiseIcon,
}
@@ -88,6 +91,7 @@ export const PAGEFLOW_ICON_COLOR_BY_TYPE: Record<PageflowEventType, string> = {
event: 'text-green-500',
error: 'text-red-500',
sale: 'text-emerald-500',
+ subscription: 'text-teal-500',
refund: 'text-orange-500',
}
@@ -156,12 +160,12 @@ const TypeIcon = ({
type: PageflowEventType
className?: string
}) => {
- const Icon = PAGEFLOW_ICON_BY_TYPE[type]
+ const Icon = PAGEFLOW_ICON_BY_TYPE[type] ?? CursorClickIcon
return (
<Icon
className={cn(
'h-4 w-4 shrink-0',
- PAGEFLOW_ICON_COLOR_BY_TYPE[type],
+ PAGEFLOW_ICON_COLOR_BY_TYPE[type] ?? 'text-gray-400',
className,
)}
weight='duotone'
@@ -298,7 +302,8 @@ const PageflowItem = ({
const [isExpanded, setIsExpanded] = useState(false)
const hasMetadata = !!metadata && metadata.length > 0
- const isMonetary = type === 'sale' || type === 'refund'
+ const isMonetary =
+ type === 'sale' || type === 'subscription' || type === 'refund'
const hasDuration = timeDuration !== null && timeDuration > 0
const showSubRow = hasDuration || hasMetadata
@@ -318,7 +323,7 @@ const PageflowItem = ({
<Text
size='sm'
weight='semibold'
- colour={type === 'sale' ? 'success' : 'warning'}
+ colour={type === 'refund' ? 'warning' : 'success'}
className='leading-4 tabular-nums'
>
{type === 'refund' ? '−' : '+'}
diff --git a/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx b/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx
index 94405ee83..b70c26df4 100644
--- a/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx
+++ b/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx
@@ -165,6 +165,7 @@ const PAGEFLOW_EVENT_LABEL_DEFAULTS: Record<PageflowEventType, string> = {
event: 'Event',
error: 'Error',
sale: 'Sale',
+ subscription: 'Subscription',
refund: 'Refund',
}
@@ -497,7 +498,11 @@ const getPageflowEventLabel = (type: PageflowEventType, t: TFunction) =>
)
const getPageflowEventDetail = (event: PageflowEvent, t: TFunction) => {
- if (event.type === 'sale' || event.type === 'refund') {
+ if (
+ event.type === 'sale' ||
+ event.type === 'subscription' ||
+ event.type === 'refund'
+ ) {
const sign = event.type === 'refund' ? '-' : '+'
const amount = `${sign}${formatPageflowAmount(
event.amount || 0,
@@ -929,7 +934,7 @@ const PlayerIconButton = ({
)
const PageflowMarkerTooltip = ({ marker }: { marker: PageflowMarker }) => {
- const Icon = PAGEFLOW_ICON_BY_TYPE[marker.type]
+ const Icon = PAGEFLOW_ICON_BY_TYPE[marker.type] ?? CursorClickIcon
return (
<div className='min-w-0'>
@@ -937,7 +942,7 @@ const PageflowMarkerTooltip = ({ marker }: { marker: PageflowMarker }) => {
<Icon
className={cn(
'size-4 shrink-0',
- PAGEFLOW_ICON_COLOR_BY_TYPE[marker.type],
+ PAGEFLOW_ICON_COLOR_BY_TYPE[marker.type] ?? 'text-gray-400',
)}
weight='duotone'
aria-hidden
diff --git a/web/app/pages/Project/tabs/Sessions/SessionsView.tsx b/web/app/pages/Project/tabs/Sessions/SessionsView.tsx
index c3d9e8763..0aba7bec1 100644
--- a/web/app/pages/Project/tabs/Sessions/SessionsView.tsx
+++ b/web/app/pages/Project/tabs/Sessions/SessionsView.tsx
@@ -34,7 +34,7 @@ import { LoaderView } from '../../View/components/LoaderView'
const SESSIONS_TAKE = 30
interface PageflowItem {
- type: 'pageview' | 'event' | 'error' | 'sale' | 'refund'
+ type: 'pageview' | 'event' | 'error' | 'sale' | 'subscription' | 'refund'
value: string
created: string
metadata?: { key: string; value: string }[]
diff --git a/web/public/locales/de.json b/web/public/locales/de.json
index ecc60c8d8..72e77e604 100644
--- a/web/public/locales/de.json
+++ b/web/public/locales/de.json
@@ -1942,6 +1942,7 @@
"event": "Ereignis",
"error": "Fehler",
"sale": "Verkauf",
+ "subscription": "Abonnement",
"refund": "Rückerstattung"
},
"timeline": {
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index cb7eb9691..2829017ff 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -1942,6 +1942,7 @@
"event": "Event",
"error": "Error",
"sale": "Sale",
+ "subscription": "Subscription",
"refund": "Refund"
},
"timeline": {
diff --git a/web/public/locales/fr.json b/web/public/locales/fr.json
index 16178dd81..d00b147fa 100644
--- a/web/public/locales/fr.json
+++ b/web/public/locales/fr.json
@@ -1942,6 +1942,7 @@
"event": "Événement",
"error": "Erreur",
"sale": "Vente",
+ "subscription": "Abonnement",
"refund": "Remboursement"
},
"timeline": {
diff --git a/web/public/locales/pl.json b/web/public/locales/pl.json
index 92db9f4f6..1b789b874 100644
--- a/web/public/locales/pl.json
+++ b/web/public/locales/pl.json
@@ -1942,6 +1942,7 @@
"event": "Zdarzenie",
"error": "Błąd",
"sale": "Sprzedaż",
+ "subscription": "Subskrypcja",
"refund": "Zwrot"
},
"timeline": {
diff --git a/web/public/locales/pt.json b/web/public/locales/pt.json
index 26c8ba6ec..38bb2337c 100644
--- a/web/public/locales/pt.json
+++ b/web/public/locales/pt.json
@@ -1942,6 +1942,7 @@
"event": "Evento",
"error": "Erro",
"sale": "Venda",
+ "subscription": "Assinatura",
"refund": "Reembolso"
},
"timeline": {
diff --git a/web/public/locales/uk.json b/web/public/locales/uk.json
index 4bad47e6c..fc829eec5 100644
--- a/web/public/locales/uk.json
+++ b/web/public/locales/uk.json
@@ -1942,6 +1942,7 @@
"event": "Подія",
"error": "Помилка",
"sale": "Продаж",
+ "subscription": "Підписка",
"refund": "Повернення"
},
"timeline": {