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!

hiding alerts tab for selfhosted

Blue Mouse85984ad3246b
diff --git a/src/pages/Project/View/ViewProject.tsx b/src/pages/Project/View/ViewProject.tsx
index db6cd5271..c9ecd3373 100644
--- a/src/pages/Project/View/ViewProject.tsx
+++ b/src/pages/Project/View/ViewProject.tsx
@@ -42,7 +42,7 @@ import EventsRunningOutBanner from 'components/EventsRunningOutBanner'
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,
+ TimeFormat, getProjectForcastCacheKey, chartTypes, roleAdmin, TRAFFIC_PANELS_ORDER, PERFORMANCE_PANELS_ORDER, isSelfhosted,
} from 'redux/constants'
import { IUser } from 'redux/models/IUser'
import { IProject, ILiveStats } from 'redux/models/IProject'
@@ -190,7 +190,7 @@ const ViewProject = ({
const { searchParams } = url
const tab = searchParams.get('tab') as string
- if (!PROJECT_TABS[tab]) {
+ if (PROJECT_TABS[tab]) {
return tab || 'traffic'
}
@@ -215,7 +215,7 @@ const ViewProject = ({
label: string
icon: any
}[] = useMemo(() => {
- return [
+ const selfhostedOnly = [
{
id: PROJECT_TABS.traffic,
label: t('dashboard.traffic'),
@@ -226,6 +226,14 @@ const ViewProject = ({
label: t('dashboard.performance'),
icon: BoltIcon,
},
+ ]
+
+ if (isSelfhosted) {
+ return selfhostedOnly
+ }
+
+ return [
+ ...selfhostedOnly,
{
id: PROJECT_TABS.alerts,
label: t('dashboard.alerts'),
diff --git a/src/redux/constants/index.ts b/src/redux/constants/index.ts
index 8cd8c5d63..332a3783b 100644
--- a/src/redux/constants/index.ts
+++ b/src/redux/constants/index.ts
@@ -68,6 +68,10 @@ export const tbPeriodPairs = (t: Function, tbs?: string[] | null, dates?: Date[]
tbs: tbs || ['custom'],
}]
+interface IStringObject {
+ [key: string]: string
+}
+
// the order of panels in the project view
export const TRAFFIC_PANELS_ORDER: string[] = ['cc', 'pg', 'lc', 'br', 'os', 'dv', 'ref', 'so', 'me', 'ca']
export const PERFORMANCE_PANELS_ORDER: string[] = ['cc', 'pg', 'br', 'dv']
@@ -86,27 +90,21 @@ export const timeBucketToDays: {
{ lt: 732, tb: ['month'] }, // 24 months
]
-export const tbsFormatMapper: {
- [key: string]: string
-} = {
+export const tbsFormatMapper: IStringObject = {
hour: '%d %b %H:%M',
day: '%d %b',
week: '%d %b',
month: '%d %b %Y',
}
-export const tbsFormatMapper24h: {
- [key: string]: string
-} = {
+export const tbsFormatMapper24h: IStringObject = {
hour: '%H:%M',
day: '%d %b',
week: '%d %b',
month: '%d %b %Y',
}
-export const TimeFormat: {
- [key: string]: string
-} = {
+export const TimeFormat: IStringObject = {
'12-hour': '12-hour',
'24-hour': '24-hour',
}
@@ -197,9 +195,7 @@ export const PAGE_FORCE_REFRESHED = 'page-force-refreshed'
// List of languages with translations available
export const whitelist: string[] = ['en', 'uk', 'pl', 'de', 'sv', 'el', 'ru', 'hi', 'zh']
export const defaultLanguage: string = 'en'
-export const languages: {
- [key: string]: string
-} = {
+export const languages: IStringObject = {
en: 'English',
uk: 'Українська',
pl: 'Polski',
@@ -211,9 +207,7 @@ export const languages: {
zh: '中文简体',
}
-export const languageFlag: {
- [key: string]: string
-} = {
+export const languageFlag: IStringObject = {
en: 'GB',
uk: 'UA',
pl: 'PL',
@@ -225,9 +219,7 @@ export const languageFlag: {
zh: 'CN',
}
-export const paddleLanguageMapping: {
- [key: string]: string
-} = {
+export const paddleLanguageMapping: IStringObject = {
zh: 'zh-Hans',
uk: 'ru',
el: 'en',
@@ -281,42 +273,39 @@ export const tabsForDashboard: IDashboardTabs[] = [
},
]
-export const PROJECT_TABS: {
- [key: string]: string
-} = {
+const SELFHOSTED_PROJECT_TABS: IStringObject = {
+ traffic: 'traffic',
+ performance: 'performance',
+}
+
+const PRODUCTION_PROJECT_TABS: IStringObject = {
traffic: 'traffic',
performance: 'performance',
alerts: 'alerts',
}
-export const DASHBOARD_TABS: {
- [key: string]: string
-} = {
+export const PROJECT_TABS = isSelfhosted ? SELFHOSTED_PROJECT_TABS : PRODUCTION_PROJECT_TABS
+
+export const DASHBOARD_TABS: IStringObject = {
owned: 'owned',
shared: 'shared',
captcha: 'captcha',
}
-export const QUERY_METRIC: {
- [key: string]: string
-} = {
+export const QUERY_METRIC: IStringObject = {
PAGE_VIEWS: 'page_views',
UNIQUE_PAGE_VIEWS: 'unique_page_views',
ONLINE_USERS: 'online_users',
}
-export const QUERY_CONDITION: {
- [key: string]: string
-} = {
+export const QUERY_CONDITION: IStringObject = {
GREATER_THAN: 'greater_than',
GREATER_EQUAL_THAN: 'greater_equal_than',
LESS_THAN: 'less_than',
LESS_EQUAL_THAN: 'less_equal_than',
}
-export const QUERY_TIME: {
- [key: string]: string
-} = {
+export const QUERY_TIME: IStringObject = {
LAST_15_MINUTES: 'last_15_minutes',
LAST_30_MINUTES: 'last_30_minutes',
LAST_1_HOUR: 'last_1_hour',
@@ -328,9 +317,7 @@ export const QUERY_TIME: {
export const INVITATION_EXPIRES_IN: number = 48 // hours
export const ENTRIES_PER_PAGE_DASHBOARD: number = 10
-export const THEME_TYPE: {
- [key: string]: string
-} = {
+export const THEME_TYPE: IStringObject = {
classic: 'classic',
christmas: 'christmas',
}