All blocks5 stages · 5.1% overall
Funnel & Cohort Dashboard
Developer activation and cohort retention dashboard featuring KPI sparklines, a horizontal conversion funnel with step-to-step drop-off metrics, interactive W0–W8 retention curves and stage trends, and a clickable weekly cohort retention heatmap.
Built withBadgeButtonCardChartGridHeadingIcon ButtonSegment GroupSelectSeparatorStackStatTableTextToast
Harbor Cloud · Developer Activation & Retention
5.1% visit-to-paid96,400 developers entered · All Channels · Last 30 days
Visit → CLI Installed
36.6%
+2.1 pts35,280 CLI installs · Last 30 days
CLI → First Deploy
56.2%
+3.4 pts19,820 activated developers
Deploy → Paid Team
24.8%
-0.8 pts4,920 converted paid teams
Week-4 Retention
43.0%
+4.1 ptsActive deployers at W4 · All Channels
Activation funnel
All Channels · Last 30 days · 96,400 landing visitors to 4,920 paid teams
Landing Visit → CLI Installed
36.6%-63%
61,120 droppedCLI Installed → First Deploy
56.2%-44%
15,460 droppedFirst Deploy → Team Invite
45.1%-55%
10,880 droppedTeam Invite → Paid Team
55.0%-45%
4,020 droppedDeveloper retention curves
Active deploying developers from W0 to W8 across acquisition channels · Toggle legend items to compare
Overlay: Oct 12 – Oct 18
Weekly cohort retention (W0–W8)
First-deploy week × weeks retained · All Channels · Select a cohort row to overlay it on the retention curve
| Cohort | Devs | W0 | W1 | W2 | W3 | W4 | W5 | W6 | W7 | W8 |
|---|---|---|---|---|---|---|---|---|---|---|
| 2,140 | 100% | 64% | 52% | 44% | 39% | 36% | 33% | 31% | 30% | |
| 2,290 | 100% | 66% | 54% | 46% | 41% | 38% | 35% | 33% | — | |
| 2,460 | 100% | 68% | 56% | 49% | 44% | 40% | 38% | — | — | |
| 2,380 | 100% | 65% | 53% | 45% | 40% | 37% | — | — | — | |
| 2,610 | 100% | 69% | 58% | 50% | 46% | — | — | — | — | |
| 2,840 | 100% | 71% | 60% | 53% | — | — | — | — | — | |
| 3,120 | 100% | 67% | 57% | — | — | — | — | — | — | |
| 2,980 | 100% | 73% | — | — | — | — | — | — | — | |
| 3,190 | 100% | — | — | — | — | — | — | — | — | |
| Weighted avg | 24,010 | 100% | 68% | 56% | 48% | 42% | 38% | 35% | 32% | 30% |
Retention scale:< 26%26–35%36–47%48–64%≥ 65%
Comparing Oct 12 – Oct 18 (2,460 devs) on chart aboveInstall
1npx stylexblocks add funnel-cohort-dashboardSource
components/blocks/ui-sdk/funnel-cohort-dashboard.tsx
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205import * as stylex from "@stylexjs/stylex";import { useMemo, useState } from "react";import { Badge } from "#components/ui/ui-sdk/badge.tsx";import { Button } from "#components/ui/ui-sdk/button.tsx";import { Card } from "#components/ui/ui-sdk/card.tsx";import { BarChart, LineChart, Sparkline, type ChartColorName,} from "#components/ui/ui-sdk/chart.tsx";import { Grid } from "#components/ui/ui-sdk/grid.tsx";import { Heading } from "#components/ui/ui-sdk/heading.tsx";import { IconButton } from "#components/ui/ui-sdk/icon-button.tsx";import { SegmentGroup } from "#components/ui/ui-sdk/segment-group.tsx";import { Select } from "#components/ui/ui-sdk/select.tsx";import { Separator } from "#components/ui/ui-sdk/separator.tsx";import { HStack, VStack } from "#components/ui/ui-sdk/stack.tsx";import { Stat } from "#components/ui/ui-sdk/stat.tsx";import { Table } from "#components/ui/ui-sdk/table.tsx";import { Text } from "#components/ui/ui-sdk/text.tsx";import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";import { amberPalette, bluePalette, grayPalette, greenPalette, orangePalette, purplePalette, redPalette, tealPalette,} from "@stylexblocks/ui/themes/palettes.ts";import { fontSizes } from "@stylexblocks/ui/tokens/font-sizes.stylex.ts";import { fontWeights } from "@stylexblocks/ui/tokens/font-weights.stylex.ts";import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";import type { StyleOverrideProps } from "#lib/recipe-props.ts";
// ============= CONTAINER BREAKPOINTS =============
const COMPACT = "@container funnel-cohort-dashboard (max-width: 720px)";
// ============= DOMAIN TYPES =============
type Channel = "all" | "docs" | "github" | "ph";type FunnelWindow = "7d" | "30d" | "90d";type CurveMode = "retention" | "conversion";
interface FunnelStage { key: string; label: string; color: ChartColorName; // Base 30-day developer counts per acquisition channel. developers: Record<Channel, number>;}
interface FunnelBarDatum { key: string; label: string; color: ChartColorName; developers: number; pctOfTop: number; stepPct: number | null; droppedFromPrev: number | null;}
interface KpiItem { key: string; label: string; value: string; deltaPts: number; helpText: string; sparklineData: ReadonlyArray<{ week: string; value: number }>;}
interface StageTrendPoint { week: number; label: string; cliInstall: number; firstDeploy: number; paidTeam: number;}
interface CohortFixture { id: string; label: string; baseSize: Record<Channel, number>; // Retention % from W0 (100) through W8 depending on cohort age. retention: readonly number[];}
// ============= CHANNEL & WINDOW MAPS =============
const CHANNEL_OPTIONS: ReadonlyArray<{ value: Channel; label: string; color: ChartColorName }> = [ { value: "all", label: "All Channels", color: "blue" }, { value: "docs", label: "Organic Docs", color: "teal" }, { value: "github", label: "GitHub Template", color: "emerald" }, { value: "ph", label: "Product Hunt", color: "orange" },];
const CHANNEL_LABEL_MAP = new Map<Channel, string>( CHANNEL_OPTIONS.map((opt) => [opt.value, opt.label]),);
const WINDOW_FACTOR: Record<FunnelWindow, number> = { "7d": 0.25, "30d": 1, "90d": 2.95,};
const WINDOW_LABEL: Record<FunnelWindow, string> = { "7d": "Last 7 days", "30d": "Last 30 days", "90d": "Last 90 days",};
// ============= HARBOR CLOUD FUNNEL DATA =============
const FUNNEL_STAGES: readonly FunnelStage[] = [ { key: "visit", label: "Landing Visit", color: "blue", developers: { all: 96400, docs: 44200, github: 31800, ph: 20400 }, }, { key: "cli", label: "CLI Installed", color: "teal", developers: { all: 35280, docs: 17680, github: 13040, ph: 4560 }, }, { key: "deploy", label: "First Deploy", color: "emerald", developers: { all: 19820, docs: 10120, github: 7560, ph: 2140 }, }, { key: "invite", label: "Team Invite", color: "orange", developers: { all: 8940, docs: 4590, github: 3520, ph: 830 }, }, { key: "paid", label: "Paid Team", color: "violet", developers: { all: 4920, docs: 2610, github: 1920, ph: 390 }, },];
// Channel-specific retention offsets applied to cohort curves & heatmap cells (W1+).const CHANNEL_RETENTION_OFFSET: Record<Channel, number> = { all: 0, docs: 3, github: 6, ph: -11,};
// Retention curves by acquisition channel (W0–W8, % of activated developers still deploying).const RETENTION_WEEKS = [0, 1, 2, 3, 4, 5, 6, 7, 8] as const;
const CHANNEL_RETENTION_CURVES: Record<Channel, readonly number[]> = { all: [100, 68, 56, 48, 43, 39, 36, 34, 33], docs: [100, 71, 59, 52, 47, 43, 40, 38, 37], github: [100, 74, 63, 56, 51, 47, 44, 42, 40], ph: [100, 54, 41, 34, 29, 26, 24, 22, 21],};
// Trailing 16-week stage conversion rates (%) for Harbor Cloud.// W5 quickstart docs overhaul lifts CLI install; W8 CLI auth regression dips first deploy// before W9 patch; W12 Product Hunt launch spikes top-of-funnel visits with lower intent;// W14–W16 team seat billing upgrades lift paid team conversion.const STAGE_TRENDS: readonly StageTrendPoint[] = [ { week: 0, label: "W1", cliInstall: 33.4, firstDeploy: 52.1, paidTeam: 22.8 }, { week: 1, label: "W2", cliInstall: 34.1, firstDeploy: 53.0, paidTeam: 23.4 }, { week: 2, label: "W3", cliInstall: 33.8, firstDeploy: 51.8, paidTeam: 22.9 }, { week: 3, label: "W4", cliInstall: 34.9, firstDeploy: 53.7, paidTeam: 24.1 }, { week: 4, label: "W5", cliInstall: 38.2, firstDeploy: 55.4, paidTeam: 24.6 }, { week: 5, label: "W6", cliInstall: 37.6, firstDeploy: 56.1, paidTeam: 25.0 }, { week: 6, label: "W7", cliInstall: 38.4, firstDeploy: 55.8, paidTeam: 24.7 }, { week: 7, label: "W8", cliInstall: 37.9, firstDeploy: 47.4, paidTeam: 21.8 }, { week: 8, label: "W9", cliInstall: 36.8, firstDeploy: 52.6, paidTeam: 23.1 }, { week: 9, label: "W10", cliInstall: 37.5, firstDeploy: 55.2, paidTeam: 24.5 }, { week: 10, label: "W11", cliInstall: 38.1, firstDeploy: 56.9, paidTeam: 25.2 }, { week: 11, label: "W12", cliInstall: 29.6, firstDeploy: 51.4, paidTeam: 22.4 }, { week: 12, label: "W13", cliInstall: 34.2, firstDeploy: 54.8, paidTeam: 23.9 }, { week: 13, label: "W14", cliInstall: 36.1, firstDeploy: 56.4, paidTeam: 25.8 }, { week: 14, label: "W15", cliInstall: 37.4, firstDeploy: 57.1, paidTeam: 26.4 }, { week: 15, label: "W16", cliInstall: 36.6, firstDeploy: 56.2, paidTeam: 24.8 },];
const STAGE_TREND_SERIES: ReadonlyArray<{ key: "cliInstall" | "firstDeploy" | "paidTeam"; label: string; color: ChartColorName;}> = [ { key: "cliInstall", label: "Visit → CLI Installed", color: "blue" }, { key: "firstDeploy", label: "CLI → First Deploy", color: "emerald" }, { key: "paidTeam", label: "Deploy → Paid Team", color: "orange" },];
const CHANNEL_TREND_OFFSET: Record< Channel, { cliInstall: number; firstDeploy: number; paidTeam: number }> = { all: { cliInstall: 0, firstDeploy: 0, paidTeam: 0 }, docs: { cliInstall: 3.4, firstDeploy: 1.1, paidTeam: 1.0 }, github: { cliInstall: 4.4, firstDeploy: 1.8, paidTeam: 0.6 }, ph: { cliInstall: -14.2, firstDeploy: -9.3, paidTeam: -6.6 },};
// Weekly cohorts (Sep 28 – Nov 29) with W0–W8 triangular retention matrix.const COHORTS: readonly CohortFixture[] = [ { id: "c-sep-28", label: "Sep 28 – Oct 4", baseSize: { all: 2140, docs: 1090, github: 810, ph: 240 }, retention: [100, 64, 52, 44, 39, 36, 33, 31, 30], }, { id: "c-oct-05", label: "Oct 5 – Oct 11", baseSize: { all: 2290, docs: 1160, github: 880, ph: 250 }, retention: [100, 66, 54, 46, 41, 38, 35, 33], }, { id: "c-oct-12", label: "Oct 12 – Oct 18", baseSize: { all: 2460, docs: 1250, github: 940, ph: 270 }, retention: [100, 68, 56, 49, 44, 40, 38], }, { id: "c-oct-19", label: "Oct 19 – Oct 25", baseSize: { all: 2380, docs: 1210, github: 910, ph: 260 }, retention: [100, 65, 53, 45, 40, 37], }, { id: "c-oct-26", label: "Oct 26 – Nov 1", baseSize: { all: 2610, docs: 1320, github: 1010, ph: 280 }, retention: [100, 69, 58, 50, 46], }, { id: "c-nov-02", label: "Nov 2 – Nov 8", baseSize: { all: 2840, docs: 1410, github: 1090, ph: 340 }, retention: [100, 71, 60, 53], }, { id: "c-nov-09", label: "Nov 9 – Nov 15", baseSize: { all: 3120, docs: 1480, github: 1150, ph: 490 }, retention: [100, 67, 57], }, { id: "c-nov-16", label: "Nov 16 – Nov 22", baseSize: { all: 2980, docs: 1510, github: 1160, ph: 310 }, retention: [100, 73], }, { id: "c-nov-23", label: "Nov 23 – Nov 29", baseSize: { all: 3190, docs: 1620, github: 1240, ph: 330 }, retention: [100], },];
const KPI_DELTAS: Record< Channel, { v2c: number; c2d: number; d2p: number; w4: number }> = { all: { v2c: 2.1, c2d: 3.4, d2p: -0.8, w4: 4.1 }, docs: { v2c: 2.8, c2d: 3.9, d2p: 0.6, w4: 4.6 }, github: { v2c: 3.5, c2d: 4.2, d2p: 1.1, w4: 5.2 }, ph: { v2c: -1.9, c2d: -2.4, d2p: -1.5, w4: -2.1 },};
const KPI_SPARKLINES: Record< Channel, { v2c: readonly number[]; c2d: readonly number[]; d2p: readonly number[]; w4: readonly number[]; }> = { all: { v2c: [33.4, 34.1, 33.8, 34.9, 38.2, 37.6, 38.4, 37.9, 36.8, 37.5, 38.1, 29.6, 34.2, 36.6], c2d: [52.1, 53.0, 51.8, 53.7, 55.4, 56.1, 55.8, 47.4, 52.6, 55.2, 56.9, 51.4, 54.8, 56.2], d2p: [22.8, 23.4, 22.9, 24.1, 24.6, 25.0, 24.7, 21.8, 23.1, 24.5, 25.2, 22.4, 25.8, 24.8], w4: [37.5, 38.1, 38.6, 39.2, 39.8, 40.4, 40.1, 39.5, 40.8, 41.4, 42.1, 41.8, 42.6, 43.0], }, docs: { v2c: [36.2, 36.8, 37.1, 37.9, 40.6, 40.1, 41.2, 40.8, 39.5, 40.4, 41.0, 38.8, 39.6, 40.0], c2d: [53.0, 53.8, 53.4, 54.9, 56.2, 57.1, 56.8, 50.1, 54.2, 56.3, 57.6, 55.9, 56.8, 57.2], d2p: [23.8, 24.1, 24.0, 24.8, 25.4, 25.9, 25.5, 23.1, 24.2, 25.4, 26.0, 25.1, 26.2, 25.8], w4: [41.2, 41.9, 42.3, 43.0, 43.8, 44.5, 44.1, 43.7, 44.9, 45.6, 46.2, 46.0, 46.7, 47.0], }, github: { v2c: [37.1, 37.8, 38.2, 38.9, 41.5, 41.1, 42.0, 41.6, 40.2, 41.3, 41.9, 40.1, 40.7, 41.0], c2d: [54.1, 54.6, 54.2, 55.8, 57.1, 58.0, 57.7, 51.2, 55.1, 57.2, 58.6, 56.8, 57.5, 58.0], d2p: [23.2, 23.8, 23.6, 24.4, 25.1, 25.6, 25.2, 22.9, 24.0, 25.1, 25.7, 24.8, 25.9, 25.4], w4: [45.0, 45.6, 46.2, 46.9, 47.6, 48.3, 48.0, 47.4, 48.8, 49.5, 50.2, 49.8, 50.6, 51.0], }, ph: { v2c: [25.8, 25.2, 24.9, 24.4, 26.1, 25.0, 24.6, 24.1, 23.8, 24.0, 23.4, 20.8, 21.9, 22.4], c2d: [50.2, 49.6, 48.9, 49.4, 50.1, 49.2, 48.8, 42.4, 46.1, 47.8, 48.2, 44.9, 46.2, 46.9], d2p: [20.4, 20.1, 19.8, 19.6, 20.2, 19.7, 19.3, 17.6, 18.4, 18.9, 19.1, 17.8, 18.5, 18.2], w4: [32.4, 31.9, 31.5, 31.2, 30.8, 30.4, 30.2, 29.8, 29.6, 29.4, 29.2, 28.6, 29.1, 29.0], },};
// ============= HELPERS =============
function nf(n: number): string { return n.toLocaleString();}
function clampPct(value: number): number { return Math.max(5, Math.min(100, Math.round(value)));}
function getCohortRetention(cohort: CohortFixture, channel: Channel): number[] { const offset = CHANNEL_RETENTION_OFFSET[channel]; return cohort.retention.map((pct, idx) => (idx === 0 ? 100 : clampPct(pct + offset)));}
function retentionPalette(pct: number) { if (pct >= 65) return greenPalette; if (pct >= 48) return tealPalette; if (pct >= 36) return amberPalette; if (pct >= 26) return orangePalette; return redPalette;}
function dropOffPalette(dropPct: number) { if (dropPct >= 55) return redPalette; if (dropPct >= 45) return amberPalette; return greenPalette;}
function toSparklineData(values: readonly number[]) { return values.map((value, idx) => ({ week: `W${idx + 1}`, value }));}
// ============= STYLES =============
const styles = stylex.create({ root: { backgroundColor: semanticColors.bg, color: semanticColors.fg, containerName: "funnel-cohort-dashboard", containerType: "inline-size", display: "flex", flexDirection: "column", fontFamily: fonts.body, height: "100%", minHeight: 0, overflowY: "auto", width: "100%", }, content: { marginInline: "auto", maxWidth: "88rem", paddingBlock: spacing._6, paddingInline: spacing._6, width: "100%", [COMPACT]: { paddingBlock: spacing._4, paddingInline: spacing._4, }, }, titleHeading: { marginBlock: 0, }, selectWrap: { minWidth: "10.5rem", width: "auto", }, kpiBody: { paddingBlock: spacing._4, paddingInline: spacing._4, }, deltaIcon: { alignItems: "center", display: "inline-flex", }, sparklineHost: { marginTop: spacing._1, }, cardInner: { paddingBlock: spacing._5, paddingInline: spacing._5, [COMPACT]: { paddingBlock: spacing._4, paddingInline: spacing._4, }, }, sectionHeading: { marginBlock: 0, }, stepGrid: { gridTemplateColumns: "repeat(auto-fit, minmax(12rem, 1fr))", overflowX: "clip", }, stepItem: { borderInlineStartColor: semanticColors.border, borderInlineStartStyle: "solid", borderInlineStartWidth: "1px", marginInlineStart: `calc(${spacing._4} / -2)`, paddingInlineStart: `calc(${spacing._4} / 2)`, }, tableScroll: { overflowX: "auto", width: "100%", }, cohortRow: { backgroundColor: { default: "transparent", ":hover": semanticColors.interactionHover, }, cursor: "pointer", }, cohortRowSelected: { backgroundColor: semanticColors.interactionSelected, }, cohortLabelBtn: { backgroundColor: "transparent", borderStyle: "none", borderWidth: 0, color: semanticColors.fg, cursor: "pointer", fontFamily: fonts.body, fontSize: fontSizes.sm, fontWeight: fontWeights.medium, paddingBlock: 0, paddingInline: 0, textAlign: "start", whiteSpace: "nowrap", }, nowrap: { whiteSpace: "nowrap", }, weekHeader: { textAlign: "center", whiteSpace: "nowrap", }, weekCell: { textAlign: "center", whiteSpace: "nowrap", }, heatBadge: { justifyContent: "center", minWidth: "2.75rem", }, footerRow: { backgroundColor: semanticColors.bgMuted, },});
// ============= INLINE SVG ICONS =============
function DownloadIcon() { return ( <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.9" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /> <polyline points="7 10 12 15 17 10" /> <line x1="12" y1="15" x2="12" y2="3" /> </svg> );}
function ArrowUpIcon() { return ( <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.25" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <line x1="12" y1="19" x2="12" y2="5" /> <polyline points="5 12 12 5 19 12" /> </svg> );}
function ArrowDownIcon() { return ( <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.25" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <line x1="12" y1="5" x2="12" y2="19" /> <polyline points="19 12 12 19 5 12" /> </svg> );}
function TrendDownIcon() { return ( <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <polyline points="22 17 13.5 8.5 8.5 13.5 2 7" /> <polyline points="16 17 22 17 22 11" /> </svg> );}
function CloseSmallIcon() { return ( <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.25" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <line x1="18" y1="6" x2="6" y2="18" /> <line x1="6" y1="6" x2="18" y2="18" /> </svg> );}
// ============= MAIN COMPONENT =============
export interface FunnelCohortDashboardProps extends StyleOverrideProps {}
/** * FunnelCohortDashboard — Harbor Cloud developer activation funnel, KPI * sparkline tiles, step-to-step drop-off metrics, interactive retention curves * and stage trends powered by UI SDK Chart primitives, and a W0–W8 weekly * cohort retention heatmap table. */export function FunnelCohortDashboard({ palette, style }: FunnelCohortDashboardProps) { const queue = useMemo(() => Toast.createToaster(), []); const [channel, setChannel] = useState<Channel>("all"); const [funnelWindow, setFunnelWindow] = useState<FunnelWindow>("30d"); const [curveMode, setCurveMode] = useState<CurveMode>("retention"); const [selectedCohortId, setSelectedCohortId] = useState<string | null>("c-oct-12");
const channelLabel = CHANNEL_LABEL_MAP.get(channel) ?? "All Channels"; const windowFactor = WINDOW_FACTOR[funnelWindow];
// Scaled funnel bar data for the selected channel and time window. const funnelBars = useMemo<FunnelBarDatum[]>(() => { const counts = FUNNEL_STAGES.map((stage) => Math.round(stage.developers[channel] * windowFactor), ); const top = counts[0] || 1; return FUNNEL_STAGES.map((stage, i) => { const developers = counts[i] ?? 0; const prev = i > 0 ? (counts[i - 1] ?? 0) : null; return { key: stage.key, label: stage.label, color: stage.color, developers, pctOfTop: (developers / top) * 100, stepPct: prev != null && prev > 0 ? (developers / prev) * 100 : null, droppedFromPrev: prev != null ? Math.max(0, prev - developers) : null, }; }); }, [channel, windowFactor]);
const funnelChartData = useMemo( () => funnelBars.map((bar) => ({ stage: bar.label, [bar.label]: bar.developers, })), [funnelBars], );
const funnelCategories = useMemo(() => funnelBars.map((bar) => bar.label), [funnelBars]); const funnelColors = useMemo(() => funnelBars.map((bar) => bar.color), [funnelBars]);
const topOfFunnel = funnelBars[0]?.developers ?? 0; const paidTeams = funnelBars[funnelBars.length - 1]?.developers ?? 0; const overallConversion = topOfFunnel > 0 ? ((paidTeams / topOfFunnel) * 100).toFixed(1) : "0.0";
// Step-to-step drop-off metrics directly derived from the active funnel. const funnelSteps = useMemo(() => { return funnelBars.slice(1).map((bar, i) => { const prev = funnelBars[i]; const conv = bar.stepPct ?? 0; const drop = 100 - conv; return { key: bar.key, label: `${prev?.label ?? ""} → ${bar.label}`, conv, drop, dropped: bar.droppedFromPrev ?? 0, }; }); }, [funnelBars]);
// Headline KPI tiles derived from active funnel & channel retention curve. const kpis = useMemo<KpiItem[]>(() => { const visit = funnelBars[0]?.developers ?? 1; const cli = funnelBars[1]?.developers ?? 0; const deploy = funnelBars[2]?.developers ?? 0; const paid = funnelBars[4]?.developers ?? 0; const deltas = KPI_DELTAS[channel]; const sparks = KPI_SPARKLINES[channel]; const w4Retention = CHANNEL_RETENTION_CURVES[channel][4] ?? 0;
return [ { key: "v2c", label: "Visit → CLI Installed", value: `${((cli / visit) * 100).toFixed(1)}%`, deltaPts: deltas.v2c, helpText: `${nf(cli)} CLI installs · ${WINDOW_LABEL[funnelWindow]}`, sparklineData: toSparklineData(sparks.v2c), }, { key: "c2d", label: "CLI → First Deploy", value: `${(cli > 0 ? (deploy / cli) * 100 : 0).toFixed(1)}%`, deltaPts: deltas.c2d, helpText: `${nf(deploy)} activated developers`, sparklineData: toSparklineData(sparks.c2d), }, { key: "d2p", label: "Deploy → Paid Team", value: `${(deploy > 0 ? (paid / deploy) * 100 : 0).toFixed(1)}%`, deltaPts: deltas.d2p, helpText: `${nf(paid)} converted paid teams`, sparklineData: toSparklineData(sparks.d2p), }, { key: "w4", label: "Week-4 Retention", value: `${w4Retention.toFixed(1)}%`, deltaPts: deltas.w4, helpText: `Active deployers at W4 · ${channelLabel}`, sparklineData: toSparklineData(sparks.w4), }, ]; }, [channel, channelLabel, funnelBars, funnelWindow]);
// Weekly cohort rows adjusted for the selected channel. const cohortRows = useMemo(() => { return COHORTS.map((cohort) => ({ id: cohort.id, label: cohort.label, size: cohort.baseSize[channel], retention: getCohortRetention(cohort, channel), })); }, [channel]);
const totalCohortDevs = useMemo( () => cohortRows.reduce((sum, row) => sum + row.size, 0), [cohortRows], );
// Weighted average retention across all cohorts that have reached each week. const averageRetention = useMemo(() => { return RETENTION_WEEKS.map((week) => { let weightedSum = 0; let totalWeight = 0; for (const row of cohortRows) { const pct = row.retention[week]; if (pct != null) { weightedSum += pct * row.size; totalWeight += row.size; } } return totalWeight > 0 ? Math.round(weightedSum / totalWeight) : null; }); }, [cohortRows]);
const selectedCohort = useMemo(() => { if (!selectedCohortId) return null; return cohortRows.find((row) => row.id === selectedCohortId) ?? null; }, [cohortRows, selectedCohortId]);
// Retention curve chart data (W0–W8) with optional selected cohort overlay. const retentionChartData = useMemo(() => { const cohortSeriesName = selectedCohort ? `Cohort: ${selectedCohort.label}` : null; return RETENTION_WEEKS.map((week) => { const row: Record<string, string | number | null> = { week: `W${week}` }; for (const opt of CHANNEL_OPTIONS) { row[opt.label] = CHANNEL_RETENTION_CURVES[opt.value][week] ?? null; } if (selectedCohort && cohortSeriesName) { row[cohortSeriesName] = selectedCohort.retention[week] ?? null; } return row; }); }, [selectedCohort]);
const retentionCategories = useMemo(() => { const base = CHANNEL_OPTIONS.map((opt) => opt.label); return selectedCohort ? [...base, `Cohort: ${selectedCohort.label}`] : base; }, [selectedCohort]);
const retentionColors = useMemo<ChartColorName[]>(() => { const base = CHANNEL_OPTIONS.map((opt) => opt.color); return selectedCohort ? [...base, "violet"] : base; }, [selectedCohort]);
// Stage conversion trend data adjusted for active channel. const stageTrendData = useMemo(() => { const offset = CHANNEL_TREND_OFFSET[channel]; return STAGE_TRENDS.map((pt) => { const row: Record<string, string | number> = { week: pt.label }; for (const series of STAGE_TREND_SERIES) { row[series.label] = Number( Math.max(8, Math.min(90, pt[series.key] + offset[series.key])).toFixed(1), ); } return row; }); }, [channel]);
const stageTrendCategories = useMemo(() => STAGE_TREND_SERIES.map((s) => s.label), []); const stageTrendColors = useMemo(() => STAGE_TREND_SERIES.map((s) => s.color), []);
return ( <div {...stylex.props(styles.root, palette, style)}> <VStack render={<main />} gap="6" style={styles.content}> {/* Header */} <HStack render={<header />} justify="between" align="center" wrap="wrap" gap="4"> <VStack gap="1"> <HStack align="center" wrap="wrap" gap="2.5"> <Heading render={<h1 />} size="xl" style={styles.titleHeading}> Harbor Cloud · Developer Activation & Retention </Heading> <Badge variant="subtle" size="sm" palette={bluePalette}> {overallConversion}% visit-to-paid </Badge> </HStack> <Text size="sm" tone="muted"> {nf(topOfFunnel)} developers entered · {channelLabel} · {WINDOW_LABEL[funnelWindow]} </Text> </VStack>
<HStack align="center" wrap="wrap" gap="2"> <SegmentGroup.Root size="sm" value={funnelWindow} onValueChange={(next) => { if (next === "7d" || next === "30d" || next === "90d") { setFunnelWindow(next); } }} aria-label="Funnel time window" > <SegmentGroup.Item value="7d">7d</SegmentGroup.Item> <SegmentGroup.Item value="30d">30d</SegmentGroup.Item> <SegmentGroup.Item value="90d">90d</SegmentGroup.Item> </SegmentGroup.Root>
<Select.Root size="sm" variant="outline" value={channel} onValueChange={(next) => { if (next === "all" || next === "docs" || next === "github" || next === "ph") { setChannel(next); } }} style={styles.selectWrap} > <Select.Control> <Select.Trigger aria-label="Acquisition channel"> <Select.Value>{channelLabel}</Select.Value> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {CHANNEL_OPTIONS.map((opt) => ( <Select.Item key={opt.value} value={opt.value}> <Select.ItemText>{opt.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root>
<Button variant="surface" size="sm" onClick={() => queue.info( `Exported ${channelLabel} (${funnelWindow}) activation & cohort report as CSV`, ) } > <DownloadIcon /> Export </Button> </HStack> </HStack>
<Separator />
{/* Band 1: Headline KPI cards with Sparklines */} <Grid render={<section aria-label="Activation and retention KPIs" />} columns="autoFit" gap="4"> {kpis.map((kpi) => { const favorable = kpi.deltaPts >= 0; return ( <Card.Root key={kpi.key} variant="outline"> <VStack gap="2" style={styles.kpiBody}> <Stat.Root size="md"> <Stat.Label>{kpi.label}</Stat.Label> <HStack align="baseline" wrap="wrap" gap="2"> <Stat.ValueText>{kpi.value}</Stat.ValueText> <HStack render={<span />} align="center" gap="0.5"> <Text render={<span />} size="xs" weight="medium" tone={favorable ? "success" : "error"} style={styles.deltaIcon} > {favorable ? <ArrowUpIcon /> : <ArrowDownIcon />} </Text> <Text render={<span />} size="xs" weight="medium" tone="muted" tabular="true"> {kpi.deltaPts >= 0 ? "+" : ""} {kpi.deltaPts.toFixed(1)} pts </Text> </HStack> </HStack> <Stat.HelpText>{kpi.helpText}</Stat.HelpText> </Stat.Root> <Sparkline data={kpi.sparklineData} index="week" categories={["value"]} colors={[favorable ? "blue" : "orange"]} height={36} curve="linear" ariaLabel={`${kpi.label} trailing 14-week sparkline`} style={styles.sparklineHost} /> </VStack> </Card.Root> ); })} </Grid>
{/* Band 2: Developer activation funnel + step-to-step drop-off */} <section aria-label="Developer activation funnel"> <Card.Root variant="outline"> <VStack gap="5" style={styles.cardInner}> <HStack justify="between" align="start" wrap="wrap" gap="3"> <VStack gap="1"> <Heading render={<h2 />} size="md" style={styles.sectionHeading}> Activation funnel </Heading> <Text size="xs" tone="muted"> {channelLabel} · {WINDOW_LABEL[funnelWindow]} · {nf(topOfFunnel)} landing visitors to {nf(paidTeams)} paid teams </Text> </VStack> <Badge variant="outline" size="sm" palette={grayPalette}> 5 stages · {overallConversion}% overall </Badge> </HStack>
<BarChart data={funnelChartData} index="stage" categories={funnelCategories} colors={funnelColors} type="stacked" layout="horizontal" height={240} showLegend={false} ariaLabel={`Developer activation funnel for ${channelLabel}`} />
<Separator />
<Grid gap="4" style={styles.stepGrid}> {funnelSteps.map((step) => ( <VStack key={step.key} gap="1.5" style={styles.stepItem}> <Text render={<span />} size="xs" weight="medium" tone="muted"> {step.label} </Text> <HStack align="center" wrap="wrap" gap="2"> <Text render={<span />} size="xl" weight="semibold" tabular="true"> {step.conv.toFixed(1)}% </Text> <Badge size="sm" variant="subtle" palette={dropOffPalette(step.drop)}> <TrendDownIcon />-{step.drop.toFixed(0)}% </Badge> </HStack> <Text render={<span />} variant="mono" size="xs" tone="subtle" tabular="true"> {nf(step.dropped)} dropped </Text> </VStack> ))} </Grid> </VStack> </Card.Root> </section>
{/* Band 3: Interactive retention curves & stage conversion trends */} <section aria-label="Retention curves and stage conversion trends"> <Card.Root variant="outline"> <VStack gap="5" style={styles.cardInner}> <HStack justify="between" align="start" wrap="wrap" gap="3"> <VStack gap="1"> <Heading render={<h2 />} size="md" style={styles.sectionHeading}> {curveMode === "retention" ? "Developer retention curves" : "Stage conversion trends"} </Heading> <Text size="xs" tone="muted"> {curveMode === "retention" ? "Active deploying developers from W0 to W8 across acquisition channels · Toggle legend items to compare" : `Weekly stage conversion rates for ${channelLabel} · Trailing ${STAGE_TRENDS.length} weeks`} </Text> </VStack>
<HStack align="center" wrap="wrap" gap="2"> {curveMode === "retention" && selectedCohort && ( <HStack align="center" gap="1"> <Badge variant="subtle" size="sm" palette={purplePalette}> Overlay: {selectedCohort.label} </Badge> <IconButton size="2xs" variant="ghost" shape="rounded" palette={purplePalette} aria-label={`Clear ${selectedCohort.label} cohort overlay`} onClick={() => setSelectedCohortId(null)} > <CloseSmallIcon /> </IconButton> </HStack> )}
<SegmentGroup.Root size="xs" value={curveMode} onValueChange={(next) => { if (next === "retention" || next === "conversion") { setCurveMode(next); } }} aria-label="Chart view mode" > <SegmentGroup.Item value="retention">Retention curves</SegmentGroup.Item> <SegmentGroup.Item value="conversion">Stage trends</SegmentGroup.Item> </SegmentGroup.Root> </HStack> </HStack>
{curveMode === "retention" ? ( <LineChart data={retentionChartData} index="week" categories={retentionCategories} colors={retentionColors} height={264} curve="linear" valueFormatter={(value) => `${Math.round(value)}%`} ariaLabel="Weekly developer retention curves from W0 to W8 by acquisition channel" /> ) : ( <LineChart data={stageTrendData} index="week" categories={stageTrendCategories} colors={stageTrendColors} height={264} curve="linear" valueFormatter={(value) => Number.isInteger(value) ? `${value}%` : `${value.toFixed(1)}%` } ariaLabel="Trailing 16-week stage conversion rate trends" /> )} </VStack> </Card.Root> </section>
<Separator />
{/* Band 4: Weekly cohort retention heatmap table (W0–W8) */} <section aria-label="Weekly cohort retention heatmap"> <Card.Root variant="outline"> <VStack gap="5" style={styles.cardInner}> <HStack justify="between" align="start" wrap="wrap" gap="3"> <VStack gap="1"> <Heading render={<h2 />} size="md" style={styles.sectionHeading}> Weekly cohort retention (W0–W8) </Heading> <Text size="xs" tone="muted"> First-deploy week × weeks retained · {channelLabel} · Select a cohort row to overlay it on the retention curve </Text> </VStack>
<Button variant="surface" size="sm" onClick={() => queue.info( `Exported W0–W8 cohort matrix for ${channelLabel} (${cohortRows.length} weekly cohorts)`, ) } > <DownloadIcon /> Export cohort CSV </Button> </HStack>
<div {...stylex.props(styles.tableScroll)}> <Table.Root size="sm"> <Table.Header> <Table.Row> <Table.ColumnHeader>Cohort</Table.ColumnHeader> <Table.ColumnHeader>Devs</Table.ColumnHeader> {RETENTION_WEEKS.map((week) => ( <Table.ColumnHeader key={week} style={styles.weekHeader}> W{week} </Table.ColumnHeader> ))} </Table.Row> </Table.Header> <Table.Body> {cohortRows.map((row) => { const isSelected = selectedCohortId === row.id; const toggleCohort = () => { setSelectedCohortId((prev) => (prev === row.id ? null : row.id)); setCurveMode("retention"); };
return ( <Table.Row key={row.id} aria-selected={isSelected} onClick={toggleCohort} style={[styles.cohortRow, isSelected && styles.cohortRowSelected]} > <Table.Cell> <button type="button" aria-pressed={isSelected} onClick={(e) => { e.stopPropagation(); toggleCohort(); }} {...stylex.props(styles.cohortLabelBtn)} > {row.label} </button> </Table.Cell> <Table.Cell style={styles.nowrap}> <Text render={<span />} variant="mono" size="xs" tone="muted" tabular="true"> {nf(row.size)} </Text> </Table.Cell> {RETENTION_WEEKS.map((week) => { const pct = row.retention[week]; if (pct == null) { return ( <Table.Cell key={week} style={styles.weekCell}> <Text render={<span />} size="xs" tone="subtle"> — </Text> </Table.Cell> ); } return ( <Table.Cell key={week} style={styles.weekCell}> <Badge size="sm" variant="subtle" palette={retentionPalette(pct)} style={styles.heatBadge} > {pct}% </Badge> </Table.Cell> ); })} </Table.Row> ); })} </Table.Body> <Table.Footer> <Table.Row style={styles.footerRow}> <Table.Cell style={styles.nowrap}> <Text render={<span />} size="xs" weight="semibold"> Weighted avg </Text> </Table.Cell> <Table.Cell style={styles.nowrap}> <Text render={<span />} variant="mono" size="xs" tone="muted" tabular="true"> {nf(totalCohortDevs)} </Text> </Table.Cell> {RETENTION_WEEKS.map((week) => { const avg = averageRetention[week]; return ( <Table.Cell key={week} style={styles.weekCell}> {avg == null ? ( <Text render={<span />} size="xs" tone="subtle"> — </Text> ) : ( <Badge size="sm" variant="outline" palette={retentionPalette(avg)} style={styles.heatBadge} > {avg}% </Badge> )} </Table.Cell> ); })} </Table.Row> </Table.Footer> </Table.Root> </div>
<HStack justify="between" align="center" wrap="wrap" gap="3"> <HStack align="center" wrap="wrap" gap="2"> <Text render={<span />} size="xs" weight="medium" tone="muted"> Retention scale: </Text> <Badge size="sm" variant="subtle" palette={redPalette}> < 26% </Badge> <Badge size="sm" variant="subtle" palette={orangePalette}> 26–35% </Badge> <Badge size="sm" variant="subtle" palette={amberPalette}> 36–47% </Badge> <Badge size="sm" variant="subtle" palette={tealPalette}> 48–64% </Badge> <Badge size="sm" variant="subtle" palette={greenPalette}> ≥ 65% </Badge> </HStack> <Text render={<span />} size="xs" tone="muted"> {selectedCohort ? `Comparing ${selectedCohort.label} (${nf(selectedCohort.size)} devs) on chart above` : "Click any cohort row to overlay its curve above"} </Text> </HStack> </VStack> </Card.Root> </section> </VStack>
<Toaster toaster={queue} /> </div> );}
Inspired by the Funnel & Cohort Dashboard template from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.).