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!

(feature) Errors tracking (#404)

Andrii Romasiun0854a487d8e3
diff --git a/app/App.tsx b/app/App.tsx
index 26e0cc047..751dd94b1 100644
--- a/app/App.tsx
+++ b/app/App.tsx
@@ -107,9 +107,9 @@ const App: React.FC<IApp> = ({ ssrTheme, ssrAuthenticated }) => {
return (
// eslint-disable-next-line react/jsx-no-useless-fragment
<>
- {pathname !== routesPath.main && pathname !== routesPath.performance && !isReferralPage && !isProjectViewPage && (
- <Header ssrTheme={ssrTheme} authenticated={authenticated} />
- )}
+ {!_includes([routesPath.main, routesPath.performance, routesPath.errorTracking], pathname) &&
+ !isReferralPage &&
+ !isProjectViewPage && <Header ssrTheme={ssrTheme} authenticated={authenticated} />}
<Outlet />
{!isReferralPage && !isProjectViewPage && <Footer minimal={isMinimalFooter} authenticated={authenticated} />}
</>
diff --git a/app/api/index.ts b/app/api/index.ts
index b331360ed..b1ae0438b 100644
--- a/app/api/index.ts
+++ b/app/api/index.ts
@@ -508,6 +508,35 @@ export const getSessions = (
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
+export const getErrors = (
+ pid: string,
+ period: string = '3d',
+ filters: string[] = [],
+ options: any = {},
+ from: string = '',
+ to: string = '',
+ take: number = 30,
+ skip: number = 0,
+ timezone: string = '',
+ password: string | undefined = '',
+) =>
+ api
+ .get(
+ `log/errors?pid=${pid}&take=${take}&skip=${skip}&period=${period}&filters=${JSON.stringify(
+ filters,
+ )}&options=${JSON.stringify(options)}&from=${from}&to=${to}&timezone=${timezone}`,
+ {
+ headers: {
+ 'x-password': password,
+ },
+ },
+ )
+ .then((response) => response.data)
+ .catch((error) => {
+ debug('%s', error)
+ throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
+ })
+
export const getSession = (pid: string, psid: string, timezone: string = '', password: string | undefined = '') =>
api
.get(`log/session?pid=${pid}&psid=${psid}&timezone=${timezone}`, {
@@ -521,6 +550,27 @@ export const getSession = (pid: string, psid: string, timezone: string = '', pas
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
+export const getError = (
+ pid: string,
+ eid: string,
+ period: string = '7d',
+ from: string = '',
+ to: string = '',
+ timezone: string = '',
+ password: string | undefined = '',
+) =>
+ api
+ .get(`log/get-error?pid=${pid}&eid=${eid}&period=${period}&from=${from}&to=${to}&timezone=${timezone}`, {
+ headers: {
+ 'x-password': password,
+ },
+ })
+ .then((response) => response.data)
+ .catch((error) => {
+ debug('%s', error)
+ throw error.response
+ })
+
export const getFunnelData = (
pid: string,
period: string = '3d',
@@ -1188,6 +1238,19 @@ export const getFilters = (pid: string, type: string, password = '') =>
throw error
})
+export const getErrorsFilters = (pid: string, type: string, password = '') =>
+ api
+ .get(`log/errors-filters?pid=${pid}&type=${type}`, {
+ headers: {
+ 'x-password': password,
+ },
+ })
+ .then((response): string[] => response.data)
+ .catch((error) => {
+ debug('%s', error)
+ throw error
+ })
+
export const resetFilters = (pid: string, type: string, filters: string[]) =>
api
.delete(`project/reset-filters/${pid}?type=${type}&filters=${JSON.stringify(filters)}`)
@@ -1302,3 +1365,12 @@ export const unsubscribeFromEmailReports3rdParty = (token: string) =>
debug('%s', error)
throw error
})
+
+export const updateErrorStatus = (pid: string, status: 'resolved' | 'active', eid?: string, eids?: string[]) =>
+ api
+ .patch('log/error-status', { pid, eid, eids, status })
+ .then((response): any => response.data)
+ .catch((error) => {
+ debug('%s', error)
+ throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
+ })
diff --git a/app/pages/ErrorTracking/index.tsx b/app/pages/ErrorTracking/index.tsx
new file mode 100644
index 000000000..06666e826
--- /dev/null
+++ b/app/pages/ErrorTracking/index.tsx
@@ -0,0 +1,363 @@
+import { Link } from '@remix-run/react'
+import React, { memo } from 'react'
+import { useTranslation, Trans } from 'react-i18next'
+import { useSelector } from 'react-redux'
+import { ClientOnly } from 'remix-utils/client-only'
+import { ArrowTopRightOnSquareIcon, ArrowSmallRightIcon, ChevronRightIcon } from '@heroicons/react/24/solid'
+import _map from 'lodash/map'
+import _isEmpty from 'lodash/isEmpty'
+
+import routesPath from 'routesPath'
+import { getAccessToken } from 'utils/accessToken'
+import { nFormatterSeparated } from 'utils/generic'
+import { ERROR_TRACKING_LIVE_DEMO_URL, isBrowser } from 'redux/constants'
+import { StateType } from 'redux/store/index'
+import BackgroundSvg from 'ui/icons/BackgroundSvg'
+
+import Header from 'components/Header'
+import Pricing from '../MainPage/Pricing'
+
+export const Lines = (): JSX.Element => (
+ <div className='relative pointer-events-none'>
+ <div className='absolute rotate-6 right-[-48rem] top-[32rem] h-px w-[800%] bg-gradient-to-l from-slate-600 dark:from-slate-400 opacity-10' />
+ <div className='absolute rotate-[96deg] top-[22.26rem] xl:top-[23.5rem] -left-60 ml-[-0.5px] h-96 w-[2px] rounded-full bg-gradient-to-t from-red-600 dark:from-red-700 opacity-50' />
+ </div>
+)
+
+interface IErrorTracking {
+ ssrTheme: 'dark' | 'light'
+ ssrAuthenticated: boolean
+}
+
+const ErrorTracking: React.FC<IErrorTracking> = ({ ssrTheme, ssrAuthenticated }): JSX.Element => {
+ const {
+ t,
+ i18n: { language },
+ } = useTranslation('common')
+ const reduxTheme = useSelector((state: StateType) => state.ui.theme.theme)
+ const { authenticated: reduxAuthenticated, loading } = useSelector((state: StateType) => state.auth)
+ const { stats, lastBlogPost } = useSelector((state: StateType) => state.ui.misc)
+ const theme = isBrowser ? reduxTheme : ssrTheme
+ const accessToken = getAccessToken()
+ const authenticated = isBrowser ? (loading ? !!accessToken : reduxAuthenticated) : ssrAuthenticated
+
+ const events = nFormatterSeparated(Number(stats.events))
+ const users = nFormatterSeparated(Number(stats.users))
+ const websites = nFormatterSeparated(Number(stats.projects))
+
+ return (
+ <div className='overflow-hidden'>
+ <main className='bg-white dark:bg-slate-900'>
+ {/* first block with live demo */}
+ <div className='relative overflow-x-clip isolate'>
+ <svg
+ className='absolute inset-0 -z-10 h-full w-full stroke-gray-200 dark:stroke-white/10 [mask-image:radial-gradient(100%_100%_at_top_right,white,transparent)]'
+ aria-hidden='true'
+ >
+ <defs>
+ <pattern id='rect-pattern' width={200} height={200} x='50%' y={-1} patternUnits='userSpaceOnUse'>
+ <path d='M.5 200V.5H200' fill='none' />
+ </pattern>
+ </defs>
+ <svg x='50%' y={-1} className='overflow-visible fill-white dark:fill-gray-800/20'>
+ <path
+ d='M-200 0h201v201h-201Z M600 0h201v201h-201Z M-400 600h201v201h-201Z M200 800h201v201h-201Z'
+ strokeWidth={0}
+ />
+ </svg>
+ <rect width='100%' height='100%' strokeWidth={0} fill='url(#rect-pattern)' />
+ </svg>
+ <div
+ className='absolute left-[calc(50%-4rem)] top-10 -z-10 transform-gpu blur-3xl sm:left-[calc(50%-18rem)] lg:left-48 lg:top-[calc(50%-30rem)] xl:left-[calc(50%-24rem)]'
+ aria-hidden='true'
+ >
+ <div
+ className='aspect-[1108/632] w-[69.25rem] bg-gradient-to-r from-[#80caff] to-[#4f46e5] opacity-20'
+ style={{
+ clipPath:
+ 'polygon(73.6% 51.7%, 91.7% 11.8%, 100% 46.4%, 97.4% 82.2%, 92.5% 84.9%, 75.7% 64%, 55.3% 47.5%, 46.5% 49.4%, 45% 62.9%, 50.3% 87.2%, 21.3% 64.1%, 0.1% 100%, 5.4% 51.1%, 21.4% 63.9%, 58.9% 0.2%, 73.6% 51.7%)',
+ }}
+ />
+ </div>
+ <Header ssrTheme={ssrTheme} authenticated={authenticated} transparent />
+ <div className='flex justify-center items-center py-2 px-2'>
+ <a
+ href='https://u24.gov.ua/'
+ target='_blank'
+ rel='noreferrer noopener'
+ className='text-slate-900 dark:text-white border-transparent border-b-2 hover:border-slate-900 dark:hover:border-white text-center'
+ >
+ {t('main.ukrSupport')}
+ </a>
+ <ArrowTopRightOnSquareIcon className='h-4 w-4 text-slate-800 dark:text-white ml-1 hidden md:block' />
+ </div>
+ <div className='relative pt-10 lg:pt-24 pb-5 xl:px-8 lg:px-6 sm:px-3 mx-auto min-h-[740px]'>
+ <div className='relative z-20 flex flex-row content-between 2xl:mr-[14vw] 2xl:justify-center justify-center lg:justify-start'>
+ <div className='lg:mt-0 text-left relative lg:mr-14 px-4'>
+ <h1 className='max-w-2xl text-3xl sm:text-5xl md:text-5xl font-extrabold text-slate-900 dark:text-white sm:leading-none lg:text-5xl xl:text-6xl xl:leading-[110%]'>
+ <Trans
+ // @ts-ignore
+ t={t}
+ i18nKey='errors.slogan'
+ components={{
+ span: (
+ <span className='from-red-700 to-red-700 dark:from-red-600 dark:to-red-400 text-transparent bg-clip-text bg-gradient-to-r' />
+ ),
+ }}
+ />
+ </h1>
+ <div className='flex items-center overflow-hidden mt-2 mb-2 sm:text-xl lg:text-lg xl:text-lg'>
+ <p className='rounded-full bg-indigo-500/10 px-3 py-1 text-sm text-center font-semibold leading-6 text-indigo-600 dark:text-indigo-400 ring-1 ring-inset ring-indigo-500/20'>
+ Latest news
+ </p>
+ {_isEmpty(lastBlogPost) ? (
+ <div className='h-6 ml-1 bg-slate-300 dark:bg-slate-700 w-full max-w-xs rounded-md animate-pulse' />
+ ) : (
+ <ClientOnly
+ fallback={
+ <div className='h-6 ml-1 bg-slate-300 dark:bg-slate-700 w-full max-w-xs rounded-md animate-pulse' />
+ }
+ >
+ {() => (
+ <Link
+ className='inline-flex ml-1 items-center space-x-1 text-sm font-semibold leading-6 text-slate-700 dark:text-slate-300 hover:underline'
+ to={`blog/${lastBlogPost.handle}`}
+ >
+ <small className='text-sm'>{lastBlogPost.title}</small>
+ <ChevronRightIcon className='h-4 w-4 text-slate-500' aria-hidden='true' />
+ </Link>
+ )}
+ </ClientOnly>
+ )}
+ </div>
+ <p className='text-base leading-8 text-slate-900 dark:text-slate-300 sm:text-xl lg:text-lg xl:text-lg'>
+ {t('errors.description')}
+ <br />
+ {t('main.trackEveryMetric')}
+ </p>
+ <div className='mt-10 flex flex-col items-center sm:flex-row'>
+ <Link
+ to={routesPath.signup}
+ className='rounded-md !duration-300 transition-all w-full sm:max-w-[210px] h-12 flex items-center justify-center sm:mr-6 shadow-sm ring-1 text-white bg-slate-900 ring-slate-900 hover:bg-slate-700 dark:bg-indigo-700 dark:ring-indigo-700 dark:hover:bg-indigo-600'
+ aria-label={t('titles.signup')}
+ >
+ <span className='text-base font-semibold mr-1'>{t('common.getStarted')}</span>
+ <ArrowSmallRightIcon className='h-4 w-5 mt-[1px]' />
+ </Link>
+ <a
+ href={ERROR_TRACKING_LIVE_DEMO_URL}
+ className='rounded-md !duration-300 transition-all sm:mt-0 mt-2 ring-1 ring-slate-900 dark:ring-white/20 w-full sm:max-w-[210px] h-12 flex items-center justify-center shadow-sm text-slate-900 dark:text-white bg-transparent hover:bg-slate-200 dark:hover:bg-gray-800'
+ target='_blank'
+ rel='noopener noreferrer'
+ aria-label={`${t('common.liveDemo')} (opens in a new tab)`}
+ >
+ <span className='text-base font-semibold'>{t('common.liveDemo')}</span>
+ </a>
+ </div>
+ </div>
+ <div className='max-w-md xl:max-w-lg hidden lg:block'>
+ <Lines />
+ <picture>
+ <source
+ srcSet={
+ theme === 'dark' ? '/assets/screenshot_errors_dark.webp' : '/assets/screenshot_errors_light.webp'
+ }
+ type='image/webp'
+ />
+ <img
+ src={
+ theme === 'dark' ? '/assets/screenshot_errors_dark.png' : '/assets/screenshot_errors_light.png'
+ }
+ className='h-full min-w-[880px] rounded-xl relative shadow-2xl ring-1 ring-gray-900/10 dark:ring-white/10'
+ width='100%'
+ height='auto'
+ alt='Swetrix Analytics dashboard'
+ />
+ </picture>
+ </div>
+ </div>
+ <div className='my-10 block lg:hidden relative z-20 px-4 md:px-0'>
+ <picture>
+ <source
+ srcSet={
+ theme === 'dark' ? '/assets/screenshot_errors_dark.webp' : '/assets/screenshot_errors_light.webp'
+ }
+ type='image/webp'
+ />
+ <img
+ src={theme === 'dark' ? '/assets/screenshot_errors_dark.png' : '/assets/screenshot_errors_light.png'}
+ className='rounded-xl relative shadow-2xl w-full ring-1 ring-gray-900/10 dark:ring-white/10'
+ width='100%'
+ height='auto'
+ alt='Swetrix Analytics dashboard'
+ />
+ </picture>
+ </div>
+ </div>
+ </div>
+ {/* end first block with live demo */}
+
+ <div className='dark:bg-slate-900 bg-white px-4 pb-16 mx-auto max-w-7xl whitespace-pre-line mt-12'>
+ <h2 className='font-extrabold text-4xl dark:text-white text-slate-900'>{t('errors.fast.title')}</h2>
+ <p className='mt-6 dark:text-gray-50 text-gray-900 text-lg'>
+ <Trans
+ // @ts-ignore
+ t={t}
+ i18nKey='errors.fast.desc'
+ components={{
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
+ indexUrl: (
+ <Link to={routesPath.main} className='font-medium text-red-600 dark:text-red-400 hover:underline' />
+ ),
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
+ perfUrl: (
+ <Link
+ to={routesPath.performance}
+ className='font-medium text-red-600 dark:text-red-400 hover:underline'
+ />
+ ),
+ oneLC: (
+ <a
+ href='https://docs.swetrix.com/swetrix-js-reference#trackerrors'
+ className='font-medium text-red-600 dark:text-red-400 hover:underline'
+ target='_blank'
+ rel='noopener noreferrer'
+ />
+ ),
+ }}
+ />
+ </p>
+ <ul className='mt-2 list-disc list-inside dark:text-gray-50 text-gray-900 text-lg'>
+ {_map(t('errors.fast.list', { returnObjects: true }), (item) => (
+ <li key={item} className='mb-2'>
+ {item}
+ </li>
+ ))}
+ </ul>
+
+ <h2 className='mt-10 font-extrabold text-4xl dark:text-white text-slate-900'>{t('errors.track.title')}</h2>
+ <p className='mt-6 dark:text-gray-50 text-gray-900 text-lg'>{t('errors.track.desc')}</p>
+
+ <h2 className='mt-10 font-extrabold text-4xl dark:text-white text-slate-900'>
+ {t('performance.privacy.title')}
+ </h2>
+ <p className='mt-6 dark:text-gray-50 text-gray-900 text-lg'>{t('performance.privacy.desc')}</p>
+ </div>
+
+ {/* For now let's hide Pricing for authenticated users on the main page as the Paddle script only loads on the Billing page */}
+ {!authenticated && <Pricing authenticated={false} t={t} language={language} />}
+
+ <div className='bg-white dark:bg-slate-900 px-4 md:px-8 pb-12'>
+ <section
+ className='relative isolate max-w-7xl w-full mx-auto bg-slate-800 overflow-hidden lg:h-[450px]'
+ style={{ borderRadius: '100px 30px 30px 30px' }}
+ >
+ <div className='absolute -z-10 inset-0 overflow-hidden' aria-hidden='true'>
+ <div className='absolute left-[calc(20%-19rem)] top-[calc(50%-36rem)] transform-gpu blur-3xl'>
+ <div
+ className='aspect-[1097/1023] w-[68.5625rem] bg-gradient-to-r from-[#ff4694] to-[#776fff] opacity-25 dark:opacity-10'
+ style={{
+ clipPath:
+ 'polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)',
+ }}
+ />
+ </div>
+ </div>
+ <div className='flex items-start justify-between pt-8 pl-8 sm:pl-14 lg:pl-28 md:flex-row flex-col'>
+ <div className='max-w-[520px] w-full pt-14 pr-3 mb-16 md:mb-0'>
+ <h2 className='font-bold text-2xl leading-9 sm:text-4xl sm:leading-[48px] md:text-[28px] md:leading-10 lg:text-[33px] lg:leading-[48px] text-white mb-3'>
+ <Trans
+ // @ts-ignore
+ t={t}
+ i18nKey='main.timeToDitchGoogleAnalytics'
+ components={{
+ colour: <span className='text-red-600' />,
+ }}
+ />
+ </h2>
+ <p className='text-gray-300 mb-9 font-medium text-base sm:text-lg'>{t('main.whyDitch')}</p>
+ <Link
+ to={routesPath.signup}
+ className='rounded-md border !duration-300 transition-all w-full max-w-[210px] h-[50px] flex items-center justify-center sm:mr-6 shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 border-transparent'
+ aria-label={t('titles.signup')}
+ >
+ <span className='text-base font-semibold mr-1'>{t('main.start')}</span>
+ <ArrowSmallRightIcon className='w-5 h-4 mt-[1px]' />
+ </Link>
+ </div>
+ <div className='max-w-md xl:max-w-lg block h-[450px] md:shadow-[8px_8px_10px_3px] md:rounded-md '>
+ <img
+ className='rounded-xl ring-1 ring-gray-900/10 min-h-[600px] min-w-[880px]'
+ width='1760'
+ height='880'
+ src={theme === 'dark' ? '/assets/screenshot_errors_dark.png' : '/assets/screenshot_errors_light.png'}
+ alt='Swetrix Analytics dashboard'
+ />
+ </div>
+ </div>
+ </section>
+ </div>
+
+ {/* Become a developer */}
+ <section className='bg-white dark:bg-slate-900 pt-20 pb-44 relative'>
+ <div className='absolute right-0 top-16 z-0'>
+ <BackgroundSvg theme={theme} type='threecircle' />
+ </div>
+ <div className='absolute -left-9 top-52 rotate-90'>
+ <BackgroundSvg theme={theme} type='shapes' />
+ </div>
+ <div className='max-w-5xl w-full mx-auto px-3'>
+ <div className='max-w-prose w-full mx-auto'>
+ <h2 className='text-gray-900 dark:text-white text-3xl md:text-4xl font-extrabold text-center'>
+ {t('main.peopleLoveSwetrix')}
+ </h2>
+ <p className='mt-5 text-xl max-w-prose text-gray-600 dark:text-gray-200 text-center mx-auto'>
+ {t('main.whyPeopleLoveSwetrix')}
+ </p>
+ </div>
+ <div className='flex items-center justify-between mt-20 md:mt-32 md:flex-row flex-col'>
+ <div className='text-center'>
+ <ClientOnly fallback={<p className='text-indigo-700 text-5xl font-extrabold text-center'>0</p>}>
+ {() => (
+ <p className='text-indigo-700 text-5xl font-extrabold text-center'>
+ {users[0]}
+ {users[1] && <span className='text-gray-900 dark:text-indigo-200'>{users[1]}+</span>}
+ </p>
+ )}
+ </ClientOnly>
+ <p className='text-gray-600 text-lg dark:text-gray-200'>{t('main.users')}</p>
+ </div>
+ <div className='bg-gray-800 dark:bg-gray-200 w-2 h-2 rounded-full mx-5 mb-14 mt-16 md:mb-0 md:mt-0' />
+ <div className='text-center'>
+ <ClientOnly fallback={<p className='text-indigo-700 text-5xl font-extrabold text-center'>0</p>}>
+ {() => (
+ <p className='text-indigo-700 text-5xl font-extrabold text-center'>
+ {websites[0]}
+ {websites[1] && <span className='text-gray-900 dark:text-indigo-200'>{websites[1]}+</span>}
+ </p>
+ )}
+ </ClientOnly>
+ <p className='text-gray-600 text-lg dark:text-gray-200'>{t('main.websites')}</p>
+ </div>
+ <div className='bg-gray-800 dark:bg-gray-200 w-2 h-2 rounded-full mx-5 mb-14 mt-16 md:mb-0 md:mt-0' />
+ <div className='text-center'>
+ <ClientOnly fallback={<p className='text-indigo-700 text-5xl font-extrabold text-center'>0</p>}>
+ {() => (
+ <p className='text-indigo-700 text-5xl font-extrabold text-center'>
+ {events[0]}
+ {events[1] && <span className='text-gray-900 dark:text-indigo-200'>{events[1]}+</span>}
+ </p>
+ )}
+ </ClientOnly>
+ <p className='text-gray-600 text-lg dark:text-gray-200'>{t('main.pageviews')}</p>
+ </div>
+ </div>
+ </div>
+ </section>
+ {/* end Become a developer */}
+ </main>
+ </div>
+ )
+}
+
+export default memo(ErrorTracking)
diff --git a/app/pages/Performance/index.tsx b/app/pages/Performance/index.tsx
index b34870546..3b834a980 100644
--- a/app/pages/Performance/index.tsx
+++ b/app/pages/Performance/index.tsx
@@ -24,12 +24,12 @@ export const Lines = (): JSX.Element => (
</div>
)
-interface IMain {
+interface IPerformance {
ssrTheme: 'dark' | 'light'
ssrAuthenticated: boolean
}
-const Main: React.FC<IMain> = ({ ssrTheme, ssrAuthenticated }): JSX.Element => {
+const Performance: React.FC<IPerformance> = ({ ssrTheme, ssrAuthenticated }): JSX.Element => {
const {
t,
i18n: { language },
@@ -355,4 +355,4 @@ const Main: React.FC<IMain> = ({ ssrTheme, ssrAuthenticated }): JSX.Element => {
)
}
-export default memo(Main)
+export default memo(Performance)
diff --git a/app/pages/Project/View/Panels.tsx b/app/pages/Project/View/Panels.tsx
index 7e769e523..94b1c29ce 100644
--- a/app/pages/Project/View/Panels.tsx
+++ b/app/pages/Project/View/Panels.tsx
@@ -172,7 +172,7 @@ const PanelContainer = ({
</>
)}
- {type === 'pg' && activeTab !== PROJECT_TABS.performance && (
+ {type === 'pg' && activeTab !== PROJECT_TABS.performance && activeTab !== PROJECT_TABS.errors && (
<>
<RectangleGroupIcon
className={cx(iconClassName, 'ml-2 cursor-pointer', {
@@ -243,7 +243,12 @@ const PanelContainer = ({
{/* for other tabs */}
<div
className={cx('flex flex-col h-full scroll-auto', {
- 'overflow-auto': !(type === 'pg' && activeTab !== PROJECT_TABS.performance && activeFragment === 1),
+ 'overflow-auto': !(
+ type === 'pg' &&
+ activeTab !== PROJECT_TABS.performance &&
+ activeTab !== PROJECT_TABS.errors &&
+ activeFragment === 1
+ ),
relative: isCustomContent,
})}
>
diff --git a/app/pages/Project/View/ViewProject.helpers.tsx b/app/pages/Project/View/ViewProject.helpers.tsx
index 86ab9c3af..d41f62ce5 100644
--- a/app/pages/Project/View/ViewProject.helpers.tsx
+++ b/app/pages/Project/View/ViewProject.helpers.tsx
@@ -192,6 +192,10 @@ const CHART_METRICS_MAPPING = {
cumulativeMode: 'cumulativeMode',
}
+const ERROR_FILTERS_MAPPING = {
+ showResolved: 'showResolved',
+}
+
const FILTER_CHART_METRICS_MAPPING_FOR_COMPARE = ['bounce', 'viewsPerUnique', 'trendlines', 'customEvents']
const CHART_METRICS_MAPPING_PERF = {
@@ -225,7 +229,7 @@ const getColumns = (
[key: string]: string[]
},
) => {
- const { views, bounce, viewsPerUnique, unique, trendlines, sessionDuration } = activeChartMetrics
+ const { views, bounce, viewsPerUnique, unique, trendlines, sessionDuration, occurrences } = activeChartMetrics
const columns: any[] = [['x', ..._map(chart.x, (el) => dayjs(el).toDate())]]
@@ -240,6 +244,14 @@ const getColumns = (
}
}
+ if (occurrences) {
+ columns.push(['occurrences', ...chart.occurrences])
+
+ if (compareChart?.occurrences) {
+ columns.push(['occurrencesCompare', ...compareChart.occurrences])
+ }
+ }
+
if (views) {
columns.push(['total', ...chart.visits])
if (trendlines) {
@@ -917,6 +929,131 @@ const getSettingsSession = (
}
}
+// function to get the settings and data for the error details chart
+const getSettingsError = (
+ chart: any,
+ timeBucket: string,
+ timeFormat: string,
+ rotateXAxis: boolean,
+ chartType: string,
+) => {
+ const xAxisSize = _size(chart.x)
+
+ const columns = getColumns(chart, { occurrences: true }, {})
+
+ let regionStart
+
+ if (xAxisSize > 1) {
+ regionStart = dayjs(chart.x[xAxisSize - 2]).toDate()
+ } else {
+ regionStart = dayjs(chart.x[xAxisSize - 1]).toDate()
+ }
+
+ return {
+ data: {
+ x: 'x',
+ columns,
+ types: {
+ occurrences: chartType === chartTypes.line ? area() : bar(),
+ },
+ colors: {
+ occurrences: '#dc2626',
+ occurrencesCompare: 'rgba(220, 38, 38, 0.4)',
+ },
+ regions: {
+ occurrences: [
+ {
+ start: regionStart,
+ style: {
+ dasharray: '6 2',
+ },
+ },
+ ],
+ },
+ },
+ // grid: {
+ // x: {
+ // lines,
+ // },
+ // },
+ transition: {
+ duration: 500,
+ },
+ resize: {
+ auto: true,
+ timer: false,
+ },
+ axis: {
+ x: {
+ clipPath: false,
+ tick: {
+ fit: true,
+ rotate: rotateXAxis ? 45 : 0,
+ format:
+ timeFormat === TimeFormat['24-hour']
+ ? (x: string) => d3.timeFormat(tbsFormatMapper24h[timeBucket])(x)
+ : (x: string) => d3.timeFormat(tbsFormatMapper[timeBucket])(x),
+ },
+ localtime: timeFormat === TimeFormat['24-hour'],
+ type: 'timeseries',
+ },
+ y: {
+ tick: {
+ format: (d: number) => nFormatter(d, 1),
+ },
+ show: true,
+ inner: true,
+ },
+ },
+ tooltip: {
+ contents: (item: any, _: any, __: any, color: any) => {
+ return `<ul class='bg-gray-100 dark:text-gray-50 dark:bg-slate-800 rounded-md shadow-md px-3 py-1'>
+ <li class='font-semibold'>${
+ timeFormat === TimeFormat['24-hour']
+ ? d3.timeFormat(tbsFormatMapperTooltip24h[timeBucket])(item[0].x)
+ : d3.timeFormat(tbsFormatMapperTooltip[timeBucket])(item[0].x)
+ }</li>
+ <hr class='border-gray-200 dark:border-gray-600' />
+ ${_map(
+ item,
+ (el: { id: string; index: number; name: string; value: string; x: Date }) => `
+ <li class='flex justify-between'>
+ <div class='flex justify-items-start'>
+ <div class='w-3 h-3 rounded-sm mt-1.5 mr-2' style=background-color:${color(el.id)}></div>
+ <span>${el.name}</span>
+ </div>
+ <span class='pl-4'>${el.value}</span>
+ </li>
+ `,
+ ).join('')}`
+ },
+ },
+ point: {
+ focus: {
+ only: xAxisSize > 1,
+ },
+ pattern: ['circle'],
+ r: 3,
+ },
+ legend: {
+ usePoint: true,
+ item: {
+ tile: {
+ width: 10,
+ },
+ },
+ hide: ['uniqueCompare', 'totalCompare', 'bounceCompare', 'sessionDurationCompare'],
+ },
+ area: {
+ linearGradient: true,
+ },
+ bar: {
+ linearGradient: true,
+ },
+ bindto: '#errorChart',
+ }
+}
+
// function to get the settings and data for the funnels chart
const getSettingsFunnels = (
funnel: IAnalyticsFunnel[],
@@ -1447,4 +1584,6 @@ export {
SHORTCUTS_GENERAL_LISTENERS,
SHORTCUTS_TIMEBUCKETS_LISTENERS,
CHART_MEASURES_MAPPING_PERF,
+ getSettingsError,
+ ERROR_FILTERS_MAPPING,
}
diff --git a/app/pages/Project/View/ViewProject.tsx b/app/pages/Project/View/ViewProject.tsx
index c65438624..8f5bdc774 100644
--- a/app/pages/Project/View/ViewProject.tsx
+++ b/app/pages/Project/View/ViewProject.tsx
@@ -17,6 +17,7 @@ import {
ChevronLeftIcon,
GlobeAltIcon,
UsersIcon,
+ BugAntIcon,
} from '@heroicons/react/24/outline'
import cx from 'clsx'
import dayjs from 'dayjs'
@@ -86,6 +87,9 @@ import {
OS_LOGO_MAP,
OS_LOGO_MAP_DARK,
ITBPeriodPairs,
+ ERROR_PANELS_ORDER,
+ ERRORS_FILTERS_PANELS_ORDER,
+ errorPeriodPairs,
} from 'redux/constants'
import { IUser } from 'redux/models/IUser'
import {
@@ -130,6 +134,9 @@ import {
getPerformanceOverallStats,
getSessions,
getSession,
+ getErrors,
+ getError,
+ updateErrorStatus,
} from 'api'
import { getChartPrediction } from 'api/ai'
import { Panel, CustomEvents } from './Panels'
@@ -156,6 +163,7 @@ import {
SHORTCUTS_GENERAL_LISTENERS,
SHORTCUTS_TIMEBUCKETS_LISTENERS,
CHART_MEASURES_MAPPING_PERF,
+ ERROR_FILTERS_MAPPING,
} from './ViewProject.helpers'
import CCRow from './components/CCRow'
import FunnelsList from './components/FunnelsList'
@@ -175,12 +183,19 @@ import { Sessions } from './components/Sessions'
import { Pageflow } from './components/Pageflow'
import { SessionDetails } from './components/SessionDetails'
import { SessionChart } from './components/SessionChart'
+import { Errors } from './components/Errors'
import LockedDashboard from './components/LockedDashboard'
import WaitingForAnEvent from './components/WaitingForAnEvent'
+import { ErrorChart } from './components/ErrorChart'
+import { ErrorDetails } from './components/ErrorDetails'
+import { IError } from './interfaces/error'
+import NoErrorDetails from './components/NoErrorDetails'
+import WaitingForAnError from './components/WaitingForAnError'
const SwetrixSDK = require('@swetrix/sdk')
const CUSTOM_EV_DROPDOWN_MAX_VISIBLE_LENGTH = 32
const SESSIONS_TAKE = 30
+const ERRORS_TAKE = 30
interface IViewProject {
projects: IProject[]
@@ -386,6 +401,11 @@ const ViewProject = ({
[CHART_METRICS_MAPPING.trendlines]: false,
[CHART_METRICS_MAPPING.cumulativeMode]: false,
})
+ const [errorOptions, setErrorOptions] = useState<{
+ [key: string]: boolean
+ }>({
+ [ERROR_FILTERS_MAPPING.showResolved]: false,
+ })
// similar activeChartMetrics but using for performance tab
const [activeChartMetricsPerf, setActiveChartMetricsPerf] = useState<string>(CHART_METRICS_MAPPING_PERF.timing)
const [activePerfMeasure, setActivePerfMeasure] = useState(CHART_MEASURES_MAPPING_PERF.median)
@@ -401,6 +421,8 @@ const ViewProject = ({
// similar filters but using for the sessions tab
const [filtersSessions, setFiltersSessions] = useState<any[]>([])
const [areFiltersSessionsParsed, setAreFiltersSessionsParsed] = useState<boolean>(false)
+ const [filtersErrors, setFiltersErrors] = useState<any[]>([])
+ const [areFiltersErrorsParsed, setAreFiltersErrorsParsed] = useState<boolean>(false)
// isLoading is a true when we loading data from api
const isLoading = authenticated ? _isLoading : false
@@ -434,6 +456,16 @@ const ViewProject = ({
const [activeSession, setActiveSession] = useState<any>(null)
const [sessionLoading, setSessionLoading] = useState<boolean>(false)
+ // errors
+ const [errorsSkip, setErrorsSkip] = useState<number>(0)
+ const [canLoadMoreErrors, setCanLoadMoreErrors] = useState<boolean>(false)
+ const [errors, setErrors] = useState<any[]>([])
+ const [errorsLoading, setErrorsLoading] = useState<boolean | null>(null) // null - not loaded, true - loading, false - loaded
+ const [activeError, setActiveError] = useState<any>(null)
+ const [errorLoading, setErrorLoading] = useState<boolean>(false)
+ const [errorStatusUpdating, setErrorStatusUpdating] = useState(false)
+ const [activeEID, setActiveEID] = useState<string | null>(null)
+
const [activeFunnel, setActiveFunnel] = useState<IFunnel | null>(null)
const [funnelToEdit, setFunnelToEdit] = useState<IFunnel | undefined>(undefined)
const [funnelActionLoading, setFunnelActionLoading] = useState<boolean>(false)
@@ -636,6 +668,28 @@ const ViewProject = ({
// sharedRoles is a role for shared project
const sharedRoles = useMemo(() => _find(user.sharedProjects, (p) => p.project.id === id)?.role || {}, [user, id])
+ const timeBucketSelectorItems = useMemo(() => {
+ if (activeTab === PROJECT_TABS.errors) {
+ return _filter(periodPairs, (el) => {
+ return _includes(errorPeriodPairs, el.period)
+ })
+ }
+
+ if (isActiveCompare) {
+ return _filter(periodPairs, (el) => {
+ return _includes(filtersPeriodPairs, el.period)
+ })
+ }
+
+ if (_includes(filtersPeriodPairs, period)) {
+ return periodPairs
+ }
+
+ return _filter(periodPairs, (el) => {
+ return el.period !== PERIOD_PAIRS_COMPARE.COMPARE
+ })
+ }, [activeTab, isActiveCompare, period, periodPairs])
+
// for search filters
const [showFiltersSearch, setShowFiltersSearch] = useState(false)
@@ -687,6 +741,16 @@ const ViewProject = ({
]
}, [t, activeChartMetrics])
+ const errorFilters = useMemo(() => {
+ return [
+ {
+ id: ERROR_FILTERS_MAPPING.showResolved,
+ label: t('project.showResolved'),
+ active: errorOptions[ERROR_FILTERS_MAPPING.showResolved],
+ },
+ ]
+ }, [t, errorOptions])
+
// chartMetricsPerf is a list of metrics for dropdown in performance tab
const chartMetricsPerf = useMemo(() => {
return [
@@ -772,6 +836,7 @@ const ViewProject = ({
viewsPerUnique: t('dashboard.viewsPerUnique'),
trendlineTotal: t('project.trendlineTotal'),
trendlineUnique: t('project.trendlineUnique'),
+ occurrences: t('project.occurrences'),
sessionDuration: t('dashboard.sessionDuration'),
...dataNamesCustomEvents,
}),
@@ -848,6 +913,11 @@ const ViewProject = ({
label: t('dashboard.sessions'),
icon: UsersIcon,
},
+ {
+ id: PROJECT_TABS.errors,
+ label: t('dashboard.errors'),
+ icon: BugAntIcon,
+ },
{
id: PROJECT_TABS.funnels,
label: t('dashboard.funnels'),
@@ -884,6 +954,76 @@ const ViewProject = ({
[activeTab],
)
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ const switchActiveErrorFilter = useCallback(
+ _debounce((pairID: string) => {
+ setErrorOptions((prev) => ({ ...prev, [pairID]: !prev[pairID] }))
+ resetErrors()
+ }, 0),
+ [],
+ )
+
+ const updateStatusInErrors = (status: 'active' | 'resolved') => {
+ if (!activeError?.details?.eid) {
+ return
+ }
+
+ const index = _findIndex(errors, (error) => error.eid === activeEID)
+
+ if (index === -1) {
+ return
+ }
+
+ errors[index] = {
+ ...errors[index],
+ status,
+ }
+ }
+
+ const markErrorAsResolved = async () => {
+ if (errorStatusUpdating || !activeEID || !activeError?.details?.eid) {
+ return
+ }
+
+ setErrorStatusUpdating(true)
+
+ try {
+ await updateErrorStatus(project.id, 'resolved', activeEID)
+ await loadError(activeEID)
+ updateStatusInErrors('resolved')
+ } catch (reason) {
+ console.error('[markErrorAsResolved]', reason)
+ generateAlert(t('apiNotifications.updateErrorStatusFailed'), 'error')
+ setErrorStatusUpdating(false)
+ return
+ }
+
+ generateAlert(t('apiNotifications.errorStatusUpdated'), 'success')
+ setErrorStatusUpdating(false)
+ }
+
+ const markErrorAsActive = async () => {
+ if (errorStatusUpdating || !activeEID || !activeError?.details?.eid) {
+ return
+ }
+
+ setErrorStatusUpdating(true)
+
+ try {
+ await updateErrorStatus(project.id, 'active', activeEID)
+ await loadError(activeEID)
+ updateStatusInErrors('active')
+ } catch (reason) {
+ console.error('[markErrorAsResolved]', reason)
+ generateAlert(t('apiNotifications.updateErrorStatusFailed'), 'error')
+ setErrorStatusUpdating(false)
+ return
+ }
+
+ generateAlert(t('apiNotifications.errorStatusUpdated'), 'success')
+ setErrorStatusUpdating(false)
+ }
+
// onErrorLoading is a function for redirect to dashboard when project do not exist
const onErrorLoading = () => {
if (projectPassword) {
@@ -1311,6 +1451,45 @@ const ViewProject = ({
return getCustomEventsMetadata(id, event, timeBucket, period, '', '', timezone, projectPassword)
}
+ const loadError = useCallback(
+ async (eid: string) => {
+ setErrorLoading(true)
+
+ try {
+ let error
+ let from
+ let to
+
+ if (dateRange) {
+ from = getFormatDate(dateRange[0])
+ to = getFormatDate(dateRange[1])
+ }
+
+ if (period === 'custom' && dateRange) {
+ error = await getError(id, eid, '', from, to, timezone, projectPassword)
+ } else {
+ error = await getError(id, eid, period, '', '', timezone, projectPassword)
+ }
+
+ setActiveError(error)
+ } catch (reason: any) {
+ if (reason?.status === 400) {
+ // this error did not occur within specified time frame
+ setErrorLoading(false)
+ setActiveError(null)
+ return
+ }
+
+ const message = _isEmpty(reason.data?.message) ? reason.data : reason.data.message
+
+ console.error('[ERROR] (loadError)(getError)', message)
+ showError(message)
+ }
+ setErrorLoading(false)
+ },
+ [dateRange, id, period, projectPassword, showError, timezone],
+ )
+
const loadSession = async (psid: string) => {
if (sessionLoading) {
return
@@ -1347,6 +1526,29 @@ const ViewProject = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
+ useEffect(() => {
+ // @ts-ignore
+ const url = new URL(window.location)
+ const { searchParams } = url
+ const eid = searchParams.get('eid') as string
+ const tab = searchParams.get('tab') as string
+
+ if (eid && tab === PROJECT_TABS.errors) {
+ // loadError(eid)
+ setActiveEID(eid)
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [])
+
+ useEffect(() => {
+ if (!activeEID) {
+ return
+ }
+
+ loadError(activeEID)
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [period, dateRange, timeBucket, activeEID])
+
const loadSessions = async () => {
if (sessionsLoading) {
return
@@ -1406,6 +1608,79 @@ const ViewProject = ({
}
}
+ const loadErrors = async (forcedSkip?: number, override?: boolean) => {
+ if (errorsLoading) {
+ return
+ }
+
+ setErrorsLoading(true)
+
+ try {
+ const skip = typeof forcedSkip === 'number' ? forcedSkip : errorsSkip
+ let dataErrors: { errors: IError[]; appliedFilters: any[] }
+ let from
+ let to
+
+ if (dateRange) {
+ from = getFormatDate(dateRange[0])
+ to = getFormatDate(dateRange[1])
+ }
+
+ if (period === 'custom' && dateRange) {
+ dataErrors = await getErrors(
+ id,
+ '',
+ filtersErrors,
+ errorOptions,
+ from,
+ to,
+ ERRORS_TAKE,
+ skip,
+ timezone,
+ projectPassword,
+ )
+ } else {
+ dataErrors = await getErrors(
+ id,
+ period,
+ filtersErrors,
+ errorOptions,
+ '',
+ '',
+ ERRORS_TAKE,
+ skip,
+ timezone,
+ projectPassword,
+ )
+ }
+
+ if (override) {
+ setErrors(dataErrors?.errors || [])
+ } else {
+ setErrors((prev) => [...prev, ...(dataErrors?.errors || [])])
+ }
+
+ setErrorsSkip((prev) => {
+ if (typeof forcedSkip === 'number') {
+ return ERRORS_TAKE + forcedSkip
+ }
+
+ return ERRORS_TAKE + prev
+ })
+
+ if (dataErrors?.errors?.length < ERRORS_TAKE) {
+ setCanLoadMoreErrors(false)
+ } else {
+ setCanLoadMoreErrors(true)
+ }
+ } catch (e) {
+ console.error('[ERROR](loadErrors) Loading errors data failed')
+ console.error(e)
+ } finally {
+ setErrorsLoading(false)
+ }
+ }
+
// similar to loadAnalytics but using for performance tab
const loadAnalyticsPerf = async (forced = false, newFilters: any[] | null = null) => {
if (!forced && (isLoading || _isEmpty(project) || dataLoading)) {
@@ -1743,8 +2018,10 @@ const ViewProject = ({
let newFilters
let newFiltersPerf
let newFiltersSessions
+ let newFiltersErrors
const columnPerf = `${column}_perf`
const columnSessions = `${column}_sess`
+ const columnErrors = `${column}_err`
if (activeTab === PROJECT_TABS.performance) {
if (_find(filtersPerf, (f) => f.filter === filter)) {
@@ -1790,6 +2067,28 @@ const ViewProject = ({
}
}
+ if (activeTab === PROJECT_TABS.errors) {
+ if (_find(filtersErrors, (f) => f.filter === filter)) {
+ newFiltersErrors = _filter(filtersErrors, (f) => f.filter !== filter)
+
+ // @ts-ignore
+ const url = new URL(window.location)
+ url.searchParams.delete(columnErrors)
+ const { pathname, search } = url
+ navigate(`${pathname}${search}`)
+ setFiltersErrors(newFiltersErrors)
+ } else {
+ newFiltersErrors = [...filtersErrors, { column, filter, isExclusive }]
+
+ // @ts-ignore
+ const url = new URL(window.location)
+ url.searchParams.append(columnErrors, filter)
+ const { pathname, search } = url
+ navigate(`${pathname}${search}`)
+ setFiltersErrors(newFiltersErrors)
+ }
+ }
+
if (activeTab === PROJECT_TABS.traffic) {
// eslint-disable-next-line no-lonely-if
if (_find(filters, (f) => f.filter === filter) /* && f.filter === filter) */) {
@@ -1821,11 +2120,12 @@ const ViewProject = ({
}
resetSessions()
+ resetErrors()
sdkInstance?._emitEvent('filtersupdate', newFilters)
if (activeTab === PROJECT_TABS.performance) {
loadAnalyticsPerf(true, newFiltersPerf)
- } else {
+ } else if (activeTab === PROJECT_TABS.traffic) {
loadAnalytics(true, newFilters)
}
}
@@ -1902,6 +2202,36 @@ const ViewProject = ({
}
setFiltersSessions(converted)
+ } else if (activeTab === PROJECT_TABS.errors) {
+ if (override) {
+ _forEach(ERRORS_FILTERS_PANELS_ORDER, (value) => {
+ if (url.searchParams.has(`${value}_err`)) {
+ url.searchParams.delete(`${value}_err`)
+ }
+ })
+ }
+
+ _forEach(items, (item) => {
+ if (url.searchParams.has(`${item.column}_err`)) {
+ url.searchParams.delete(`${item.column}_err`)
+ }
+ _forEach(item.filter, (filter) => {
+ url.searchParams.append(`${item.column}_err`, filter)
+ })
+ })
+
+ const { pathname, search } = url
+ navigate(`${pathname}${search}`)
+
+ const converted = convertFilters(newFilters)
+ resetErrors()
+
+ if (!override) {
+ setFiltersErrors([...filters, ...converted])
+ return
+ }
+
+ setFiltersErrors(converted)
} else {
if (override) {
_forEach(FILTERS_PANELS_ORDER, (value) => {
@@ -1934,6 +2264,7 @@ const ViewProject = ({
}
resetSessions()
+ resetErrors()
}
// this function is used for requesting the data from the API when the exclusive filter is changed
@@ -1964,6 +2295,19 @@ const ViewProject = ({
return f
})
setFiltersSessions(newFilters)
+ } else if (activeTab === PROJECT_TABS.errors) {
+ newFilters = _map(filtersErrors, (f) => {
+ if (f.column === column && f.filter === filter) {
+ return {
+ ...f,
+ isExclusive,
+ }
+ }
+
+ return f
+ })
+ resetErrors()
+ setFiltersErrors(newFilters)
} else {
newFilters = _map(filters, (f) => {
if (f.column === column && f.filter === filter) {
@@ -1998,7 +2342,7 @@ const ViewProject = ({
}
// this function is used for requesting the data from the API when you press the reset button
- const refreshStats = () => {
+ const refreshStats = async () => {
if (!isLoading && !dataLoading) {
if (activeTab === PROJECT_TABS.performance) {
loadAnalyticsPerf(true)
@@ -2016,6 +2360,17 @@ const ViewProject = ({
return
}
+ if (activeTab === PROJECT_TABS.errors) {
+ if (activeEID) {
+ await loadError(activeEID)
+ return
+ }
+
+ resetErrors()
+ loadErrors(0)
+ return
+ }
+
loadAnalytics(true)
}
}
@@ -2378,6 +2733,40 @@ const ViewProject = ({
}
}, [])
+ useEffect(() => {
+ try {
+ // @ts-ignore
+ const url = new URL(window.location)
+ const { searchParams } = url
+ const initialFilters: any[] = []
+ // eslint-disable-next-line lodash/prefer-lodash-method
+ searchParams.forEach((value, key) => {
+ if (!_includes(key, '_err')) {
+ return
+ }
+
+ const keyErr = _replace(key, '_err', '')
+
+ if (!_includes(validFilters, keyErr)) {
+ return
+ }
+
+ const isExclusive = _startsWith(value, '!')
+ initialFilters.push({
+ column: keyErr,
+ filter: isExclusive ? value.substring(1) : value,
+ isExclusive,
+ })
+ })
+
+ setFiltersErrors(initialFilters)
+ } catch (reason) {
+ console.error(`[ERROR] useEffect - Parsing initial filters from url also using for errors tab: ${reason}`)
+ } finally {
+ setAreFiltersErrorsParsed(true)
+ }
+ }, [])
+
// Parsing timeBucket from url
useEffect(() => {
if (arePeriodParsed) {
@@ -2408,6 +2797,12 @@ const ViewProject = ({
setSessionsLoading(null)
}
+ const resetErrors = () => {
+ setErrorsSkip(0)
+ setErrors([])
+ setErrorsLoading(null)
+ }
+
// onRangeDateChange if is activeChartMetrics custom and we select custom date range
// we update url and state
const onRangeDateChange = (dates: Date[], onRender?: boolean) => {
@@ -2447,6 +2842,7 @@ const ViewProject = ({
setCanLoadMoreSessions(false)
resetSessions()
+ resetErrors()
sdkInstance?._emitEvent('timeupdate', {
period: 'custom',
@@ -2494,6 +2890,13 @@ const ViewProject = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activeTab, dateRange, filtersSessions, id, period, projectPassword, timezone, areFiltersSessionsParsed])
+ useEffect(() => {
+ if (activeTab === PROJECT_TABS.errors && areFiltersErrorsParsed) {
+ loadErrors()
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [activeTab, errorOptions, dateRange, filtersErrors, id, period, projectPassword, timezone, areFiltersErrorsParsed])
+
useEffect(() => {
if (period !== KEY_FOR_ALL_TIME) {
return
@@ -2624,6 +3027,7 @@ const ViewProject = ({
setCanLoadMoreSessions(false)
resetSessions()
+ resetErrors()
setDateRange(null)
}
@@ -2739,6 +3143,7 @@ const ViewProject = ({
setFilters([])
setFiltersPerf([])
setFiltersSessions([])
+ setFiltersErrors([])
if (activeTab === PROJECT_TABS.performance) {
loadAnalyticsPerf(true, [])
} else if (activeTab === PROJECT_TABS.traffic) {
@@ -2982,7 +3387,7 @@ const ViewProject = ({
)
}
- if (!project.isDataExists && !analyticsLoading) {
+ if (!project.isDataExists && activeTab !== PROJECT_TABS.errors && !analyticsLoading) {
return (
<>
{!embedded && <Header ssrTheme={ssrTheme} authenticated={authenticated} />}
@@ -3003,6 +3408,31 @@ const ViewProject = ({
)
}
+ if (
+ typeof project.isErrorDataExists === 'boolean' && // to prevent flickering
+ !project.isErrorDataExists &&
+ activeTab === PROJECT_TABS.errors
+ ) {
+ return (
+ <>
+ {!embedded && <Header ssrTheme={ssrTheme} authenticated={authenticated} />}
+ <div
+ className={cx('max-w-[1584px] bg-gray-50 dark:bg-slate-900 w-full mx-auto py-6 px-2 sm:px-4 lg:px-8', {
+ 'min-h-min-footer': !embedded,
+ 'min-h-[100vh]': embedded,
+ })}
+ >
+ <TabsSelector />
+ <h2 className='text-xl mt-2 font-bold text-gray-900 dark:text-gray-50 break-words break-all text-center sm:text-left'>
+ {name}
+ </h2>
+ <WaitingForAnError />
+ </div>
+ {!embedded && <Footer authenticated={authenticated} minimal />}
+ </>
+ )
+ }
+
return (
<ClientOnly>
{() => (
@@ -3091,6 +3521,7 @@ const ViewProject = ({
<div
className={cx('border-gray-200 dark:border-gray-600', {
'lg:border-r': activeTab === PROJECT_TABS.funnels,
+ hidden: activeTab === PROJECT_TABS.errors && activeError,
})}
>
<button
@@ -3107,36 +3538,38 @@ const ViewProject = ({
<MagnifyingGlassIcon className='w-5 h-5 stroke-2 text-gray-700 dark:text-gray-50' />
</button>
</div>
- {activeTab !== PROJECT_TABS.funnels && activeTab !== PROJECT_TABS.sessions && (
- <Dropdown
- header={t('project.exportData')}
- items={[
- ...exportTypes,
- ...customExportTypes,
- { label: t('project.lookingForMore'), lookingForMore: true, onClick: () => {} },
- ]}
- title={[<ArrowDownTrayIcon key='download-icon' className='w-5 h-5' />]}
- labelExtractor={(item) => {
- const { label } = item
-
- return label
- }}
- keyExtractor={(item) => item.label}
- onSelect={(item, e) => {
- if (item.lookingForMore) {
- e?.stopPropagation()
- window.open(MARKETPLACE_URL, '_blank')
-
- return
- }
-
- item.onClick(panelsData, t)
- }}
- chevron='mini'
- buttonClassName='!p-2 rounded-md hover:bg-white hover:shadow-sm dark:hover:bg-slate-800 focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 focus:dark:ring-gray-200 focus:dark:border-gray-200'
- headless
- />
- )}
+ {activeTab !== PROJECT_TABS.funnels &&
+ activeTab !== PROJECT_TABS.sessions &&
+ activeTab !== PROJECT_TABS.errors && (
+ <Dropdown
+ header={t('project.exportData')}
+ items={[
+ ...exportTypes,
+ ...customExportTypes,
+ { label: t('project.lookingForMore'), lookingForMore: true, onClick: () => {} },
+ ]}
+ title={[<ArrowDownTrayIcon key='download-icon' className='w-5 h-5' />]}
+ labelExtractor={(item) => {
+ const { label } = item
+
+ return label
+ }}
+ keyExtractor={(item) => item.label}
+ onSelect={(item, e) => {
+ if (item.lookingForMore) {
+ e?.stopPropagation()
+ window.open(MARKETPLACE_URL, '_blank')
+
+ return
+ }
+
+ item.onClick(panelsData, t)
+ }}
+ chevron='mini'
+ buttonClassName='!p-2 rounded-md hover:bg-white hover:shadow-sm dark:hover:bg-slate-800 focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 focus:dark:ring-gray-200 focus:dark:border-gray-200'
+ headless
+ />
+ )}
<div
className={cx(
'border-gray-200 dark:border-gray-600 lg:px-3 sm:mr-3 space-x-2 lg:border-x',
@@ -3145,7 +3578,8 @@ const ViewProject = ({
isPanelsDataEmpty ||
analyticsLoading ||
checkIfAllMetricsAreDisabled ||
- activeTab === PROJECT_TABS.sessions,
+ activeTab === PROJECT_TABS.sessions ||
+ activeTab === PROJECT_TABS.errors,
},
)}
>
@@ -3283,10 +3717,60 @@ const ViewProject = ({
headless
/>
)}
- {activeTab === PROJECT_TABS.funnels && (
- <button
- type='button'
- title={t('project.refreshStats')}
+ {activeTab === PROJECT_TABS.errors &&
+ activeError &&
+ activeError?.details?.status !== 'resolved' && (
+ <button
+ type='button'
+ disabled={errorStatusUpdating}
+ onClick={markErrorAsResolved}
+ className={cx('text-sm p-2 font-medium text-gray-700 dark:text-gray-50', {
+ 'cursor-not-allowed': isLoading || errorLoading,
+ 'opacity-50': errorLoading && !errorStatusUpdating,
+ 'animate-pulse cursor-not-allowed': errorStatusUpdating,
+ })}
+ >
+ {t('project.resolve')}
+ </button>
+ )}
+ {activeTab === PROJECT_TABS.errors &&
+ activeError &&
+ activeError?.details?.status === 'resolved' && (
+ <button
+ type='button'
+ disabled={errorStatusUpdating}
+ onClick={markErrorAsActive}
+ className={cx('text-sm p-2 font-medium text-gray-700 dark:text-gray-50', {
+ 'cursor-not-allowed': isLoading || errorLoading,
+ 'opacity-50': errorLoading && !errorStatusUpdating,
+ 'animate-pulse cursor-not-allowed': errorStatusUpdating,
+ })}
+ >
+ {t('project.markAsActive')}
+ </button>
+ )}
+ {activeTab === PROJECT_TABS.errors && !activeError && (
+ <Dropdown
+ items={errorFilters}
+ title={t('project.filters')}
+ labelExtractor={(pair) => {
+ const { label, id: pairID, active } = pair
+
+ return <Checkbox className='px-4 py-2' label={label} id={pairID} checked={active} />
+ }}
+ selectItemClassName='group text-gray-700 dark:text-gray-50 dark:border-gray-800 dark:bg-slate-800 block text-sm cursor-pointer hover:bg-gray-200 dark:hover:bg-slate-700'
+ keyExtractor={(pair) => pair.id}
+ onSelect={({ id: pairID }) => {
+ switchActiveErrorFilter(pairID)
+ }}
+ chevron='mini'
+ headless
+ />
+ )}
+ {activeTab === PROJECT_TABS.funnels && (
+ <button
+ type='button'
+ title={t('project.refreshStats')}
onClick={refreshStats}
className={cx(
'relative rounded-md p-2 bg-gray-50 text-sm font-medium hover:bg-white hover:shadow-sm dark:bg-slate-900 dark:hover:bg-slate-800 focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 focus:dark:ring-gray-200 focus:dark:border-gray-200',
@@ -3339,20 +3823,13 @@ const ViewProject = ({
/>
)}
<TBPeriodSelector
+ classes={{
+ timeBucket: activeTab === PROJECT_TABS.errors && !activeEID ? 'hidden' : '',
+ }}
activePeriod={activePeriod}
updateTimebucket={updateTimebucket}
timeBucket={timeBucket}
- items={
- isActiveCompare
- ? _filter(periodPairs, (el) => {
- return _includes(filtersPeriodPairs, el.period)
- })
- : _includes(filtersPeriodPairs, period)
- ? periodPairs
- : _filter(periodPairs, (el) => {
- return el.period !== PERIOD_PAIRS_COMPARE.COMPARE
- })
- }
+ items={timeBucketSelectorItems}
title={activePeriod?.label}
onSelect={(pair) => {
if (pair.period === PERIOD_PAIRS_COMPARE.COMPARE) {
@@ -3381,7 +3858,7 @@ const ViewProject = ({
}
}}
/>
- {isActiveCompare && (
+ {isActiveCompare && activeTab !== PROJECT_TABS.errors && (
<>
<div className='mx-2 text-md font-medium text-gray-600 whitespace-pre-line dark:text-gray-200'>
vs
@@ -3548,9 +4025,7 @@ const ViewProject = ({
<ChevronLeftIcon className='w-4 h-4' />
{t('project.backToSessions')}
</button>
- {activeSession?.details && (
- <SessionDetails details={activeSession?.details} psid={activeSession?.psid} />
- )}
+ {activeSession?.details && <SessionDetails details={activeSession?.details} />}
<SessionChart
chart={activeSession?.chart}
timeBucket={activeSession?.timeBucket}
@@ -3562,6 +4037,289 @@ const ViewProject = ({
<Pageflow pages={activeSession?.pages} />
</>
)}
+ {activeTab === PROJECT_TABS.errors && !activeEID && (
+ <>
+ <Filters
+ filters={filtersErrors}
+ onRemoveFilter={filterHandler}
+ onChangeExclusive={onChangeExclusive}
+ tnMapping={tnMapping}
+ />
+ {!errorsLoading && _isEmpty(errors) && (
+ <NoEvents filters={filtersErrors} resetFilters={resetFilters} />
+ )}
+ <Errors
+ errors={errors}
+ onClick={(eidToLoad) => {
+ setActiveEID(eidToLoad)
+ setErrorLoading(true)
+ }}
+ />
+ {canLoadMoreErrors && (
+ <button
+ type='button'
+ title={t('project.refreshStats')}
+ onClick={() => loadErrors()}
+ className={cx(
+ 'flex items-center mx-auto mt-2 text-gray-700 dark:text-gray-50 relative rounded-md p-2 bg-gray-50 text-sm font-medium hover:bg-white hover:shadow-sm dark:bg-slate-900 dark:hover:bg-slate-800 focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 focus:dark:ring-gray-200 focus:dark:border-gray-200',
+ {
+ 'cursor-not-allowed opacity-50': sessionsLoading,
+ },
+ )}
+ >
+ <ArrowDownTrayIcon className='w-5 h-5 mr-2' />
+ {t('project.loadMore')}
+ </button>
+ )}
+ {_isEmpty(errors) && errorsLoading && <Loader />}
+ </>
+ )}
+ {activeTab === PROJECT_TABS.errors && activeEID && (
+ <>
+ <button
+ onClick={() => {
+ setActiveError(null)
+ setActiveEID(null)
+ const url = new URL(window.location.href)
+ url.searchParams.delete('eid')
+ window.history.pushState({}, '', url.toString())
+ }}
+ className='flex items-center text-base font-normal underline decoration-dashed hover:decoration-solid mb-4 mx-auto lg:mx-0 mt-2 lg:mt-0 text-gray-900 dark:text-gray-100'
+ >
+ <ChevronLeftIcon className='w-4 h-4' />
+ {t('project.backToErrors')}
+ </button>
+ {activeError?.details && <ErrorDetails details={activeError.details} />}
+ {activeError?.chart && (
+ <ErrorChart
+ chart={activeError?.chart}
+ timeBucket={activeError?.timeBucket}
+ timeFormat={timeFormat}
+ rotateXAxis={rotateXAxis}
+ chartType={chartType}
+ dataNames={dataNames}
+ />
+ )}
+ <div className='mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3'>
+ {!_isEmpty(activeError?.params) &&
+ _map(ERROR_PANELS_ORDER, (type: keyof typeof tnMapping) => {
+ const panelName = tnMapping[type]
+ // @ts-ignore
+ const panelIcon = panelIconMapping[type]
+
+ if (type === 'cc') {
+ const ccPanelName = tnMapping[countryActiveTab]
+
+ const rowMapper = (entry: ICountryEntry) => {
+ const { name: entryName, cc } = entry
+
+ if (cc) {
+ return <CCRow cc={cc} name={entryName} language={language} />
+ }
+
+ return <CCRow cc={entryName} language={language} />
+ }
+
+ return (
+ <Panel
+ projectPassword={projectPassword}
+ t={t}
+ key={countryActiveTab}
+ icon={panelIcon}
+ id={countryActiveTab}
+ onFilter={filterHandler}
+ activeTab={activeTab}
+ name={<CountryDropdown onSelect={setCountryActiveTab} title={ccPanelName} />}
+ data={activeError.params[countryActiveTab]}
+ rowMapper={rowMapper}
+ />
+ )
+ }
+
+ if (type === 'br') {
+ const rowMapper = (entry: any) => {
+ const { name: entryName } = entry
+ // @ts-ignore
+ const logoUrl = BROWSER_LOGO_MAP[entryName]
+
+ if (!logoUrl) {
+ return (
+ <>
+ <GlobeAltIcon className='w-5 h-5' />
+ &nbsp;
+ {entryName}
+ </>
+ )
+ }
+
+ return (
+ <>
+ <img src={logoUrl} className='w-5 h-5' alt='' />
+ &nbsp;
+ {entryName}
+ </>
+ )
+ }
+
+ return (
+ <Panel
+ projectPassword={projectPassword}
+ t={t}
+ key={type}
+ icon={panelIcon}
+ id={type}
+ activeTab={activeTab}
+ onFilter={filterHandler}
+ name={panelName}
+ data={activeError.params[type]}
+ rowMapper={rowMapper}
+ />
+ )
+ }
+
+ if (type === 'os') {
+ const rowMapper = (entry: any) => {
+ const { name: entryName } = entry
+ // @ts-ignore
+ const logoPathLight = OS_LOGO_MAP[entryName]
+ // @ts-ignore
+ const logoPathDark = OS_LOGO_MAP_DARK[entryName]
+
+ let logoPath = _theme === 'dark' ? logoPathDark : logoPathLight
+ logoPath ||= logoPathLight
+
+ if (!logoPath) {
+ return (
+ <>
+ <GlobeAltIcon className='w-5 h-5' />
+ &nbsp;
+ {entryName}
+ </>
+ )
+ }
+
+ const logoUrl = `/${logoPath}`
+
+ return (
+ <>
+ <img src={logoUrl} className='w-5 h-5 dark:fill-gray-50' alt='' />
+ &nbsp;
+ {entryName}
+ </>
+ )
+ }
+
+ return (
+ <Panel
+ projectPassword={projectPassword}
+ t={t}
+ key={type}
+ icon={panelIcon}
+ id={type}
+ activeTab={activeTab}
+ onFilter={filterHandler}
+ name={panelName}
+ data={activeError.params[type]}
+ rowMapper={rowMapper}
+ />
+ )
+ }
+
+ if (type === 'dv') {
+ return (
+ <Panel
+ projectPassword={projectPassword}
+ t={t}
+ key={type}
+ activeTab={activeTab}
+ icon={panelIcon}
+ id={type}
+ onFilter={filterHandler}
+ name={panelName}
+ data={activeError.params[type]}
+ capitalize
+ />
+ )
+ }
+
+ if (type === 'pg') {
+ return (
+ <Panel
+ projectPassword={projectPassword}
+ t={t}
+ key={type}
+ icon={panelIcon}
+ id={type}
+ onFilter={filterHandler}
+ onFragmentChange={setPgActiveFragment}
+ // @ts-ignore
+ rowMapper={({ name: entryName }) => {
+ if (!entryName) {
+ return _toUpper(t('project.redactedPage'))
+ }
+
+ let decodedUri = entryName as string
+
+ try {
+ decodedUri = decodeURIComponent(entryName)
+ } catch (_) {
+ // do nothing
+ }
+
+ return decodedUri
+ }}
+ name={pgPanelNameMapping[pgActiveFragment]}
+ data={activeError.params[type]}
+ period={period}
+ activeTab={activeTab}
+ pid={id}
+ timeBucket={timeBucket}
+ filters={filters}
+ from={dateRange ? getFormatDate(dateRange[0]) : null}
+ to={dateRange ? getFormatDate(dateRange[1]) : null}
+ timezone={timezone}
+ />
+ )
+ }
+
+ if (type === 'lc') {
+ return (
+ <Panel
+ projectPassword={projectPassword}
+ t={t}
+ key={type}
+ icon={panelIcon}
+ id={type}
+ activeTab={activeTab}
+ onFilter={filterHandler}
+ name={panelName}
+ data={activeError.params[type]}
+ rowMapper={({ name: entryName }: { name: string }) =>
+ getLocaleDisplayName(entryName, language)
+ }
+ />
+ )
+ }
+
+ return (
+ <Panel
+ projectPassword={projectPassword}
+ t={t}
+ key={type}
+ icon={panelIcon}
+ id={type}
+ activeTab={activeTab}
+ onFilter={filterHandler}
+ name={panelName}
+ data={activeError.params[type]}
+ />
+ )
+ })}
+ </div>
+ {_isEmpty(activeError) && errorLoading && <Loader />}
+ {!errorLoading && _isEmpty(activeError) && <NoErrorDetails />}
+ </>
+ )}
{activeTab === PROJECT_TABS.alerts && !isSharedProject && project?.isOwner && authenticated && (
<ProjectAlertsView projectId={id} />
)}
@@ -3844,7 +4602,9 @@ const ViewProject = ({
onFilter={filterHandler}
name={panelName}
data={panelsData.data[type]}
- rowMapper={({ name: entryName }) => getLocaleDisplayName(entryName, language)}
+ rowMapper={({ name: entryName }: { name: string }) =>
+ getLocaleDisplayName(entryName, language)
+ }
customTabs={customTabs}
/>
)
@@ -4102,6 +4862,7 @@ const ViewProject = ({
loading={funnelActionLoading}
/>
<SearchFilters
+ type={activeTab === PROJECT_TABS.errors ? 'errors' : 'traffic'}
projectPassword={projectPassword}
showModal={showFiltersSearch}
setShowModal={setShowFiltersSearch}
@@ -4113,7 +4874,9 @@ const ViewProject = ({
? filtersPerf
: activeTab === PROJECT_TABS.sessions
? filtersSessions
- : filters
+ : activeTab === PROJECT_TABS.errors
+ ? filtersErrors
+ : filters
}
/>
{!embedded && <Footer authenticated={authenticated} minimal showDBIPMessage />}
diff --git a/app/pages/Project/View/components/ErrorChart.tsx b/app/pages/Project/View/components/ErrorChart.tsx
new file mode 100644
index 000000000..53b4138ab
--- /dev/null
+++ b/app/pages/Project/View/components/ErrorChart.tsx
@@ -0,0 +1,33 @@
+import { useEffect } from 'react'
+import bb from 'billboard.js'
+import { getSettingsError } from '../ViewProject.helpers'
+
+interface IErrorChart {
+ chart?: {
+ x: string[]
+ occurrences: number[]
+ }
+ timeBucket?: string
+ timeFormat: string
+ rotateXAxis: boolean
+ chartType: string
+ dataNames: any
+}
+
+export const ErrorChart = ({ chart, timeBucket, timeFormat, rotateXAxis, chartType, dataNames }: IErrorChart) => {
+ useEffect(() => {
+ // @ts-ignore
+ const bbSettings: bb.ChartOptions = getSettingsError(
+ chart,
+ timeBucket as string,
+ timeFormat,
+ rotateXAxis,
+ chartType,
+ )
+
+ const generate = bb.generate(bbSettings)
+ generate.data.names(dataNames)
+ }, [chart, timeBucket, timeFormat, rotateXAxis, chartType, dataNames])
+
+ return <div className='h-80 mt-5 md:mt-0 [&_svg]:!overflow-visible' id='errorChart' />
+}
diff --git a/app/pages/Project/View/components/ErrorDetails.tsx b/app/pages/Project/View/components/ErrorDetails.tsx
new file mode 100644
index 000000000..049559504
--- /dev/null
+++ b/app/pages/Project/View/components/ErrorDetails.tsx
@@ -0,0 +1,62 @@
+import React, { useMemo } from 'react'
+import { useTranslation } from 'react-i18next'
+import { IErrorDetails } from '../interfaces/error'
+import { MetricCard } from './MetricCards'
+import { getRelativeDateIfPossible } from 'utils/date'
+import Tooltip from 'ui/Tooltip'
+
+interface IErrorDetailsComponent {
+ details: IErrorDetails
+}
+
+export const ErrorDetails = ({ details }: IErrorDetailsComponent) => {
+ const {
+ t,
+ i18n: { language },
+ } = useTranslation('common')
+
+ const firstSeen = useMemo(() => {
+ return getRelativeDateIfPossible(details.first_seen, language)
+ }, [details.first_seen, language])
+
+ const lastSeen = useMemo(() => {
+ return getRelativeDateIfPossible(details.last_seen, language)
+ }, [details.last_seen, language])
+
+ return (
+ <div className='flex justify-center lg:justify-start gap-5 mb-5 flex-wrap'>
+ <div className='flex flex-col'>
+ <p className='font-bold max-md:text-xl md:text-3xl text-slate-900 dark:text-gray-50'>{`${details.name}: ${details.message}`}</p>
+ <p className='text-sm font-medium text-slate-700 dark:text-gray-200'>
+ {t('dashboard.atFile', {
+ filename: details.filename,
+ lineno: details.lineno,
+ colno: details.colno,
+ })}
+ </p>
+ </div>
+
+ <MetricCard
+ classes={{
+ value: 'max-md:text-xl md:text-3xl',
+ }}
+ label={t('dashboard.firstSeen')}
+ value={details.first_seen || 'N/A'}
+ valueMapper={(value) => (
+ <Tooltip className='max-w-content !w-full' tooltipNode={<span>{firstSeen}</span>} text={`${value} UTC`} />
+ )}
+ />
+
+ <MetricCard
+ classes={{
+ value: 'max-md:text-xl md:text-3xl',
+ }}
+ label={t('dashboard.lastSeen')}
+ value={details.last_seen || 'N/A'}
+ valueMapper={(value) => (
+ <Tooltip className='max-w-content !w-full' tooltipNode={<span>{lastSeen}</span>} text={`${value} UTC`} />
+ )}
+ />
+ </div>
+ )
+}
diff --git a/app/pages/Project/View/components/Errors.tsx b/app/pages/Project/View/components/Errors.tsx
new file mode 100644
index 000000000..b9085e943
--- /dev/null
+++ b/app/pages/Project/View/components/Errors.tsx
@@ -0,0 +1,141 @@
+import React, { useMemo } from 'react'
+import { Link } from '@remix-run/react'
+import { ClientOnly } from 'remix-utils/client-only'
+import { useTranslation } from 'react-i18next'
+import _map from 'lodash/map'
+import cx from 'clsx'
+import { ChevronRightIcon } from '@heroicons/react/24/outline'
+import Loader from 'ui/Loader'
+import { IError } from '../interfaces/error'
+import { getRelativeDateIfPossible } from 'utils/date'
+import { Badge } from 'ui/Badge'
+
+interface IErrors {
+ errors: IError[]
+ onClick: (psid: string) => void
+}
+
+interface IErrorItem {
+ error: IError
+ onClick: (psid: string) => void
+ className?: string
+}
+
+interface ISeparator {
+ className?: string
+}
+
+const Separator = ({ className }: ISeparator) => (
+ <svg viewBox='0 0 2 2' className={cx('h-0.5 w-0.5 flex-none fill-gray-400', className)}>
+ <circle cx={1} cy={1} r={1} />
+ </svg>
+)
+
+const ErrorItem = ({ error, onClick, className }: IErrorItem) => {
+ const {
+ t,
+ i18n: { language },
+ } = useTranslation('common')
+ const lastSeen = useMemo(() => {
+ return getRelativeDateIfPossible(error.last_seen, language)
+ }, [error.last_seen, language])
+ const status: {
+ label: string
+ colour: 'red' | 'yellow' | 'slate'
+ } = useMemo(() => {
+ if (error.status === 'active') {
+ return {
+ label: t('error.status.active'),
+ colour: 'red',
+ }
+ }
+
+ if (error.status === 'regressed') {
+ return {
+ label: t('error.status.regressed'),
+ colour: 'yellow',
+ }
+ }
+
+ return {
+ label: t('error.status.resolved'),
+ colour: 'slate',
+ }
+ }, [error.status, t])
+
+ const eidUrl = new URL(window.location.href)
+ eidUrl.searchParams.set('eid', error.eid)
+ const stringifiedUrl = eidUrl.toString()
+
+ return (
+ <Link
+ onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
+ e.preventDefault()
+ e.stopPropagation()
+ window.history.pushState({}, '', stringifiedUrl)
+
+ onClick(error.eid)
+ }}
+ to={stringifiedUrl}
+ >
+ <li className='relative flex justify-between gap-x-6 py-4 bg-gray-200/60 hover:bg-gray-200 dark:bg-[#162032] dark:hover:bg-slate-800 cursor-pointer px-4 sm:px-6 mb-4 rounded-lg'>
+ <div className='flex min-w-0 gap-x-4'>
+ <div className='min-w-0 flex-auto'>
+ <p className='flex items-center gap-x-2 font-semibold leading-6 text-gray-900 dark:text-gray-50'>
+ <span className='font-bold text-base'>{error.name}</span>
+ <Separator />
+ <span className='text-gray-500 mx-1 font-normal text-sm'>{error.filename}</span>
+ </p>
+ <p className='mt-1 flex text-base leading-5 text-gray-500 dark:text-gray-300'>{error.message}</p>
+ <p className='mt-1 flex items-center gap-x-2 text-base leading-5 text-gray-500 dark:text-gray-300'>
+ <Badge className='sm:hidden mr-2' label={status.label} colour={status.colour} />
+ {lastSeen}
+ <Separator className='sm:hidden' />
+ <span className='sm:hidden'>
+ {t('dashboard.xOccurrences', {
+ x: error.count,
+ })}
+ </span>
+ </p>
+ </div>
+ </div>
+ <div className='flex shrink-0 items-center gap-x-4'>
+ <div className='hidden sm:flex sm:flex-col sm:items-end'>
+ <p className='text-sm leading-6 text-gray-900 dark:text-gray-50'>
+ {t('dashboard.xOccurrences', {
+ x: error.count,
+ })}
+ </p>
+ <Badge label={status.label} colour={status.colour} />
+ </div>
+ <ChevronRightIcon className='h-5 w-5 flex-none text-gray-400' aria-hidden='true' />
+ </div>
+ </li>
+ </Link>
+ )
+}
+
+export const Errors: React.FC<IErrors> = ({ errors, onClick }) => {
+ return (
+ <ClientOnly
+ fallback={
+ <div className='bg-gray-50 dark:bg-slate-900'>
+ <Loader />
+ </div>
+ }
+ >
+ {() => (
+ <ul className='mt-4'>
+ {_map(errors, (error, index) => (
+ <ErrorItem
+ key={error.eid}
+ error={error}
+ onClick={onClick}
+ className={`${index === 0 && 'rounded-t-md'} ${index === errors.length - 1 && 'rounded-b-md'}`}
+ />
+ ))}
+ </ul>
+ )}
+ </ClientOnly>
+ )
+}
diff --git a/app/pages/Project/View/components/NoErrorDetails.tsx b/app/pages/Project/View/components/NoErrorDetails.tsx
new file mode 100644
index 000000000..d2ac1d834
--- /dev/null
+++ b/app/pages/Project/View/components/NoErrorDetails.tsx
@@ -0,0 +1,28 @@
+import { BugAntIcon } from '@heroicons/react/24/outline'
+import { useTranslation } from 'react-i18next'
+
+const NoErrorDetails = () => {
+ const { t } = useTranslation('common')
+
+ return (
+ <div className='px-4 py-16 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8'>
+ <div className='max-w-max mx-auto'>
+ <main className='sm:flex'>
+ <BugAntIcon type='giant' className='h-12 sm:h-20 w-12 sm:w-20 -ml-1.5 mb-2 sm:m-0' />
+ <div className='sm:ml-6'>
+ <div className='sm:border-l sm:border-gray-200 sm:pl-6'>
+ <h1 className='text-4xl font-extrabold text-gray-900 dark:text-gray-50 tracking-tight sm:text-5xl'>
+ {t('project.noErrorDetails')}
+ </h1>
+ <p className='mt-1 max-w-prose whitespace-pre-line text-base text-gray-700 dark:text-gray-300'>
+ {t('project.noErrorDesc')}
+ </p>
+ </div>
+ </div>
+ </main>
+ </div>
+ </div>
+ )
+}
+
+export default NoErrorDetails
diff --git a/app/pages/Project/View/components/Pageflow.tsx b/app/pages/Project/View/components/Pageflow.tsx
index 0d359770e..7642d72df 100644
--- a/app/pages/Project/View/components/Pageflow.tsx
+++ b/app/pages/Project/View/components/Pageflow.tsx
@@ -30,7 +30,7 @@ export const Pageflow = ({ pages }: IPageflow) => {
})
return (
- <li key={`${value}${created}`}>
+ <li key={`${value}${created}${index}`}>
<div className='relative pb-8'>
{index !== pages.length - 1 ? (
<span
diff --git a/app/pages/Project/View/components/SearchFilters.tsx b/app/pages/Project/View/components/SearchFilters.tsx
index 995db604d..49abd2fc5 100644
--- a/app/pages/Project/View/components/SearchFilters.tsx
+++ b/app/pages/Project/View/components/SearchFilters.tsx
@@ -9,9 +9,9 @@ import Modal from 'ui/Modal'
import Checkbox from 'ui/Checkbox'
import Select from 'ui/Select'
import Combobox from 'ui/Combobox'
-import { FILTERS_PANELS_ORDER } from 'redux/constants'
+import { FILTERS_PANELS_ORDER, ERRORS_FILTERS_PANELS_ORDER } from 'redux/constants'
import countries from 'utils/isoCountries'
-import { getFilters } from 'api'
+import { getFilters, getErrorsFilters } from 'api'
import { Filter } from './Filters'
interface ISearchFilters {
@@ -32,11 +32,12 @@ interface ISearchFilters {
filter: string
isExclusive: boolean
}[]
+ type: 'traffic' | 'errors'
}
-const getLabelToTypeMap = (t: any) =>
+const getLabelToTypeMap = (t: any, type: 'traffic' | 'errors') =>
_reduce(
- FILTERS_PANELS_ORDER,
+ type === 'traffic' ? FILTERS_PANELS_ORDER : ERRORS_FILTERS_PANELS_ORDER,
(acc, curr) => ({
...acc,
[t(`project.mapping.${curr}`)]: curr,
@@ -67,6 +68,7 @@ const SearchFilters = ({
tnMapping,
filters,
projectPassword,
+ type,
}: ISearchFilters) => {
const {
t,
@@ -77,14 +79,21 @@ const SearchFilters = ({
const [activeFilters, setActiveFilters] = useState<any>({})
const [override, setOverride] = useState<boolean>(false)
- const labelToTypeMap = useMemo(() => getLabelToTypeMap(t), [t])
+ const labelToTypeMap = useMemo(() => getLabelToTypeMap(t, type), [t, type])
const getFiltersList = useCallback(
- async (type: string) => {
- const res = await getFilters(pid, type, projectPassword)
- setSearchList(res)
+ async (category: string) => {
+ let result: any[]
+
+ if (type === 'errors') {
+ result = await getErrorsFilters(pid, category, projectPassword)
+ } else {
+ result = await getFilters(pid, category, projectPassword)
+ }
+
+ setSearchList(result)
},
- [pid, projectPassword],
+ [pid, projectPassword, type],
)
useEffect(() => {
@@ -117,7 +126,7 @@ const SearchFilters = ({
<div className='min-h-[410px]'>
<Select
label={t('project.selectCategory')}
- items={FILTERS_PANELS_ORDER}
+ items={type === 'traffic' ? FILTERS_PANELS_ORDER : ERRORS_FILTERS_PANELS_ORDER}
labelExtractor={(item) => t(`project.mapping.${item}`)}
// @ts-ignore
onSelect={(item: string) => setFilterType(labelToTypeMap[item])}
diff --git a/app/pages/Project/View/components/SessionDetails.tsx b/app/pages/Project/View/components/SessionDetails.tsx
index 42f73c270..ba9e67729 100644
--- a/app/pages/Project/View/components/SessionDetails.tsx
+++ b/app/pages/Project/View/components/SessionDetails.tsx
@@ -10,10 +10,9 @@ import CCRow from './CCRow'
interface ISessionDetailsComponent {
details: ISessionDetails
- psid: string
}
-export const SessionDetails = ({ details, psid }: ISessionDetailsComponent) => {
+export const SessionDetails = ({ details }: ISessionDetailsComponent) => {
const {
t,
i18n: { language },
diff --git a/app/pages/Project/View/components/TBPeriodSelector.tsx b/app/pages/Project/View/components/TBPeriodSelector.tsx
index 520bc55f3..08134efe6 100644
--- a/app/pages/Project/View/components/TBPeriodSelector.tsx
+++ b/app/pages/Project/View/components/TBPeriodSelector.tsx
@@ -16,6 +16,10 @@ interface ITBPeriodSelector {
activePeriod: any
updateTimebucket: (tb: string) => void
timeBucket: string
+ classes?: {
+ timeBucket?: string
+ periods?: string
+ }
}
const TBPeriodSelector = ({
@@ -25,6 +29,7 @@ const TBPeriodSelector = ({
activePeriod,
updateTimebucket,
timeBucket,
+ classes,
}: ITBPeriodSelector): JSX.Element => {
const { t } = useTranslation('common')
@@ -58,7 +63,12 @@ const TBPeriodSelector = ({
{/* w-56 */}
<Popover.Panel className='absolute left-1/2 md:left-auto right-0 z-20 mt-3 w-max max-w-sm -translate-x-1/2 transform md:transform-none px-4 sm:px-0 lg:max-w-3xl'>
<div className='p-1 overflow-hidden rounded-lg shadow-lg ring-1 ring-black/5 bg-gray-50 dark:bg-slate-800'>
- <div className='bg-slate-200 dark:bg-slate-700 rounded-md relative z-0 flex items-center space-x-5 px-2 py-3 mb-1'>
+ <div
+ className={cx(
+ 'bg-slate-200 dark:bg-slate-700 rounded-md relative z-0 flex items-center space-x-5 px-2 py-3 mb-1',
+ classes?.timeBucket,
+ )}
+ >
{_map(periods, ({ label, value, available }) => (
<Popover.Button
key={value}
@@ -82,7 +92,7 @@ const TBPeriodSelector = ({
</Popover.Button>
))}
</div>
- <ul className='text-left w-full'>
+ <ul className={cx('text-left w-full', classes?.periods)}>
{_map(items, (item) => (
<Popover.Button
as='li'
diff --git a/app/pages/Project/View/components/WaitingForAnError.tsx b/app/pages/Project/View/components/WaitingForAnError.tsx
new file mode 100644
index 000000000..ba9c2d82d
--- /dev/null
+++ b/app/pages/Project/View/components/WaitingForAnError.tsx
@@ -0,0 +1,62 @@
+import { BugAntIcon } from '@heroicons/react/24/outline'
+import { Link } from '@remix-run/react'
+import { useTranslation, Trans } from 'react-i18next'
+import routes from 'routesPath'
+import { ERROR_TRACKING_DOCS_URL } from 'redux/constants'
+
+const TROUBLESHOOTING_URL = 'https://docs.swetrix.com/troubleshooting'
+
+const WaitingForAnError = () => {
+ const { t } = useTranslation('common')
+
+ return (
+ <div className='px-4 py-16 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8'>
+ <div className='max-w-max mx-auto'>
+ <main className='sm:flex'>
+ <BugAntIcon type='giant' className='h-12 sm:h-20 w-12 sm:w-20 -ml-1.5 mb-2 sm:m-0' />
+ <div className='sm:ml-6'>
+ <div className='sm:border-l sm:border-gray-200 sm:pl-6'>
+ <h1 className='text-4xl font-extrabold text-gray-900 dark:text-gray-50 tracking-tight sm:text-5xl'>
+ {t('project.waitingError.title')}
+ </h1>
+ <p className='mt-2 max-w-[80ch] whitespace-pre-line text-base text-gray-700 dark:text-gray-300'>
+ <Trans
+ // @ts-ignore
+ t={t}
+ i18nKey='project.waitingError.desc'
+ components={{
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
+ turl: (
+ <a
+ href={TROUBLESHOOTING_URL}
+ className='font-medium text-indigo-600 dark:text-indigo-400 hover:underline'
+ target='_blank'
+ rel='noreferrer noopener'
+ />
+ ),
+ curl: (
+ <Link
+ to={routes.contact}
+ className='font-medium text-indigo-600 dark:text-indigo-400 hover:underline'
+ />
+ ),
+ howto: (
+ <a
+ href={ERROR_TRACKING_DOCS_URL}
+ className='font-medium text-indigo-600 dark:text-indigo-400 hover:underline'
+ target='_blank'
+ rel='noreferrer noopener'
+ />
+ ),
+ }}
+ />
+ </p>
+ </div>
+ </div>
+ </main>
+ </div>
+ </div>
+ )
+}
+
+export default WaitingForAnError
diff --git a/app/pages/Project/View/components/WaitingForAnEvent.tsx b/app/pages/Project/View/components/WaitingForAnEvent.tsx
index f76a2a0b0..4eb788cf3 100644
--- a/app/pages/Project/View/components/WaitingForAnEvent.tsx
+++ b/app/pages/Project/View/components/WaitingForAnEvent.tsx
@@ -28,7 +28,7 @@ const WaitingForAnEvent = ({ project }: IWaitingForAnEvent) => {
<h1 className='text-4xl font-extrabold text-gray-900 dark:text-gray-50 tracking-tight sm:text-5xl'>
{t('project.waiting.title')}
</h1>
- <p className='mt-1 max-w-prose whitespace-pre-line text-base text-gray-700 dark:text-gray-300'>
+ <p className='mt-2 max-w-prose whitespace-pre-line text-base text-gray-700 dark:text-gray-300'>
<Trans
// @ts-ignore
t={t}
diff --git a/app/pages/Project/View/interfaces/error.tsx b/app/pages/Project/View/interfaces/error.tsx
new file mode 100644
index 000000000..b3103fe01
--- /dev/null
+++ b/app/pages/Project/View/interfaces/error.tsx
@@ -0,0 +1,15 @@
+export interface IError {
+ eid: string
+ name: string
+ message: string
+ filename: string
+ count: number
+ last_seen: string
+ status: 'active' | 'regressed' | 'fixed'
+}
+
+export interface IErrorDetails extends IError {
+ colno: number
+ lineno: number
+ first_seen: string
+}
diff --git a/app/redux/constants/index.ts b/app/redux/constants/index.ts
index d6ec386b2..91859d725 100644
--- a/app/redux/constants/index.ts
+++ b/app/redux/constants/index.ts
@@ -197,6 +197,10 @@ export const captchaTbPeriodPairs = (
export const filtersPeriodPairs = ['1h', '1d', '7d', '4w', '3M', '12M', 'custom', 'compare']
+// TODO: add 'custom' later after an issue with it is resolved
+// currently if you select a date range - it will not display errors within the last day of the date range
+export const errorPeriodPairs = ['1h', '1d', '7d', '4w', '3M', '12M']
+
export const tbPeriodPairsCompare = (
t: Function,
dates?: Date[],
@@ -236,9 +240,11 @@ interface IStringObject {
}
// the order of panels in the project view
-export const TRAFFIC_PANELS_ORDER: string[] = ['cc', 'pg', 'br', 'os', 'ref', 'lc', 'dv', 'so']
-export const FILTERS_PANELS_ORDER: string[] = ['cc', 'pg', 'br', 'os', 'ref', 'lc', 'dv']
-export const PERFORMANCE_PANELS_ORDER: string[] = ['cc', 'pg', 'br', 'dv']
+export const TRAFFIC_PANELS_ORDER = ['cc', 'pg', 'br', 'os', 'ref', 'lc', 'dv', 'so']
+export const FILTERS_PANELS_ORDER = ['cc', 'pg', 'br', 'os', 'ref', 'lc', 'dv']
+export const ERRORS_FILTERS_PANELS_ORDER = ['cc', 'pg', 'br', 'os', 'lc', 'dv']
+export const PERFORMANCE_PANELS_ORDER = ['cc', 'pg', 'br', 'dv']
+export const ERROR_PANELS_ORDER = ['cc', 'pg', 'br', 'os', 'lc', 'dv']
// the maximum amount of months user can go back when picking a date in flat picker (project view)
export const MAX_MONTHS_IN_PAST: number = 24
@@ -340,8 +346,10 @@ export const UTM_GENERATOR_URL: string = 'https://url.swetrix.com'
export const LIVE_DEMO_URL: string = '/projects/STEzHcB1rALV'
export const BOOK_A_CALL_URL: string = 'https://cal.com/swetrix'
export const PERFORMANCE_LIVE_DEMO_URL: string = '/projects/STEzHcB1rALV?tab=performance'
+export const ERROR_TRACKING_LIVE_DEMO_URL: string = '/projects/STEzHcB1rALV?tab=errors'
export const MARKETPLACE_URL: string = 'https://marketplace.swetrix.com'
export const DOCS_URL: string = 'https://docs.swetrix.com'
+export const ERROR_TRACKING_DOCS_URL: string = 'https://docs.swetrix.com/error-tracking'
export const CAPTCHA_URL: string = 'https://captcha.swetrix.com'
export const DOCS_CAPTCHA_URL: string = `${DOCS_URL}/captcha/introduction`
export const DOCS_REFERRAL_PROGRAM_URL: string = `${DOCS_URL}/affiliate/about`
@@ -533,6 +541,7 @@ const SELFHOSTED_PROJECT_TABS: IStringObject = {
performance: 'performance',
funnels: 'funnels',
sessions: 'sessions',
+ errors: 'errors',
}
const PRODUCTION_PROJECT_TABS: IStringObject = {
@@ -540,6 +549,7 @@ const PRODUCTION_PROJECT_TABS: IStringObject = {
performance: 'performance',
funnels: 'funnels',
sessions: 'sessions',
+ errors: 'errors',
alerts: 'alerts',
}
diff --git a/app/redux/models/IProject.ts b/app/redux/models/IProject.ts
index 9a4c5d246..0c8f6b342 100644
--- a/app/redux/models/IProject.ts
+++ b/app/redux/models/IProject.ts
@@ -101,6 +101,7 @@ export interface IProject {
password?: string
isLocked: boolean
isDataExists: boolean
+ isErrorDataExists: boolean
}
export interface ICaptchaProject {
diff --git a/app/redux/reducers/ui/theme.ts b/app/redux/reducers/ui/theme.ts
index dd74e648c..fdfc90584 100644
--- a/app/redux/reducers/ui/theme.ts
+++ b/app/redux/reducers/ui/theme.ts
@@ -19,7 +19,7 @@ const setTheme = (theme: string, storeToCookie = true): string => {
setThemeToDOM(theme)
if (storeToCookie) {
- setCookie(LS_THEME_SETTING, theme)
+ setCookie(LS_THEME_SETTING, theme, 3600 * 24 * 90) // storing theme data for 90 days
}
return theme
diff --git a/app/root.tsx b/app/root.tsx
index bd52635d6..4cb663210 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -23,7 +23,7 @@ import { transitions, positions, Provider as AlertProvider } from '@blaumaus/rea
import BillboardCss from 'billboard.js/dist/billboard.min.css'
import AlertTemplate from 'ui/Alert'
-import { trackViews } from 'utils/analytics'
+import { trackViews, trackErrors } from 'utils/analytics'
import { useChangeLanguage } from 'remix-i18next/react'
import { useTranslation } from 'react-i18next'
import AppWrapper from 'App'
@@ -40,6 +40,7 @@ import FlatpickrDarkCss from 'flatpickr/dist/themes/dark.css'
import FontsCss from 'styles/fonts.css'
trackViews()
+trackErrors()
declare global {
interface Window {
diff --git a/app/routes/[robots.txt].tsx b/app/routes/[robots.txt].tsx
index b7ffe6d96..aa81e72a2 100644
--- a/app/routes/[robots.txt].tsx
+++ b/app/routes/[robots.txt].tsx
@@ -1,5 +1,6 @@
-export const loader = () => {
- const robotText = `Sitemap: https://swetrix.com/sitemap.xml
+import { isSelfhosted } from 'redux/constants'
+
+const PRODUCTION_ROBOTS = `Sitemap: https://swetrix.com/sitemap.xml
User-agent: *
Disallow: /ref
@@ -10,7 +11,11 @@ Disallow: /share/*
Disallow: /change-email/*
`
- return new Response(robotText, {
+const SELFHOSTED_ROBOTS = `User-agent: *
+Disallow: /`
+
+export const loader = () => {
+ return new Response(isSelfhosted ? SELFHOSTED_ROBOTS : PRODUCTION_ROBOTS, {
status: 200,
headers: {
'Content-Type': 'text/plain',
diff --git a/app/routes/error-tracking.tsx b/app/routes/error-tracking.tsx
new file mode 100644
index 000000000..ff316994a
--- /dev/null
+++ b/app/routes/error-tracking.tsx
@@ -0,0 +1,30 @@
+import type { LoaderArgs } from '@remix-run/node'
+import { useLoaderData } from '@remix-run/react'
+import { json, redirect } from '@remix-run/node'
+import type { SitemapFunction } from 'remix-sitemap'
+
+import ErrorTracking from 'pages/ErrorTracking'
+import { detectTheme, isAuthenticated } from 'utils/server'
+import { isSelfhosted } from 'redux/constants'
+
+export const sitemap: SitemapFunction = () => ({
+ priority: 1,
+ exclude: isSelfhosted,
+})
+
+export async function loader({ request }: LoaderArgs) {
+ if (isSelfhosted) {
+ return redirect('/login', 302)
+ }
+
+ const [theme] = detectTheme(request)
+ const isAuth = isAuthenticated(request)
+
+ return json({ theme, isAuth })
+}
+
+export default function Index() {
+ const { theme, isAuth } = useLoaderData<typeof loader>()
+
+ return <ErrorTracking ssrTheme={theme} ssrAuthenticated={isAuth} />
+}
diff --git a/app/routesPath/index.ts b/app/routesPath/index.ts
index eabb243c6..b1315ae3f 100644
--- a/app/routesPath/index.ts
+++ b/app/routesPath/index.ts
@@ -2,6 +2,7 @@ const routes = Object.freeze({
signin: '/login',
signup: '/signup',
performance: '/performance',
+ errorTracking: '/error-tracking',
confirm_email: '/confirm-email',
reset_password: '/recovery',
new_password_form: '/password-reset/:id',
diff --git a/app/utils/analytics.ts b/app/utils/analytics.ts
index bda392f31..27b63e262 100644
--- a/app/utils/analytics.ts
+++ b/app/utils/analytics.ts
@@ -107,6 +107,12 @@ const trackViews = () => {
}
}
+const trackErrors = () => {
+ if (!isSelfhosted) {
+ Swetrix.trackErrors()
+ }
+}
+
const trackCustom = (ev: string, meta?: any) => {
if (!isSelfhosted) {
Swetrix.track({
@@ -116,4 +122,4 @@ const trackCustom = (ev: string, meta?: any) => {
}
}
-export { trackViews, trackCustom, SWETRIX_PID }
+export { trackViews, trackCustom, trackErrors, SWETRIX_PID }
diff --git a/app/utils/date.ts b/app/utils/date.ts
new file mode 100644
index 000000000..205f5544a
--- /dev/null
+++ b/app/utils/date.ts
@@ -0,0 +1,42 @@
+import dayjs from 'dayjs'
+
+const DIVISIONS = [
+ { amount: 60, name: 'seconds' },
+ { amount: 60, name: 'minutes' },
+ { amount: 24, name: 'hours' },
+ { amount: 7, name: 'days' },
+ { amount: 4.34524, name: 'weeks' },
+ { amount: 12, name: 'months' },
+ { amount: Number.POSITIVE_INFINITY, name: 'years' },
+]
+
+// @ts-ignore
+const formatTimeAgo = (date, language?: string) => {
+ const rtf = new Intl.RelativeTimeFormat(language)
+
+ // @ts-ignore
+ let duration = (date - new Date()) / 1000
+
+ for (let i = 0; i < DIVISIONS.length; i++) {
+ const division = DIVISIONS[i]
+ if (Math.abs(duration) < division.amount) {
+ // @ts-ignore
+ return rtf.format(Math.round(duration), division.name)
+ }
+ duration /= division.amount
+ }
+}
+
+export const getRelativeDateIfPossible = (date: string, language?: string) => {
+ if (!Intl?.RelativeTimeFormat) {
+ return new Date(date).toLocaleDateString(language, {
+ day: 'numeric',
+ month: 'short',
+ year: 'numeric',
+ hour: 'numeric',
+ minute: 'numeric',
+ })
+ }
+
+ return formatTimeAgo(dayjs.utc(date).toDate(), language)
+}
diff --git a/app/utils/server.ts b/app/utils/server.ts
index 7a6acfd01..e48bbe475 100644
--- a/app/utils/server.ts
+++ b/app/utils/server.ts
@@ -191,6 +191,12 @@ export const getPageMeta = (t: (key: string) => string, url?: string, _pathname?
}
break
+ case routes.errorTracking:
+ result = {
+ title: t('titles.errors'),
+ }
+ break
+
case routes.privacy:
result = {
title: 'Privacy Policy',
diff --git a/package.json b/package.json
index 9cb50524b..c25f398ab 100644
--- a/package.json
+++ b/package.json
@@ -69,7 +69,7 @@
"remix-sitemap": "^3.2.0",
"remix-utils": "^7.6.0",
"spacetime": "^7.6.0",
- "swetrix": "^3.0.3",
+ "swetrix": "^3.1.0",
"timezone-soft": "^1.5.2",
"ts-jest": "^29.1.2"
},
diff --git a/public/assets/screenshot_errors_dark.png b/public/assets/screenshot_errors_dark.png
new file mode 100644
index 000000000..74cd04f64
Binary files /dev/null and b/public/assets/screenshot_errors_dark.png differ
diff --git a/public/assets/screenshot_errors_dark.webp b/public/assets/screenshot_errors_dark.webp
new file mode 100644
index 000000000..e08f67417
Binary files /dev/null and b/public/assets/screenshot_errors_dark.webp differ
diff --git a/public/assets/screenshot_errors_light.png b/public/assets/screenshot_errors_light.png
new file mode 100644
index 000000000..a1119d9f3
Binary files /dev/null and b/public/assets/screenshot_errors_light.png differ
diff --git a/public/assets/screenshot_errors_light.webp b/public/assets/screenshot_errors_light.webp
new file mode 100644
index 000000000..1bc890d2a
Binary files /dev/null and b/public/assets/screenshot_errors_light.webp differ
diff --git a/public/locales/en.json b/public/locales/en.json
index 2d94d903d..f36d9a5fa 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -39,7 +39,9 @@
"funnelCreated": "The funnel has been created",
"funnelUpdated": "The funnel has been updated",
"funnelDeleted": "The funnel has been deleted",
- "errorCode": "Error code: {{error}}"
+ "errorCode": "Error code: {{error}}",
+ "updateErrorStatusFailed": "Error occured while updating error status",
+ "errorStatusUpdated": "Error status has been updated"
},
"common": {
"features": "Features",
@@ -114,6 +116,19 @@
"desc": "Swetrix is built with a privacy-first and transparent approach. We do not use cookies or collect personal information from our users. There's no cross-site or cross-device tracking. No data is ever sold to advertisers or anyone else.\nThe Swetrix dashboard is very intuitive to use, giving you real-time data and a clear view of your website. There are no layers of menus, no need to export your data into custom reports to understand it properly."
}
},
+ "errors": {
+ "slogan": "End user <span>error tracking</span> tool to deliver bug-free experiences.",
+ "description": "Focus on making beautiful apps, and we will let you know if something goes wrong.",
+ "fast": {
+ "title": "Deliver bug-free experiences",
+ "desc": "Everyone hates bugs, so in addition to <indexUrl>traffic</indexUrl> and <perfUrl>performance</perfUrl> analytics, Swetrix allows you to monitor your website errors to quickly resolve them. Easily set up error monitoring with a <oneLC>one line of code</oneLC>, so you can focus on building your applications, not hunting for bugs.",
+ "list": ["Get a bird's eye insights on what kind of errors are present on your website", "View specific error details and aggregated data by geolocation, browser, device type, page and other metrics", "Understand if the bug is new or regressed, making it easier to fix"]
+ },
+ "track": {
+ "title": "Track all errors with one tool",
+ "desc": "With Swetrix, you can track exactly what kind of errors your users are experiencing and when. We also give you insight into which browsers, operating systems, devices and more, making it even easier to resolve issues."
+ }
+ },
"main": {
"ukrSupport": "Support the Ukrainian army to fight Russian invasion.",
"slogan": "<span>Ultimate open-source web analytics</span> to satisfy all your needs.",
@@ -521,6 +536,9 @@
"disabled": "Disabled",
"pageviews": "Pageviews",
"captchaEvents": "CAPTCHA events",
+ "firstSeen": "First seen",
+ "lastSeen": "Last seen",
+ "atFile": "At {{filename}}, line {{lineno}}, column {{colno}}",
"unique": "Unique views",
"createdAt": "Created at",
"inc": "Increased by",
@@ -539,6 +557,8 @@
"performance": "Performance",
"funnels": "Funnels",
"sessions": "Sessions",
+ "xOccurrences": "{{x}} occurrences",
+ "errors": "Errors",
"xPageviews": "{{x}} pageviews",
"onePageview": "1 pageview",
"alerts": "Alerts",
@@ -601,6 +621,13 @@
"custom_events": "Custom events"
}
},
+ "error": {
+ "status": {
+ "active": "Active",
+ "resolved": "Resolved",
+ "regressed": "Regressed"
+ }
+ },
"notFoundPage": {
"title": "Page not found",
"description": "Sorry, we couldn’t find the page you’re looking for.\nPlease check the URL in the address bar and try again.",
@@ -626,10 +653,14 @@
"exportData": "Export data",
"asCSV": "As CSV",
"noEvTitle": "No events yet",
+ "noErrorDetails": "No error details",
+ "noErrorDesc": "This error does not exist or has not occurred within the specified time frame.",
"showAll": "Show all views",
"trendlineUnique": "Unique visitors trendline",
"backToFunnels": "Back to funnels list",
"backToSessions": "Back to sessions list",
+ "backToErrors": "Back to errors list",
+ "occurrences": "Occurrences",
"visitPage": "Visit {{page}}",
"visitors": "Visitors",
"events": "Events",
@@ -650,6 +681,10 @@
"title": "Waiting for your first pageview",
"desc": "We're waiting for your first pageview! If your integration is set up correctly, you should see it within 1 minute.\n<snippet>Click here</snippet> to view your JavaScript tracking code.\nStill not working? Try <turl>troubleshooting</turl> your integration or <curl>contact us</curl> for help with your setup."
},
+ "waitingError": {
+ "title": "Waiting for your first error.. hopefully not :)",
+ "desc": "We're waiting for your first error event! If your integration is set up correctly, you should see it within 1 minute when it happens.\n<howto>Click here</howto> to learn how to set up error tracking for your website.\nStill not working? Try <turl>troubleshooting</turl> your integration or <curl>contact us</curl> for help with your setup."
+ },
"trendlineTotal": "Pageviews trendline",
"noEvContent": "No events have been recorded for the specified period, please try a different period.",
"noCaptchaEv": "No events have been captured for the specified timeframe.\nIf you haven't set up CAPTCHA yet, you can check out our <url>Docs</url> to easily integrate it into your app.",
@@ -704,6 +739,10 @@
"exportImgError": "Exporting data as image failed",
"codeExample": "Or insert the following code into your website to track your events:",
"metricVis": "Metrics visualisation",
+ "filters": "Filters",
+ "showResolved": "Show resolved",
+ "resolve": "Resolve",
+ "markAsActive": "Mark as active",
"refreshStats": "Refresh stats",
"barChart": "Bar chart",
"lineChart": "Line chart",
@@ -976,7 +1015,8 @@
"open": "Open startup",
"passwordProtected": "This project is password protected",
"confirm": "Check your inbox",
- "performance": "End user performance monitoring to deliver fast websites"
+ "performance": "End user performance monitoring to deliver fast websites",
+ "errors": "End user error tracking tool to deliver bug-free experiences"
},
"header": {
"switchTheme": "Switch theme",