📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fixed some hydration errors
Blue Mouse6fc0d2fd59dd
diff --git a/app/components/GithubAuth.tsx b/app/components/GithubAuth.tsxindex edead190f..d7c78dc90 100644--- a/app/components/GithubAuth.tsx+++ b/app/components/GithubAuth.tsx@@ -7,11 +7,12 @@ import Button from 'ui/Button'import { StateType } from 'redux/store/index'import GithubDarkSVG from 'ui/icons/GithubDark'import GithubLightSVG from 'ui/icons/GithubLight'-import { SSO_PROVIDERS } from 'redux/constants'+import { SSO_PROVIDERS, isBrowser } from 'redux/constants'interface IGoogleAuth {setIsLoading: (isLoading: boolean) => void,authSSO: (provider: string, dontRemember: boolean, t: (key: string) => string, callback: (res: any) => void) => void+ ssrTheme: string,callback?: any,dontRemember?: boolean,isMiniButton?: boolean,@@ -19,10 +20,11 @@ interface IGoogleAuth {}const GithubAuth: React.FC<IGoogleAuth> = ({- setIsLoading, authSSO, dontRemember, callback, isMiniButton, className,+ setIsLoading, authSSO, dontRemember, callback, isMiniButton, className, ssrTheme,}) => {const { t } = useTranslation()- const { theme } = useSelector((state: StateType) => state.ui.theme)+ const reduxTheme = useSelector((state: StateType) => state.ui.theme.theme)+ const theme = isBrowser ? reduxTheme : ssrThemeconst googleLogin = async () => {setIsLoading(true)diff --git a/app/pages/Auth/Signin/Signin.tsx b/app/pages/Auth/Signin/Signin.tsxindex 7b87a08da..8294fbef2 100644--- a/app/pages/Auth/Signin/Signin.tsx+++ b/app/pages/Auth/Signin/Signin.tsx@@ -38,10 +38,11 @@ interface ISignin {loginSuccess: (user: IUser) => void,loginFailed: (error: string) => void,authSSO: (provider: string, dontRemember: boolean, t: (key: string) => string, callback: (res: any) => void) => void+ ssrTheme: string,}const Signin = ({- login, loginSuccess, loginFailed, authSSO,+ login, loginSuccess, loginFailed, authSSO, ssrTheme,}: ISignin): JSX.Element => {const { t }: {t: (key: string, optinions?: {@@ -268,6 +269,7 @@ const Signin = ({authSSO={authSSO}callback={loginCallback}dontRemember={form.dontRemember}+ ssrTheme={ssrTheme}/></div>)}@@ -281,6 +283,7 @@ Signin.propTypes = {loginSuccess: PropTypes.func.isRequired,loginFailed: PropTypes.func.isRequired,authSSO: PropTypes.func.isRequired,+ ssrTheme: PropTypes.string.isRequired,}export default memo(withAuthentication(Signin, auth.notAuthenticated))diff --git a/app/pages/Auth/Signup/BasicSignup.tsx b/app/pages/Auth/Signup/BasicSignup.tsxindex b56ab1358..0ddf646d0 100644--- a/app/pages/Auth/Signup/BasicSignup.tsx+++ b/app/pages/Auth/Signup/BasicSignup.tsx@@ -30,7 +30,11 @@ interface ISignUpForm {checkIfLeaked: boolean,}-const BasicSignup = (): JSX.Element => {+interface IBasicSignup {+ ssrTheme: string,+}++const BasicSignup: React.FC<IBasicSignup> = ({ ssrTheme }): JSX.Element => {const { t }: {t: (key: string, optinions?: {[key: string]: string | number,@@ -206,6 +210,7 @@ const BasicSignup = (): JSX.Element => {className='w-full flex justify-center'setIsLoading={setIsLoading}authSSO={authSSO}+ ssrTheme={ssrTheme}isMiniButton/></div>diff --git a/app/pages/Auth/Signup/Signup.tsx b/app/pages/Auth/Signup/Signup.tsxindex e23700011..cdab5c47e 100644--- a/app/pages/Auth/Signup/Signup.tsx+++ b/app/pages/Auth/Signup/Signup.tsx@@ -42,9 +42,10 @@ interface ISignup {[key: string]: string | number,}) => string, callback: (res: any) => void) => void,authSSO: (provider: string, dontRemember: boolean, t: (key: string) => string, callback: (res: any) => void) => void+ ssrTheme: string,}-const Signup = ({ signup, authSSO }: ISignup): JSX.Element => {+const Signup = ({ signup, authSSO, ssrTheme }: ISignup): JSX.Element => {const { t }: {t: (key: string, options?: {[key: string]: string | number,@@ -265,6 +266,7 @@ const Signup = ({ signup, authSSO }: ISignup): JSX.Element => {authSSO={authSSO}callback={signUpCallback}dontRemember={form.dontRemember}+ ssrTheme={ssrTheme}/></div></form>@@ -276,6 +278,7 @@ const Signup = ({ signup, authSSO }: ISignup): JSX.Element => {Signup.propTypes = {signup: PropTypes.func.isRequired,authSSO: PropTypes.func.isRequired,+ ssrTheme: PropTypes.string.isRequired,}export default memo(withAuthentication(Signup, auth.notAuthenticated))diff --git a/app/pages/MainPage/index.tsx b/app/pages/MainPage/index.tsxindex fe3407f56..8a6b156ad 100644--- a/app/pages/MainPage/index.tsx+++ b/app/pages/MainPage/index.tsx@@ -410,7 +410,7 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {{t('main.signup')}</p><div className='mt-6'>- <SignUp />+ <SignUp ssrTheme={ssrTheme} /></div></div><div className='px-4 sm:px-10'>@@ -446,12 +446,12 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {{/* end block singup */}{/* Core features section */}<section className='bg-white dark:bg-slate-900 pt-14 relative pb-14'>- <BackgroundSvg className='absolute -left-8' type='shapes' />+ <BackgroundSvg theme={theme} className='absolute -left-8' type='shapes' /><div className='mx-auto text-slate-900 font-extrabold text-3xl sm:text-5xl w-fit relative'><h2 className='relative z-20 dark:text-white'>{t('main.coreFeaturesBlock')}</h2>- <BackgroundSvg className='absolute right-0 sm:-right-16 top-9 z-10 opacity-30' type='semicircle' />+ <BackgroundSvg theme={theme} className='absolute right-0 sm:-right-16 top-9 z-10 opacity-30' type='semicircle' /></div><div className='mt-[60px] flex items-center max-w-7xl w-full mx-auto flex-wrap justify-center xl:justify-between'>{_map(t('main.features', { returnObjects: true }), (item: {@@ -467,7 +467,7 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {</div>))}</div>- <BackgroundSvg className='absolute right-0 bottom-0 z-10' type='twolinecircle' />+ <BackgroundSvg theme={theme} className='absolute right-0 bottom-0 z-10' type='twolinecircle' /></section>{/* end Core features section */}{/* section supports */}@@ -655,10 +655,10 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {{/* section Testimonials */}<section className='bg-white dark:bg-slate-900 pt-20 pb-20 relative'><div className='absolute right-0 top-0'>- <BackgroundSvg type='twolinecircle2' />+ <BackgroundSvg theme={theme} type='twolinecircle2' /></div><div className='absolute rotate-[135deg] left-0 z-0'>- <BackgroundSvg type='shapes' />+ <BackgroundSvg theme={theme} type='shapes' /></div><div className='max-w-[1000px] w-full mx-auto'><h2 className='text-slate-900 text-center font-extrabold text-5xl relative z-20 dark:text-white'>@@ -788,10 +788,10 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {{/* 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 type='threecircle' />+ <BackgroundSvg theme={theme} type='threecircle' /></div><div className='absolute -left-9 top-52 rotate-90'>- <BackgroundSvg type='shapes' />+ <BackgroundSvg theme={theme} type='shapes' /></div><div className='max-w-5xl w-full mx-auto px-3'><div className='max-w-sm w-full mx-auto'>diff --git a/app/pages/Project/View/ViewProject.container.tsx b/app/pages/Project/View/ViewProject.container.tsxindex 77881d5e4..eca40f285 100644--- a/app/pages/Project/View/ViewProject.container.tsx+++ b/app/pages/Project/View/ViewProject.container.tsx@@ -26,6 +26,7 @@ const mapStateToProps = (state: StateType) => {customEventsPrefs: state.ui.cache.customEventsPrefs,liveStats: state.ui.projects.liveStats,password: state.ui.projects.password,+ theme: state.ui.theme.theme,}}@@ -44,6 +45,7 @@ const mapStateToProps = (state: StateType) => {customEventsPrefs: state.ui.cache.customEventsPrefs,liveStats: state.ui.projects.liveStats,password: state.ui.projects.password,+ theme: state.ui.theme.theme,}}diff --git a/app/pages/Project/View/ViewProject.tsx b/app/pages/Project/View/ViewProject.tsxindex c0bda1171..9f672b583 100644--- a/app/pages/Project/View/ViewProject.tsx+++ b/app/pages/Project/View/ViewProject.tsx@@ -46,7 +46,7 @@ import {tbPeriodPairs, getProjectCacheKey, LIVE_VISITORS_UPDATE_INTERVAL, DEFAULT_TIMEZONE, CDN_URL, isDevelopment,timeBucketToDays, getProjectCacheCustomKey, roleViewer, MAX_MONTHS_IN_PAST, PROJECT_TABS,TimeFormat, getProjectForcastCacheKey, chartTypes, roleAdmin, TRAFFIC_PANELS_ORDER, PERFORMANCE_PANELS_ORDER, isSelfhosted, tbPeriodPairsCompare,- PERIOD_PAIRS_COMPARE, filtersPeriodPairs, IS_ACTIVE_COMPARE, PROJECTS_PROTECTED, getProjectCacheCustomKeyPerf,+ PERIOD_PAIRS_COMPARE, filtersPeriodPairs, IS_ACTIVE_COMPARE, PROJECTS_PROTECTED, getProjectCacheCustomKeyPerf, isBrowser,} from 'redux/constants'import { IUser } from 'redux/models/IUser'import { IProject, ILiveStats } from 'redux/models/IProject'@@ -120,12 +120,15 @@ interface IViewProject {password: {[key: string]: string,},+ theme: 'dark' | 'light',+ ssrTheme: 'dark' | 'light',}const ViewProject = ({projects, isLoading: _isLoading, showError, cache, cachePerf, setProjectCache, projectViewPrefs, setProjectViewPrefs, setPublicProject,setLiveStatsForProject, authenticated, timezone, user, sharedProjects, extensions, generateAlert, setProjectCachePerf,- projectTab, setProjectTab, setProjects, setProjectForcastCache, customEventsPrefs, setCustomEventsPrefs, liveStats, password,+ projectTab, setProjectTab, setProjects, setProjectForcastCache, customEventsPrefs, setCustomEventsPrefs, liveStats, password, theme,+ ssrTheme,}: IViewProject) => {// t is used for translationconst { t, i18n: { language } }: {@@ -137,6 +140,8 @@ const ViewProject = ({},} = useTranslation('common')+ const _theme = isBrowser ? theme : ssrTheme+// periodPairs is used for dropdown and updated when t changesconst [periodPairs, setPeriodPairs] = useState<{label: string@@ -161,6 +166,7 @@ const ViewProject = ({const dashboardRef = useRef<HTMLDivElement>(null)// { id } is a project id from url+ // @ts-ignoreconst { id }: {id: string} = useParams()@@ -1777,7 +1783,7 @@ const ViewProject = ({'!bg-gray-200 dark:!bg-gray-600 !border dark:!border-gray-500 !border-gray-300': !_isEmpty(forecasedChartData),})}>- <Robot containerClassName='w-5 h-5' className='text-gray-700 dark:text-gray-50' />+ <Robot theme={_theme} containerClassName='w-5 h-5' className='text-gray-700 dark:text-gray-50' /></button></div>)}diff --git a/app/routes/login.tsx b/app/routes/login.tsxindex f4dbcb4ed..f22cde33f 100644--- a/app/routes/login.tsx+++ b/app/routes/login.tsx@@ -1,5 +1,9 @@import Signin from 'pages/Auth/Signin'-import type { HeadersFunction } from '@remix-run/node'+import type { HeadersFunction, LoaderArgs } from '@remix-run/node'+import { useLoaderData } from '@remix-run/react'+import { json } from '@remix-run/node'++import { detectTheme } from 'utils/server'export const headers: HeadersFunction = () => {return {@@ -7,6 +11,16 @@ export const headers: HeadersFunction = () => {}}+export async function loader({ request }: LoaderArgs) {+ const theme = detectTheme(request)++ return json({ theme })+}+export default function Index() {- return <Signin />+ const {+ theme,+ } = useLoaderData<typeof loader>()++ return <Signin ssrTheme={theme} />}diff --git a/app/routes/projects.$id.tsx b/app/routes/projects.$id.tsxindex a948468d0..d6aa861be 100644--- a/app/routes/projects.$id.tsx+++ b/app/routes/projects.$id.tsx@@ -1,11 +1,24 @@import ViewProject from 'pages/Project/View'-import type { LinksFunction } from '@remix-run/node'+import type { LinksFunction, LoaderArgs } from '@remix-run/node'+import { useLoaderData } from '@remix-run/react'+import { json } from '@remix-run/node'+import { detectTheme } from 'utils/server'import ProjectViewStyle from 'styles/ProjectViewStyle.css'export const links: LinksFunction = () => [{ rel: 'stylesheet', href: ProjectViewStyle },]+export async function loader({ request }: LoaderArgs) {+ const theme = detectTheme(request)++ return json({ theme })+}+export default function Index() {- return <ViewProject />+ const {+ theme,+ } = useLoaderData<typeof loader>()++ return <ViewProject ssrTheme={theme} />}diff --git a/app/routes/signup.tsx b/app/routes/signup.tsxindex fe0be7e69..0b5b05fa9 100644--- a/app/routes/signup.tsx+++ b/app/routes/signup.tsx@@ -1,6 +1,10 @@import Singup from 'pages/Auth/Signup'import type { SitemapFunction } from 'remix-sitemap'-import type { HeadersFunction } from '@remix-run/node'+import type { HeadersFunction, LoaderArgs } from '@remix-run/node'+import { useLoaderData } from '@remix-run/react'+import { json } from '@remix-run/node'++import { detectTheme } from 'utils/server'export const headers: HeadersFunction = () => {return {@@ -8,10 +12,20 @@ export const headers: HeadersFunction = () => {}}+export async function loader({ request }: LoaderArgs) {+ const theme = detectTheme(request)++ return json({ theme })+}+export const sitemap: SitemapFunction = () => ({priority: 0.9,})export default function Index() {- return <Singup />+ const {+ theme,+ } = useLoaderData<typeof loader>()++ return <Singup ssrTheme={theme} />}diff --git a/app/ui/Button.tsx b/app/ui/Button.tsxindex 3fa864ff1..432c52652 100644--- a/app/ui/Button.tsx+++ b/app/ui/Button.tsx@@ -2,8 +2,6 @@import React, { memo } from 'react'import cx from 'clsx'import PropTypes from 'prop-types'-// import { useSelector } from 'react-redux'-// import { THEME_TYPE } from 'redux/constants'import Spin from './icons/Spin'// Define the prop types for the component@@ -40,56 +38,33 @@ interface IButton {const Button = ({text, children, primary, secondary, danger, onClick, white, small, regular, large,giant, type, className, loading, semiSmall, semiDanger, noBorder, focus, disabled,-}: IButton): JSX.Element => {- // const themeType = useSelector((state) => state.ui.theme.type)-- return (- <button- disabled={disabled}- type={type}- onClick={onClick}- className={cx('relative inline-flex select-none items-center border leading-4 font-medium rounded-md', {- 'shadow-sm text-gray-50 bg-slate-900 hover:bg-slate-700 dark:bg-indigo-700 dark:hover:bg-indigo-800 border-transparent': primary,- 'text-slate-900 bg-slate-300 hover:bg-slate-200 border-transparent': secondary,- 'text-gray-700 bg-white hover:bg-gray-50 border-transparent': white,- 'text-gray-50 bg-red-500 hover:bg-red-600 dark:bg-red-600 dark:hover:bg-red-700 border-transparent': danger,- 'text-red-500 hover:text-red-600 border-red-600 dark:text-red-300 dark:hover:text-red-400 dark:border-red-500 border-1': semiDanger,- 'focus:border-none border-none text-gray-700 dark:text-white focus:ring-0 focus:ring-offset-0': noBorder,- 'px-2.5 py-1.5 text-xs': small,- 'px-2.5 py-1.5 text-sm': semiSmall,- 'px-4 py-2 text-sm': large,- 'px-6 py-3 text-base': giant,- 'px-3 py-2 text-sm': regular,- 'cursor-not-allowed': loading,- 'focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500': focus,- }, className)}- >- {/* {themeType === THEME_TYPE.christmas ? (- <span className={cx('inline-flex items-center', {- button3: text,- button2: semiSmall || regular || large || giant,- })}- >- {loading && (- <Spin />- )}- {text || children}- </span>- ) : (- <>- {loading && (- <Spin />- )}- {text || children}- </>- )} */}- {loading && (+}: IButton): JSX.Element => (+ <button+ disabled={disabled}+ type={type}+ onClick={onClick}+ className={cx('relative inline-flex select-none items-center border leading-4 font-medium rounded-md', {+ 'shadow-sm text-gray-50 bg-slate-900 hover:bg-slate-700 dark:bg-indigo-700 dark:hover:bg-indigo-800 border-transparent': primary,+ 'text-slate-900 bg-slate-300 hover:bg-slate-200 border-transparent': secondary,+ 'text-gray-700 bg-white hover:bg-gray-50 border-transparent': white,+ 'text-gray-50 bg-red-500 hover:bg-red-600 dark:bg-red-600 dark:hover:bg-red-700 border-transparent': danger,+ 'text-red-500 hover:text-red-600 border-red-600 dark:text-red-300 dark:hover:text-red-400 dark:border-red-500 border-1': semiDanger,+ 'focus:border-none border-none text-gray-700 dark:text-white focus:ring-0 focus:ring-offset-0': noBorder,+ 'px-2.5 py-1.5 text-xs': small,+ 'px-2.5 py-1.5 text-sm': semiSmall,+ 'px-4 py-2 text-sm': large,+ 'px-6 py-3 text-base': giant,+ 'px-3 py-2 text-sm': regular,+ 'cursor-not-allowed': loading,+ 'focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500': focus,+ }, className)}+ >+ {loading && (<Spin />- )}- {text || children}- </button>- )-}+ )}+ {text || children}+ </button>+)// Define the prop types for the componentButton.propTypes = {diff --git a/app/ui/icons/BackgroundSvg.tsx b/app/ui/icons/BackgroundSvg.tsxindex 78a1589ba..b6402c5a7 100644--- a/app/ui/icons/BackgroundSvg.tsx+++ b/app/ui/icons/BackgroundSvg.tsx@@ -1,15 +1,15 @@import React from 'react'import cx from 'clsx'import PropTypes from 'prop-types'-import { getCookie } from 'utils/cookie'-const BackgroundSvg = ({ className, type, children }: {- className?: string,- type: 'shapes' | 'circle' | 'semicircle' | 'twolinecircle' | 'threecircle' | 'twolinecircle2',- children?: JSX.Element,-}): JSX.Element => {- const theme = getCookie('colour-theme') || 'light'+interface IBackgroundSvg {+ className?: string+ type: 'shapes' | 'circle' | 'semicircle' | 'twolinecircle' | 'threecircle' | 'twolinecircle2'+ children?: JSX.Element+ theme: 'dark' | 'light'+}+const BackgroundSvg: React.FC<IBackgroundSvg> = ({ className, type, children, theme }): JSX.Element => {if (type === 'shapes') {return (<svg className={className} width='112' height='112' viewBox='0 0 112 112' fill='none' xmlns='http://www.w3.org/2000/svg'>@@ -101,21 +101,18 @@ const BackgroundSvg = ({ className, type, children }: {return (<svg width='112' height='112' viewBox='0 0 112 112' fill='none' xmlns='http://www.w3.org/2000/svg'>- { children }+ {children}</svg>)}BackgroundSvg.propTypes = {className: PropTypes.string,- type: PropTypes.oneOf(['shapes', 'circle', 'semicircle', 'twolinecircle', 'threecircle', 'twolinecircle2']),- children: PropTypes.node,}BackgroundSvg.defaultProps = {className: '',type: 'shapes',- children: null,}export default BackgroundSvgdiff --git a/app/ui/icons/Robot.tsx b/app/ui/icons/Robot.tsxindex 6eaffd141..a2e83f91c 100644--- a/app/ui/icons/Robot.tsx+++ b/app/ui/icons/Robot.tsx@@ -1,16 +1,16 @@import React from 'react'import cx from 'clsx'import PropTypes from 'prop-types'-import { useSelector } from 'react-redux'-import { StateType } from 'redux/store'-const Robot = ({- className, containerClassName,-}: {+interface IRobot {className?: string,containerClassName?: string,+ theme: 'dark' | 'light'+}++const Robot: React.FC<IRobot> = ({+ className, containerClassName, theme,}): JSX.Element => {- const theme = useSelector((state: StateType) => state.ui.theme.theme)const cn = cx(className, {'fill-text-gray-700': theme === 'dark','fill-white': theme === 'light',