-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(replay): show screen name in url bar for mobile replays
- Loading branch information
1 parent
3e90887
commit 74e7210
Showing
5 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {useMemo} from 'react'; | ||
import * as Sentry from '@sentry/react'; | ||
|
||
import {useReplayContext} from 'sentry/components/replays/replayContext'; | ||
import TextCopyInput from 'sentry/components/textCopyInput'; | ||
import {t} from 'sentry/locale'; | ||
import getCurrentScreenName from 'sentry/utils/replays/getCurrentScreenName'; | ||
|
||
// Screen name component for video/mobile replays - mirrors replayCurrentUrl.tsx | ||
function ReplayCurrentScreen() { | ||
const {currentTime, replay} = useReplayContext(); | ||
const frames = replay?.getMobileNavigationFrames(); | ||
|
||
const screenName = useMemo(() => { | ||
try { | ||
return getCurrentScreenName(frames, currentTime); | ||
} catch (err) { | ||
Sentry.captureException(err); | ||
return ''; | ||
} | ||
}, [frames, currentTime]); | ||
|
||
if (!replay || !screenName) { | ||
return ( | ||
<TextCopyInput aria-label={t('Current Screen Name')} size="sm" disabled> | ||
{''} | ||
</TextCopyInput> | ||
); | ||
} | ||
|
||
return ( | ||
<TextCopyInput aria-label={t('Current Screen Name')} size="sm"> | ||
{screenName} | ||
</TextCopyInput> | ||
); | ||
} | ||
|
||
export default ReplayCurrentScreen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type {BreadcrumbFrame} from 'sentry/utils/replays/types'; | ||
|
||
// Gets the current screen name for video/mobile replays - mirrors getCurrentUrl.tsx | ||
function getCurrentScreenName( | ||
frames: undefined | BreadcrumbFrame[], | ||
currentOffsetMS: number | ||
) { | ||
const framesBeforeCurrentOffset = frames?.filter( | ||
frame => frame.offsetMs < currentOffsetMS | ||
); | ||
|
||
const mostRecentFrame = framesBeforeCurrentOffset?.at(-1) ?? frames?.at(0); | ||
if (!mostRecentFrame) { | ||
return ''; | ||
} | ||
|
||
return mostRecentFrame.data.to; | ||
} | ||
|
||
export default getCurrentScreenName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters