📈 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
added paid subscription notification modal
Blue Mouse463b83c4d80a
diff --git a/public/locales/en.json b/public/locales/en.jsonindex 049206a2f..5a6f94720 100644--- a/public/locales/en.json+++ b/public/locales/en.json@@ -522,6 +522,12 @@"update": "Update payment details","nextBillDate": "Next bill date:"},+ "modals": {+ "paidFeature": {+ "title": "Upgrade your plan to use this feature",+ "desc": "We are sorry for the inconvenience, but you have to subscribe to a paid plan in order to use this feature.\n\nWe realise that you might not be ready to buy a paid subscription yet, but buying it will not only give you access to this feature, but also many other great perks, such as access to all the other paid features, higher limits on visits per month and number of websites available, and will help you support the growth of small business :)"+ }+ },"pricing": {"title": "Pricing Plans","adv": "Start out for free, no credit card needed.\nWhen your business grows, you can upgrade your plan at any time.",diff --git a/src/modals/PaidFeature.jsx b/src/modals/PaidFeature.jsxnew file mode 100644index 000000000..23303e964--- /dev/null+++ b/src/modals/PaidFeature.jsx@@ -0,0 +1,36 @@+import React from 'react'+import { useHistory } from 'react-router-dom'+import { useTranslation } from 'react-i18next'+import PropTypes from 'prop-types'++import Modal from 'ui/Modal'+import routes from 'routes'++const PaidFeature = ({ onClose, isOpened }) => {+ const { t } = useTranslation('common')+ const history = useHistory()++ const onSubmit = () => {+ history.push(routes.billing)+ }++ return (+ <Modal+ type='info'+ onClose={onClose}+ onSubmit={onSubmit}+ submitText={t('pricing.upgrade')}+ closeText={t('common.cancel')}+ message={t('modals.paidFeature.desc')}+ title={t('modals.paidFeature.title')}+ isOpened={isOpened}+ />+ )+}++PaidFeature.propTypes = {+ onClose: PropTypes.func.isRequired,+ isOpened: PropTypes.bool.isRequired,+}++export default PaidFeaturediff --git a/src/redux/constants/index.js b/src/redux/constants/index.jsindex 8d14dcf59..68e4a1e70 100644--- a/src/redux/constants/index.js+++ b/src/redux/constants/index.js@@ -76,6 +76,8 @@ export const tbsFormatMapper = {month: '%d %B %Y',}+export const FREE_TIER_KEY = 'free'+export const reportFrequencies = ['weekly', 'monthly', 'never']export const GDPR_EXPORT_TIMEFRAME = 14 // daysdiff --git a/src/redux/reducers/auth.js b/src/redux/reducers/auth.jsindex c3a4bbaee..bb981d018 100644--- a/src/redux/reducers/auth.js+++ b/src/redux/reducers/auth.js@@ -1,6 +1,7 @@import { types } from 'redux/actions/auth/types'import _filter from 'lodash/filter'import _map from 'lodash/map'+import { FREE_TIER_KEY, isSelfhosted } from '../constants'const initialState = {redirectPath: null,@@ -8,14 +9,24 @@ const initialState = {loading: true,user: {},dontRemember: false,+ // if the app is selfhosted, we assume that the user is using a paid tier so there won't be any restrictions or advertising of it+ isPaidTierUsed: isSelfhosted,}// eslint-disable-next-line default-param-lastconst authReducer = (state = initialState, { type, payload }) => {switch (type) {case types.SIGNUP_UP_SUCCESSFUL:- case types.LOGIN_SUCCESSFUL:- return { ...state, user: payload.user, authenticated: true }+ case types.LOGIN_SUCCESSFUL: {+ const { user } = payload++ return {+ ...state,+ user: payload.user,+ authenticated: true,+ isPaidTierUsed: isSelfhosted || (user?.planCode && user.planCode !== FREE_TIER_KEY),+ }+ }case types.UPDATE_USER_PROFILE_SUCCESS:return { ...state, user: payload.user }@@ -49,7 +60,14 @@ const authReducer = (state = initialState, { type, payload }) => {case types.UPDATE_USER_DATA: {const { data } = payload- return { ...state, user: { ...state.user, ...data } }++ return {+ ...state,+ user: {+ ...state.user,+ ...data,+ },+ }}case types.SET_USER_SHARE_DATA: {