Condense analytics graphs using tabs
This commit is contained in:
parent
6d5a4d6e3f
commit
c40c7af0b0
|
@ -1,5 +1,7 @@
|
||||||
|
import clsx from 'clsx'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
import { useState } from 'react'
|
||||||
import { IS_PRIVATE_MANIFOLD } from '../../common/envs/constants'
|
import { IS_PRIVATE_MANIFOLD } from '../../common/envs/constants'
|
||||||
import {
|
import {
|
||||||
DailyCountChart,
|
DailyCountChart,
|
||||||
|
@ -152,68 +154,176 @@ export function CustomAnalytics(props: {
|
||||||
} = props
|
} = props
|
||||||
return (
|
return (
|
||||||
<Col>
|
<Col>
|
||||||
<Title text="Daily Active Users" />
|
<Title text="Active users" />
|
||||||
<DailyCountChart
|
<p className="text-gray-500">
|
||||||
dailyCounts={dailyActiveUsers}
|
An active user is a user who has traded in, commented on, or created a
|
||||||
startDate={startDate}
|
market.
|
||||||
small
|
</p>
|
||||||
/>
|
<Spacer h={4} />
|
||||||
|
|
||||||
<Title text="Weekly Active Users" />
|
<Tabs
|
||||||
<DailyCountChart
|
defaultIndex={1}
|
||||||
dailyCounts={weeklyActiveUsers}
|
tabs={[
|
||||||
startDate={startDate}
|
{
|
||||||
small
|
title: 'Daily',
|
||||||
/>
|
content: (
|
||||||
|
<DailyCountChart
|
||||||
<Title text="Monthly Active Users" />
|
dailyCounts={dailyActiveUsers}
|
||||||
<DailyCountChart
|
startDate={startDate}
|
||||||
dailyCounts={monthlyActiveUsers}
|
small
|
||||||
startDate={startDate}
|
/>
|
||||||
small
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Weekly',
|
||||||
|
content: (
|
||||||
|
<DailyCountChart
|
||||||
|
dailyCounts={weeklyActiveUsers}
|
||||||
|
startDate={startDate}
|
||||||
|
small
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Monthly',
|
||||||
|
content: (
|
||||||
|
<DailyCountChart
|
||||||
|
dailyCounts={monthlyActiveUsers}
|
||||||
|
startDate={startDate}
|
||||||
|
small
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
|
<Spacer h={8} />
|
||||||
|
|
||||||
<Title text="Week-on-week retention" />
|
<Title text="Week-on-week retention" />
|
||||||
|
<p className="text-gray-500">
|
||||||
|
Out of all active users 2 weeks ago, how many came back last week?
|
||||||
|
</p>
|
||||||
<DailyPercentChart
|
<DailyPercentChart
|
||||||
dailyPercent={weekOnWeekRetention}
|
dailyPercent={weekOnWeekRetention}
|
||||||
startDate={startDate}
|
startDate={startDate}
|
||||||
small
|
small
|
||||||
/>
|
/>
|
||||||
|
<Spacer h={8} />
|
||||||
|
|
||||||
<Title text="Trades" />
|
<Title text="Daily activity" />
|
||||||
<DailyCountChart
|
<Tabs
|
||||||
dailyCounts={dailyBetCounts}
|
defaultIndex={0}
|
||||||
startDate={startDate}
|
tabs={[
|
||||||
small
|
{
|
||||||
/>
|
title: 'Trades',
|
||||||
|
content: (
|
||||||
<Title text="Markets created" />
|
<DailyCountChart
|
||||||
<DailyCountChart
|
dailyCounts={dailyBetCounts}
|
||||||
dailyCounts={dailyContractCounts}
|
startDate={startDate}
|
||||||
startDate={startDate}
|
small
|
||||||
small
|
/>
|
||||||
/>
|
),
|
||||||
|
},
|
||||||
<Title text="Comments" />
|
{
|
||||||
<DailyCountChart
|
title: 'Markets created',
|
||||||
dailyCounts={dailyCommentCounts}
|
content: (
|
||||||
startDate={startDate}
|
<DailyCountChart
|
||||||
small
|
dailyCounts={dailyContractCounts}
|
||||||
|
startDate={startDate}
|
||||||
|
small
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Comments',
|
||||||
|
content: (
|
||||||
|
<DailyCountChart
|
||||||
|
dailyCounts={dailyCommentCounts}
|
||||||
|
startDate={startDate}
|
||||||
|
small
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
|
<Spacer h={8} />
|
||||||
</Col>
|
</Col>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Tab = {
|
||||||
|
title: string
|
||||||
|
content: JSX.Element
|
||||||
|
}
|
||||||
|
|
||||||
|
function Tabs(props: { tabs: Tab[]; defaultIndex: number }) {
|
||||||
|
const { tabs, defaultIndex } = props
|
||||||
|
const [activeTab, setActiveTab] = useState(tabs[defaultIndex])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="sm:hidden">
|
||||||
|
<label htmlFor="tabs" className="sr-only">
|
||||||
|
Select a tab
|
||||||
|
</label>
|
||||||
|
{/* Use an "onChange" listener to redirect the user to the selected tab URL. */}
|
||||||
|
<select
|
||||||
|
id="tabs"
|
||||||
|
name="tabs"
|
||||||
|
className="block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500"
|
||||||
|
defaultValue={activeTab.title}
|
||||||
|
>
|
||||||
|
{tabs.map((tab) => (
|
||||||
|
<option key={tab.title}>{tab.title}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div className="hidden sm:block">
|
||||||
|
<nav className="flex space-x-4" aria-label="Tabs">
|
||||||
|
{tabs.map((tab) => (
|
||||||
|
<a
|
||||||
|
key={tab.title}
|
||||||
|
href="#"
|
||||||
|
className={clsx(
|
||||||
|
tab.title === activeTab.title
|
||||||
|
? 'bg-gray-100 text-gray-700'
|
||||||
|
: 'text-gray-500 hover:text-gray-700',
|
||||||
|
'rounded-md px-3 py-2 text-sm font-medium'
|
||||||
|
)}
|
||||||
|
aria-current={tab.title === activeTab.title ? 'page' : undefined}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
setActiveTab(tab)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{tab.title}
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-4">{activeTab.content}</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export function FirebaseAnalytics() {
|
export function FirebaseAnalytics() {
|
||||||
// Edit dashboard at https://datastudio.google.com/u/0/reporting/faeaf3a4-c8da-4275-b157-98dad017d305/page/Gg3/edit
|
// Edit dashboard at https://datastudio.google.com/u/0/reporting/faeaf3a4-c8da-4275-b157-98dad017d305/page/Gg3/edit
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<iframe
|
<>
|
||||||
className="w-full"
|
<Title text="Google Analytics" />
|
||||||
height={2200}
|
<p className="text-gray-500">
|
||||||
src="https://datastudio.google.com/embed/reporting/faeaf3a4-c8da-4275-b157-98dad017d305/page/Gg3"
|
Less accurate; includes all viewers (not just signed-in users).
|
||||||
frameBorder="0"
|
</p>
|
||||||
style={{ border: 0 }}
|
<Spacer h={4} />
|
||||||
allowFullScreen
|
<iframe
|
||||||
/>
|
className="w-full"
|
||||||
|
height={2200}
|
||||||
|
src="https://datastudio.google.com/embed/reporting/faeaf3a4-c8da-4275-b157-98dad017d305/page/Gg3"
|
||||||
|
frameBorder="0"
|
||||||
|
style={{ border: 0 }}
|
||||||
|
allowFullScreen
|
||||||
|
/>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user