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!

added support for pub projects for anonymous users

Blue Mouse95181442dbb2
diff --git a/src/hoc/protected.js b/src/hoc/protected.js
index 2c97774fa..63541c820 100644
--- a/src/hoc/protected.js
+++ b/src/hoc/protected.js
@@ -9,11 +9,7 @@ export const isAuthenticated = connectedRouterRedirect({
})
export const notAuthenticated = connectedRouterRedirect({
- redirectPath: (state) => {
- const path = state.auth.redirectPath
- return path || routes.dashboard
- },
-
+ redirectPath: () => routes.dashboard,
authenticatedSelector: state => !state.auth.authenticated,
wrapperDisplayName: 'userIsNotAuthenticated',
allowRedirectBack: false
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 520650bc9..1b7cea99a 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -7,6 +7,8 @@
"pricing": "Pricing",
"faqs": "FAQs",
"you": "You",
+ "explore": "Explore",
+ "liveDemo": "Live demo",
"dashboard": "Dashboard",
"logout": "Logout",
"save": "Save",
@@ -26,7 +28,7 @@
"signup": "Sign up, it's free!",
"signupTerms": "By signing up, you agree to our <tos>Terms and Conditions</tos> and <pp>Privacy Policy.</pp>",
"techDetails": "Want to know more technical details?",
- "lookAtDocs": "Look at the documentation and features pages.",
+ "lookAtDocs": "Look at the documentation and live demonstration pages.",
"readyToStart": "Ready to get started?",
"exploreService": "Explore our service or create an account.",
"faq": {
@@ -219,6 +221,7 @@
"contents": "Contents"
},
"project": {
+ "ad": "Want these stats for your website?",
"noExist": "The selected project does not exist",
"exportImg": "Export as image",
"noEvTitle": "No events yet",
diff --git a/src/index.scss b/src/index.scss
deleted file mode 100644
index 292f90752..000000000
--- a/src/index.scss
+++ /dev/null
@@ -1,40 +0,0 @@
-@tailwind base;
-@tailwind components;
-@tailwind utilities;
-
-html {
- scroll-behavior: smooth;
-}
-
-body {
- margin: 0;
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
- sans-serif;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
-}
-
-code {
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
-}
-
-.label {
- text-overflow: clip;
- white-space: nowrap;
- overflow-x: auto;
- scrollbar-width: thin;
-}
-
-.disabled {
- opacity: 0.8;
- cursor: not-allowed;
-}
-
-.hoverable {
- transition: opacity 300ms;
-
- &:hover {
- opacity: 0.75;
- }
-}
diff --git a/src/pages/MainPage/index.jsx b/src/pages/MainPage/index.jsx
index d3f56add7..5d03004ab 100644
--- a/src/pages/MainPage/index.jsx
+++ b/src/pages/MainPage/index.jsx
@@ -10,6 +10,8 @@ import Title from 'components/Title'
import SignUp from '../Auth/Signup/BasicSignup'
import Pricing from './Pricing'
+const LIVE_DEMO_URL = '/projects/STEzHcB1rALV'
+
const SquareDots = ({ className }) => (
<div className='hidden lg:block lg:absolute lg:inset-0 pointer-events-none' aria-hidden='true'>
<svg
@@ -171,10 +173,10 @@ const Main = () => {
</h2>
<div className='mt-6 space-y-4 sm:space-y-0 sm:flex sm:space-x-5'>
<Link
- to={routes.features}
+ to={LIVE_DEMO_URL}
className='flex items-center justify-center px-3 py-2 border border-transparent text-lg font-medium rounded-md shadow-sm text-indigo-800 bg-indigo-50 hover:bg-indigo-100'
>
- {t('common.features')}
+ {t('common.liveDemo')}
</Link>
<Link
to={routes.docs}
diff --git a/src/pages/Project/View/ViewProject.container.jsx b/src/pages/Project/View/ViewProject.container.jsx
index 898109e05..7bf1de3c1 100644
--- a/src/pages/Project/View/ViewProject.container.jsx
+++ b/src/pages/Project/View/ViewProject.container.jsx
@@ -8,6 +8,7 @@ const mapStateToProps = (state) => ({
isLoading: state.ui.projects.isLoading,
cache: state.ui.cache.analytics,
projectViewPrefs: state.ui.cache.projectViewPrefs,
+ authenticated: state.auth.authenticated,
})
const mapDispatchToProps = (dispatch) => ({
diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsx
index 246107a0d..3e28003eb 100644
--- a/src/pages/Project/View/ViewProject.jsx
+++ b/src/pages/Project/View/ViewProject.jsx
@@ -23,7 +23,6 @@ import Title from 'components/Title'
import {
tbPeriodPairs, tbsFormatMapper, getProjectCacheKey, LIVE_VISITORS_UPDATE_INTERVAL,
} from 'redux/constants'
-import { isAuthenticated } from 'hoc/protected'
import Button from 'ui/Button'
import Loader from 'ui/Loader'
import Dropdown from 'ui/Dropdown'
@@ -143,11 +142,11 @@ const NoEvents = ({ t }) => (
)
const ViewProject = ({
- projects, isLoading, showError, cache, setProjectCache, projectViewPrefs, setProjectViewPrefs, setPublicProject, setLiveStatsForProject,
+ projects, isLoading: _isLoading, showError, cache, setProjectCache, projectViewPrefs, setProjectViewPrefs, setPublicProject,
+ setLiveStatsForProject, authenticated,
}) => {
const { t } = useTranslation('common')
const periodPairs = tbPeriodPairs(t)
-
const dashboardRef = useRef(null)
const { id } = useParams()
const history = useHistory()
@@ -164,6 +163,7 @@ const ViewProject = ({
// That is needed when using 'Export as image' feature
// Because headless browser cannot do a request to the DDG API due to absense of The Same Origin Policy header
const [showIcons, setShowIcons] = useState(true)
+ const isLoading = authenticated ? _isLoading : false
const tnMapping = typeNameMapping(t)
@@ -244,7 +244,7 @@ const ViewProject = ({
}
return () => clearInterval(interval)
- }, [project])
+ }, [project, setLiveStatsForProject])
useEffect(() => {
if (!isLoading && _isEmpty(project)) {
@@ -274,7 +274,7 @@ const ViewProject = ({
onErrorLoading()
})
}
- }, [isLoading, project])
+ }, [isLoading, project, id, setPublicProject]) // eslint-disable-line
const updatePeriod = (newPeriod) => {
const newPeriodFull = _find(periodPairs, (el) => el.period === newPeriod)
@@ -317,7 +317,10 @@ const ViewProject = ({
if (!isLoading) {
return (
<Title title={name}>
- <div className='min-h-min-footer bg-gray-50 py-6 px-4 sm:px-6 lg:px-8' ref={dashboardRef}>
+ <div className={cx('bg-gray-50 py-6 px-4 sm:px-6 lg:px-8', {
+ 'min-h-min-footer': authenticated,
+ 'min-h-min-footer-ad': !authenticated,
+ })} ref={dashboardRef}>
<div className='flex flex-col md:flex-row items-center md:items-start justify-between h-10'>
<h2 className='text-3xl font-extrabold text-gray-900 break-words'>{name}</h2>
<div className='flex mt-3 md:mt-0'>
@@ -430,6 +433,34 @@ const ViewProject = ({
</div>
</div>
</div>
+ {!authenticated && (
+ <div className='bg-indigo-600'>
+ <div className='w-11/12 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:px-8 lg:flex lg:items-center lg:justify-between'>
+ <h2 className='text-3xl sm:text-4xl font-extrabold tracking-tight text-gray-900'>
+ <span className='block text-white'>
+ {t('project.ad')}
+ </span>
+ <span className='block text-gray-300'>
+ {t('main.exploreService')}
+ </span>
+ </h2>
+ <div className='mt-6 space-y-4 sm:space-y-0 sm:flex sm:space-x-5'>
+ <Link
+ to={routes.signup}
+ className='flex items-center justify-center px-3 py-2 border border-transparent text-lg font-medium rounded-md shadow-sm text-indigo-800 bg-indigo-50 hover:bg-indigo-100'
+ >
+ {t('common.getStarted')}
+ </Link>
+ <Link
+ to={routes.main}
+ className='flex items-center justify-center px-3 py-2 border border-transparent text-lg font-medium rounded-md shadow-sm text-indigo-800 bg-indigo-50 hover:bg-indigo-100'
+ >
+ {t('common.explore')}
+ </Link>
+ </div>
+ </div>
+ </div>
+ )}
</Title>
)
}
@@ -454,6 +485,7 @@ ViewProject.propTypes = {
user: PropTypes.object.isRequired,
setPublicProject: PropTypes.func.isRequired,
setLiveStatsForProject: PropTypes.func.isRequired,
+ authenticated: PropTypes.bool.isRequired,
}
-export default isAuthenticated(memo(ViewProject))
+export default memo(ViewProject)
diff --git a/tailwind.config.js b/tailwind.config.js
index a3b20f178..edd6af1b9 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -27,6 +27,7 @@ module.exports = {
'72': '18rem',
'page': 'calc(100vh - 74px)', // header height -> 74px
'min-footer': 'calc(100vh - 162px)', // 74px + 88px footer height
+ 'min-footer-ad': 'calc(100vh - 265px)', // 74px + 88px footer height
},
},
variants: {