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!

Integrated Stripe payments, added scroll to top HOC & minor bug fixes

Blue Mouse1dc124383081
diff --git a/.env.example b/.env.example
index fca0453f4..db09d5a05 100644
--- a/.env.example
+++ b/.env.example
@@ -1,3 +1,4 @@
REACT_APP_API_URL=https://example.com/api/
REACT_APP_TITLE_SUFFIX=| Swetrix
+REACT_APP_STRIPE_PUB_KEY=pk_live_thisisanexamplekey3415
CHOKIDAR_USEPOLLING=true
\ No newline at end of file
diff --git a/src/App.js b/src/App.js
index 27f86a80d..b6976550d 100644
--- a/src/App.js
+++ b/src/App.js
@@ -20,7 +20,9 @@ import UserSettings from 'pages/UserSettings'
import VerifyEmail from 'pages/Auth/VerifyEmail'
import ProjectSettings from 'pages/Project/Settings'
import ViewProject from 'pages/Project/View'
+import Billing from 'pages/Billing'
+import ScrollToTop from 'hoc/ScrollToTop'
import { isAuthenticated, notAuthenticated } from './hoc/protected'
import { getAccessToken } from 'utils/accessToken'
import { authMe } from './api'
@@ -29,6 +31,7 @@ import { errorsActions } from 'redux/actions/errors'
import { alertsActions } from 'redux/actions/alerts'
const ProtectedMain = notAuthenticated(MainPage)
+const ProtectedBilling = isAuthenticated(Billing)
const ProtectedSignIn = notAuthenticated(SignIn)
const ProtectedSignUp = notAuthenticated(SignUp)
const ProtectedForgotPassword = notAuthenticated(ForgotPassword)
@@ -94,21 +97,24 @@ const App = () => {
<>
<Header authenticated={authenticated} />
<Switch>
- <Route path={routes.main} component={ProtectedMain} exact />
- <Route path={routes.signin} component={ProtectedSignIn} exact />
- <Route path={routes.signup} component={ProtectedSignUp} exact />
- <Route path={routes.dashboard} component={ProtectedDashboard} exact />
- <Route path={routes.user_settings} component={ProtectedUserSettings} exact />
- <Route path={routes.verify} component={VerifyEmail} exact />
- <Route path={routes.change_email} component={VerifyEmail} exact />
- <Route path={routes.reset_password} component={ProtectedForgotPassword} exact />
- <Route path={routes.new_password_form} component={ProtectedNewPasswordForm} exact />
- <Route path={routes.new_project} component={ProtectedProjectSettings} exact />
- <Route path={routes.project_settings} component={ProtectedProjectSettings} exact />
- <Route path={routes.project} component={ProtectedViewProject} exact />
- <Route path={routes.docs} component={Docs} exact />
- <Route path={routes.features} component={Features} exact />
- <Redirect to={routes.main} />
+ <ScrollToTop>
+ <Route path={routes.main} component={ProtectedMain} exact />
+ <Route path={routes.signin} component={ProtectedSignIn} exact />
+ <Route path={routes.signup} component={ProtectedSignUp} exact />
+ <Route path={routes.dashboard} component={ProtectedDashboard} exact />
+ <Route path={routes.user_settings} component={ProtectedUserSettings} exact />
+ <Route path={routes.verify} component={VerifyEmail} exact />
+ <Route path={routes.change_email} component={VerifyEmail} exact />
+ <Route path={routes.reset_password} component={ProtectedForgotPassword} exact />
+ <Route path={routes.new_password_form} component={ProtectedNewPasswordForm} exact />
+ <Route path={routes.new_project} component={ProtectedProjectSettings} exact />
+ <Route path={routes.project_settings} component={ProtectedProjectSettings} exact />
+ <Route path={routes.project} component={ProtectedViewProject} exact />
+ <Route path={routes.billing} component={ProtectedBilling} exact />
+ <Route path={routes.docs} component={Docs} exact />
+ <Route path={routes.features} component={Features} exact />
+ <Redirect to={routes.main} />
+ </ScrollToTop>
</Switch>
<Footer minimal={isMinimalFooter} />
</>
diff --git a/src/api/index.js b/src/api/index.js
index eb42a707b..3424545c0 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -87,6 +87,22 @@ export const changeUserDetails = (data) =>
throw new Error(errorsArray)
})
+
+export const upgradePlan = (planCode) =>
+ api
+ .post('/user/upgrade', { planCode })
+ .catch(error => {
+ if (error?.response) {
+ const errorsArray = error.response.data.message
+ if (Array.isArray(errorsArray)) {
+ throw errorsArray
+ }
+ throw new Error(errorsArray)
+ } else {
+ throw new Error(error)
+ }
+ })
+
export const forgotPassword = (email) =>
api
.post('/auth/reset-password', email)
diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx
index 43b8e14f0..f8487e85e 100644
--- a/src/components/Header/index.jsx
+++ b/src/components/Header/index.jsx
@@ -24,7 +24,11 @@ const Header = ({ authenticated }) => {
</Link>
<div className='hidden ml-10 space-x-1 lg:block'>
<NavLink to={routes.features} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Features'>Features</NavLink>
- <HashLink to={`${routes.main}#pricing`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>Pricing</HashLink>
+ {authenticated ? (
+ <NavLink to={routes.billing} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Billing'>Billing</NavLink>
+ ) : (
+ <HashLink to={`${routes.main}#pricing`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>Pricing</HashLink>
+ )}
<HashLink to={`${routes.main}#faqs`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='FAQs'>FAQs</HashLink>
<NavLink to={routes.docs} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Docs'>Docs</NavLink>
</div>
@@ -46,7 +50,11 @@ const Header = ({ authenticated }) => {
</div>
<div className='py-4 flex flex-wrap justify-center space-x-2 lg:hidden'>
<NavLink to={routes.features} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Features'>Features</NavLink>
- <HashLink to={`${routes.main}#pricing`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>Pricing</HashLink>
+ {authenticated ? (
+ <NavLink to={routes.billing} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Billing'>Billing</NavLink>
+ ) : (
+ <HashLink to={`${routes.main}#pricing`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>Pricing</HashLink>
+ )}
<HashLink to={`${routes.main}#faqs`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='FAQs'>FAQs</HashLink>
<NavLink to={routes.docs} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Docs'>Docs</NavLink>
</div>
diff --git a/src/hoc/ScrollToTop.jsx b/src/hoc/ScrollToTop.jsx
new file mode 100644
index 000000000..5bc7427bc
--- /dev/null
+++ b/src/hoc/ScrollToTop.jsx
@@ -0,0 +1,30 @@
+import React, { useEffect } from 'react'
+import { useHistory } from 'react-router-dom'
+
+/**
+ * A HOC which listens to history changes and scrolls to top of the page when triggered.
+ *
+ * @component
+ * @param {HTMLElement} children The children covered by the listener.
+ */
+const ScrollToTop = ({ children }) => {
+ const history = useHistory()
+
+ useEffect(() => {
+ const unlisten = history.listen(({ hash }) => {
+ if (hash === '') {
+ setTimeout(() => {
+ window.scrollTo({
+ top: 0,
+ behavior: 'smooth',
+ })
+ }, 0)
+ }
+ })
+ return unlisten
+ }, [history])
+
+ return <>{children}</>
+}
+
+export default ScrollToTop
diff --git a/src/pages/Billing/index.jsx b/src/pages/Billing/index.jsx
new file mode 100644
index 000000000..9c3c93d1c
--- /dev/null
+++ b/src/pages/Billing/index.jsx
@@ -0,0 +1,33 @@
+import React from 'react'
+
+import Pricing from '../MainPage/Pricing'
+import Title from 'components/Title'
+
+const Features = () => {
+ return (
+ <Title title='Billing'>
+ <div className='bg-gray-50'>
+ <div className='w-4/5 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:px-8'>
+ <h1 className='text-4xl mb-4 font-extrabold text-gray-900 tracking-tight'>Billing &amp; Plans</h1>
+ <p className='text-lg text-gray-900 tracking-tight'>
+ It is free to get started and use our services.<br />
+ If you need to handle more traffic, you probably need to upgrade your plan.<br />
+ Below is a list of available plans. No hidden fees or other BS, everything is clear and transparent!
+ </p>
+ <Pricing />
+ <p className='text-lg text-gray-900 tracking-tight mt-10'>
+ Need to track more than 1 million events per month?<br />
+ Contact us at&nbsp;
+ <a href='mailto:[email protected]' className='font-medium text-indigo-600 hover:text-indigo-500'>
+ </a>
+ &nbsp;
+ to discuss your needs.
+ </p>
+ </div>
+ </div>
+ </Title>
+ )
+}
+
+export default Features
diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsx
index a9974872c..b9c3f181a 100644
--- a/src/pages/Dashboard/Dashboard.jsx
+++ b/src/pages/Dashboard/Dashboard.jsx
@@ -43,7 +43,7 @@ const ProjectCart = ({ name, url, created, active, overall }) => {
<EyeIcon className='flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400' />
Pageviews:&nbsp;
<dd className='flex items-baseline'>
- <p className='h-5 w-5 text-gray-500'>
+ <p className='h-5 mr-1 text-gray-500'>
{overall.thisWeek}
</p>
<p className={cx('flex text-xs -ml-1 items-baseline', {
diff --git a/src/pages/MainPage/Pricing.jsx b/src/pages/MainPage/Pricing.jsx
index f64228343..572b6ddf0 100644
--- a/src/pages/MainPage/Pricing.jsx
+++ b/src/pages/MainPage/Pricing.jsx
@@ -1,25 +1,33 @@
-import React from 'react'
+import React, { memo, useState } from 'react'
+import { useSelector, useDispatch } from 'react-redux'
import { Link } from 'react-router-dom'
import { CheckIcon } from '@heroicons/react/solid'
import _map from 'lodash/map'
import _isNil from 'lodash/isNil'
+import _isString from 'lodash/isString'
+import _isEmpty from 'lodash/isEmpty'
+import cx from 'classnames'
+import Spin from '../../ui/icons/Spin'
+import { errorsActions } from 'redux/actions/errors'
+import { upgradePlan } from 'api'
import routes from 'routes'
const tiers = [
{
name: 'Hobby',
+ planCode: 'free',
priceMonthly: null,
includedFeatures: [
'Up to 3000 events per month.',
'Create up to 5 projects.',
- '1 month of data retention.',
+ '3 months of data retention.',
'High standard security.',
],
},
{
name: 'Freelancer',
- href: '#',
+ planCode: 'freelancer',
priceMonthly: 24,
includedFeatures: [
'Everything \'Hobby\' plan includes.',
@@ -27,12 +35,13 @@ const tiers = [
'Create up to 10 projects.',
'12 months of data retention.',
'By buying this in you are supporting a small business.',
+ 'Your subscription contributes to carbon removal.',
],
},
{
name: 'Startup',
- href: '#',
- priceMonthly: 32,
+ planCode: 'startup',
+ priceMonthly: 72,
includedFeatures: [
'Everything \'Freelancer\' plan includes.',
'500k events per month.',
@@ -41,8 +50,8 @@ const tiers = [
},
{
name: 'Enterprise',
- href: '#',
- priceMonthly: 48,
+ planCode: 'enterprise',
+ priceMonthly: 110,
includedFeatures: [
'Everything \'Startup\' plan includes.',
'1m events per month.',
@@ -51,77 +60,136 @@ const tiers = [
},
]
-const Pricing = () => (
- <div id='pricing' className='bg-white'>
- <div className='w-11/12 max-w-7xl mx-auto py-24 px-4 sm:px-6 lg:px-8'>
- <div className='sm:flex sm:flex-col sm:align-center'>
- <h1 className='text-3xl font-extrabold text-gray-900 sm:text-center'>Pricing Plans</h1>
- <p className='mt-5 text-xl text-gray-500 sm:text-center'>
- Start out for free, no credit card needed.<br />
- When your business grows, you can upgrade your plan at any time.
- </p>
- {/* <div className='relative self-center mt-6 bg-gray-100 rounded-lg p-0.5 flex sm:mt-8'>
- <button
- type='button'
- className='relative w-1/2 bg-white border-gray-200 rounded-md shadow-sm py-2 text-sm font-medium text-gray-900 whitespace-nowrap focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:z-10 sm:w-auto sm:px-8'
- >
- Monthly billing
- </button>
- <button
- type='button'
- className='ml-0.5 relative w-1/2 border border-transparent rounded-md py-2 text-sm font-medium text-gray-700 whitespace-nowrap focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:z-10 sm:w-auto sm:px-8'
- >
- Yearly billing
- </button>
- </div> */}
- </div>
- <div className='mt-12 space-y-4 sm:mt-16 sm:space-y-0 sm:grid sm:grid-cols-2 sm:gap-6 lg:max-w-4xl lg:mx-auto xl:max-w-none xl:mx-0 xl:grid-cols-4'>
- {_map(tiers, (tier) => (
- <div key={tier.name} className='border border-gray-200 rounded-lg shadow-sm divide-y divide-gray-200'>
- <div className='p-6'>
- <h2 className='text-lg leading-6 font-medium text-gray-900'>{tier.name}</h2>
- <p className='mt-4'>
+const Pricing = () => {
+ const dispatch = useDispatch()
+ const { authenticated, user } = useSelector(state => state.auth)
+ const [planCodeLoading, setPlanCodeLoading] = useState(null)
+
+ const onPlanChange = async (planCode) => {
+ if (planCodeLoading === null) {
+ setPlanCodeLoading(planCode)
+ try {
+ const { data: { url } } = await upgradePlan(planCode)
+
+ if (_isEmpty(url)) {
+ dispatch('Payment error: No Stripe URL was provided')
+ } else {
+ window.location.href = url
+ }
+ } catch ({ message }) {
+ if (_isString(message)) {
+ dispatch(errorsActions.genericError(message))
+ }
+ } finally {
+ setPlanCodeLoading(null)
+ }
+ }
+ }
+
+ return (
+ <div id='pricing' className={cx({ 'bg-white': !authenticated })}>
+ <div className={cx('w-11/12 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8', { 'py-24': !authenticated })}>
+ <div className='sm:flex sm:flex-col sm:align-center'>
+ {!authenticated && (
+ <>
+ <h1 className='text-3xl font-extrabold text-gray-900 sm:text-center'>Pricing Plans</h1>
+ <p className='mt-5 text-xl text-gray-500 sm:text-center'>
+ Start out for free, no credit card needed.<br />
+ When your business grows, you can upgrade your plan at any time.
+ </p>
+ </>
+ )}
+ {/* <div className='relative self-center mt-6 bg-gray-100 rounded-lg p-0.5 flex sm:mt-8'>
+ <button
+ type='button'
+ className='relative w-1/2 bg-white border-gray-200 rounded-md shadow-sm py-2 text-sm font-medium text-gray-900 whitespace-nowrap focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:z-10 sm:w-auto sm:px-8'
+ >
+ Monthly billing
+ </button>
+ <button
+ type='button'
+ className='ml-0.5 relative w-1/2 border border-transparent rounded-md py-2 text-sm font-medium text-gray-700 whitespace-nowrap focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:z-10 sm:w-auto sm:px-8'
+ >
+ Yearly billing
+ </button>
+ </div> */}
+ </div>
+ <div className='mt-12 space-y-4 sm:mt-16 sm:space-y-0 sm:grid sm:grid-cols-2 sm:gap-6 lg:max-w-4xl lg:mx-auto xl:max-w-none xl:mx-0 xl:grid-cols-4'>
+ {_map(tiers, (tier) => (
+ <div key={tier.name} className={cx('relative border rounded-lg shadow-sm divide-y divide-gray-200', {
+ 'border-indigo-400': user.planCode === tier.planCode,
+ 'border-gray-200': user.planCode !== tier.planCode,
+ })}>
+ {user.planCode === tier.planCode && (
+ <div className='absolute inset-x-0 top-0 transform translate-y-px'>
+ <div className='flex justify-center transform -translate-y-1/2'>
+ <span className='inline-flex rounded-full bg-indigo-600 px-4 py-1 text-sm font-semibold tracking-wider uppercase text-white'>
+ Current plan
+ </span>
+ </div>
+ </div>
+ )}
+ <div className='p-6'>
+ <h2 className='text-lg leading-6 font-medium text-gray-900'>{tier.name}</h2>
+ <p className='mt-4'>
+ {_isNil(tier.priceMonthly) ? (
+ <span className='text-4xl font-extrabold text-gray-900'>Free</span>
+ ) : (
+ <>
+ <span className='text-4xl font-extrabold text-gray-900'>${tier.priceMonthly}</span>{' '}
+ <span className='text-base font-medium text-gray-500'>/mo</span>
+ </>
+ )}
+ </p>
{_isNil(tier.priceMonthly) ? (
- <span className='text-4xl font-extrabold text-gray-900'>Free</span>
+ <Link
+ className={cx('inline-flex items-center justify-center mt-8 w-full rounded-md py-2 text-sm font-semibold text-white text-center cursor-pointer select-none', {
+ 'bg-indigo-600 hover:bg-indigo-700': planCodeLoading === null,
+ 'bg-indigo-400': planCodeLoading !== null,
+ })}
+ to={routes.signup}
+ >
+ Get started
+ </Link>
+ ) : authenticated ? (
+ <span
+ onClick={() => onPlanChange(tier.planCode)}
+ className={cx('inline-flex items-center justify-center mt-8 w-full rounded-md py-2 text-sm font-semibold text-white text-center cursor-pointer select-none', {
+ 'bg-indigo-600 hover:bg-indigo-700': planCodeLoading === null,
+ 'bg-indigo-400': planCodeLoading !== null,
+ })}
+ >
+ {planCodeLoading === tier.planCode && (
+ <Spin />
+ )}
+ Upgrade
+ </span>
) : (
- <>
- <span className='text-4xl font-extrabold text-gray-900'>${tier.priceMonthly}</span>{' '}
- <span className='text-base font-medium text-gray-500'>/mo</span>
- </>
+ <Link
+ className='mt-8 block w-full bg-indigo-600 rounded-md py-2 text-sm font-semibold text-white text-center hover:bg-indigo-700'
+ to={routes.signup}
+ >
+ Upgrade
+ </Link>
)}
- </p>
- {_isNil(tier.priceMonthly) ? (
- <Link
- className='mt-8 block w-full bg-indigo-600 rounded-md py-2 text-sm font-semibold text-white text-center hover:bg-indigo-700'
- to={routes.signup}
- >
- Get started
- </Link>
- ) : (
- <a
- href={tier.href}
- className='mt-8 block w-full bg-indigo-600 rounded-md py-2 text-sm font-semibold text-white text-center hover:bg-indigo-700'
- >
- Buy {tier.name}
- </a>
- )}
- </div>
- <div className='pt-6 pb-8 px-6'>
- <h3 className='text-xs font-medium text-gray-900 tracking-wide uppercase'>What's included</h3>
- <ul className='mt-6 space-y-4'>
- {_map(tier.includedFeatures, (feature) => (
- <li key={feature} className='flex space-x-3'>
- <CheckIcon className='flex-shrink-0 h-5 w-5 text-green-500' aria-hidden='true' />
- <span className='text-sm text-gray-500'>{feature}</span>
- </li>
- ))}
- </ul>
+ </div>
+ <div className='pt-6 pb-8 px-6'>
+ <h3 className='text-xs font-medium text-gray-900 tracking-wide uppercase'>What's included</h3>
+ <ul className='mt-6 space-y-4'>
+ {_map(tier.includedFeatures, (feature) => (
+ <li key={feature} className='flex space-x-3'>
+ <CheckIcon className='flex-shrink-0 h-5 w-5 text-green-500' aria-hidden='true' />
+ <span className='text-sm text-gray-500'>{feature}</span>
+ </li>
+ ))}
+ </ul>
+ </div>
</div>
- </div>
- ))}
+ ))}
+ </div>
</div>
</div>
- </div>
-)
+ )
+}
-export default Pricing
+export default memo(Pricing)
diff --git a/src/pages/Project/View/Panels.jsx b/src/pages/Project/View/Panels.jsx
index 543efeb66..2f2d50884 100644
--- a/src/pages/Project/View/Panels.jsx
+++ b/src/pages/Project/View/Panels.jsx
@@ -53,14 +53,14 @@ const Overview = ({
<div className='flex justify-between'>
<p className='text-lg'>Pageviews:</p>
- <p className='h-5 w-5 mr-2 text-gray-900 text-xl'>
+ <p className='h-5 mr-2 text-gray-900 text-xl'>
{pageviews}
</p>
</div>
<div className='flex justify-between'>
<p className='text-lg'>Unique views:</p>
- <p className='h-5 w-5 mr-2 text-gray-900 text-xl'>
+ <p className='h-5 mr-2 text-gray-900 text-xl'>
{uniques}
</p>
</div>
@@ -73,7 +73,7 @@ const Overview = ({
<div className='flex justify-between'>
<p className='text-lg'>Pageviews:</p>
<dd className='flex items-baseline'>
- <p className='h-5 w-5 mr-2 text-gray-900 text-lg'>
+ <p className='h-5 mr-2 text-gray-900 text-lg'>
{overall.thisWeek}
</p>
<p className={cx('flex text-sm -ml-1 items-baseline', {
@@ -102,7 +102,7 @@ const Overview = ({
<div className='flex justify-between'>
<p className='text-lg'>Unique views:</p>
<dd className='flex items-baseline'>
- <p className='h-5 w-5 mr-2 text-gray-900 text-lg'>
+ <p className='h-5 mr-2 text-gray-900 text-lg'>
{overall.thisWeekUnique}
</p>
<p className={cx('flex text-sm -ml-1 items-baseline', {
diff --git a/src/redux/constants/index.js b/src/redux/constants/index.js
index 1f6cacc06..a463c06e0 100644
--- a/src/redux/constants/index.js
+++ b/src/redux/constants/index.js
@@ -45,6 +45,8 @@ export const TOKEN = 'access_token'
export const TITLE_SUFFIX = process.env.REACT_APP_TITLE_SUFFIX
+export const STRIPE_PUBLIC_KEY = process.env.REACT_APP_STRIPE_PUB_KEY
+
// Functions
export const getProjectCacheKey = (period, timeBucket) => `${period}${timeBucket}`
diff --git a/src/redux/reducers/auth.js b/src/redux/reducers/auth.js
index 202fcb485..588f52af1 100644
--- a/src/redux/reducers/auth.js
+++ b/src/redux/reducers/auth.js
@@ -4,7 +4,7 @@ const initialState = {
redirectPath: null,
authenticated: false,
loading: true,
- user: null
+ user: {},
}
const authReducer = (state = initialState, { type, payload }) => {
@@ -24,7 +24,7 @@ const authReducer = (state = initialState, { type, payload }) => {
case types.LOGOUT:
case types.DELETE_ACCOUNT_SUCCESS:
- return { ...state, authenticated: false, user: null }
+ return { ...state, authenticated: false, user: {} }
case types.FINISH_LOADING:
return { ...state, loading: false }
diff --git a/src/redux/sagas/ui/load_projects.js b/src/redux/sagas/ui/load_projects.js
index a9a38544e..3bb6a268e 100644
--- a/src/redux/sagas/ui/load_projects.js
+++ b/src/redux/sagas/ui/load_projects.js
@@ -1,5 +1,6 @@
import { put, call } from 'redux-saga/effects'
import _map from 'lodash/map'
+import _isString from 'lodash/isString'
import Debug from 'debug'
import { getProjects, getOverallStats } from '../../../api'
@@ -18,9 +19,10 @@ export default function* loadProjects() {
overall: overall[res.id],
}))
yield put(UIActions.setProjects(results))
- } catch (e) {
- const { message } = e
- yield put(UIActions.setProjectsError(message))
+ } catch ({ message }) {
+ if (_isString(message)) {
+ yield put(UIActions.setProjectsError(message))
+ }
debug('failed to load projects: %s', message)
}
}
diff --git a/src/routes.js b/src/routes.js
index 56b98c90d..035bd6b9e 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -13,6 +13,7 @@ const routes = Object.freeze({
project: '/projects/:id',
docs: '/docs',
features: '/features',
+ billing: '/billing',
})
export default routes