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!

limited some parts of timeperiods for free users

Blue Mousec5588e7c04cd
diff --git a/src/pages/Project/View/ViewProject.container.jsx b/src/pages/Project/View/ViewProject.container.jsx
index c94e11096..78df864d3 100644
--- a/src/pages/Project/View/ViewProject.container.jsx
+++ b/src/pages/Project/View/ViewProject.container.jsx
@@ -15,6 +15,7 @@ const mapStateToProps = (state) => {
projectViewPrefs: state.ui.cache.projectViewPrefs,
authenticated: state.auth.authenticated,
timezone: state.auth.user.timezone,
+ isPaidTierUsed: state.auth.isPaidTierUsed,
user: state.auth.user,
}
}
@@ -27,6 +28,7 @@ const mapStateToProps = (state) => {
projectViewPrefs: state.ui.cache.projectViewPrefs,
authenticated: state.auth.authenticated,
timezone: state.auth.user.timezone,
+ isPaidTierUsed: state.auth.isPaidTierUsed,
user: state.auth.user,
}
}
diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsx
index 80b33eb87..8ad7a1f30 100644
--- a/src/pages/Project/View/ViewProject.jsx
+++ b/src/pages/Project/View/ViewProject.jsx
@@ -8,7 +8,9 @@ import { saveAs } from 'file-saver'
import bb, { area } from 'billboard.js'
import Flag from 'react-flagkit'
import {
- GlobeEuropeAfricaIcon, LanguageIcon, DocumentTextIcon, DeviceTabletIcon, ArrowRightCircleIcon, MagnifyingGlassIcon, ServerIcon, ArrowDownTrayIcon, Cog8ToothIcon, ArrowPathIcon,
+ GlobeEuropeAfricaIcon, LanguageIcon, DocumentTextIcon, DeviceTabletIcon,
+ ArrowRightCircleIcon, MagnifyingGlassIcon, ServerIcon, ArrowDownTrayIcon,
+ Cog8ToothIcon, ArrowPathIcon, CurrencyDollarIcon,
} from '@heroicons/react/24/outline'
import cx from 'clsx'
import * as d3 from 'd3'
@@ -31,13 +33,14 @@ import Title from 'components/Title'
import EventsRunningOutBanner from 'components/EventsRunningOutBanner'
import {
tbPeriodPairs, tbsFormatMapper, getProjectCacheKey, LIVE_VISITORS_UPDATE_INTERVAL, DEFAULT_TIMEZONE,
- timeBucketToDays, getProjectCacheCustomKey, roleViewer,
+ timeBucketToDays, getProjectCacheCustomKey, roleViewer, MAX_MONTHS_IN_PAST, MAX_MONTHS_IN_PAST_FREE,
} from 'redux/constants'
import Button from 'ui/Button'
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 {
getProjectData, getProject, getOverallStats, getLiveVisitors,
@@ -341,7 +344,7 @@ const Filters = ({
const ViewProject = ({
projects, isLoading: _isLoading, showError, cache, setProjectCache, projectViewPrefs, setProjectViewPrefs, setPublicProject,
- setLiveStatsForProject, authenticated, timezone, user, sharedProjects,
+ setLiveStatsForProject, authenticated, timezone, user, sharedProjects, isPaidTierUsed,
}) => {
const { t, i18n: { language } } = useTranslation('common')
const [periodPairs, setPeriodPairs] = useState(tbPeriodPairs(t))
@@ -355,6 +358,7 @@ const ViewProject = ({
const [arePeriodParsed, setArePeriodParsed] = useState(false)
const [panelsData, setPanelsData] = useState({})
const [isPanelsDataEmpty, setIsPanelsDataEmpty] = useState(false)
+ const [isPaidFeatureOpened, setIsPaidFeatureOpened] = useState(false)
const [analyticsLoading, setAnalyticsLoading] = useState(true)
const [period, setPeriod] = useState(projectViewPrefs[id]?.period || periodPairs[3].period)
const [timeBucket, setTimebucket] = useState(projectViewPrefs[id]?.timeBucket || periodPairs[3].tbs[1])
@@ -894,9 +898,27 @@ const ViewProject = ({
<Dropdown
items={periodPairs}
title={activePeriod.label}
- labelExtractor={(pair) => pair.dropdownLabel || pair.label}
+ labelExtractor={(pair) => {
+ const label = pair.dropdownLabel || pair.label
+
+ if (!isPaidTierUsed && pair.access === 'paid') {
+ return (
+ <span className='flex items-center'>
+ <CurrencyDollarIcon className='w-4 h-4 mr-1' />
+ {label}
+ </span>
+ )
+ }
+
+ return label
+ }}
keyExtractor={(pair) => pair.label}
onSelect={(pair) => {
+ if (!isPaidTierUsed && pair.access === 'paid') {
+ setIsPaidFeatureOpened(true)
+ return
+ }
+
if (pair.isCustomDate) {
setTimeout(() => {
refCalendar.current.openCalendar()
@@ -912,6 +934,7 @@ const ViewProject = ({
ref={refCalendar}
onChange={(date) => setRangeDate(date)}
value={rangeDate}
+ maxDateMonths={isPaidTierUsed ? MAX_MONTHS_IN_PAST : MAX_MONTHS_IN_PAST_FREE}
/>
</div>
</div>
@@ -1082,6 +1105,10 @@ const ViewProject = ({
</div>
</div>
)}
+ <PaidFeature
+ isOpened={isPaidFeatureOpened}
+ onClose={() => setIsPaidFeatureOpened(false)}
+ />
</Title>
)
}
@@ -1107,6 +1134,7 @@ ViewProject.propTypes = {
setPublicProject: PropTypes.func.isRequired,
setLiveStatsForProject: PropTypes.func.isRequired,
authenticated: PropTypes.bool.isRequired,
+ isPaidTierUsed: PropTypes.bool.isRequired,
timezone: PropTypes.string,
}
diff --git a/src/redux/constants/index.js b/src/redux/constants/index.js
index f17573b47..9d5634d6d 100644
--- a/src/redux/constants/index.js
+++ b/src/redux/constants/index.js
@@ -59,9 +59,13 @@ export const tbPeriodPairs = (t, tbs, dates) => [{
isCustomDate: true,
period: 'custom',
tbs: tbs || ['custom'],
- access: 'paid',
+ access: 'free',
}]
+// the maximum amount of months user can go back when picking a date in flat picker (project view)
+export const MAX_MONTHS_IN_PAST = 24
+export const MAX_MONTHS_IN_PAST_FREE = 3
+
export const timeBucketToDays = [
{ lt: 7, tb: ['hour', 'day'] }, // 7 days
{ lt: 28, tb: ['day', 'week'] }, // 4 weeks
diff --git a/src/ui/Flatpicker.jsx b/src/ui/Flatpicker.jsx
index d56e42830..a6c7340c5 100644
--- a/src/ui/Flatpicker.jsx
+++ b/src/ui/Flatpicker.jsx
@@ -5,6 +5,7 @@ import _size from 'lodash/size'
import PropTypes from 'prop-types'
import { getItem } from 'utils/localstorage'
+import { MAX_MONTHS_IN_PAST } from 'redux/constants'
import './Flatpicker.css'
if (getItem('colour-theme') === 'light') {
@@ -44,7 +45,7 @@ class FlatPicker extends React.Component {
}
render() {
- const { value } = this.props
+ const { value, maxDateMonths } = this.props
return (
<div className='h-0 flatpicker-custom'>
@@ -54,7 +55,7 @@ class FlatPicker extends React.Component {
options={{
mode: 'range',
maxDate: 'today',
- minDate: this.removeMonths(new Date(), 24),
+ minDate: this.removeMonths(new Date(), maxDateMonths),
showMonths: 1,
static: true,
animate: true,
@@ -74,11 +75,13 @@ class FlatPicker extends React.Component {
FlatPicker.propTypes = {
onChange: PropTypes.func,
value: PropTypes.arrayOf(PropTypes.instanceOf(Date)),
+ maxDateMonths: PropTypes.number,
}
FlatPicker.defaultProps = {
onChange: () => { },
value: [],
+ maxDateMonths: MAX_MONTHS_IN_PAST,
}
export default memo(FlatPicker)