📈 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
some improvements
Blue Mouse9a566ab9875c
diff --git a/public/locales/en.json b/public/locales/en.jsonindex 2b37442e9..d0f5fa528 100644--- a/public/locales/en.json+++ b/public/locales/en.json@@ -631,6 +631,8 @@"xEvMo": "{{amount}} events per month.","upToXVMo": "Up to {{amount}} visits per month.","xVMo": "{{amount}} visits per month.",+ "xAlertsSingular": "{{amount}} alerting rule",+ "xAlertsPlural": "{{amount}} alerting rules","upToXProjects": "Create up to {{amount}} projects.","upToXWebsites": "Add up to {{amount}} websites.","xMoDataRetention": "{{amount}} months of data retention.",diff --git a/src/pages/MainPage/Pricing.jsx b/src/pages/MainPage/Pricing.jsxindex 59ac03c14..a12816452 100644--- a/src/pages/MainPage/Pricing.jsx+++ b/src/pages/MainPage/Pricing.jsx@@ -11,7 +11,7 @@ import cx from 'clsx'import Modal from 'ui/Modal'import Spin from 'ui/icons/Spin'-import { CONTACT_EMAIL, paddleLanguageMapping } from 'redux/constants'+import { CONTACT_EMAIL, paddleLanguageMapping, PLAN_LIMITS } from 'redux/constants'import { errorsActions } from 'redux/actions/errors'import { alertsActions } from 'redux/actions/alerts'import { authActions } from 'redux/actions/auth'@@ -25,8 +25,9 @@ const getTiers = (t) => [priceMonthly: null,includedFeatures: [t('pricing.tiers.upToXVMo', { amount: '5,000' }),- t('pricing.tiers.upToXWebsites', { amount: 10 }),+ t('pricing.tiers.upToXWebsites', { amount: PLAN_LIMITS.free.maxProjects }),// t('pricing.tiers.xMoDataRetention', { amount: 3 }),+ t('pricing.tiers.xAlertsSingular', { amount: PLAN_LIMITS.free.maxAlerts }),t('pricing.tiers.dataExports'),t('pricing.tiers.dataOwnership'),t('pricing.tiers.noBanners'),@@ -42,7 +43,8 @@ const getTiers = (t) => [includedFeatures: [t('pricing.tiers.evXPlanIncl', { plan: t('pricing.tiers.hobby') }),t('pricing.tiers.xVMo', { amount: '100,000' }),- t('pricing.tiers.upToXWebsites', { amount: 20 }),+ t('pricing.tiers.upToXWebsites', { amount: PLAN_LIMITS.freelancer.maxProjects }),+ t('pricing.tiers.xAlertsPlural', { amount: PLAN_LIMITS.freelancer.maxAlerts }),// t('pricing.tiers.xMoDataRetention', { amount: 12 }),t('pricing.tiers.smallBusiSupport'),],@@ -57,6 +59,7 @@ const getTiers = (t) => [includedFeatures: [t('pricing.tiers.evXPlanIncl', { plan: t('pricing.tiers.freelancer') }),t('pricing.tiers.xVMo', { amount: '1,000,000' }),+ t('pricing.tiers.xAlertsPlural', { amount: PLAN_LIMITS.startup.maxAlerts }),// t('pricing.tiers.xMoDataRetention', { amount: 12 }),],pid: 752317,@@ -71,7 +74,8 @@ const getTiers = (t) => [includedFeatures: [t('pricing.tiers.evXPlanIncl', { plan: t('pricing.tiers.startup') }),t('pricing.tiers.xVMo', { amount: '5,000,000' }),- t('pricing.tiers.upToXWebsites', { amount: 30 }),+ t('pricing.tiers.upToXWebsites', { amount: PLAN_LIMITS.enterprise.maxProjects }),+ t('pricing.tiers.xAlertsPlural', { amount: PLAN_LIMITS.enterprise.maxAlerts }),// t('pricing.tiers.xMoDataRetention', { amount: 24 }),],pid: 752318,diff --git a/src/pages/Project/Alerts/View/ProjectAlertsView.container.jsx b/src/pages/Project/Alerts/View/ProjectAlertsView.container.jsxindex 646913f49..476179d1a 100644--- a/src/pages/Project/Alerts/View/ProjectAlertsView.container.jsx+++ b/src/pages/Project/Alerts/View/ProjectAlertsView.container.jsx@@ -6,6 +6,7 @@ const mapStateToProps = (state) => ({alerts: state.ui.alerts.alerts,loading: state.ui.alerts.loading,user: state.auth.user,+ total: state.ui.alerts.total,})export default connect(mapStateToProps)(ProjectAlerts)diff --git a/src/pages/Project/Alerts/View/ProjectAlertsView.jsx b/src/pages/Project/Alerts/View/ProjectAlertsView.jsxindex 38e0ec3cd..e6bb8e4a2 100644--- a/src/pages/Project/Alerts/View/ProjectAlertsView.jsx+++ b/src/pages/Project/Alerts/View/ProjectAlertsView.jsx@@ -1,5 +1,7 @@/* eslint-disable react/forbid-prop-types */-import React, { useMemo, memo } from 'react'+import React, {+ useMemo, memo, useState,+} from 'react'import dayjs from 'dayjs'import _map from 'lodash/map'import _isEmpty from 'lodash/isEmpty'@@ -11,19 +13,23 @@ import _trucate from 'lodash/truncate'import { useHistory } from 'react-router-dom'import { useTranslation } from 'react-i18next'import PropTypes from 'prop-types'-import { BellIcon } from '@heroicons/react/24/outline'+import { BellIcon, CurrencyDollarIcon } from '@heroicons/react/24/outline'import routes from 'routes'import Button from 'ui/Button'-import { QUERY_METRIC } from 'redux/constants'+import PaidFeature from 'modals/PaidFeature'+import { QUERY_METRIC, PLAN_LIMITS } from 'redux/constants'const ProjectAlerts = ({- projectId, alerts, loading, user,+ projectId, alerts, loading, user, total,}) => {const { t, i18n: { language } } = useTranslation()+ const [isPaidFeatureOpened, setIsPaidFeatureOpened] = useState(false)const history = useHistory()- // find in alerts alert with pid === projectId+ const limits = PLAN_LIMITS[user.planCode]+ const isLimitReached = total >= limits.maxAlerts+const projectAlerts = useMemo(() => {if (loading) return []return _filter(alerts, ({ pid }) => pid === projectId)@@ -42,21 +48,30 @@ const ProjectAlerts = ({return !_isEmpty(user) && user.telegramChatId && user.isTelegramChatIdConfirmed}, [user])+ const handleNewAlert = () => {+ if (isLimitReached) {+ setIsPaidFeatureOpened(true)+ return+ }++ history.push(_replace(routes.create_alert, ':pid', projectId))+ }+return (<div>- <div className='flex justify-between items-center'>+ <div className='flex justify-between items-center mt-4'>{!loading && !_isEmpty(projectAlerts) && (<><h2 className='text-2xl font-bold dark:text-white text-gray-800'>Alerts</h2><Button- className='mt-4'type='button'primarylarge- onClick={() => {- history.push(_replace(routes.create_alert, ':pid', projectId))- }}+ onClick={handleNewAlert}>+ {isLimitReached && (+ <CurrencyDollarIcon className='w-5 h-5 mr-1' />+ )}{t('alert.add')}</Button></>@@ -142,6 +157,10 @@ const ProjectAlerts = ({</div>)}</div>+ <PaidFeature+ isOpened={isPaidFeatureOpened}+ onClose={() => setIsPaidFeatureOpened(false)}+ /></div>)}@@ -151,6 +170,7 @@ ProjectAlerts.propTypes = {alerts: PropTypes.array.isRequired,loading: PropTypes.bool.isRequired,user: PropTypes.object.isRequired,+ total: PropTypes.number.isRequired,}export default memo(ProjectAlerts)diff --git a/src/redux/constants/index.js b/src/redux/constants/index.jsindex 408d3023d..501871b48 100644--- a/src/redux/constants/index.js+++ b/src/redux/constants/index.js@@ -235,3 +235,27 @@ export const THEME_TYPE = {}export const DEFAULT_ALERTS_TAKE = 10++// Eventually this should be fetched from the API, e.g. GET /config route+export const PLAN_LIMITS = {+ free: {+ monthlyUsageLimit: 5000,+ maxProjects: 10,+ maxAlerts: 1,+ },+ freelancer: {+ monthlyUsageLimit: 100000,+ maxProjects: 20,+ maxAlerts: 10,+ },+ startup: {+ monthlyUsageLimit: 1000000,+ maxProjects: 20,+ maxAlerts: 50,+ },+ enterprise: {+ monthlyUsageLimit: 5000000,+ maxProjects: 30,+ maxAlerts: 100,+ },+}