mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-10-30 14:49:14 +00:00
75 lines
2.3 KiB
TypeScript
75 lines
2.3 KiB
TypeScript
import {useMemo} from 'react';
|
|
import * as Sentry from '@sentry/react';
|
|
|
|
import ExternalLink from 'sentry/components/links/externalLink';
|
|
import Link from 'sentry/components/links/link';
|
|
import {useReplayContext} from 'sentry/components/replays/replayContext';
|
|
import TextCopyInput from 'sentry/components/textCopyInput';
|
|
import {Tooltip} from 'sentry/components/tooltip';
|
|
import {t, tct} from 'sentry/locale';
|
|
import getCurrentUrl from 'sentry/utils/replays/getCurrentUrl';
|
|
import useProjects from 'sentry/utils/useProjects';
|
|
|
|
function ReplayCurrentUrl() {
|
|
const {currentTime, replay} = useReplayContext();
|
|
const replayRecord = replay?.getReplay();
|
|
const frames = replay?.getNavigationFrames();
|
|
const projId = replayRecord?.project_id;
|
|
const {projects} = useProjects();
|
|
const projSlug = projects.find(p => p.id === projId)?.slug ?? undefined;
|
|
|
|
const url = useMemo(() => {
|
|
try {
|
|
return getCurrentUrl(replayRecord, frames, currentTime);
|
|
} catch (err) {
|
|
Sentry.captureException(err);
|
|
return '';
|
|
}
|
|
}, [replayRecord, frames, currentTime]);
|
|
|
|
if (!replay || !url) {
|
|
return (
|
|
<TextCopyInput aria-label={t('Current URL')} size="sm" disabled>
|
|
{''}
|
|
</TextCopyInput>
|
|
);
|
|
}
|
|
|
|
if (url.includes('[Filtered]')) {
|
|
return (
|
|
<Tooltip
|
|
title={tct(
|
|
"Funny looking URL? It contains content scrubbed by our [filters] and may no longer be valid. This is to protect your users' privacy. If necessary, you can turn this off in your [settings].",
|
|
{
|
|
filters: (
|
|
<ExternalLink href="https://docs.sentry.io/product/data-management-settings/scrubbing/server-side-scrubbing/">
|
|
{'Data Scrubber'}
|
|
</ExternalLink>
|
|
),
|
|
settings: projSlug ? (
|
|
<Link to={`/settings/projects/${projSlug}/security-and-privacy/`}>
|
|
{'Settings, under Security & Privacy'}
|
|
</Link>
|
|
) : (
|
|
'Settings, under Security & Privacy'
|
|
),
|
|
}
|
|
)}
|
|
isHoverable
|
|
>
|
|
<TextCopyInput aria-label={t('Current URL')} size="sm">
|
|
{url}
|
|
</TextCopyInput>
|
|
</Tooltip>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<TextCopyInput aria-label={t('Current URL')} size="sm">
|
|
{url}
|
|
</TextCopyInput>
|
|
);
|
|
}
|
|
|
|
export default ReplayCurrentUrl;
|