📈 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
protected project related improvements
Blue Mouse373e590b30ad
diff --git a/public/locales/en.json b/public/locales/en.jsonindex 70a6a7c81..9acdfd440 100644--- a/public/locales/en.json+++ b/public/locales/en.json@@ -30,7 +30,9 @@"socialisationUnlinkGenericError": "Error occurred while unlinking Swetrix account with the 3rd party service","socialisationAuthGenericError": "Error occurred while authenticating with a 3rd party service","socialAccountLinked": "The Swetrix account has been linked with your selected provider",- "socialAccountUninked": "The Swetrix account has been unlinked from the selected provider"+ "socialAccountUninked": "The Swetrix account has been unlinked from the selected provider",+ "enterPassword": "Please enter the password",+ "incorrectPassword": "Incorrect password, please try again."},"common": {"features": "Features",@@ -655,7 +657,10 @@"partially": "Reset partially","partiallyDesc": "The 'Reset partially' function allows you to reset the data of a specific project within a given date range.","partiallyHint": "To reset the data of a specific project within a date range, select the start and end dates of the range and the project you wish to reset.\nDouble-check that you have selected the correct project and date range before clicking 'Reset'.\nOnce you click 'Reset', all the data associated with the selected project within the selected date range will be permanently deleted and cannot be recovered."- }+ },+ "protected": "Password protected Dashboard",+ "protectedHint": "You can make your Dashboard public & password protected. This way, only people who know the password will be able to access it.",+ "password": "Dashboard password"},"captcha": {"settings": {@@ -816,7 +821,8 @@"main": "Ultimate open-source analytics to satisfy all your needs","press": "Media & Press","socialisation": "Socialisation",- "open": "Open startup"+ "open": "Open startup",+ "passwordProtected": "This project is password protected"},"header": {"switchTheme": "Switch theme",diff --git a/src/api/index.ts b/src/api/index.tsindex c1a9eba36..63e7de455 100644--- a/src/api/index.ts+++ b/src/api/index.ts@@ -283,7 +283,7 @@ export const getProject = (pid: string, isCaptcha: boolean = false, password?: sapi.get(`/project/${pid}?isCaptcha=${isCaptcha}`, {headers: {- password,+ 'x-password': password,},}).then((response): IProject => response.data)@@ -379,7 +379,7 @@ export const getProjectData = (`log?pid=${pid}&timeBucket=${tb}&period=${period}&filters=${JSON.stringify(filters)}&from=${from}&to=${to}&timezone=${timezone}`,{headers: {- password,+ 'x-password': password,},},)@@ -406,7 +406,7 @@ export const getProjectCompareData = (`log/chart?pid=${pid}&timeBucket=${tb}&period=${period}&filters=${JSON.stringify(filters)}&from=${from}&to=${to}&timezone=${timezone}`,{headers: {- password,+ 'x-password': password,},},)@@ -433,7 +433,7 @@ export const getPerfData = (`log/performance?pid=${pid}&timeBucket=${tb}&period=${period}&filters=${JSON.stringify(filters)}&from=${from}&to=${to}&timezone=${timezone}`,{headers: {- password,+ 'x-password': password,},},)@@ -471,7 +471,7 @@ export const getOverallStats = (pids: string[], password?: string) =>`log/birdseye?pids=[${_map(pids, (pid) => `"${pid}"`).join(',')}]`,{headers: {- password,+ 'x-password': password,},},)@@ -498,7 +498,7 @@ export const getLiveVisitors = (pids: string[], password?: string) =>api.get(`log/hb?pids=[${_map(pids, (pid) => `"${pid}"`).join(',')}]`, {headers: {- password,+ 'x-password': password,},}).then((response) => response.data)@@ -681,7 +681,7 @@ export const getLiveVisitorsInfo = (pid: string, password?: string) =>api.get(`log/liveVisitors?pid=${pid}`, {headers: {- password,+ 'x-password': password,},}).then((response): IGetLiveVisitorsInfo[] => response.data)@@ -843,7 +843,7 @@ export const getProjectDataCustomEvents = (`log/custom-events?pid=${pid}&timeBucket=${tb}&period=${period}&filters=${JSON.stringify(filters)}&from=${from}&to=${to}&timezone=${timezone}&customEvents=${JSON.stringify(customEvents)}`,{headers: {- password,+ 'x-password': password,},},)@@ -999,7 +999,7 @@ export const getUserFlow = (`log/user-flow?pid=${pid}&timeBucket=${tb}&period=${period}&filters=${JSON.stringify(filters)}&from=${from}&to=${to}&timezone=${timezone}`,{headers: {- password,+ 'x-password': password,},},)@@ -1015,7 +1015,7 @@ export const checkPassword = (pid: string, password: string) =>api.get(`project/password/${pid}`, {headers: {- password,+ 'x-password': password,},}).then((response): Boolean => response.data)diff --git a/src/pages/Project/ProjectProtectedPassword/index.tsx b/src/pages/Project/ProjectProtectedPassword/index.tsxindex 537867d38..e747e3d56 100644--- a/src/pages/Project/ProjectProtectedPassword/index.tsx+++ b/src/pages/Project/ProjectProtectedPassword/index.tsx@@ -3,15 +3,13 @@ import { useHistory, useParams } from 'react-router-dom'import { useTranslation } from 'react-i18next'import _keys from 'lodash/keys'import _isEmpty from 'lodash/isEmpty'+import _size from 'lodash/size'import _replace from 'lodash/replace'import Title from 'components/Title'import routes from 'routes'import Input from 'ui/Input'import Button from 'ui/Button'-import {- isValidPassword, MIN_PASSWORD_CHARS,-} from 'utils/validator'import { checkPassword } from 'api'import { useDispatch } from 'react-redux'import UIActions from 'redux/reducers/ui'@@ -20,6 +18,8 @@ interface IProjectProtectedPasswordForm {password: string,}+const MAX_PASSWORD_LENGTH = 80+const ProjectProtectedPassword = (): JSX.Element => {const { t }: {t: (key: string, optinions?: {@@ -46,8 +46,12 @@ const ProjectProtectedPassword = (): JSX.Element => {password?: string,}- if (!isValidPassword(form.password)) {- allErrors.password = t('auth.common.xCharsError', { amount: MIN_PASSWORD_CHARS })+ if (_isEmpty(form.password)) {+ allErrors.password = t('apiNotifications.enterPassword')+ }++ if (_size(form.password) >= MAX_PASSWORD_LENGTH) {+ allErrors.password = t('auth.common.passwordTooLong', { amount: MAX_PASSWORD_LENGTH })}const valid = _isEmpty(_keys(allErrors))@@ -73,7 +77,7 @@ const ProjectProtectedPassword = (): JSX.Element => {history.push(_replace(routes.project, ':id', id))}setErrors({- password: t('auth.common.wrongPassword'),+ password: t('apiNotifications.incorrectPassword'),})}).catch((err) => {@@ -111,31 +115,29 @@ const ProjectProtectedPassword = (): JSX.Element => {}return (- <Title title={t('titles.password')}>+ <Title title={t('titles.passwordProtected')}><div className='min-h-page bg-gray-50 dark:bg-slate-900 flex flex-col py-6 px-4 sm:px-6 lg:px-8'><form className='max-w-7xl w-full mx-auto' onSubmit={handleSubmit}><h2 className='mt-2 text-3xl font-bold text-gray-900 dark:text-gray-50'>- {t('auth.common.password')}- {id}+ {t('titles.passwordProtected')}</h2><Inputname='password'id='password'type='password'label={t('auth.common.password')}- hint={t('auth.common.hint', { amount: MIN_PASSWORD_CHARS })}value={form.password}placeholder={t('auth.common.password')}className='mt-4'onChange={handleInput}error={beenSubmitted && errors.password}/>- <div className='mt-2'>+ <div className='mt-5'><Button className='mr-2 border-indigo-100 dark:text-gray-50 dark:border-slate-700/50 dark:bg-slate-800 dark:hover:bg-slate-700' onClick={onCancel} secondary regular>{t('common.cancel')}</Button><Button type='submit' loading={isLoading} primary regular>- {t('common.save')}+ {t('common.continue')}</Button></div></form>diff --git a/src/pages/Project/Settings/ProjectSettings.tsx b/src/pages/Project/Settings/ProjectSettings.tsxindex 695185338..06b33e7b4 100644--- a/src/pages/Project/Settings/ProjectSettings.tsx+++ b/src/pages/Project/Settings/ProjectSettings.tsx@@ -33,7 +33,6 @@ import Checkbox from 'ui/Checkbox'import Modal from 'ui/Modal'import FlatPicker from 'ui/Flatpicker'import { nanoid } from 'utils/random'-import { isValidPassword, MIN_PASSWORD_CHARS } from 'utils/validator'import { trackCustom } from 'utils/analytics'import routes from 'routes'import { getFormatDate } from '../View/ViewProject.helpers'@@ -232,7 +231,6 @@ const ProjectSettings = ({}loadProjects(isSharedProject)- history.push(routes.dashboard)} catch (e) {if (isSettings) {updateProjectFailed(e as string)@@ -315,10 +313,6 @@ const ProjectSettings = ({allErrors.ipBlacklist = t('project.settings.oxCharsError', { amount: MAX_IPBLACKLIST_LENGTH })}- if (!_isEmpty(form?.password) && _size(form.password) > 0 && !isValidPassword(form?.password || '')) {- allErrors.password = t('auth.common.xCharsError', { amount: MIN_PASSWORD_CHARS })- }-const valid = _isEmpty(_keys(allErrors))setErrors(allErrors)