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 link display

Blue Mousefb9da11f0600
diff --git a/web/app/pages/Project/tabs/Traffic/RefRow.tsx b/web/app/pages/Project/tabs/Traffic/RefRow.tsx
index 2811ae408..07868d735 100644
--- a/web/app/pages/Project/tabs/Traffic/RefRow.tsx
+++ b/web/app/pages/Project/tabs/Traffic/RefRow.tsx
@@ -1,4 +1,4 @@
-import { LinkIcon } from 'lucide-react'
+import { ExternalLinkIcon, LinkIcon } from 'lucide-react'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
@@ -7,22 +7,20 @@ import { getFaviconHost } from '~/utils/referrers'
const RefRow = ({ rowName }: { rowName: string | null }) => {
const { t } = useTranslation('common')
- const { isUrl, faviconHost } = useMemo(() => {
- if (!rowName) return { isUrl: false, faviconHost: null as string | null }
+ const { isUrl, faviconHost, displayRowName } = useMemo(() => {
+ if (!rowName) return { isUrl: false, faviconHost: null as string | null, displayRowName: '' }
let isUrl = false
try {
- // If it parses, we treat it as a URL for linking
- // Favicon host will be derived by the util anyway
- // from either the URL, a hostname string or a mapped group name
new URL(rowName)
isUrl = true
} catch {
isUrl = false
}
- return { isUrl, faviconHost: getFaviconHost(rowName) }
- }, [rowName])
- const linkClassName = 'text-blue-600 hover:underline dark:text-blue-500'
+ const displayRowName = rowName.replace(/^https?:\/\//, '').replace(/\/$/, '')
+
+ return { isUrl, faviconHost: getFaviconHost(rowName), displayRowName }
+ }, [rowName])
if (rowName === null) {
return (
@@ -34,7 +32,7 @@ const RefRow = ({ rowName }: { rowName: string | null }) => {
}
return (
- <div className='scrollbar-thin hover-always-overflow flex items-center'>
+ <div className='scrollbar-thin hover-always-overflow flex min-w-0 items-center'>
{faviconHost ? (
<img
className='float-left mr-1.5 size-5'
@@ -44,20 +42,22 @@ const RefRow = ({ rowName }: { rowName: string | null }) => {
aria-hidden='true'
/>
) : null}
+ <span className='truncate text-sm text-gray-900 dark:text-gray-100'>{displayRowName}</span>
{isUrl ? (
<a
- className={linkClassName}
href={rowName}
target='_blank'
rel='noopener noreferrer nofollow'
onClick={(e) => e.stopPropagation()}
aria-label={`${rowName} (opens in a new tab)`}
+ className='ml-1 shrink-0 rounded-md p-1 text-gray-800 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-slate-700'
>
- {rowName}
+ <ExternalLinkIcon
+ className='size-3.5 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100'
+ strokeWidth={2}
+ />
</a>
- ) : (
- <span>{rowName}</span>
- )}
+ ) : null}
</div>
)
}