📈 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
Improved Notificatons, Dashboard & Project
Blue Mouseb9ddfa319449
diff --git a/src/index.js b/src/index.jsindex 7f8ee6d79..6b7506aa9 100644--- a/src/index.js+++ b/src/index.js@@ -4,7 +4,7 @@ import { BrowserRouter } from 'react-router-dom'import { store } from 'redux/store'import { Provider } from 'react-redux'import { transitions, positions, Provider as AlertProvider } from 'react-alert'-import AlertTemplate from 'react-alert-template-basic'+import AlertTemplate from 'ui/Alert'import 'billboard.js/dist/billboard.min.css'import App from './App'diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsxindex 555a90f49..0a68273dd 100644--- a/src/pages/Dashboard/Dashboard.jsx+++ b/src/pages/Dashboard/Dashboard.jsx@@ -2,6 +2,7 @@ import React, { memo } from 'react'import { Link } from 'react-router-dom'import Spinner from 'react-bootstrap/Spinner'import Alert from 'react-bootstrap/Alert'+import dayjs from 'dayjs'import PropTypes from 'prop-types'import _isEmpty from 'lodash/isEmpty'import _map from 'lodash/map'@@ -9,9 +10,10 @@ import { EyeIcon } from '@heroicons/react/outline'import { ChartBarIcon } from '@heroicons/react/outline'import { CalendarIcon } from '@heroicons/react/outline'+import { ActivePin, InactivePin } from 'ui/Pin'import routes from 'routes'-const ProjectCart = ({ name, url }) => (+const ProjectCart = ({ name, url, created, active }) => (<li><Link to={url} className='block hover:bg-gray-50'><div className='px-4 py-4 sm:px-6'>@@ -19,10 +21,12 @@ const ProjectCart = ({ name, url }) => (<p className='text-base font-medium text-indigo-600 truncate'>{name}</p>- <div class="ml-2 flex-shrink-0 flex">- <p class="px-2 inline-flex text-sm leading-5 font-semibold rounded-full bg-green-100 text-green-800">- Active- </p>+ <div className='ml-2 flex-shrink-0 flex'>+ {active ? (+ <ActivePin label='Active' />+ ) : (+ <InactivePin label='Disabled' />+ )}</div></div><div className='mt-2 sm:flex sm:justify-between'>@@ -39,7 +43,7 @@ const ProjectCart = ({ name, url }) => (<div className='mt-2 flex items-center text-sm text-gray-500'><CalendarIcon className='flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400' /><p>- Created at <time datetime='2020-01-07'>January 7, 2020</time>+ Created at <time datetime='2020-01-07'>{dayjs(created).format('MMMM D, YYYY')}</time></p></div></div>@@ -90,8 +94,8 @@ const Dashboard = ({ projects, isLoading, error }) => {) : (<div className='bg-white shadow overflow-hidden sm:rounded-md mt-10'><ul className='divide-y divide-gray-200'>- {_map(projects, ({ name, id }) => (- <ProjectCart key={id} name={name} url={routes.project.replace(':id', id)} />+ {_map(projects, ({ name, id, created, active }) => (+ <ProjectCart key={id} name={name} created={created} active={active} url={routes.project.replace(':id', id)} />))}</ul></div>diff --git a/src/pages/Project/Settings/ProjectSettings.jsx b/src/pages/Project/Settings/ProjectSettings.jsxindex 3bd2c45fc..57d704310 100644--- a/src/pages/Project/Settings/ProjectSettings.jsx+++ b/src/pages/Project/Settings/ProjectSettings.jsx@@ -8,6 +8,7 @@ import PropTypes from 'prop-types'import { createProject, updateProject, deleteProject } from 'api'import Input from 'ui/Input'import Button from 'ui/Button'+import Checkbox from 'ui/Checkbox'import { nanoid } from 'utils/random'import routes from 'routes'import Modal from 'components/Modal'@@ -147,16 +148,27 @@ const ProjectSettings = ({disabled/>{isSettings && (- <Input- name='origins'- id='origins'- type='text'- label='Allowed origins'- value={form.origins}- className='mt-4'- onChange={handleInput}- error={beenSubmitted && errors.origins}- />+ <>+ <Input+ name='origins'+ id='origins'+ type='text'+ label='Allowed origins'+ value={form.origins}+ className='mt-4'+ onChange={handleInput}+ error={beenSubmitted && errors.origins}+ />+ <Checkbox+ checked={Boolean(form.active)}+ onChange={handleInput}+ name='active'+ id='active'+ className='mt-4'+ label='Is project enabled'+ hint={'Disabled projects will not count any newly incoming events or pageviews.\nYou will still be able to access the project\'s analytics in dashboard.'}+ />+ </>)}<div className='flex justify-between mt-4'><div>diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsxindex ec7d36fc0..93c83d5bc 100644--- a/src/pages/Project/View/ViewProject.jsx+++ b/src/pages/Project/View/ViewProject.jsx@@ -22,7 +22,7 @@ import routes from 'routes'import { getProjectData } from 'api'const typeNameMapping = {- tz: 'Timezone',+ cc: 'Country',pg: 'Page',lc: 'Locale',ref: 'Referrer',diff --git a/src/pages/UserSettings/UserSettings.jsx b/src/pages/UserSettings/UserSettings.jsxindex 089d05e59..7df1c621b 100644--- a/src/pages/UserSettings/UserSettings.jsx+++ b/src/pages/UserSettings/UserSettings.jsx@@ -112,6 +112,7 @@ const UserSettings = ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {<Button className='mt-4' type='submit' primary large>Update profile</Button>+ <hr className='mt-3' />{!user?.isActive && (<div href='#' className='flex cursor-pointer mt-4 pl-0 underline text-blue-600 hover:text-indigo-800' onClick={() => onEmailConfirm(setError)}><MailIcon className='mt-0.5 mr-2 w-6 h-6 text-blue-500' />diff --git a/src/redux/constants/index.js b/src/redux/constants/index.jsindex 64efac364..82a4aff28 100644--- a/src/redux/constants/index.js+++ b/src/redux/constants/index.js@@ -15,17 +15,17 @@ export const tbPeriodPairs = [{access: 'free',}, {label: 'Last 3 months',- period: '3m',+ period: '3M',tbs: ['week', 'month'],access: 'paid',}, {label: 'Last 12 months',- period: '12m',+ period: '12M',tbs: ['week', 'month'],access: 'paid',}, {label: 'Last 24 months',- period: '12m',+ period: '24M',tbs: ['month'],access: 'paid',}]diff --git a/src/ui/Alert.jsx b/src/ui/Alert.jsxnew file mode 100644index 000000000..44c8cafb4--- /dev/null+++ b/src/ui/Alert.jsx@@ -0,0 +1,61 @@+// Custom Alert template for react-alert+import React, { memo } from 'react'+import cx from 'classnames'+import PropTypes from 'prop-types'+import { CheckCircleIcon } from '@heroicons/react/solid'+import { InformationCircleIcon } from '@heroicons/react/solid'+import { XCircleIcon } from '@heroicons/react/solid'+import { XIcon } from '@heroicons/react/solid'++const AlertTemplate = ({ message, options, className, close }) => {+ const { type } = options+ const isInfo = type === 'info'+ const isSuccess = type === 'success'+ const isError = type === 'error'++ return (+ <div className={cx('flex justify-between items-center mb-5 mr-2 rounded-md p-4 z-20 shadow-sm w-96', {+ 'bg-green-50': isSuccess,+ 'bg-blue-50': isInfo,+ 'bg-red-50': isError,+ }, className)}>+ <div className='flex-shrink-0'>+ {isInfo && <InformationCircleIcon className='h-5 w-5 mr-2 text-blue-400' />}+ {isSuccess && <CheckCircleIcon className='h-5 w-5 mr-2 text-green-400' />}+ {isError && <XCircleIcon className='h-6 w-6 mr-2 text-red-400' />}+ </div>+ <span className={cx('text-sm font-medium uppercase', {+ 'text-green-800': isSuccess,+ 'text-blue-700': isInfo,+ 'text-red-800': isError,+ })}>{message}</span>+ <button+ onClick={close}+ type='button'+ className={cx('inline-flex cursor-pointer rounded-md p-1.5 focus:outline-none focus:ring-2 focus:ring-offset-2', {+ 'bg-green-50 text-green-500 hover:bg-green-100 focus:ring-offset-green-50 focus:ring-green-600': isSuccess,+ 'bg-blue-50 text-blue-500 hover:bg-blue-100 focus:ring-offset-blue-50 focus:ring-blue-600': isInfo,+ 'bg-red-50 text-red-500 hover:bg-red-100 focus:ring-offset-red-50 focus:ring-red-600': isError,+ })}>+ <span className='sr-only'>Dismiss</span>+ <XIcon className='h-5 w-5' />+ </button>+ </div>+ )+}++AlertTemplate.propTypes = {+ message: PropTypes.string,+ className: PropTypes.string,+ options: PropTypes.object,+ close: PropTypes.func,+}++AlertTemplate.defaultProps = {+ message: '',+ className: '',+ options: {},+ close: () => { },+}++export default memo(AlertTemplate)\ No newline at end of filediff --git a/src/ui/Checkbox.jsx b/src/ui/Checkbox.jsxindex ea1114b8f..9eae6c1d1 100644--- a/src/ui/Checkbox.jsx+++ b/src/ui/Checkbox.jsx@@ -8,7 +8,7 @@ const Checkbox = ({const identifier = id || namereturn (- <div className={cx('relative flex items-start', className)}>+ <div className={cx('relative flex items-start whitespace-pre-line', className)}><div className='flex items-center h-5'><inputid={identifier}@@ -17,11 +17,11 @@ const Checkbox = ({type='checkbox'checked={checked}onChange={onChange}- className='focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded'+ className='focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded cursor-pointer'/></div><div className='ml-3 text-sm'>- <label for={identifier} className='font-medium text-gray-700'>{label}</label>+ <label for={identifier} className='font-medium text-gray-700 cursor-pointer'>{label}</label>{hint && (<p id={`${identifier}-description`} className='text-gray-500'>{hint}</p>)}diff --git a/src/ui/Pin.jsx b/src/ui/Pin.jsxnew file mode 100644index 000000000..c82cace11--- /dev/null+++ b/src/ui/Pin.jsx@@ -0,0 +1,36 @@+import React from 'react'+import cx from 'classnames'+import PropTypes from 'prop-types'++const propTypes = {+ label: PropTypes.string.isRequired,+ className: PropTypes.string,+}++const defaultProps = {+ label: PropTypes.string.isRequired,+ className: '',+}++const ActivePin = ({ label, className }) => (+ <p className={cx('px-2 inline-flex text-sm leading-5 font-semibold rounded-full bg-green-100 text-green-800', className)}>+ {label}+ </p>+)++const InactivePin = ({ label, className }) => (+ <p className={cx('px-2 inline-flex text-sm leading-5 font-semibold rounded-full bg-red-100 text-red-800', className)}>+ {label}+ </p>+)++ActivePin.propTypes = propTypes+ActivePin.defaultProps = defaultProps++InactivePin.propTypes = propTypes+InactivePin.defaultProps = defaultProps++export {+ ActivePin,+ InactivePin,+}diff --git a/src/utils/random.js b/src/utils/random.jsindex a869a4ea3..212c8a86d 100644--- a/src/utils/random.js+++ b/src/utils/random.js@@ -2,4 +2,4 @@ import { customAlphabet } from 'nanoid'const legalCharacters = '1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm-'-export const nanoid = customAlphabet(legalCharacters, 11)+export const nanoid = customAlphabet(legalCharacters, 12)