📈 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
get rid of internal documentation in favour of docs.swetrix.com
Blue Mousea60ad715f88b
diff --git a/src/App.js b/src/App.jsindex 1747adbf3..7e85c974b 100644--- a/src/App.js+++ b/src/App.js@@ -33,7 +33,6 @@ const ForgotPassword = lazy(() => import('pages/Auth/ForgotPassword'))const CreateNewPassword = lazy(() => import('pages/Auth/CreateNewPassword'))const Dashboard = lazy(() => import('pages/Dashboard'))const Contact = lazy(() => import('pages/Contact'))-const Docs = lazy(() => import('pages/Docs'))const Features = lazy(() => import('pages/Features'))const UserSettings = lazy(() => import('pages/UserSettings'))const VerifyEmail = lazy(() => import('pages/Auth/VerifyEmail'))@@ -186,7 +185,6 @@ const App = () => {<Route path={routes.project_settings} component={ProjectSettings} exact /><Route path={routes.project} component={ViewProject} exact /><Route path={routes.billing} component={Billing} exact />- <Route path={routes.docs} component={Docs} exact /><Route path={routes.contact} component={Contact} exact /><Route path={routes.features} component={Features} exact /><Route path={routes.privacy} component={Privacy} exact />diff --git a/src/components/Footer/index.jsx b/src/components/Footer/index.jsxindex 019d85832..bb7974242 100644--- a/src/components/Footer/index.jsx+++ b/src/components/Footer/index.jsx@@ -9,15 +9,14 @@ import PropTypes from 'prop-types'import {isSelfhosted, DONATE_URL, FIREFOX_ADDON_URL, CHROME_EXTENSION_URL, GITHUB_URL,LINKEDIN_URL, STATUSPAGE_URL, TWITTER_URL, BLOG_URL, UTM_GENERATOR_URL, SWETRIX_VS_GOOGLE,- SWETRIX_VS_CLOUDFLARE,+ SWETRIX_VS_CLOUDFLARE, DOCS_URL,} from 'redux/constants'import routes from 'routes'const navigation = {support: [(authenticated) => (authenticated ? { key: 'billing', href: routes.billing } : { key: 'pricing', href: `${routes.main}#pricing` }),- () => ({ key: 'docs', href: routes.docs }),- () => ({ key: 'guides', href: `${routes.docs}#docs-ht` }),+ () => ({ key: 'docs', href: DOCS_URL }),() => ({ key: 'contact', href: routes.contact, internal: true }),],company: [diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsxindex 409f2c1d1..9c438d386 100644--- a/src/components/Header/index.jsx+++ b/src/components/Header/index.jsx@@ -16,7 +16,7 @@ import routes from 'routes'import { authActions } from 'redux/actions/auth'import UIActions from 'redux/actions/ui'import {- whitelist, languages, languageFlag, isSelfhosted, BLOG_URL, THEME_TYPE,+ whitelist, languages, languageFlag, isSelfhosted, BLOG_URL, THEME_TYPE, DOCS_URL,} from 'redux/constants'import Dropdown from 'ui/Dropdown'@@ -94,10 +94,10 @@ const Header = ({ authenticated, theme, themeType }) => {</>))}- <NavLink to={routes.docs} className='flex justify-center items-center text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-2 dark:hover:bg-gray-700 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700 dark:bg-gray-700' key='Docs'>+ <a href={DOCS_URL} className='flex justify-center items-center text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-2 dark:hover:bg-gray-700 hover:bg-indigo-500 rounded-md' target='_blank' rel='noreferrer noopener'><DocumentTextIcon className='w-5 h-5 mr-1' />{t('common.docs')}- </NavLink>+ </a></div></div><div className='hidden md:flex justify-center items-center flex-wrap ml-1 md:ml-10 space-y-1 sm:space-y-0 space-x-2 md:space-x-4'>@@ -195,10 +195,10 @@ const Header = ({ authenticated, theme, themeType }) => {</NavLink></>)}- <NavLink to={routes.docs} className='flex justify-center items-center text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-2 dark:hover:bg-gray-700 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700 dark:bg-gray-700' key='Docs'>+ <a href={DOCS_URL} className='flex justify-center items-center text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-2 dark:hover:bg-gray-700 hover:bg-indigo-500 rounded-md' target='_blank' rel='noreferrer noopener'><DocumentTextIcon className='w-5 h-5 mr-1' />{t('common.docs')}- </NavLink>+ </a></div></nav></header>diff --git a/src/pages/Docs/Docs.container.jsx b/src/pages/Docs/Docs.container.jsxdeleted file mode 100644index 3da0e4e21..000000000--- a/src/pages/Docs/Docs.container.jsx+++ /dev/null@@ -1,5 +0,0 @@-// Container is needed just in case if the react-redux will be ever used in this component-// so it would be easy to integrate connect() here-import Docs from './Docs'--export default Docsdiff --git a/src/pages/Docs/Docs.jsx b/src/pages/Docs/Docs.jsxdeleted file mode 100644index e4a256a23..000000000--- a/src/pages/Docs/Docs.jsx+++ /dev/null@@ -1,291 +0,0 @@-/* eslint-disable jsx-a11y/anchor-has-content, react/jsx-one-expression-per-line */-import React, { memo, Fragment, useEffect } from 'react'-import _map from 'lodash/map'-import Prism from 'prismjs'-import { useTranslation, Trans } from 'react-i18next'--import Title from 'components/Title'-import Code from 'ui/Code'-import {- umdBuildExample, trackPageView, trackPVAPI, init, track, trackExample, npmInstall,- esExample, npmImport, trackPVReturnAPI,-} from './examples'--const contents = (t) => [{- name: t('docs.titles.start'),- id: 'docs-gs',- content: [{- name: t('docs.titles.umd'),- id: 'docs-umd',- }, {- name: t('docs.titles.npm'),- id: 'docs-npm',- }, {- name: t('docs.titles.int'),- id: 'docs-int',- }],-}, {- name: t('docs.titles.how'),- id: 'docs-ht',- content: [{- name: t('docs.titles.pv'),- id: 'docs-pv',- }, {- name: t('docs.titles.ce'),- id: 'docs-ce',- }],-}, {- name: t('docs.titles.api'),- id: 'docs-api',- content: [{- name: 'init',- id: 'docs-init',- }, {- name: 'track',- id: 'docs-tr',- }, {- name: 'trackViews',- id: 'docs-tv',- }],-}]--const NEXTJS_REPO_URL = 'https://github.com/Swetrix/swetrix-nextjs'--const integrations = [- {- name: 'Next.js',- link: NEXTJS_REPO_URL,- },- {- name: 'Python Django',- link: 'https://github.com/Swetrix/integrations/blob/main/django/README.md',- },- {- name: 'Webflow',- link: 'https://github.com/Swetrix/integrations/blob/main/webflow/README.md',- },- {- name: 'Wordpress',- link: 'https://github.com/Swetrix/integrations/blob/main/wordpress/README.md',- },- {- name: 'Wix',- link: 'https://github.com/Swetrix/integrations/blob/main/wix/README.md',- },- {- name: 'Ghost',- link: 'https://github.com/Swetrix/integrations/blob/main/ghost/README.md',- },- {- name: 'SvelteKit',- link: 'https://github.com/Swetrix/integrations/blob/main/sveltekit/README.md',- },-]--const thirdPartyIntegrations = [- {- name: 'Java SDK',- link: 'https://github.com/Casterlabs/swetrix-java',- },- {- name: 'Vue',- link: 'https://github.com/ansidev/swetrix-vue',- },-]--const Contents = ({ t }) => {- const tContents = contents(t)-- return (- <div className='lg:flex flex-1 items-start justify-center lg:order-2'>- <h2 className='block lg:hidden text-3xl font-bold text-gray-900 dark:text-gray-50 tracking-tight'>- {t('docs.contents')}- :- </h2>- <ol className='mb-10 lg:mb-0 lg:sticky lg:top-10'>- {_map(tContents, ({ name, id, content }) => (- <Fragment key={id}>- <li className='mt-3'>- <a className='hover:underline text-2xl text-blue-600 dark:text-gray-50 font-bold' href={`#${id}`}>{name}</a>- </li>- <ol>- {_map(content, ({ name: cname, id: cid }) => (- <li key={cid}>- <a className='hover:underline text-lg text-blue-500 dark:text-gray-200 px-4' href={`#${cid}`}>{cname}</a>- </li>- ))}- </ol>- </Fragment>- ))}- </ol>- </div>- )-}--const CHeader = ({ id, name, addHr = true }) => (- <>- {addHr && (- <hr className='mt-10 border-gray-200 dark:border-gray-600' />- )}- <h2 id={id} className='text-3xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-2 -mb-5'>{name}</h2>- </>-)--const CSection = ({ id, name }) => (- <h3 id={id} className='text-2xl font-normal text-gray-900 dark:text-gray-50 tracking-tight mt-8'>{name}</h3>-)--const Docs = () => {- const { t } = useTranslation('common')-- useEffect(() => {- Prism.highlightAll()- }, [])-- return (- <Title title={t('titles.docs')}>- <div className='bg-gray-50 dark:bg-gray-800'>- <div className='w-11/12 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:w-11/12 lg:px-8 lg:flex'>- <Contents t={t} />- <div className='flex-1 lg:order-1 whitespace-pre-line'>- <h1 className='text-4xl font-extrabold text-gray-900 dark:text-gray-50 tracking-tight'>- {t('titles.docs')}- </h1>-- <CHeader id='docs-gs' name={t('docs.titles.start')} addHr={false} />- <CSection id='docs-umd' name={t('docs.titles.umd')} />- <Code text={umdBuildExample} language='html' />-- <CSection id='docs-npm' name={t('docs.titles.npm')} />- <p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>- {t('docs.install')}- :- </p>- <Code text={npmInstall} language='bash' />- <p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>- {t('docs.import')}- :- </p>- <Code text={npmImport} language='javascript' />- <p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>- {t('docs.track')}- </p>- <Code text={esExample} language='javascript' />-- <CSection id='docs-int' name={t('docs.titles.int')} />- <p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>- {t('docs.integrations')}- :- </p>- <ul className='ml-5 text-lg list-disc marker:text-gray-900 dark:marker:text-gray-50'>- {_map(integrations, ({ name, link }) => (- <li key={name}>- <a href={link} className='flex hover:underline hover:opacity-80 text-indigo-600 dark:text-indigo-400 ml-1' target='_blank' rel='noopener noreferrer'>- {name}- </a>- </li>- ))}- </ul>- <p className='text-lg mt-5 text-gray-900 dark:text-gray-50 tracking-tight'>- {t('docs.3rdPartyInt')}- :- </p>- <ul className='ml-5 text-lg list-disc marker:text-gray-900 dark:marker:text-gray-50'>- {_map(thirdPartyIntegrations, ({ name, link }) => (- <li key={name}>- <a href={link} className='flex hover:underline hover:opacity-80 text-indigo-600 dark:text-indigo-400 ml-1' target='_blank' rel='noopener noreferrer'>- {name}- </a>- </li>- ))}- </ul>-- <CHeader id='docs-ht' name={t('docs.titles.how')} />- <CSection id='docs-pv' name={t('docs.titles.pv')} />- <p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>- <Trans- t={t}- i18nKey='docs.pv'- components={{- url: <a href='#docs-tv' className='font-bold hover:underline' />,- }}- />- </p>- <Code text={trackPageView} language='javascript' />-- <CSection id='docs-ce' name={t('docs.titles.ce')} />- <p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>- {t('docs.ce')}- </p>- <Code text={trackExample} language='javascript' />-- <CHeader id='docs-api' name={t('docs.titles.api')} />-- <CSection id='docs-init' name='init' />- <p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>- {t('docs.init')}- </p>- <Code text={init} language='javascript' />-- <CSection id='docs-tr' name='track' />- <p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>- {t('docs.tr')}- </p>- <Code text={track} language='javascript' />-- <CSection id='docs-tv' name='trackViews' />- <div className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>- {t('docs.tv.call')}- <div className='mb-5'>- <ul className='ml-10'>- <li><b>pid</b> - {t('docs.tv.params.pid')}</li>- <li><b>lc</b> - {t('docs.tv.params.lc')}</li>- <li><b>tz</b> - {t('docs.tv.params.tz')}</li>- <li><b>ref</b> - {t('docs.tv.params.ref')}</li>- <li><b>so</b> - {t('docs.tv.params.so')}</li>- <li><b>me</b> - {t('docs.tv.params.me')}</li>- <li><b>ca</b> - {t('docs.tv.params.ca')}</li>- <li><b>pg</b> - {t('docs.tv.params.pg')}</li>- </ul>- </div>- <Trans- t={t}- i18nKey='docs.tv.gather'- components={{- b: <b />,- }}- />- </div>- <Code text={trackPVAPI} language='javascript' />- <p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>- {t('docs.tvReturn')}- </p>- <Code text={trackPVReturnAPI} language='javascript' />-- <hr className='mt-10 mb-4 border-gray-200 dark:border-gray-600' />- <div className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>- <i>Last updated: December 31, 2022.</i><br />- <div>- <br />- - The- {' '}- <a className='hover:underline text-gray-700 dark:text-gray-300' href='#docs-tv'>trackViews</a>- {' '}- method is now asynchronous and returns a promise. The- {' '}- <a className='hover:underline text-gray-700 dark:text-gray-300' href='#docs-tv'>trackViews</a>- {' '}- starts working after the load event fires. It is required for the performance stats to be collected correctly.-- <br />- - Now the tracking scripts collects performance stats (like DNS resolution times, TTFB, DOM Loading timing and so on).- </div>- </div>- </div>- </div>- </div>- </Title>- )-}--export default memo(Docs)diff --git a/src/pages/Docs/examples.js b/src/pages/Docs/examples.jsindex 3d6d4c313..cf36d5860 100644--- a/src/pages/Docs/examples.js+++ b/src/pages/Docs/examples.js@@ -43,81 +43,3 @@ export const getUMDBuildExample = (pid) => `<!-- Put this at the end of the <bod/></noscript>`--export const npmInstall = 'npm install swetrix'-export const npmImport = 'import * as Swetrix from \'swetrix\''-export const esExample = `Swetrix.init('YOUR_PROJECT_ID')-Swetrix.trackViews()-`--export const trackPageView = 'swetrix.trackViews()'--export const track = `swetrix.track({- // The event identifier you want to track.- // This has to be a string, which:- // - only contains English letters (a-Z A-Z), numbers (0-9),- // underscores (_) and dots (.).- // - is fewer than 64 characters.- // - starts with an English letter.- ev: 'YOUR_EVENT_NAME',-- // If true, only 1 event with the same ID will be saved per user session.- // The principle of this parameter is similar to page views and unique views.- unique: false,-})-`--export const trackExample = `swetrix.track({- ev: 'USER_SIGN_UP',-})-`--export const init = `swetrix.init('YOUR_PROJECT_ID', {- // When set to true, all tracking logs will be- // printed to console and localhost events will be sent to server.- debug: false,-- // When set to true, the tracking library won't send any data to server.- // Useful for development purposes when this value is set based on '.env' var.- disabled: false,-- // By setting this flag to true, we will not collect ANY kind of data- // about the user with the DNT setting.- // This setting is not true by default because our service- // anonymises all incoming data and does not pass it on- // to any third parties under any circumstances- respectDNT: false,-- // Set a custom URL of the API server (for selfhosted variants of Swetrix)- apiURL: 'https://api.swetrix.com/log',-})-`--export const trackPVAPI = `swetrix.trackViews({- // If true, only unique events will be saved.- // This param is useful when tracking single-page landing websites.- unique: false,-- // A list of regular expressions or string pathes to ignore.- // for example: ['/dashboard', /^\/projects/i] setting will force- // script to ignore all pathes which start with /projects or equal to /dashboard- // Please pay attention, that the pathes always start with /- ignore: [],-- // Do not send Heartbeat requests to the server.- // By setting this to true you will not be able to see the realtime amount of- // users on your website.- noHeartbeat: false,-- // Send Heartbeat requests when the website tab is not active in the browser.- // Setting this to true means that users who opened your website in inactive- // browser tab or window will not be counted into users realtime statistics.- // Setting this to true is usually useful for services like Spotify or Youtube- heartbeatOnBackground: false,-})`--export const trackPVReturnAPI = `{- // This function stops the tracking of pages.- stop() {},-}-`diff --git a/src/pages/Docs/index.jsx b/src/pages/Docs/index.jsxdeleted file mode 100644index 490b1c39a..000000000--- a/src/pages/Docs/index.jsx+++ /dev/null@@ -1,3 +0,0 @@-import Docs from './Docs.container'--export default Docsdiff --git a/src/pages/Features/index.jsx b/src/pages/Features/index.jsxindex e78dcbd8a..721925753 100644--- a/src/pages/Features/index.jsx+++ b/src/pages/Features/index.jsx@@ -1,12 +1,13 @@/* eslint-disable jsx-a11y/anchor-has-content */import React, { Fragment } from 'react'import { Link } from 'react-router-dom'-import { HashLink } from 'react-router-hash-link'import { useTranslation, Trans } from 'react-i18next'import _map from 'lodash/map'import Title from 'components/Title'-import { CHROME_EXTENSION_URL, FIREFOX_ADDON_URL } from 'redux/constants'+import {+ CHROME_EXTENSION_URL, FIREFOX_ADDON_URL, DOCS_URL,+} from 'redux/constants'import routes from 'routes'const Features = () => {@@ -28,7 +29,7 @@ const Features = () => {t={t}i18nKey='features.feature1Content'components={{- docs: <HashLink className='text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-500' to={`${routes.docs}#docs-tv`} />,+ docs: <a className='text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-500' href={`${DOCS_URL}/swetrix-js-reference#trackviews`} target='_blank' rel='noreferrer noopener' />,gh: <a className='text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-500' href='https://github.com/Swetrix' target='_blank' rel='noopener noreferrer' />,}}/>diff --git a/src/pages/Privacy/index.jsx b/src/pages/Privacy/index.jsxindex 7bb41b697..aa08737d0 100644--- a/src/pages/Privacy/index.jsx+++ b/src/pages/Privacy/index.jsx@@ -1,11 +1,11 @@/* eslint-disable react/no-unescaped-entities */import React from 'react'-import { HashLink } from 'react-router-hash-link'import _map from 'lodash/map'import Title from 'components/Title'-import { CONTACT_EMAIL, SECURITY_EMAIL } from 'redux/constants'-import routes from 'routes'+import {+ CONTACT_EMAIL, SECURITY_EMAIL, DOCS_URL,+} from 'redux/constants'const serviceProviders = [{@@ -120,7 +120,7 @@ const Features = () => {<br />The information processed may include but is not limited to IP addresses, device or system information, and other information about the traffic on our Customers websites, devices, applications, and/or networks (collectively, “Log Data”). You can find more information on the data collected and how we process it{' '}- <HashLink className='text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-500' to={`${routes.docs}#docs-tv`}>here</HashLink>+ <a className='text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-500' href={`${DOCS_URL}/swetrix-js-reference#trackviews`} target='_blank' rel='noreferrer noopener'>here</a>.</p>diff --git a/src/pages/Project/View/components/NoEvents.jsx b/src/pages/Project/View/components/NoEvents.jsxindex 5c1f27dca..b89ef0282 100644--- a/src/pages/Project/View/components/NoEvents.jsx+++ b/src/pages/Project/View/components/NoEvents.jsx@@ -2,7 +2,6 @@ import React, {memo, useEffect, useState, useRef,} from 'react'import { useTranslation, Trans } from 'react-i18next'-import { Link } from 'react-router-dom'import Prism from 'prismjs'import { ClipboardDocumentIcon } from '@heroicons/react/24/outline'import _isEmpty from 'lodash/isEmpty'@@ -11,7 +10,7 @@ import PropTypes from 'prop-types'import Code from 'ui/Code'import Button from 'ui/Button'import { getUMDBuildExample } from 'pages/Docs/examples'-import routes from 'routes'+import { DOCS_URL } from 'redux/constants'/*** This component is used to display text if the data is not available.@@ -59,7 +58,8 @@ const NoEvents = ({t={t}i18nKey='project.noEvContent'components={{- url: <Link to={routes.docs} className='hover:underline text-blue-600' />,+ // eslint-disable-next-line jsx-a11y/anchor-has-content+ url: <a href={DOCS_URL} className='hover:underline text-blue-600' target='_blank' rel='noreferrer noopener' />,}}/></h2>diff --git a/src/redux/constants/index.js b/src/redux/constants/index.jsindex 18a3da56d..2985e30d3 100644--- a/src/redux/constants/index.js+++ b/src/redux/constants/index.js@@ -111,6 +111,7 @@ export const STATUSPAGE_URL = 'https://stats.uptimerobot.com/33rvmiXXEz'export const BLOG_URL = 'https://blog.swetrix.com'export const UTM_GENERATOR_URL = 'https://url.swetrix.com'export const MARKETPLACE_URL = 'https://marketplace.swetrix.com'+export const DOCS_URL = 'https://docs.swetrix.com'export const CDN_URL = process.env.REACT_APP_CDN_URL// Swetrix vs ...diff --git a/src/routes.js b/src/routes.jsindex 8e2e3ef9d..c3be080ff 100644--- a/src/routes.js+++ b/src/routes.js@@ -12,7 +12,6 @@ const routes = Object.freeze({new_project: '/projects/new',project_settings: '/projects/settings/:id',project: '/projects/:id',- docs: '/docs',features: '/features',billing: '/billing',privacy: '/privacy',