diff --git a/functions/src/update-stats.ts b/functions/src/update-stats.ts index 997f4e05..046d0dc9 100644 --- a/functions/src/update-stats.ts +++ b/functions/src/update-stats.ts @@ -199,8 +199,7 @@ export const updateStatsCore = async () => { const retainedCount = sumBy(Array.from(newTwoWeeksAgo), (userId) => activeLastWeek.has(userId) ? 1 : 0 ) - const retainedFrac = retainedCount / newTwoWeeksAgo.size - return Math.round(retainedFrac * 100 * 100) / 100 + return retainedCount / newTwoWeeksAgo.size }) const weekOnWeekRetention = dailyUserIds.map((_userId, i) => { @@ -222,8 +221,7 @@ export const updateStatsCore = async () => { const retainedCount = sumBy(Array.from(activeTwoWeeksAgo), (userId) => activeLastWeek.has(userId) ? 1 : 0 ) - const retainedFrac = retainedCount / activeTwoWeeksAgo.size - return Math.round(retainedFrac * 100 * 100) / 100 + return retainedCount / activeTwoWeeksAgo.size }) const monthlyRetention = dailyUserIds.map((_userId, i) => { @@ -245,8 +243,7 @@ export const updateStatsCore = async () => { const retainedCount = sumBy(Array.from(activeTwoMonthsAgo), (userId) => activeLastMonth.has(userId) ? 1 : 0 ) - const retainedFrac = retainedCount / activeTwoMonthsAgo.size - return Math.round(retainedFrac * 100 * 100) / 100 + return retainedCount / activeTwoMonthsAgo.size }) const firstBetDict: { [userId: string]: number } = {} @@ -272,8 +269,7 @@ export const updateStatsCore = async () => { } } } - const frac = activatedCount / (newUsers || 1) - return Math.round(frac * 100 * 100) / 100 + return activatedCount / (newUsers || 1) }) const dailySignups = dailyNewUsers.map((users) => users.length) diff --git a/web/components/analytics/charts.tsx b/web/components/analytics/charts.tsx index 56e71257..e078ce21 100644 --- a/web/components/analytics/charts.tsx +++ b/web/components/analytics/charts.tsx @@ -1,5 +1,6 @@ import { Point, ResponsiveLine } from '@nivo/line' import clsx from 'clsx' +import { formatPercent } from 'common/util/format' import dayjs from 'dayjs' import { zip } from 'lodash' import { useWindowSize } from 'web/hooks/use-window-size' @@ -71,9 +72,9 @@ export function DailyPercentChart(props: { dayjs(startDate).add(i, 'day').toDate() ) - const points = zip(dates, dailyPercent).map(([date, betCount]) => ({ + const points = zip(dates, dailyPercent).map(([date, percent]) => ({ x: date, - y: betCount, + y: percent, })) const data = [{ id: 'Percent', data: points, color: '#11b981' }] @@ -93,7 +94,7 @@ export function DailyPercentChart(props: { type: 'time', }} axisLeft={{ - format: (value) => `${value}%`, + format: formatPercent, }} axisBottom={{ tickValues: bottomAxisTicks, @@ -109,15 +110,15 @@ export function DailyPercentChart(props: { margin={{ top: 20, right: 28, bottom: 22, left: 40 }} sliceTooltip={({ slice }) => { const point = slice.points[0] - return + return }} /> ) } -function Tooltip(props: { point: Point }) { - const { point } = props +function Tooltip(props: { point: Point; isPercent?: boolean }) { + const { point, isPercent } = props return (
- {point.serieId} {point.data.yFormatted} + {point.serieId}{' '} + {isPercent ? formatPercent(+point.data.y) : point.data.yFormatted}
{dayjs(point.data.x).format('MMM DD')}
diff --git a/web/pages/stats.tsx b/web/pages/stats.tsx index 27796c01..5328e5a2 100644 --- a/web/pages/stats.tsx +++ b/web/pages/stats.tsx @@ -145,14 +145,18 @@ export function CustomAnalytics(props: Stats) { { title: 'D1', content: ( - + ), }, { title: 'D1 weekly average', content: ( - @@ -175,8 +179,8 @@ export function CustomAnalytics(props: Stats) { { title: 'W1', content: ( -