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!

a few improvements & fixes

Blue Mouse872ff9e2c369
diff --git a/app/hoc/projectProtected.tsx b/app/hoc/projectProtected.tsx
index d12d6f6ce..569a05a25 100644
--- a/app/hoc/projectProtected.tsx
+++ b/app/hoc/projectProtected.tsx
@@ -1,7 +1,6 @@
import React from 'react'
import { useSelector } from 'react-redux'
import { useNavigate, useParams } from '@remix-run/react'
-
import _find from 'lodash/find'
import _replace from 'lodash/replace'
import { StateType } from 'redux/store'
@@ -16,13 +15,8 @@ export const withProjectProtected = <P extends PropsType>(WrappedComponent: any)
const passwords = useSelector((state: StateType) => state.ui.projects.password)
const projects = useSelector((state: StateType) => state.ui.projects.projects)
const navigate = useNavigate()
-
- const { id }: {
- id: string
- } = useParams()
-
- const queryPassword = new URLSearchParams(window.location.search).get('password')
-
+ const { id }: any = useParams()
+ const { queryPassword } = props
const project = _find(projects, { id })
if (project?.isOwner) {
diff --git a/app/pages/Project/View/ViewProject.tsx b/app/pages/Project/View/ViewProject.tsx
index e33ab90fb..a862c77d6 100644
--- a/app/pages/Project/View/ViewProject.tsx
+++ b/app/pages/Project/View/ViewProject.tsx
@@ -126,13 +126,14 @@ interface IViewProject {
ssrTheme: 'dark' | 'light',
embedded: boolean,
ssrAuthenticated: boolean,
+ queryPassword: string | null,
}
const ViewProject = ({
projects, isLoading: _isLoading, showError, cache, cachePerf, setProjectCache, projectViewPrefs, setProjectViewPrefs, setPublicProject,
setLiveStatsForProject, authenticated: csrAuthenticated, timezone, user, sharedProjects, extensions, generateAlert, setProjectCachePerf,
projectTab, setProjectTab, setProjects, setProjectForcastCache, customEventsPrefs, setCustomEventsPrefs, liveStats, password, theme,
- ssrTheme, embedded, ssrAuthenticated,
+ ssrTheme, embedded, ssrAuthenticated, queryPassword,
}: IViewProject) => {
const authenticated = isBrowser ? csrAuthenticated : ssrAuthenticated
@@ -182,7 +183,7 @@ const ViewProject = ({
// find project by id from url from state in redux projects and sharedProjects. projects and sharedProjects loading from api in Saga on page load
const project: IProjectForShared = useMemo(() => _find([...projects, ..._map(sharedProjects, (item) => ({ ...item.project, role: item.role }))], p => p.id === id) || {} as IProjectForShared, [projects, id, sharedProjects])
- const projectPassword: string = useMemo(() => password[id] || getItem(PROJECTS_PROTECTED)?.[id] || new URLSearchParams(window.location.search).get('password') || '', [id, password])
+ const projectPassword: string = useMemo(() => password[id] || getItem(PROJECTS_PROTECTED)?.[id] || queryPassword || '', [id, password, queryPassword])
/* isSharedProject is a boolean check if project is shared. If isSharedProject is true,
we used role and other colummn from sharedProjects.
@@ -2715,10 +2716,12 @@ ViewProject.propTypes = {
timezone: PropTypes.string,
embedded: PropTypes.bool.isRequired,
ssrAuthenticated: PropTypes.bool.isRequired,
+ queryPassword: PropTypes.string,
}
ViewProject.defaultProps = {
timezone: DEFAULT_TIMEZONE,
+ queryPassword: null,
}
export default memo(withProjectProtected(ViewProject))
diff --git a/app/pages/Project/View/components/RefRow.tsx b/app/pages/Project/View/components/RefRow.tsx
index bee34ee08..ac520688b 100644
--- a/app/pages/Project/View/components/RefRow.tsx
+++ b/app/pages/Project/View/components/RefRow.tsx
@@ -23,7 +23,7 @@ const RefRow = ({ rowName, showIcons }: {
}
return (
- <div>
+ <div className='overflow-auto'>
{showIcons && isUrl && !_isEmpty(url?.hostname) && (
<img
className='w-5 h-5 mr-1.5 float-left'
@@ -34,7 +34,7 @@ const RefRow = ({ rowName, showIcons }: {
)}
{isUrl ? (
<a
- className='flex label overflow-visible hover:underline text-blue-600 dark:text-blue-500'
+ className='flex label hover:underline text-blue-600 dark:text-blue-500'
href={rowName}
target='_blank'
rel='noopener noreferrer nofollow'
@@ -44,7 +44,7 @@ const RefRow = ({ rowName, showIcons }: {
{rowName}
</a>
) : (
- <span className='flex label overflow-visible hover:underline text-blue-600 dark:text-blue-500'>
+ <span className='flex label hover:underline text-blue-600 dark:text-blue-500'>
{rowName}
</span>
)}
diff --git a/app/root.tsx b/app/root.tsx
index b6b8084b9..b5d478da2 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -218,11 +218,17 @@ export default function App() {
const { i18n, t } = useTranslation('common')
const { title } = getPageMeta(t, url)
- const alternateLinks = _map(whitelist, (lc) => ({
- rel: 'alternate',
- hrefLang: lc,
- href: `${url}?lng=${lc}`,
- }))
+ const urlObject = new URL(url)
+
+ const alternateLinks = _map(whitelist, (lc) => {
+ urlObject.searchParams.set('lng', lc)
+
+ return {
+ rel: 'alternate',
+ hrefLang: lc,
+ href: urlObject.toString(),
+ }
+ })
useChangeLanguage(locale)
diff --git a/app/routes/projects.$id.tsx b/app/routes/projects.$id.tsx
index 7f57241aa..054f4733e 100644
--- a/app/routes/projects.$id.tsx
+++ b/app/routes/projects.$id.tsx
@@ -5,7 +5,9 @@ import { json } from '@remix-run/node'
import _split from 'lodash/split'
import { API_URL } from 'redux/constants'
-import { detectTheme, isEmbedded, isAuthenticated } from 'utils/server'
+import {
+ detectTheme, isEmbedded, isAuthenticated, getProjectPassword,
+} from 'utils/server'
import ProjectViewStyle from 'styles/ProjectViewStyle.css'
export const links: LinksFunction = () => [
@@ -25,16 +27,19 @@ export const meta: V2_MetaFunction = ({ location }) => {
export async function loader({ request }: LoaderArgs) {
const embedded = isEmbedded(request)
+ const queryPassword = getProjectPassword(request)
const [theme] = detectTheme(request)
const isAuth = isAuthenticated(request)
- return json({ theme, embedded, isAuth })
+ return json({
+ theme, embedded, isAuth, queryPassword,
+ })
}
export default function Index() {
const {
- theme, embedded, isAuth,
+ theme, embedded, isAuth, queryPassword,
} = useLoaderData<typeof loader>()
- return <ViewProject ssrTheme={theme} ssrAuthenticated={isAuth} embedded={embedded} />
+ return <ViewProject ssrTheme={theme} ssrAuthenticated={isAuth} embedded={embedded} queryPassword={queryPassword} />
}
diff --git a/app/styles/index.css b/app/styles/index.css
index 0779bde9f..924decd57 100644
--- a/app/styles/index.css
+++ b/app/styles/index.css
@@ -160,151 +160,6 @@ html {
scroll-behavior: smooth;
}
-
-.santa-claus {
- position: absolute;
- top: 0;
- right: 0;
- z-index: 20;
- /* rotateZ(195deg) */
- transform: rotateZ(195deg) translateY(140px) translateX(15px);
- /* move to top 100px after render */
-}
-
-.sc-head {
- width: 80px;
- height: 80px;
- border-radius: 40%;
- background: #f7caaf;
- position: relative;
-}
-
-.sc-head .eyes {
- position: absolute;
- left: 2px;
- top: 20px;
- display: table;
- margin: 0 auto;
-}
-
-.sc-head .eyes::before,
-.sc-head .eyes::after {
- content: "";
- width: 8px;
- height: 8px;
- background: #000;
- border-radius: 50%;
- display: inline-block;
- margin: 0 15px;
-}
-
-.sc-head .nose {
- width: 20px;
- height: 13px;
- border-radius: 50%;
- background: #d48c7e;
- top: 32px;
- position: relative;
-}
-
-.sc-head .beard {
- position: absolute;
- bottom: -45px;
- left: -10px;
- background: #fff;
- width: calc(100% + 20px);
- height: 80px;
- border-radius: 20% 20% 60% 60%;
-}
-
-.sc-head .beard::before {
- content: "";
- width: 20px;
- height: 20px;
- background: #000;
- border-radius: 0 0 50% 50%;
- margin-top: 6px;
-}
-
-.sc-head .ears {
- width: calc(100% + 17px);
- position: absolute;
- top: 25px;
- left: -8px;
-}
-
-.sc-head .ears .ear {
- width: 10px;
- height: 20px;
- background: #d48c7e;
- border-radius: 50% 0 0 50%;
-}
-
-.sc-head .ears .ear.left {
- float: left;
-}
-
-.sc-head .ears .ear.right {
- float: right;
- transform: rotateZ(180deg);
-}
-
-.sc-hat {
- position: absolute;
- top: -37px;
- left: -6px;
- width: calc(100% + 10px);
- height: 55px;
- background: #de3939;
- border-radius: 60px 80px 0 0;
-}
-
-.sc-hat::before {
- content: "";
- width: inherit;
- height: 20px;
- background: #fff;
- display: block;
- border-radius: 6px;
- position: absolute;
- bottom: -5px;
- left: -4px;
-}
-
-.sc-hat .hat-tip {
- width: 0;
- height: 0;
- border-left: 20px solid transparent;
- border-right: 20px solid transparent;
- border-bottom: 69px solid #de3939;
- position: absolute;
- top: -37px;
- animation: 2s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
- left: 8px;
-}
-
-.sc-hat .hat-tip::before {
- content: "";
- width: 20px;
- height: 20px;
- background: #fff;
- border-radius: 50%;
- display: block;
- position: absolute;
- left: -13px;
- top: -10px;
-}
-
-.sc-body {
- position: absolute;
- left: -70px;
- width: 200px;
- height: 200px;
- background: #de3939;
- border-radius: 30%;
-}
-
-
/* Temporary solution: this WILL override all the other colour - background colour transitions */
/* Do not use animations for people with vestibular motion disorders */
* {
diff --git a/app/utils/getPosts.ts b/app/utils/getPosts.ts
index 6c8b59dff..a11b9bc56 100644
--- a/app/utils/getPosts.ts
+++ b/app/utils/getPosts.ts
@@ -9,7 +9,7 @@ renderer.link = (href: string, title: string | null | undefined, text: string) =
const url = new URL(href)
if (url.hostname !== 'swetrix.com') {
- url.searchParams.append('utm_source', 'swetrix.com')
+ url.searchParams.set('utm_source', 'swetrix.com')
}
return `<a href="${url.toString()}" referrerpolicy="strict-origin-when-cross-origin" target="_blank" rel="noopener noreferrer">${text}</a>`
diff --git a/app/utils/server.ts b/app/utils/server.ts
index b1d54e0c1..0caec60ce 100644
--- a/app/utils/server.ts
+++ b/app/utils/server.ts
@@ -44,9 +44,8 @@ export function detectTheme(request: Request): [ThemeType, boolean] {
return ['light', false]
}
-
/**
- * Function detects theme based on user's browser hints and cookies
+ * Function detects theme based on the query
*
* @param request
* @returns boolean
@@ -55,6 +54,16 @@ export function isEmbedded(request: Request): boolean {
return new URL(request.url).searchParams.get('embedded') === 'true'
}
+/**
+ * Function returns password from query
+ *
+ * @param request
+ * @returns boolean
+ */
+export function getProjectPassword(request: Request): string | null {
+ return new URL(request.url).searchParams.get('password')
+}
+
export function getAccessToken(request: Request): string | null {
const cookie = request.headers.get('Cookie')
const accessToken = cookie?.match(/(?<=access_token=)[^;]*/)?.[0]