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!

Nicer Pageflow UI

Blue Mouse51d5a843394b
diff --git a/web/app/pages/Project/tabs/Sessions/Pageflow.tsx b/web/app/pages/Project/tabs/Sessions/Pageflow.tsx
index c7304e64d..69d937ea1 100644
--- a/web/app/pages/Project/tabs/Sessions/Pageflow.tsx
+++ b/web/app/pages/Project/tabs/Sessions/Pageflow.tsx
@@ -7,16 +7,18 @@ import _truncate from 'lodash/truncate'
import {
WarningIcon,
CaretDownIcon,
- CircleIcon,
CurrencyDollarIcon,
FileTextIcon,
CursorClickIcon,
ArrowCounterClockwiseIcon,
TagIcon,
+ ClockIcon,
+ ClockCounterClockwiseIcon,
} from '@phosphor-icons/react'
import React, { useMemo, useState } from 'react'
-import { Trans, useTranslation } from 'react-i18next'
+import { useTranslation } from 'react-i18next'
+import { Text } from '~/ui/Text'
import { cn, getStringFromTime, getTimeFromSeconds } from '~/utils/generic'
interface Metadata {
@@ -24,9 +26,11 @@ interface Metadata {
value: string
}
+type EventType = 'pageview' | 'event' | 'error' | 'sale' | 'refund'
+
interface PageflowProps {
pages: {
- type: 'pageview' | 'event' | 'error' | 'sale' | 'refund'
+ type: EventType
value: string
created: string
metadata?: Metadata[]
@@ -41,19 +45,90 @@ interface PageflowProps {
}
interface PageflowItemProps {
+ index: number
value: string
created: string
- type: 'pageview' | 'event' | 'error' | 'sale' | 'refund'
+ type: EventType
metadata?: Metadata[]
displayCreated: string
timeDuration: number | null
- isLastEvent: boolean
t: TFunction
amount?: number
currency?: string
websiteUrl?: string | null
}
+const ICON_BY_TYPE: Record<EventType, React.ElementType> = {
+ pageview: FileTextIcon,
+ event: CursorClickIcon,
+ error: WarningIcon,
+ sale: CurrencyDollarIcon,
+ refund: ArrowCounterClockwiseIcon,
+}
+
+const ICON_COLOR_BY_TYPE: Record<EventType, string> = {
+ pageview: 'text-yellow-500',
+ event: 'text-green-500',
+ error: 'text-red-500',
+ sale: 'text-emerald-500',
+ refund: 'text-orange-500',
+}
+
+const formatDuration = (seconds: number): string => {
+ if (seconds <= 0) return ''
+ if (seconds < 1) return '<1s'
+ return getStringFromTime(getTimeFromSeconds(seconds))
+}
+
+const StepNumber = ({ number }: { number: number }) => (
+ <Text
+ size='xs'
+ weight='semibold'
+ colour='secondary'
+ className='flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-white tabular-nums ring-1 ring-gray-300 dark:bg-slate-900 dark:ring-slate-700/80'
+ >
+ {number}
+ </Text>
+)
+
+const RailLine = () => (
+ <div className='flex flex-1 justify-center pt-1.5'>
+ <div
+ className='w-px self-stretch bg-gray-200 dark:bg-slate-700/80'
+ aria-hidden
+ />
+ </div>
+)
+
+const TypeIcon = ({
+ type,
+ className,
+}: {
+ type: EventType
+ className?: string
+}) => {
+ const Icon = ICON_BY_TYPE[type]
+ return (
+ <Icon
+ className={cn('h-4 w-4 shrink-0', ICON_COLOR_BY_TYPE[type], className)}
+ weight='duotone'
+ aria-hidden
+ />
+ )
+}
+
+const Duration = ({ seconds }: { seconds: number }) => (
+ <Text
+ size='xs'
+ weight='medium'
+ colour='muted'
+ className='inline-flex items-center gap-1 tabular-nums'
+ >
+ <ClockIcon className='h-3 w-3' aria-hidden />
+ {formatDuration(seconds)}
+ </Text>
+)
+
const MetadataPanel = ({
metadata,
t,
@@ -70,86 +145,89 @@ const MetadataPanel = ({
const remainingCount = metadata.length - INITIAL_SHOW_COUNT
return (
- <div className='mt-2 overflow-hidden rounded-lg border border-slate-200 bg-white sm:ml-5 dark:border-slate-700 dark:bg-slate-950/50'>
- {/* Header */}
- <div className='border-b border-slate-200 bg-slate-50 px-3 py-1.5 dark:border-slate-700 dark:bg-slate-900/50'>
- <span className='text-[10px] font-semibold tracking-wide text-slate-500 uppercase dark:text-slate-400'>
- {t('project.properties')}
- </span>
- </div>
-
- {/* Table */}
- <div className='divide-y divide-slate-100 dark:divide-slate-800'>
+ <div className='mt-2 overflow-hidden rounded-md bg-gray-50/80 ring-1 ring-gray-200/80 dark:bg-slate-950/40 dark:ring-slate-700/60'>
+ <dl className='divide-y divide-gray-200/70 dark:divide-slate-800/80'>
{_map(displayedMetadata, ({ key, value }, index) => {
- const needsTruncation = _size(value) > 60
+ const needsTruncation = _size(value) > 80
const displayValue = needsTruncation
- ? _truncate(value, { length: 60 })
+ ? _truncate(value, { length: 80 })
: value
return (
<div
key={`${key}${value}${index}`}
- className='flex flex-col gap-1 px-3 py-2 transition-colors hover:bg-slate-50 sm:grid sm:grid-cols-[minmax(80px,auto)_1fr] sm:gap-3 dark:hover:bg-slate-900/30'
+ className='grid grid-cols-1 gap-1 px-3 py-2 sm:grid-cols-[minmax(96px,160px)_1fr] sm:gap-4'
>
- <div className='flex items-start'>
- <span className='font-mono text-[11px] font-medium text-slate-500 dark:text-slate-400'>
- {key}
- </span>
- </div>
- <div className='flex items-start'>
- <span
- className={cn(
- 'text-xs break-all text-slate-700 dark:text-slate-300',
- needsTruncation && 'cursor-help',
- )}
- title={needsTruncation ? value : undefined}
- >
- {displayValue}
- </span>
- </div>
+ <Text
+ as='dt'
+ size='xs'
+ weight='medium'
+ colour='muted'
+ tracking='tight'
+ className='font-mono leading-5'
+ >
+ {key}
+ </Text>
+ <Text
+ as='dd'
+ size='xs'
+ colour='secondary'
+ className={cn(
+ 'leading-5 wrap-break-word',
+ needsTruncation && 'cursor-help',
+ )}
+ title={needsTruncation ? value : undefined}
+ >
+ {displayValue}
+ </Text>
</div>
)
})}
- </div>
-
- {/* Show more button */}
+ </dl>
{hasMore ? (
- <button
+ <Text
+ as='button'
+ size='xs'
+ weight='medium'
+ colour='muted'
type='button'
onClick={() => setShowAll(!showAll)}
- className='w-full border-t border-slate-200 bg-slate-50 px-3 py-1.5 text-[11px] font-medium text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 dark:border-slate-700 dark:bg-slate-900/50 dark:text-slate-400 dark:hover:bg-slate-700/50 dark:hover:text-slate-300'
+ className='block w-full border-t border-gray-200/70 px-3 py-1.5 text-left transition-colors hover:bg-gray-100/70 hover:text-gray-700 focus-visible:ring-2 focus-visible:ring-slate-900 focus-visible:outline-none focus-visible:ring-inset dark:border-slate-800/80 dark:hover:bg-slate-900/60 dark:hover:text-gray-200 dark:focus-visible:ring-slate-300'
>
{showAll
? t('project.showLess')
: t('project.showMore', { count: remainingCount })}
- </button>
+ </Text>
) : null}
</div>
)
}
-const formatDuration = (seconds: number): string => {
- if (seconds <= 0) {
- return ''
+const formatAmount = (amount: number, currency?: string) => {
+ try {
+ return new Intl.NumberFormat('en-US', {
+ style: 'currency',
+ currency: currency || 'USD',
+ maximumFractionDigits: 2,
+ }).format(Math.abs(amount))
+ } catch {
+ return `${Math.abs(amount).toFixed(2)} ${currency || 'USD'}`
}
-
- return getStringFromTime(getTimeFromSeconds(seconds))
}
const PageflowItem = ({
+ index,
value,
created,
type,
metadata,
displayCreated,
timeDuration,
- isLastEvent,
t,
amount,
currency,
websiteUrl,
}: PageflowItemProps) => {
- // Construct full URL for pageview links
const fullPageUrl = useMemo(() => {
if (type !== 'pageview' || !value || !websiteUrl) return null
try {
@@ -159,200 +237,157 @@ const PageflowItem = ({
return null
}
}, [type, value, websiteUrl])
+
const [isExpanded, setIsExpanded] = useState(false)
- const hasMetadata = metadata && metadata.length > 0
+ const hasMetadata = !!metadata && metadata.length > 0
+ const isMonetary = type === 'sale' || type === 'refund'
+ const hasDuration = timeDuration !== null && timeDuration > 0
+ const showSubRow = hasDuration || hasMetadata
return (
- <li>
- <div className='relative pb-8'>
- {/* Solid line to next event OR dotted line to end of session */}
- {!isLastEvent ? (
- <span
- className='absolute top-4 left-4 -ml-px h-full w-0.5 bg-slate-200 dark:bg-slate-700'
- aria-hidden='true'
- />
- ) : (
- <span
- className='absolute top-4 left-4 -ml-px h-full w-0.5 border-l-2 border-dashed border-slate-200 dark:border-slate-700'
- aria-hidden='true'
- />
- )}
- <div className='relative flex space-x-3'>
- <div>
- <span
- className={cn(
- 'flex h-8 w-8 items-center justify-center rounded-full',
- {
- 'bg-slate-400 dark:bg-slate-900':
- type === 'pageview' || type === 'event',
- 'bg-red-400 dark:bg-red-800': type === 'error',
- 'bg-green-500 dark:bg-green-700': type === 'sale',
- 'bg-orange-500 dark:bg-orange-700': type === 'refund',
- },
- )}
- >
- {type === 'pageview' ? (
- <FileTextIcon
- className='h-5 w-5 text-white'
- aria-hidden='true'
- />
- ) : null}
- {type === 'event' ? (
- <CursorClickIcon
- className='h-5 w-5 text-white'
- aria-hidden='true'
- />
- ) : null}
- {type === 'error' ? (
- <WarningIcon
- className='h-5 w-5 text-white'
- aria-hidden='true'
- />
- ) : null}
- {type === 'sale' ? (
- <CurrencyDollarIcon
- className='h-5 w-5 text-white'
- aria-hidden='true'
- />
- ) : null}
- {type === 'refund' ? (
- <ArrowCounterClockwiseIcon
- className='h-5 w-5 text-white'
- aria-hidden='true'
- />
- ) : null}
- </span>
- </div>
- <div className='flex min-w-0 flex-1 flex-col pt-1.5'>
- <div className='flex flex-col gap-y-1 sm:flex-row sm:justify-between sm:space-x-4'>
- <div
- className={cn(
- 'flex flex-wrap items-center gap-x-1 text-sm text-gray-700 dark:text-gray-300',
- {
- 'cursor-pointer': hasMetadata,
- },
- )}
- onClick={
- hasMetadata ? () => setIsExpanded(!isExpanded) : undefined
- }
- // eslint-disable-next-line jsx-a11y/prefer-tag-over-role -- conditionally interactive, contains nested interactive elements
- role='button'
- tabIndex={hasMetadata ? 0 : undefined}
- onKeyDown={
- hasMetadata
- ? (e) => {
- if (e.target !== e.currentTarget) return
- if (e.key === 'Enter' || e.key === ' ') {
- e.preventDefault()
- setIsExpanded(!isExpanded)
- }
- }
- : undefined
- }
- >
- {type === 'sale' || type === 'refund' ? (
- <span className='flex items-center'>
- <span
- className={cn('font-semibold', {
- 'text-green-600 dark:text-green-400': type === 'sale',
- 'text-orange-600 dark:text-orange-400':
- type === 'refund',
- })}
- >
- {type === 'refund' ? '-' : ''}
- {new Intl.NumberFormat('en-US', {
- style: 'currency',
- currency: currency || 'USD',
- }).format(Math.abs(amount || 0))}
- </span>
- {value ? (
- <span className='ml-2 text-gray-500 dark:text-gray-400'>
- ({value})
- </span>
- ) : null}
- </span>
- ) : (
- <Trans
- t={t}
- i18nKey={
- type === 'pageview'
- ? 'project.pageviewX'
- : type === 'event'
- ? 'project.eventX'
- : 'project.errorX'
- }
- components={{
- value: fullPageUrl ? (
- <a
- href={fullPageUrl}
- target='_blank'
- rel='noopener noreferrer nofollow'
- onClick={(e) => e.stopPropagation()}
- className='ml-1 font-medium break-all text-gray-900 underline decoration-dashed underline-offset-2 hover:decoration-solid dark:text-gray-50'
- />
- ) : (
- <span className='ml-1 font-medium text-gray-900 dark:text-gray-50' />
- ),
- span: <span />,
- }}
- values={{
- x: value || _toUpper(t('common.notSet')),
- }}
- />
- )}
- {hasMetadata ? (
- <span className='ml-2 inline-flex shrink-0 items-center gap-0.5 rounded-full bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:bg-slate-700 dark:text-slate-400'>
- <TagIcon className='h-2.5 w-2.5' />
- {metadata!.length}
- </span>
- ) : null}
- {hasMetadata ? (
- <CaretDownIcon
- className={cn(
- 'ml-1 h-4 w-4 shrink-0 text-gray-400 transition-transform duration-200 dark:text-gray-500',
- isExpanded && 'rotate-180',
- )}
- aria-hidden='true'
- />
+ <li className='grid grid-cols-[28px_1fr] gap-x-3.5'>
+ <div className='flex flex-col items-center'>
+ <StepNumber number={index} />
+ <RailLine />
+ </div>
+
+ <div className='min-w-0 pb-6'>
+ <div className='flex min-h-7 items-center justify-between gap-3'>
+ <div className='flex min-w-0 items-center gap-2'>
+ <TypeIcon type={type} />
+ {isMonetary ? (
+ <div className='flex flex-wrap items-baseline gap-x-2 leading-4'>
+ <Text
+ size='sm'
+ weight='semibold'
+ colour={type === 'sale' ? 'success' : 'warning'}
+ className='leading-4 tabular-nums'
+ >
+ {type === 'refund' ? '−' : '+'}
+ {formatAmount(amount || 0, currency)}
+ </Text>
+ {value ? (
+ <Text size='xs' colour='muted'>
+ · {value}
+ </Text>
) : null}
</div>
- <div className='text-left text-xs whitespace-nowrap text-gray-500 sm:text-right sm:text-sm sm:text-gray-700 dark:text-gray-400 sm:dark:text-gray-300'>
- <time dateTime={created}>{displayCreated}</time>
- </div>
- </div>
+ ) : fullPageUrl ? (
+ <a
+ href={fullPageUrl}
+ target='_blank'
+ rel='noopener noreferrer nofollow'
+ className='leading-4 underline decoration-gray-300 decoration-dashed underline-offset-2 transition-colors hover:decoration-gray-500 dark:decoration-slate-600 dark:hover:decoration-slate-400'
+ >
+ <Text
+ size='sm'
+ weight='medium'
+ colour='primary'
+ className='leading-4 wrap-break-word'
+ >
+ {value}
+ </Text>
+ </a>
+ ) : (
+ <Text
+ size='sm'
+ weight='medium'
+ colour='primary'
+ className='leading-4 wrap-break-word'
+ >
+ {value || _toUpper(t('common.notSet'))}
+ </Text>
+ )}
+ </div>
+ <time dateTime={created} className='hidden shrink-0 sm:inline-block'>
+ <Text size='xs' colour='muted' className='tabular-nums'>
+ {displayCreated}
+ </Text>
+ </time>
+ </div>
- {/* Collapsible metadata */}
- {hasMetadata && isExpanded ? (
- <MetadataPanel metadata={metadata!} t={t} />
+ {showSubRow ? (
+ <div className='mt-1 flex flex-wrap items-center gap-x-3 gap-y-1.5 pl-6'>
+ {hasDuration ? <Duration seconds={timeDuration!} /> : null}
+ {hasMetadata ? (
+ <Text
+ as='button'
+ size='xs'
+ weight='medium'
+ colour='muted'
+ type='button'
+ aria-expanded={isExpanded}
+ onClick={() => setIsExpanded(!isExpanded)}
+ className='inline-flex items-center gap-1.5 rounded-md transition-colors hover:text-gray-800 focus-visible:ring-2 focus-visible:ring-slate-900 focus-visible:ring-offset-2 focus-visible:ring-offset-white focus-visible:outline-none dark:hover:text-gray-200 dark:focus-visible:ring-slate-300 dark:focus-visible:ring-offset-slate-900'
+ >
+ <span className='inline-flex items-center gap-1 rounded-full bg-gray-100 px-1.5 py-0.5 ring-1 ring-gray-200/80 dark:bg-slate-800 dark:ring-slate-700/70'>
+ <TagIcon className='h-2.5 w-2.5' aria-hidden />
+ <Text
+ as='span'
+ size='xxs'
+ colour='secondary'
+ className='tabular-nums'
+ >
+ {metadata!.length}
+ </Text>
+ </span>
+ <span>{t('project.properties')}</span>
+ <CaretDownIcon
+ className={cn(
+ 'h-3 w-3 transition-transform duration-200 ease-out motion-reduce:transition-none',
+ isExpanded && 'rotate-180',
+ )}
+ aria-hidden
+ />
+ </Text>
) : null}
+ </div>
+ ) : null}
- {/* Time duration to next step */}
- {timeDuration !== null && timeDuration > 0 ? (
- <div className='mt-1 flex items-center text-xs text-gray-500 dark:text-gray-400'>
- <svg
- className='mr-1 h-3 w-3'
- fill='none'
- stroke='currentColor'
- viewBox='0 0 24 24'
- xmlns='http://www.w3.org/2000/svg'
- >
- <circle cx='12' cy='12' r='10' strokeWidth='2' />
- <polyline
- points='12 6 12 12 16 14'
- strokeWidth='2'
- strokeLinecap='round'
- />
- </svg>
- {formatDuration(timeDuration)}
- </div>
- ) : null}
+ {hasMetadata && isExpanded ? (
+ <div className='pl-6'>
+ <MetadataPanel metadata={metadata!} t={t} />
</div>
- </div>
+ ) : null}
</div>
</li>
)
}
+const Terminator = ({ isLive, t }: { isLive?: boolean; t: TFunction }) => (
+ <li className='grid grid-cols-[28px_1fr] gap-x-3.5'>
+ <div className='flex flex-col items-center'>
+ <span
+ className={cn(
+ 'flex h-7 w-7 shrink-0 items-center justify-center rounded-full ring-1',
+ isLive
+ ? 'bg-red-50 ring-red-200 dark:bg-red-500/10 dark:ring-red-500/30'
+ : 'bg-gray-50 ring-gray-300 dark:bg-slate-900 dark:ring-slate-700/80',
+ )}
+ >
+ {isLive ? (
+ <span className='relative flex h-2 w-2'>
+ <span className='absolute inline-flex h-full w-full animate-ping rounded-full bg-red-400 opacity-75' />
+ <span className='relative inline-flex h-2 w-2 rounded-full bg-red-500' />
+ </span>
+ ) : (
+ <span className='h-1.5 w-1.5 rounded-full bg-gray-400 dark:bg-slate-500' />
+ )}
+ </span>
+ </div>
+ <div className='flex min-h-7 min-w-0 items-center'>
+ <Text
+ size='xs'
+ weight='medium'
+ tracking='tight'
+ colour={isLive ? 'error' : 'muted'}
+ >
+ {isLive ? t('project.sessionInProgress') : t('project.endOfSession')}
+ </Text>
+ </div>
+ </li>
+)
+
export const Pageflow = ({
pages,
timeFormat,
@@ -367,13 +402,8 @@ export const Pageflow = ({
} = useTranslation('common')
const filteredPages = useMemo(() => {
- if (!pages) {
- return []
- }
-
- if (!zoomedTimeRange) {
- return pages
- }
+ if (!pages) return []
+ if (!zoomedTimeRange) return pages
return pages.filter((page) => {
const pageTime = new Date(page.created).getTime()
@@ -384,135 +414,88 @@ export const Pageflow = ({
})
}, [pages, zoomedTimeRange])
- // Calculate time between events
const timeBetweenEvents = useMemo(() => {
- if (filteredPages.length < 2) {
- return []
- }
-
+ if (filteredPages.length < 2) return []
const times: number[] = []
for (let i = 0; i < filteredPages.length - 1; i++) {
const currentTime = new Date(filteredPages[i].created).getTime()
const nextTime = new Date(filteredPages[i + 1].created).getTime()
- const diffSeconds = Math.round((nextTime - currentTime) / 1000)
- times.push(diffSeconds)
+ times.push(Math.round((nextTime - currentTime) / 1000))
}
return times
}, [filteredPages])
- // Calculate time remaining after the last event
const timeAfterLastEvent = useMemo(() => {
- if (sdur <= 0 || filteredPages.length === 0) {
- return 0
- }
-
+ if (sdur <= 0 || filteredPages.length === 0) return 0
const firstEventTime = new Date(filteredPages[0].created).getTime()
const lastEventTime = new Date(
filteredPages[filteredPages.length - 1].created,
).getTime()
- const timeBetweenFirstAndLast = Math.round(
- (lastEventTime - firstEventTime) / 1000,
- )
- const remaining = sdur - timeBetweenFirstAndLast
-
+ const remaining = sdur - Math.round((lastEventTime - firstEventTime) / 1000)
return remaining > 0 ? remaining : 0
}, [filteredPages, sdur])
if (zoomedTimeRange && _isEmpty(filteredPages)) {
return (
- <div className='my-4 py-8 text-center text-gray-800 dark:text-gray-300'>
- {t('project.noEventsForSelectedPeriod')}
+ <div className='flex flex-col items-center justify-center gap-2 px-6 py-10 text-center'>
+ <ClockCounterClockwiseIcon
+ className='h-6 w-6 text-gray-400 dark:text-slate-500'
+ aria-hidden
+ />
+ <Text as='p' size='sm' colour='secondary' className='max-w-xs'>
+ {t('project.noEventsForSelectedPeriod')}
+ </Text>
</div>
)
}
+ if (_isEmpty(filteredPages)) {
+ return null
+ }
+
return (
- <div className='flow-root'>
- <ul className='-mb-8'>
- {_map(
- filteredPages,
- ({ value, created, type, metadata, amount, currency }, index) => {
- const displayCreated = new Date(created).toLocaleDateString(
- language,
- {
- day: 'numeric',
- month: 'short',
- hour: 'numeric',
- minute: 'numeric',
- second: 'numeric',
- hourCycle: timeFormat === '12-hour' ? 'h12' : 'h23',
- },
- )
-
- const isLastEvent = index === filteredPages.length - 1
- // For the last event, show the remaining time (sdur - time between first and last event)
- // as "time spent on the last event" under the last item rather than under "End of session".
- const timeDuration = !isLastEvent
- ? timeBetweenEvents[index]
- : timeAfterLastEvent > 0
- ? timeAfterLastEvent
- : null
-
- return (
- <PageflowItem
- key={`${value}${created}${index}`}
- value={value}
- created={created}
- type={type}
- metadata={metadata}
- displayCreated={displayCreated}
- timeDuration={timeDuration}
- isLastEvent={isLastEvent}
- t={t}
- amount={amount}
- currency={currency}
- websiteUrl={websiteUrl}
- />
- )
- },
- )}
+ <ol className='relative'>
+ {_map(
+ filteredPages,
+ ({ value, created, type, metadata, amount, currency }, index) => {
+ const displayCreated = new Date(created).toLocaleDateString(
+ language,
+ {
+ day: 'numeric',
+ month: 'short',
+ hour: 'numeric',
+ minute: 'numeric',
+ second: 'numeric',
+ hourCycle: timeFormat === '12-hour' ? 'h12' : 'h23',
+ },
+ )
- {/* End of session / active session marker */}
- {filteredPages.length > 0 ? (
- <li>
- <div className='relative pb-8'>
- <div className='relative flex space-x-3'>
- <div>
- {isLive ? (
- <span className='flex h-8 w-8 items-center justify-center rounded-full border-2 border-red-300 bg-white dark:border-red-600 dark:bg-slate-950'>
- <span className='h-2.5 w-2.5 animate-pulse rounded-full bg-red-500' />
- </span>
- ) : (
- <span className='flex h-8 w-8 items-center justify-center rounded-full border-2 border-slate-300 bg-white dark:border-slate-600 dark:bg-slate-950'>
- <CircleIcon
- className='h-3 w-3 text-slate-400 dark:text-slate-500'
- aria-hidden='true'
- fill='currentColor'
- />
- </span>
- )}
- </div>
- <div className='flex min-w-0 flex-1 flex-col pt-1.5'>
- <div className='flex justify-between space-x-4'>
- <div
- className={cn(
- 'text-sm font-medium',
- isLive
- ? 'text-red-500 dark:text-red-400'
- : 'text-gray-500 dark:text-gray-400',
- )}
- >
- {isLive
- ? t('project.sessionInProgress')
- : t('project.endOfSession')}
- </div>
- </div>
- </div>
- </div>
- </div>
- </li>
- ) : null}
- </ul>
- </div>
+ const isLastEvent = index === filteredPages.length - 1
+ const timeDuration = !isLastEvent
+ ? timeBetweenEvents[index]
+ : timeAfterLastEvent > 0
+ ? timeAfterLastEvent
+ : null
+
+ return (
+ <PageflowItem
+ key={`${value}${created}${index}`}
+ index={index + 1}
+ value={value}
+ created={created}
+ type={type}
+ metadata={metadata}
+ displayCreated={displayCreated}
+ timeDuration={timeDuration}
+ t={t}
+ amount={amount}
+ currency={currency}
+ websiteUrl={websiteUrl}
+ />
+ )
+ },
+ )}
+ <Terminator isLive={isLive} t={t} />
+ </ol>
)
}