📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Session replays: add an option to skip inactive moments
Blue Mouse09e0cc5ed52a
diff --git a/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx b/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsxindex 85897a60f..94405ee83 100644--- a/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx+++ b/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx@@ -13,6 +13,7 @@ import {CornersOutIcon,CursorClickIcon,DownloadSimpleIcon,+ FastForwardIcon,GaugeIcon,GearSixIcon,ListBulletsIcon,@@ -88,6 +89,7 @@ const XHTML_XMLNS = 'http://www.w3.org/1999/xhtml'const SCREENSHOT_ASSET_WAIT_MS = 1000const EXPORT_POLL_INTERVAL_MS = 2000const PLAYER_READY_FALLBACK_MS = 8000+const INACTIVE_SKIP_THRESHOLD_MS = 10_000type ReplayEvent = Omit<eventWithTime, 'data'> & {data?: Record<string, any>@@ -1046,6 +1048,7 @@ const SessionReplayModal = ({const [isPlaying, setIsPlaying] = useState(false)const [isPlayerReady, setIsPlayerReady] = useState(false)const [speed, setSpeed] = useState(1)+ const [skipInactive, setSkipInactive] = useState(true)const [showTimeline, setShowTimeline] = useState(false)const [isFullscreen, setIsFullscreen] = useState(false)const [hoverPreview, setHoverPreview] = useState<HoverPreview | null>(null)@@ -1072,9 +1075,9 @@ const SessionReplayModal = ({const exportPollTimeout = useRef<number | null>(null)const exportAbortController = useRef<AbortController | null>(null)const isModalOpenRef = useRef(isOpen)- const playStart = useRef({ offset: 0, at: 0, speed: 1 })const currentTimeRef = useRef(0)const speedRef = useRef(1)+ const skipInactiveRef = useRef(true)const events = useMemo(() => (payload?.events || []) as ReplayEvent[],@@ -1229,12 +1232,15 @@ const SessionReplayModal = ({setError(null)setDuration(0)setCurrentTime(0)+ currentTimeRef.current = 0setIsPlaying(false)setIsPlayerReady(false)+ setSkipInactive(true)setHoverPreview(null)setIsPlayerHovered(false)setIsControlsFocused(false)setPlayerSize({ width: 0, height: 0 })+ skipInactiveRef.current = truefetchSessionReplay(projectId, psid, selectedReplayId).then((result) => {@@ -1270,6 +1276,7 @@ const SessionReplayModal = ({setIsPlaying(false)setIsPlayerReady(false)setCurrentTime(0)+ currentTimeRef.current = 0let instance: Replayer | null = nulllet readyFallback: number | null = nulllet readyRaf: number | null = null@@ -1291,6 +1298,8 @@ const SessionReplayModal = ({instance = new Replayer(events as eventWithTime[], {root,speed: speedRef.current,+ skipInactive: skipInactiveRef.current,+ inactivePeriodThreshold: INACTIVE_SKIP_THRESHOLD_MS,insertStyleRules: ['html, body { background-color: #fff; }'],})instance.on(ReplayerEvents.FullsnapshotRebuilded, markPlayerReady)@@ -1382,10 +1391,15 @@ const SessionReplayModal = ({if (!isOpen || !isPlaying || duration <= 0) returnconst timer = window.setInterval(() => {- const elapsed =- (performance.now() - playStart.current.at) * playStart.current.speed- const next = Math.min(duration, playStart.current.offset + elapsed)+ const next = Math.min(+ duration,+ Math.max(+ 0,+ replayer.current?.getCurrentTime() ?? currentTimeRef.current,+ ),+ )setCurrentTime(next)+ currentTimeRef.current = nextif (next >= duration) {replayer.current?.pause(duration)@@ -1455,9 +1469,10 @@ const SessionReplayModal = ({const syncPlaybackOffset = useCallback(() => {if (!isPlaying) return currentTimeRef.current- const elapsed =- (performance.now() - playStart.current.at) * playStart.current.speed- return Math.min(duration, playStart.current.offset + elapsed)+ return Math.min(+ duration,+ Math.max(0, replayer.current?.getCurrentTime() ?? currentTimeRef.current),+ )}, [duration, isPlaying])const play = useCallback(() => {@@ -1465,9 +1480,10 @@ const SessionReplayModal = ({const offset = Math.min(currentTimeRef.current, Math.max(0, duration - 1))replayer.current.play(offset)- playStart.current = { offset, at: performance.now(), speed }+ setCurrentTime(offset)+ currentTimeRef.current = offsetsetIsPlaying(true)- }, [duration, speed])+ }, [duration])const pause = useCallback(() => {if (!replayer.current) return@@ -1475,6 +1491,7 @@ const SessionReplayModal = ({const offset = syncPlaybackOffset()replayer.current.pause(offset)setCurrentTime(offset)+ currentTimeRef.current = offsetsetIsPlaying(false)}, [syncPlaybackOffset])@@ -1504,17 +1521,12 @@ const SessionReplayModal = ({currentTimeRef.current = nextOffsetif (shouldPlay) {- playStart.current = {- offset: nextOffset,- at: performance.now(),- speed,- }setIsPlaying(true)} else {setIsPlaying(false)}},- [duration, isPlaying, speed],+ [duration, isPlaying],)const handlePlayerClick = useCallback(@@ -1597,17 +1609,22 @@ const SessionReplayModal = ({setSpeed(nextSpeed)replayer.current?.setConfig({ speed: nextSpeed })setCurrentTime(offset)+ currentTimeRef.current = offsetif (isPlaying) {replayer.current?.play(offset)- playStart.current = {- offset,- at: performance.now(),- speed: nextSpeed,- }}}+ const setSkipInactiveMoments = (checked: boolean) => {+ skipInactiveRef.current = checked+ setSkipInactive(checked)+ replayer.current?.setConfig({+ skipInactive: checked,+ inactivePeriodThreshold: INACTIVE_SKIP_THRESHOLD_MS,+ })+ }+const toggleFullscreen = async () => {try {if (document.fullscreenElement) {@@ -2250,6 +2267,37 @@ const SessionReplayModal = ({/></Button>+ <Button+ variant='ghost'+ focus={false}+ role='switch'+ aria-checked={skipInactive}+ tabIndex={0}+ onClick={() =>+ setSkipInactiveMoments(!skipInactive)+ }+ className={SETTINGS_ROW_CLASS}+ >+ <FastForwardIcon+ weight='duotone'+ className='size-5 shrink-0 text-gray-50'+ aria-hidden+ />+ <Text+ as='span'+ size='sm'+ colour='primary'+ className='dark flex-1'+ >+ {t('project.sessionReplay.skipInactive')}+ </Text>+ <Switch+ checked={skipInactive}+ visualOnly+ className='shrink-0'+ />+ </Button>+<Buttonvariant='ghost'focus={false}diff --git a/web/public/locales/de.json b/web/public/locales/de.jsonindex 2c25c9ae5..85161f232 100644--- a/web/public/locales/de.json+++ b/web/public/locales/de.json@@ -2015,6 +2015,7 @@"settings": "Einstellungen","speed": "Wiedergabegeschwindigkeit","normalSpeed": "Normal",+ "skipInactive": "Inaktive Momente überspringen","screenshot": "Screenshot herunterladen","screenshotError": "Dieser Replay-Frame konnte nicht aufgenommen werden. Cross-Origin-Medien können Screenshots blockieren.","screenshotDownloaded": "Replay-Screenshot heruntergeladen",diff --git a/web/public/locales/en.json b/web/public/locales/en.jsonindex c0f627a98..67e5ff64c 100644--- a/web/public/locales/en.json+++ b/web/public/locales/en.json@@ -2015,6 +2015,7 @@"settings": "Settings","speed": "Playback speed","normalSpeed": "Normal",+ "skipInactive": "Skip inactive moments","screenshot": "Download screenshot","screenshotError": "Could not capture this replay frame. Cross-origin media can block screenshots.","screenshotDownloaded": "Replay screenshot downloaded",diff --git a/web/public/locales/fr.json b/web/public/locales/fr.jsonindex 8d4fce41f..6ca3ea4ab 100644--- a/web/public/locales/fr.json+++ b/web/public/locales/fr.json@@ -2015,6 +2015,7 @@"settings": "Paramètres","speed": "Vitesse de lecture","normalSpeed": "Normal",+ "skipInactive": "Passer les moments inactifs","screenshot": "Télécharger la capture d'écran","screenshotError": "Impossible de capturer cette image du replay. Les médias cross-origin peuvent bloquer les captures d'écran.","screenshotDownloaded": "Capture d'écran du replay téléchargée",diff --git a/web/public/locales/pl.json b/web/public/locales/pl.jsonindex f87d06e64..1de37a271 100644--- a/web/public/locales/pl.json+++ b/web/public/locales/pl.json@@ -2015,6 +2015,7 @@"settings": "Ustawienia","speed": "Prędkość odtwarzania","normalSpeed": "Normalna",+ "skipInactive": "Pomiń nieaktywne momenty","screenshot": "Pobierz zrzut ekranu","screenshotError": "Nie udało się przechwycić tej klatki nagrania. Multimedia z innych źródeł (cross-origin) mogą blokować zrzuty ekranu.","screenshotDownloaded": "Pobrano zrzut ekranu nagrania",diff --git a/web/public/locales/uk.json b/web/public/locales/uk.jsonindex cc62e6743..841263b5f 100644--- a/web/public/locales/uk.json+++ b/web/public/locales/uk.json@@ -2015,6 +2015,7 @@"settings": "Налаштування","speed": "Швидкість відтворення","normalSpeed": "Звичайна",+ "skipInactive": "Пропускати неактивні моменти","screenshot": "Завантажити скриншот","screenshotError": "Не вдалося зробити скриншот цього кадру. Медіа з інших доменів (cross-origin) можуть блокувати скриншоти.","screenshotDownloaded": "Скриншот запису завантажено",