manifold/web/pages/embed/analytics.tsx
Marshall Polaris 0067bee94b
Compute stats in Firebase instead of Vercel (#584)
* Add stats updating cloud function

* Read stats from database on client instead of computing them

* Improve logging for stats updater

* Tidying up
2022-06-26 14:42:42 -07:00

24 lines
668 B
TypeScript

import { useState, useEffect } from 'react'
import { Col } from 'web/components/layout/col'
import { Spacer } from 'web/components/layout/spacer'
import { CustomAnalytics, FirebaseAnalytics } from '../stats'
import { getStats } from 'web/lib/firebase/stats'
import { Stats } from 'common/stats'
export default function AnalyticsEmbed() {
const [stats, setStats] = useState<Stats | undefined>(undefined)
useEffect(() => {
getStats().then(setStats)
}, [])
if (stats == null) {
return <></>
}
return (
<Col className="w-full bg-white px-2">
<CustomAnalytics {...stats} />
<Spacer h={8} />
<FirebaseAnalytics />
</Col>
)
}