📈 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
removed the free tier limitation regarding time periods / time buckets
Blue Mousef4caa393651b
diff --git a/src/pages/Captcha/View/ViewCaptcha.container.tsx b/src/pages/Captcha/View/ViewCaptcha.container.tsxindex c1ffdbb53..390c2bd59 100644--- a/src/pages/Captcha/View/ViewCaptcha.container.tsx+++ b/src/pages/Captcha/View/ViewCaptcha.container.tsx@@ -13,7 +13,6 @@ const mapStateToProps = (state: StateType) => ({projectViewPrefs: state.ui.cache.captchaProjectsViewPrefs,authenticated: state.auth.authenticated,timezone: state.auth.user.timezone,- isPaidTierUsed: state.auth.isPaidTierUsed,user: state.auth.user,liveStats: state.ui.projects.liveStats,})diff --git a/src/pages/Captcha/View/ViewCaptcha.helpers.tsx b/src/pages/Captcha/View/ViewCaptcha.helpers.tsxindex defd6cdb3..8c4907669 100644--- a/src/pages/Captcha/View/ViewCaptcha.helpers.tsx+++ b/src/pages/Captcha/View/ViewCaptcha.helpers.tsx@@ -228,7 +228,6 @@ const getSettings = (chart: any, timeBucket: string, activeChartMetrics: {const validTimeBacket = ['hour', 'day', 'week', 'month']const validPeriods = ['custom', 'today', 'yesterday', '1d', '7d', '4w', '3M', '12M', '24M']-const paidPeriods = ['12M', '24M']const validFilters = ['cc', 'pg', 'lc', 'ref', 'dv', 'br', 'os', 'so', 'me', 'ca', 'lt', 'ev']const typeNameMapping = (t: (key: string) => string) => ({@@ -269,6 +268,6 @@ const getFormatDate = (date: Date) => {export {iconClassName, getFormatDate, panelIconMapping, typeNameMapping, validFilters,- validPeriods, validTimeBacket, paidPeriods, noRegionPeriods, getSettings,+ validPeriods, validTimeBacket, noRegionPeriods, getSettings,getExportFilename, getColumns, onCSVExportClick, CHART_METRICS_MAPPING,}diff --git a/src/pages/Captcha/View/ViewCaptcha.tsx b/src/pages/Captcha/View/ViewCaptcha.tsxindex 8d410a38d..044985922 100644--- a/src/pages/Captcha/View/ViewCaptcha.tsx+++ b/src/pages/Captcha/View/ViewCaptcha.tsx@@ -10,7 +10,7 @@ import domToImage from 'dom-to-image'import { saveAs } from 'file-saver'import bb from 'billboard.js'import {- ArrowDownTrayIcon, Cog8ToothIcon, ArrowPathIcon, CurrencyDollarIcon, PresentationChartBarIcon, PresentationChartLineIcon,+ ArrowDownTrayIcon, Cog8ToothIcon, ArrowPathIcon, PresentationChartBarIcon, PresentationChartLineIcon,} from '@heroicons/react/24/outline'import cx from 'clsx'import dayjs from 'dayjs'@@ -28,14 +28,13 @@ import _debounce from 'lodash/debounce'import _some from 'lodash/some'import PropTypes from 'prop-types'-import { SWETRIX_PID } from 'utils/analytics'import { getTimeFromSeconds, getStringFromTime } from 'utils/generic'import { getItem, setItem } from 'utils/localstorage'import Title from 'components/Title'import EventsRunningOutBanner from 'components/EventsRunningOutBanner'import {tbPeriodPairs, getProjectCaptchaCacheKey, timeBucketToDays, getProjectCacheCustomKey, roleViewer,- MAX_MONTHS_IN_PAST, MAX_MONTHS_IN_PAST_FREE, TimeFormat, chartTypes,+ MAX_MONTHS_IN_PAST, TimeFormat, chartTypes,} from 'redux/constants'import { ICaptchaProject, IProject, ILiveStats } from 'redux/models/IProject'import { IUser } from 'redux/models/IUser'@@ -44,7 +43,6 @@ import Loader from 'ui/Loader'import Dropdown from 'ui/Dropdown'import Checkbox from 'ui/Checkbox'import FlatPicker from 'ui/Flatpicker'-import PaidFeature from 'modals/PaidFeature'import routes from 'routes'import {getProject, getOverallStats, getLiveVisitors, getCaptchaData,@@ -54,7 +52,7 @@ import {} from './Panels'import {onCSVExportClick, getFormatDate, panelIconMapping, typeNameMapping, validFilters, validPeriods,- validTimeBacket, paidPeriods, noRegionPeriods, getSettings, CHART_METRICS_MAPPING,+ validTimeBacket, noRegionPeriods, getSettings, CHART_METRICS_MAPPING,} from './ViewCaptcha.helpers'import CCRow from './components/CCRow'import RefRow from './components/RefRow'@@ -67,7 +65,7 @@ interface IProjectView extends ICaptchaProject {}const ViewProject = ({- projects, isLoading: _isLoading, showError, cache, setProjectCache, projectViewPrefs, setProjectViewPrefs, authenticated, user, isPaidTierUsed, setProjects, liveStats,+ projects, isLoading: _isLoading, showError, cache, setProjectCache, projectViewPrefs, setProjectViewPrefs, authenticated, user, setProjects, liveStats,}: {projects: IProjectView[],isLoading: boolean,@@ -78,7 +76,6 @@ const ViewProject = ({setProjectViewPrefs: (pid: string, period: string, timeBucket: string, rangeDate?: Date[] | null) => void,authenticated: boolean,user: IUser,- isPaidTierUsed: boolean,// eslint-disable-next-line no-unused-vars, no-shadowsetProjects: (projects: ICaptchaProject[]) => void,liveStats: ILiveStats,@@ -101,7 +98,6 @@ const ViewProject = ({const [arePeriodParsed, setArePeriodParsed] = useState<boolean>(false)const [panelsData, setPanelsData] = useState<any>({})const [isPanelsDataEmpty, setIsPanelsDataEmpty] = useState<boolean>(false)- const [isPaidFeatureOpened, setIsPaidFeatureOpened] = useState<boolean>(false)const [analyticsLoading, setAnalyticsLoading] = useState<boolean>(true)const [period, setPeriod] = useState<string>(projectViewPrefs ? projectViewPrefs[id]?.period || periodPairs[3].period : periodPairs[3].period)const [timeBucket, setTimebucket] = useState<string>(projectViewPrefs ? projectViewPrefs[id]?.timeBucket || periodPairs[3].tbs[1] : periodPairs[3].tbs[1])@@ -572,7 +568,7 @@ const ViewProject = ({const url = new URL(window.location)const { searchParams } = urlconst intialPeriod = projectViewPrefs ? searchParams.get('period') || projectViewPrefs[id]?.period : searchParams.get('period') || '7d'- if (!_includes(validPeriods, intialPeriod) || (id !== SWETRIX_PID && !isPaidTierUsed && _includes(paidPeriods, intialPeriod))) {+ if (!_includes(validPeriods, intialPeriod)) {return}@@ -699,29 +695,9 @@ const ViewProject = ({<Dropdownitems={periodPairs}title={activePeriod.label}- labelExtractor={(pair) => {- const label = pair.dropdownLabel || pair.label-- // disable limitation for shared projects as project hosts already have a paid plan- // disable limitation for Swetrix public project (for demonstration purposes)- if (id !== SWETRIX_PID && !isPaidTierUsed && pair.access === 'paid') {- return (- <span className='flex items-center'>- <CurrencyDollarIcon className='w-4 h-4 mr-1' />- {label}- </span>- )- }-- return label- }}+ labelExtractor={(pair) => pair.dropdownLabel || pair.label}keyExtractor={(pair) => pair.label}onSelect={(pair) => {- if (id !== SWETRIX_PID && !isPaidTierUsed && pair.access === 'paid') {- setIsPaidFeatureOpened(true)- return- }-if (pair.isCustomDate) {setTimeout(() => {// @ts-ignore@@ -738,7 +714,7 @@ const ViewProject = ({ref={refCalendar}onChange={(date) => setDateRange(date)}value={dateRange || []}- maxDateMonths={(isPaidTierUsed || id === SWETRIX_PID) ? MAX_MONTHS_IN_PAST : MAX_MONTHS_IN_PAST_FREE}+ maxDateMonths={MAX_MONTHS_IN_PAST}/></div></div>@@ -971,10 +947,6 @@ const ViewProject = ({</div></div>)}- <PaidFeature- isOpened={isPaidFeatureOpened}- onClose={() => setIsPaidFeatureOpened(false)}- /></Title>)}@@ -997,7 +969,6 @@ ViewProject.propTypes = {setProjectViewPrefs: PropTypes.func.isRequired,isLoading: PropTypes.bool.isRequired,authenticated: PropTypes.bool.isRequired,- isPaidTierUsed: PropTypes.bool.isRequired,}export default memo(ViewProject)diff --git a/src/pages/Project/View/ViewProject.container.tsx b/src/pages/Project/View/ViewProject.container.tsxindex e9983346c..acb6d610a 100644--- a/src/pages/Project/View/ViewProject.container.tsx+++ b/src/pages/Project/View/ViewProject.container.tsx@@ -20,7 +20,6 @@ const mapStateToProps = (state: StateType) => {projectViewPrefs: state.ui.cache.projectViewPrefs,authenticated: state.auth.authenticated,timezone: state.auth.user.timezone,- isPaidTierUsed: state.auth.isPaidTierUsed,extensions: state.ui.misc.extensions,user: state.auth.user,projectTab: state.ui.projects.projectTab,@@ -38,7 +37,6 @@ const mapStateToProps = (state: StateType) => {projectViewPrefs: state.ui.cache.projectViewPrefs,authenticated: state.auth.authenticated,timezone: state.auth.user.timezone,- isPaidTierUsed: state.auth.isPaidTierUsed,extensions: state.ui.misc.extensions,user: state.auth.user,projectTab: state.ui.projects.projectTab,diff --git a/src/pages/Project/View/ViewProject.helpers.tsx b/src/pages/Project/View/ViewProject.helpers.tsxindex 6f94d9a80..2717330ba 100644--- a/src/pages/Project/View/ViewProject.helpers.tsx+++ b/src/pages/Project/View/ViewProject.helpers.tsx@@ -620,7 +620,6 @@ const getSettingsPerf = (const validTimeBacket = ['hour', 'day', 'week', 'month']const validPeriods = ['custom', 'today', 'yesterday', '1d', '7d', '4w', '3M', '12M', '24M']-const paidPeriods = ['12M', '24M']const validFilters = ['cc', 'pg', 'lc', 'ref', 'dv', 'br', 'os', 'so', 'me', 'ca', 'lt', 'ev']const typeNameMapping = (t: (str: string) => string) => ({@@ -661,7 +660,7 @@ const getFormatDate = (date: Date) => {export {iconClassName, getFormatDate, panelIconMapping, typeNameMapping, validFilters,- validPeriods, validTimeBacket, paidPeriods, noRegionPeriods, getSettings,+ validPeriods, validTimeBacket, noRegionPeriods, getSettings,getExportFilename, getColumns, onCSVExportClick, CHART_METRICS_MAPPING,CHART_METRICS_MAPPING_PERF, getColumnsPerf, getSettingsPerf, transformAIChartData,}diff --git a/src/pages/Project/View/ViewProject.tsx b/src/pages/Project/View/ViewProject.tsxindex 2b808b460..540accefb 100644--- a/src/pages/Project/View/ViewProject.tsx+++ b/src/pages/Project/View/ViewProject.tsx@@ -10,7 +10,8 @@ import domToImage from 'dom-to-image'import { saveAs } from 'file-saver'import bb from 'billboard.js'import {- ArrowDownTrayIcon, Cog8ToothIcon, ArrowPathIcon, CurrencyDollarIcon, ChartBarIcon, BoltIcon, BellIcon, PresentationChartBarIcon, PresentationChartLineIcon, NoSymbolIcon,+ ArrowDownTrayIcon, Cog8ToothIcon, ArrowPathIcon, ChartBarIcon, BoltIcon, BellIcon,+ PresentationChartBarIcon, PresentationChartLineIcon, NoSymbolIcon,} from '@heroicons/react/24/outline'import cx from 'clsx'import dayjs from 'dayjs'@@ -35,14 +36,13 @@ import _truncate from 'lodash/truncate'import PropTypes from 'prop-types'import * as SwetrixSDK from '@swetrix/sdk'-import { SWETRIX_PID } from 'utils/analytics'import { getTimeFromSeconds, getStringFromTime } from 'utils/generic'import { getItem, setItem } from 'utils/localstorage'import Title from 'components/Title'import EventsRunningOutBanner from 'components/EventsRunningOutBanner'import {tbPeriodPairs, getProjectCacheKey, LIVE_VISITORS_UPDATE_INTERVAL, DEFAULT_TIMEZONE, CDN_URL, isDevelopment,- timeBucketToDays, getProjectCacheCustomKey, roleViewer, MAX_MONTHS_IN_PAST, MAX_MONTHS_IN_PAST_FREE, PROJECT_TABS,+ timeBucketToDays, getProjectCacheCustomKey, roleViewer, MAX_MONTHS_IN_PAST, PROJECT_TABS,TimeFormat, getProjectForcastCacheKey, chartTypes, roleAdmin, TRAFFIC_PANELS_ORDER, PERFORMANCE_PANELS_ORDER,} from 'redux/constants'import { IUser } from 'redux/models/IUser'@@ -55,7 +55,6 @@ import Checkbox from 'ui/Checkbox'import Select from 'ui/Select'import FlatPicker from 'ui/Flatpicker'import Robot from 'ui/icons/Robot'-import PaidFeature from 'modals/PaidFeature'import Forecast from 'modals/Forecast'import routes from 'routes'import {@@ -67,7 +66,7 @@ import {} from './Panels'import {onCSVExportClick, getFormatDate, panelIconMapping, typeNameMapping, validFilters, validPeriods,- validTimeBacket, paidPeriods, noRegionPeriods, getSettings, getColumns, CHART_METRICS_MAPPING,+ validTimeBacket, noRegionPeriods, getSettings, getColumns, CHART_METRICS_MAPPING,CHART_METRICS_MAPPING_PERF, getSettingsPerf, transformAIChartData,} from './ViewProject.helpers'import CCRow from './components/CCRow'@@ -86,7 +85,7 @@ interface IProjectView extends IProject {const ViewProject = ({projects, isLoading: _isLoading, showError, cache, cachePerf, setProjectCache, projectViewPrefs, setProjectViewPrefs, setPublicProject,- setLiveStatsForProject, authenticated, timezone, user, sharedProjects, isPaidTierUsed, extensions, generateAlert, setProjectCachePerf,+ setLiveStatsForProject, authenticated, timezone, user, sharedProjects, extensions, generateAlert, setProjectCachePerf,projectTab, setProjectTab, setProjects, setProjectForcastCache, customEventsPrefs, setCustomEventsPrefs, liveStats,}: {projects: IProjectView[],@@ -111,7 +110,6 @@ const ViewProject = ({setProjectForcastCache: (pid: string, data: any, key: string) => void,authenticated: boolean,user: IUser,- isPaidTierUsed: boolean,timezone: string,sharedProjects: ISharedProject[],projectTab: string,@@ -134,7 +132,6 @@ const ViewProject = ({label: stringperiod: stringtbs: string[]- access: stringdropdownLabel?: stringisCustomDate?: boolean}[]>(tbPeriodPairs(t))@@ -158,7 +155,6 @@ const ViewProject = ({const [arePeriodParsed, setArePeriodParsed] = useState<boolean>(false)const [panelsData, setPanelsData] = useState<any>({})const [isPanelsDataEmpty, setIsPanelsDataEmpty] = useState<boolean>(false)- const [isPaidFeatureOpened, setIsPaidFeatureOpened] = useState<boolean>(false)const [isForecastOpened, setIsForecastOpened] = useState<boolean>(false)const [analyticsLoading, setAnalyticsLoading] = useState<boolean>(true)const [period, setPeriod] = useState<string>(projectViewPrefs ? projectViewPrefs[id]?.period || periodPairs[3].period : periodPairs[3].period)@@ -1320,7 +1316,7 @@ const ViewProject = ({setProjectTab(PROJECT_TABS.performance)}- if (!_includes(validPeriods, intialPeriod) || (!isSharedProject && id !== SWETRIX_PID && !isPaidTierUsed && _includes(paidPeriods, intialPeriod))) {+ if (!_includes(validPeriods, intialPeriod)) {return}@@ -1543,29 +1539,9 @@ const ViewProject = ({<Dropdownitems={periodPairs}title={activePeriod?.label}- labelExtractor={(pair) => {- const label = pair.dropdownLabel || pair.label-- // disable limitation for shared projects as project hosts already have a paid plan- // disable limitation for Swetrix public project (for demonstration purposes)- if (!isSharedProject && id !== SWETRIX_PID && !isPaidTierUsed && pair.access === 'paid') {- return (- <span className='flex items-center'>- <CurrencyDollarIcon className='w-4 h-4 mr-1' />- {label}- </span>- )- }-- return label- }}+ labelExtractor={(pair) => pair.dropdownLabel || pair.label}keyExtractor={(pair) => pair.label}onSelect={(pair) => {- if (!isSharedProject && id !== SWETRIX_PID && !isPaidTierUsed && pair.access === 'paid') {- setIsPaidFeatureOpened(true)- return- }-if (pair.isCustomDate) {setTimeout(() => {// @ts-ignore@@ -1582,7 +1558,7 @@ const ViewProject = ({ref={refCalendar}onChange={(date) => setDateRange(date)}value={dateRange || []}- maxDateMonths={(isPaidTierUsed || id === SWETRIX_PID || isSharedProject) ? MAX_MONTHS_IN_PAST : MAX_MONTHS_IN_PAST_FREE}+ maxDateMonths={MAX_MONTHS_IN_PAST}/></div></div>@@ -2041,10 +2017,6 @@ const ViewProject = ({</div></div>)}- <PaidFeature- isOpened={isPaidFeatureOpened}- onClose={() => setIsPaidFeatureOpened(false)}- /><ForecastisOpened={isForecastOpened}onClose={() => setIsForecastOpened(false)}@@ -2077,7 +2049,6 @@ ViewProject.propTypes = {setLiveStatsForProject: PropTypes.func.isRequired,authenticated: PropTypes.bool.isRequired,extensions: PropTypes.arrayOf(PropTypes.object).isRequired,- isPaidTierUsed: PropTypes.bool.isRequired,timezone: PropTypes.string,}diff --git a/src/redux/constants/index.ts b/src/redux/constants/index.tsindex 4413a42d8..be7984efb 100644--- a/src/redux/constants/index.ts+++ b/src/redux/constants/index.ts@@ -26,56 +26,46 @@ export const tbPeriodPairs = (t: Function, tbs?: string[] | null, dates?: Date[]label: stringperiod: stringtbs: string[]- access: stringdropdownLabel?: stringisCustomDate?: boolean}[] => [{label: t('project.today'),period: 'today',tbs: ['hour'],- access: 'free',}, {label: t('project.yesterday'),period: 'yesterday',tbs: ['hour'],- access: 'free',}, {label: t('project.last24h'),period: '1d',tbs: ['hour'],- access: 'free',}, {label: t('project.lastXDays', { amount: 7 }),period: '7d',tbs: ['hour', 'day'],- access: 'free',}, {label: t('project.lastXWeeks', { amount: 4 }),period: '4w',tbs: ['day', 'week'],- access: 'free',}, {label: t('project.lastXMonths', { amount: 3 }),period: '3M',tbs: ['week', 'month'],- access: 'free',}, {label: t('project.lastXMonths', { amount: 12 }),period: '12M',tbs: ['week', 'month'],- access: 'paid',}, {label: t('project.lastXMonths', { amount: 24 }),period: '24M',tbs: ['month'],- access: 'paid',}, {label: dates ? getCustomLabel(dates, t) : t('project.custom'),dropdownLabel: t('project.custom'),isCustomDate: true,period: 'custom',tbs: tbs || ['custom'],- access: 'free',}]// the order of panels in the project view@@ -84,7 +74,6 @@ export const PERFORMANCE_PANELS_ORDER: string[] = ['cc', 'pg', 'br', '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-export const MAX_MONTHS_IN_PAST_FREE: number = 3export const timeBucketToDays: {lt: number