diff --git a/apps/marketing/src/app/(marketing)/open/gh-metrics.tsx b/apps/marketing/src/app/(marketing)/open/bar-metrics.tsx similarity index 70% rename from apps/marketing/src/app/(marketing)/open/gh-metrics.tsx rename to apps/marketing/src/app/(marketing)/open/bar-metrics.tsx index 5c0c79716..42295c0bf 100644 --- a/apps/marketing/src/app/(marketing)/open/gh-metrics.tsx +++ b/apps/marketing/src/app/(marketing)/open/bar-metrics.tsx @@ -7,26 +7,25 @@ import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recha import { formatMonth } from '@documenso/lib/client-only/format-month'; import { cn } from '@documenso/ui/lib/utils'; -import { StargazersType } from './page'; - -export type MetricsDataKey = 'stars' | 'forks' | 'mergedPRs' | 'openIssues'; -export type GithubMetricProps = HTMLAttributes & { - data: StargazersType; - metricKey: MetricsDataKey; +export type BarMetricProps> = HTMLAttributes & { + data: T; + metricKey: keyof T[string]; title: string; label: string; chartHeight?: number; + extraInfo?: JSX.Element; }; -export const GithubMetric = ({ +export const BarMetric = >>({ className, data, metricKey, title, label, chartHeight = 400, + extraInfo, ...props -}: GithubMetricProps) => { +}: BarMetricProps) => { const formattedData = Object.keys(data) .map((key) => ({ month: formatMonth(key), @@ -36,7 +35,10 @@ export const GithubMetric = ({ return (
-

{title}

+
+

{title}

+ {extraInfo} +
@@ -50,7 +52,7 @@ export const GithubMetric = ({ formatter={(value) => [Number(value), label]} cursor={{ fill: 'hsl(var(--primary) / 10%)' }} /> - + {' '}
diff --git a/apps/marketing/src/app/(marketing)/open/funding-raised.tsx b/apps/marketing/src/app/(marketing)/open/funding-raised.tsx index c6601f547..51857bb06 100644 --- a/apps/marketing/src/app/(marketing)/open/funding-raised.tsx +++ b/apps/marketing/src/app/(marketing)/open/funding-raised.tsx @@ -7,14 +7,14 @@ import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recha import { formatMonth } from '@documenso/lib/client-only/format-month'; import { cn } from '@documenso/ui/lib/utils'; -import { FUNDING_RAISED } from '~/app/(marketing)/open/data'; +export type FundingRaisedProps = HTMLAttributes & { + data: Record[]; +}; -export type FundingRaisedProps = HTMLAttributes; - -export const FundingRaised = ({ className, ...props }: FundingRaisedProps) => { - const formattedData = FUNDING_RAISED.map((item) => ({ +export const FundingRaised = ({ className, data, ...props }: FundingRaisedProps) => { + const formattedData = data.map((item) => ({ amount: Number(item.amount), - date: formatMonth(item.date), + date: formatMonth(item.date as string), })); return ( diff --git a/apps/marketing/src/app/(marketing)/open/page.tsx b/apps/marketing/src/app/(marketing)/open/page.tsx index 37d390223..debdf92b9 100644 --- a/apps/marketing/src/app/(marketing)/open/page.tsx +++ b/apps/marketing/src/app/(marketing)/open/page.tsx @@ -1,12 +1,14 @@ import { z } from 'zod'; +import { FUNDING_RAISED } from '~/app/(marketing)/open/data'; import { MetricCard } from '~/app/(marketing)/open/metric-card'; import { SalaryBands } from '~/app/(marketing)/open/salary-bands'; +import { BarMetric } from './bar-metrics'; import { CapTable } from './cap-table'; import { FundingRaised } from './funding-raised'; -import { GithubMetric } from './gh-metrics'; import { TeamMembers } from './team-members'; +import { OpenPageTooltip } from './tooltip'; export const revalidate = 3600; @@ -29,9 +31,16 @@ const ZStargazersLiveResponse = z.record( }), ); -export type StargazersType = z.infer; +const ZEarlyAdoptersResponse = z.record( + z.object({ + id: z.number(), + time: z.string().datetime(), + earlyAdopters: z.number(), + }), +); -// const ZOpenPullRequestsResponse = ZMergedPullRequestsResponse; +export type StargazersType = z.infer; +export type EarlyAdoptersType = z.infer; export default async function OpenPage() { const { @@ -65,6 +74,14 @@ export default async function OpenPage() { .then(async (res) => res.json()) .then((res) => ZStargazersLiveResponse.parse(res)); + const EARLY_ADOPTERS_DATA = await fetch('https://stargrazer-live.onrender.com/api/stats/stripe', { + headers: { + accept: 'application/json', + }, + }) + .then(async (res) => res.json()) + .then((res) => ZEarlyAdoptersResponse.parse(res)); + return (
@@ -107,10 +124,20 @@ export default async function OpenPage() { - + - + data={EARLY_ADOPTERS_DATA} + metricKey="earlyAdopters" + title="Early Adopters" + label="Early Adopters" + className="col-span-12 lg:col-span-6" + extraInfo={} + /> + + data={STARGAZERS_DATA} metricKey="stars" title="Github: Total Stars" @@ -118,29 +145,31 @@ export default async function OpenPage() { className="col-span-12 lg:col-span-6" /> - data={STARGAZERS_DATA} metricKey="mergedPRs" title="Github: Total Merged PRs" label="Merged PRs" chartHeight={300} - className="col-span-12 lg:col-span-4" + className="col-span-12 lg:col-span-6" /> - data={STARGAZERS_DATA} metricKey="forks" title="Github: Total Forks" label="Forks" chartHeight={300} - className="col-span-12 lg:col-span-4" + className="col-span-12 lg:col-span-6" /> - data={STARGAZERS_DATA} metricKey="openIssues" title="Github: Total Open Issues" label="Open Issues" chartHeight={300} - className="col-span-12 lg:col-span-4" + className="col-span-12 lg:col-span-6" />
diff --git a/apps/marketing/src/app/(marketing)/open/tooltip.tsx b/apps/marketing/src/app/(marketing)/open/tooltip.tsx new file mode 100644 index 000000000..e6bf48a94 --- /dev/null +++ b/apps/marketing/src/app/(marketing)/open/tooltip.tsx @@ -0,0 +1,40 @@ +import React from 'react'; + +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from '@documenso/ui/primitives/tooltip'; + +export function OpenPageTooltip() { + return ( + + + + + + + + +

+ August and earlier: Active subscribers. September and beyond: Numbers of active + subscriptions. +

+
+
+
+ ); +}