+ {/* Header */}
+
+
+
+
+
+
My Analytics
+
+
+
+ {(isAccountOwner || isSuperAdmin) && (
+
+ Team Analytics
+
+ )}
+
+
+
+
+ {/* Stat Cards */}
+
+
+
+
+
+
+
+ {/* Area Chart — Sessions over Time */}
+
+
+ My Sessions Over Time
+
+
+
+
+ {
+ const d = new Date(value)
+ return `${d.getMonth() + 1}/${d.getDate()}`
+ }}
+ />
+
+ {
+ const d = new Date(String(value))
+ return d.toLocaleDateString(undefined, {
+ month: 'short',
+ day: 'numeric',
+ year: 'numeric',
+ })
+ }}
+ />
+
+
+
+
+
+
+
+ {/* Chart legend */}
+
+ {Object.entries(OUTCOME_COLORS).map(([key, color]) => (
+
+ ))}
+
+
+
+ {/* Two-Column: Top Flows & Outcome Distribution */}
+
+ {/* My Top Flows */}
+
+
+ My Top Flows
+
+ {top_flows.length === 0 ? (
+
No flow data for this period.
+ ) : (
+
+
+
+
+ |
+ Name
+ |
+
+ Sessions
+ |
+
+ Completion
+ |
+
+ Median
+ |
+
+
+
+ {top_flows.map((flow) => (
+
+ |
+ {flow.name}
+ |
+
+ {flow.sessions}
+ |
+
+ {(flow.completion_rate * 100).toFixed(1)}%
+ |
+
+ {flow.median_duration_minutes} min
+ |
+
+ ))}
+
+
+
+ )}
+
+
+ {/* Outcome Distribution */}
+
+
+ Outcome Distribution
+
+ {summary.total_sessions === 0 ? (
+
No session data for this period.
+ ) : (
+
+ {(
+ Object.entries(outcomeBreakdown) as [string, number][]
+ ).map(([outcome, count]) => {
+ const total = Object.values(outcomeBreakdown).reduce(
+ (sum, v) => sum + v,
+ 0
+ )
+ const pct = total > 0 ? (count / total) * 100 : 0
+
+ return (
+
+
+
+
+ {count} ({pct.toFixed(1)}%)
+
+
+
+
+ )
+ })}
+
+ )}
+
+
+
+ )
+}
+
+function StatCard({
+ icon: Icon,
+ label,
+ value,
+}: {
+ icon: React.ComponentType<{ size?: number; className?: string }>
+ label: string
+ value: string
+}) {
+ return (
+