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 open-startup metrics

Blue Mouse0fb27021ebf7
diff --git a/public/locales/en.json b/public/locales/en.json
index b8bae9a7f..f7af9d830 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -771,6 +771,18 @@
"description": "We use {{font}} font on Swetrix websites. See more information about it on it's <url>official website</url>."
}
},
+ "open": {
+ "desc": "Swetrix is an Open Startup, we share our metrics, such as revenue, losses, amount of users, etc. with the public.",
+ "updated": "This page is updated regularly.",
+ "finance": {
+ "title": "Finance metrics",
+ "desc": "Our financial metrics, such as revenue, losses, etc."
+ },
+ "usage": {
+ "title": "Usage metrics",
+ "desc": "Our user metrics, such as amount of active users, connected websites."
+ }
+ },
"titles": {
"recovery": "Account recovery",
"signin": "Sign in",
@@ -786,7 +798,8 @@
"changelog": "Changelog",
"main": "Ultimate open-source analytics to satisfy all your needs",
"press": "Media & Press",
- "socialisation": "Socialisation"
+ "socialisation": "Socialisation",
+ "open": "Open startup"
},
"header": {
"switchTheme": "Switch theme",
diff --git a/src/App.tsx b/src/App.tsx
index bf6832f36..8ce2a246f 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -62,6 +62,7 @@ const MediaAndPress = lazy(() => import('pages/Press'))
const TransferProjectConfirm = lazy(() => import('pages/Project/Settings/TransferProject/TransferProjectConfirm'))
const TransferProjectReject = lazy(() => import('pages/Project/Settings/TransferProject/TransferProjectReject'))
const Socialised = lazy(() => import('pages/Auth/Socialised'))
+const OpenStartup = lazy(() => import('pages/OpenStartup'))
const minimalFooterPages = [
'/projects', '/dashboard', '/settings', '/contact',
@@ -242,6 +243,7 @@ const App = () => {
<Route path={routes.transfer_confirm} component={TransferProjectConfirm} exact />
<Route path={routes.transfer_reject} component={TransferProjectReject} exact />
<Route path={routes.socialised} component={Socialised} exact />
+ <Route path={routes.open} component={OpenStartup} exact />
<Route path='*' component={NotFound} />
</Switch>
</Suspense>
diff --git a/src/hoc/Selfhosted.tsx b/src/hoc/Selfhosted.tsx
index 3b73a15fd..e3c06ce63 100644
--- a/src/hoc/Selfhosted.tsx
+++ b/src/hoc/Selfhosted.tsx
@@ -8,6 +8,7 @@ import routes from 'routes'
const selfHostedBlacklist = [
routes.signup, routes.reset_password, routes.new_password_form, routes.main,
routes.user_settings, routes.verify, routes.change_email, routes.billing,
+ routes.open,
]
const DEFAULT_PAGE = routes.signin
diff --git a/src/pages/OpenStartup/index.tsx b/src/pages/OpenStartup/index.tsx
new file mode 100644
index 000000000..efd46357e
--- /dev/null
+++ b/src/pages/OpenStartup/index.tsx
@@ -0,0 +1,332 @@
+/* eslint-disable */
+import React, { useEffect } from 'react'
+import _map from 'lodash/map'
+import bb, {
+ bar, line,
+} from 'billboard.js'
+import { useTranslation } from 'react-i18next'
+import { useSelector } from 'react-redux'
+
+import { nFormatterSeparated } from 'utils/generic'
+import { StateType } from 'redux/store/index'
+import Title from 'components/Title'
+import '../Project/View/styles.css'
+
+// This should be generated on the API side, will be done later.
+const financeData = {
+ '2021-08-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': 0,
+ 'MRR': 0
+ },
+ '2021-09-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': 0,
+ 'MRR': 0
+ },
+ '2021-10-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': 0,
+ 'MRR': 0
+ },
+ '2021-11-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': 0,
+ 'MRR': 0
+ },
+ '2021-12-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': 0,
+ 'MRR': 0
+ },
+ '2022-01-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': 0,
+ 'MRR': 0
+ },
+ '2022-02-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': 0,
+ 'MRR': 2
+ },
+ '2022-03-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': 0,
+ 'MRR': 15
+ },
+ '2022-04-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': -300,
+ 'MRR': 15
+ },
+ '2022-05-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': -300,
+ 'MRR': 15
+ },
+ '2022-06-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': -300,
+ 'MRR': 15
+ },
+ '2022-07-01': {
+ 'Technical Expences': -32,
+ 'Business Expences': -300,
+ 'MRR': 15
+ },
+ '2022-08-01': {
+ 'Technical Expences': -42,
+ 'Business Expences': -300,
+ 'MRR': 15
+ },
+ '2022-09-01': {
+ 'Technical Expences': -42,
+ 'Business Expences': -350,
+ 'MRR': 15
+ },
+ '2022-10-01': {
+ 'Technical Expences': -48,
+ 'Business Expences': -300,
+ 'MRR': 15
+ },
+ '2022-11-01': {
+ 'Technical Expences': -48,
+ 'Business Expences': -300,
+ 'MRR': 15
+ },
+ '2022-12-01': {
+ 'Technical Expences': -48,
+ 'Business Expences': -400,
+ 'MRR': 15
+ },
+ '2023-01-01': {
+ 'Technical Expences': -48,
+ 'Business Expences': -375,
+ 'MRR': 15
+ },
+ '2023-02-01': {
+ 'Technical Expences': -48,
+ 'Business Expences': -300,
+ 'MRR': 35
+ },
+ '2023-03-01': {
+ 'Technical Expences': -48,
+ 'Business Expences': -370,
+ 'MRR': 30
+ },
+ '2023-04-01': {
+ 'Technical Expences': -48,
+ 'Business Expences': -50,
+ 'MRR': 34
+ },
+ '2023-05-01': {
+ 'Technical Expences': -48,
+ 'Business Expences': -300,
+ 'MRR': 38
+ }
+}
+
+const financeDataToColumns = (financeData: any) => {
+ const dates = Object.keys(financeData)
+ const columns = [
+ ['Technical Expences'],
+ ['Business Expences'],
+ ['MRR'],
+ ['Revenue'],
+ ['x']
+ ]
+
+ dates.forEach((date) => {
+ columns[0].push(financeData[date]['Technical Expences'])
+ columns[1].push(financeData[date]['Business Expences'])
+ columns[2].push(financeData[date]['MRR'])
+ columns[3].push(
+ financeData[date]['MRR'] + financeData[date]['Technical Expences'] + financeData[date]['Business Expences']
+ )
+ columns[4].push(date)
+ })
+
+ return columns
+}
+
+const columns = financeDataToColumns(financeData)
+
+const getSettings = () => {
+ return {
+ data: {
+ x: 'x',
+ xFormat: '%b %Y',
+ columns,
+ types: {
+ 'Technical Expences': bar(),
+ 'Business Expences': bar(),
+ MRR: bar(),
+ revenue: line(),
+ },
+ colors: {
+ 'Technical Expences': '#EC4319',
+ 'Business Expences': '#F27059',
+ MRR: '#709775',
+ Revenue: '#A5E6AB',
+ },
+ groups: [
+ ['Technical Expences', 'Business Expences', 'MRR', 'Revenue'],
+ ],
+ },
+ axis: {
+ x: {
+ type: 'timeseries',
+ tick: {
+ format: '%b %Y',
+ },
+ },
+ y: {
+ tick: {
+ // format: (d: string) => getStringFromTime(getTimeFromSeconds(d), true),
+ },
+ },
+ },
+ tooltip: {
+ // format: {
+ // title: (x: string) => d3.timeFormat(tbsFormatMapper[timeBucket])(x),
+ // },
+ contents: {
+ template: `
+ <ul class='bg-gray-100 dark:text-gray-50 dark:bg-slate-800 rounded-md shadow-md px-3 py-1'>
+ <li class='font-semibold'>{=TITLE}</li>
+ <hr class='border-gray-200 dark:border-gray-600' />
+ {{
+ <li class='flex justify-between'>
+ <div class='flex justify-items-start'>
+ <div class='w-3 h-3 rounded-sm mt-1.5 mr-2' style=background-color:{=COLOR}></div>
+ <span>{=NAME}</span>
+ </div>
+ <span class='pl-4'>{=VALUE} US\$</span>
+ </li>
+ }}
+ </ul>
+ `,
+ },
+ },
+ point: {
+ // focus: {
+ // only: xAxisSize > 1,
+ // },
+ pattern: [
+ 'circle',
+ ],
+ r: 3,
+ },
+ legend: {
+ usePoint: true,
+ item: {
+ tile: {
+ width: 10,
+ },
+ },
+ },
+ // area: {
+ // linearGradient: true,
+ // },
+ // padding: {
+ // right: rotateXAxias && 35,
+ // },
+ bindto: '#open-startup',
+ }
+}
+
+const OpenStartup = (): JSX.Element => {
+ const { t }: {
+ t: (key: string) => string
+ } = useTranslation('common')
+ const { stats } = useSelector((state: StateType) => state.ui.misc)
+
+ const events = nFormatterSeparated(Number(stats.pageviews), 2)
+ const users = nFormatterSeparated(Number(stats.users), 2)
+ const websites = nFormatterSeparated(Number(stats.projects), 2)
+
+ useEffect(() => {
+ const bbSettings = getSettings()
+
+ console.log(bbSettings)
+
+ // @ts-ignore
+ bb.generate(bbSettings)
+ }, [])
+
+ return (
+ <Title title={t('titles.open')}>
+ <div className='min-h-page bg-gray-50 dark:bg-slate-900'>
+ <div className='w-11/12 md:w-4/5 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:px-8 whitespace-pre-line'>
+ <h1 className='text-4xl font-bold text-gray-900 dark:text-gray-50 tracking-tight'>
+ {t('titles.open')}
+ </h1>
+
+ <p className='mt-2 text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
+ {t('open.desc')}
+ </p>
+
+ <p className='mt-2 text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
+ {t('open.updated')}
+ </p>
+
+ <h2 className='mt-8 text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight'>
+ {t('open.finance.title')}
+ </h2>
+
+ <p className='mt-2 text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
+ {t('open.finance.desc')}
+ </p>
+
+ <div className='h-80 mt-4' id='open-startup' />
+
+ <h2 className='mt-8 text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight'>
+ {t('open.usage.title')}
+ </h2>
+
+ <p className='mt-2 text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
+ {t('open.usage.desc')}
+ </p>
+
+ <p className='mt-2 text-md text-gray-900 dark:text-gray-50 tracking-tight'>
+ {t('main.users')}
+ {': '}
+ {users[0]}
+ {users[1] && (
+ <span className='text-gray-900 dark:text-indigo-200'>
+ {users[1]}
+ +
+ </span>
+ )}
+ </p>
+
+ <p className='mt-2 text-md text-gray-900 dark:text-gray-50 tracking-tight'>
+ {t('main.websites')}
+ {': '}
+ {websites[0]}
+ {websites[1] && (
+ <span className='text-gray-900 dark:text-indigo-200'>
+ {websites[1]}
+ +
+ </span>
+ )}
+ </p>
+
+ <p className='mt-2 text-md text-gray-900 dark:text-gray-50 tracking-tight'>
+ {t('main.pageviews')}
+ {': '}
+ {events[0]}
+ {events[1] && (
+ <span className='text-gray-900 dark:text-indigo-200'>
+ {events[1]}
+ +
+ </span>
+ )}
+ </p>
+ </div>
+ </div>
+ </Title>
+ )
+}
+
+export default OpenStartup
diff --git a/src/pages/Project/View/ViewProject.tsx b/src/pages/Project/View/ViewProject.tsx
index 32515b7fb..20c9b8759 100644
--- a/src/pages/Project/View/ViewProject.tsx
+++ b/src/pages/Project/View/ViewProject.tsx
@@ -514,6 +514,8 @@ const ViewProject = ({
const bbSettings = getSettings(chart, timeBucket, activeChartMetrics, applyRegions, timeFormat, forecasedChartData, rotateXAxias, chartType, customEventsChart)
setChartData(chart)
+ console.log(bbSettings)
+
setPanelsData({
types: _keys(params),
data: params,
diff --git a/src/routes.ts b/src/routes.ts
index 6bb9bab82..b4cd24023 100644
--- a/src/routes.ts
+++ b/src/routes.ts
@@ -30,6 +30,7 @@ const routes = Object.freeze({
transfer_confirm: '/project/transfer/confirm',
transfer_reject: '/project/transfer/cancel',
socialised: '/socialised',
+ open: '/open',
})
export default routes