Refine analytics KPIs and charts, and relabel exam prep as Duolingo/IELTS.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
ef170e7fbd
commit
d16cb84006
|
|
@ -225,11 +225,11 @@ export const RESOURCE_TYPE_OPTIONS: { value: string; label: string }[] = [
|
|||
{ value: "CATEGORY", label: "Category" },
|
||||
{ value: "SUB_COURSE", label: "Sub-course" },
|
||||
{ value: "QUESTION_SET", label: "Question set" },
|
||||
{ value: "EXAM_PREP_CATALOG_COURSE", label: "Exam prep course" },
|
||||
{ value: "EXAM_PREP_UNIT", label: "Exam prep unit" },
|
||||
{ value: "EXAM_PREP_MODULE", label: "Exam prep module" },
|
||||
{ value: "EXAM_PREP_LESSON", label: "Exam prep lesson" },
|
||||
{ value: "EXAM_PREP_PRACTICE", label: "Exam prep practice" },
|
||||
{ value: "EXAM_PREP_CATALOG_COURSE", label: "Duolingo/IELTS course" },
|
||||
{ value: "EXAM_PREP_UNIT", label: "Duolingo/IELTS unit" },
|
||||
{ value: "EXAM_PREP_MODULE", label: "Duolingo/IELTS module" },
|
||||
{ value: "EXAM_PREP_LESSON", label: "Duolingo/IELTS lesson" },
|
||||
{ value: "EXAM_PREP_PRACTICE", label: "Duolingo/IELTS practice" },
|
||||
{ value: "APP_VERSION", label: "App version" },
|
||||
{ value: "FIELD_OPTION", label: "Field option" },
|
||||
{ value: "DEVICE", label: "Device" },
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ export function getPrimaryQuestionTypeSummary(questionsByType: LabelCount[]): st
|
|||
}
|
||||
|
||||
export function getVideoLessonsSummary(lmsLessonsWithVideo = 0, examPrepLessonsWithVideo = 0): string {
|
||||
return `${lmsLessonsWithVideo.toLocaleString()} LMS · ${examPrepLessonsWithVideo.toLocaleString()} exam prep lessons`
|
||||
return `${lmsLessonsWithVideo.toLocaleString()} LMS · ${examPrepLessonsWithVideo.toLocaleString()} Duolingo/IELTS lessons`
|
||||
}
|
||||
|
||||
export interface MonthlyRevenuePoint {
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ import {
|
|||
BarChart,
|
||||
CartesianGrid,
|
||||
Cell,
|
||||
Legend,
|
||||
Line,
|
||||
LineChart,
|
||||
Pie,
|
||||
PieChart,
|
||||
ResponsiveContainer,
|
||||
|
|
@ -49,13 +46,10 @@ import { cn } from "../../lib/utils"
|
|||
import { getDashboard } from "../../api/analytics.api"
|
||||
import { AnalyticsTimeRangeFilter, getDashboardFilterLabel } from "../../components/analytics/AnalyticsTimeRangeFilter"
|
||||
import {
|
||||
ActivePlansBreakdownCard,
|
||||
MonthlyRevenueAreaChart,
|
||||
MonthlyRevenueTrendPanel,
|
||||
RenewalRateCard,
|
||||
SensitiveYtdValue,
|
||||
analyticsSoftCardClass,
|
||||
labelCountsToPieSlices,
|
||||
} from "../../components/analytics/SubscriptionRevenueVisuals"
|
||||
import {
|
||||
getPrimaryQuestionTypeSummary,
|
||||
|
|
@ -64,15 +58,27 @@ import {
|
|||
getSubscriptionMetrics,
|
||||
getVideoLessonsSummary,
|
||||
formatPercentRate,
|
||||
buildSubscriptionStatusPie,
|
||||
aggregateRevenueByMonth,
|
||||
formatAnalyticsSeriesDate,
|
||||
aggregateRevenueByMonth,
|
||||
formatRevenueAxisTick,
|
||||
} from "../../lib/analytics"
|
||||
import type { DashboardData, DashboardFilters, LabelCount } from "../../types/analytics.types"
|
||||
import { UnassignedLabel, isUnassignedLabel } from "../../lib/displayValue"
|
||||
|
||||
const PIE_COLORS = ["#9E2891", "#FFD23F", "#1DE9B6", "#C26FC0", "#6366F1", "#F97316", "#14B8A6", "#EF4444", "#8B5CF6", "#EC4899", "#06B6D4", "#84CC16"]
|
||||
|
||||
function genderAnalyticsRowLabel(label: string): ReactNode {
|
||||
const trimmed = label?.trim() ?? ""
|
||||
if (
|
||||
isUnassignedLabel(trimmed) ||
|
||||
trimmed.toUpperCase() === "OTHER" ||
|
||||
trimmed.toLowerCase() === "unknown"
|
||||
) {
|
||||
return <UnassignedLabel />
|
||||
}
|
||||
return formatAnalyticsLabel(label)
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string) {
|
||||
return formatAnalyticsSeriesDate(dateStr)
|
||||
}
|
||||
|
|
@ -139,11 +145,13 @@ function BreakdownList({
|
|||
data,
|
||||
total,
|
||||
scrollable: _scrollable,
|
||||
formatRowLabel,
|
||||
}: {
|
||||
title: string
|
||||
data: LabelCount[]
|
||||
total?: number
|
||||
scrollable?: boolean
|
||||
formatRowLabel?: (label: string) => ReactNode
|
||||
}) {
|
||||
const computedTotal = total ?? data.reduce((s, d) => s + d.count, 0)
|
||||
const sorted = [...data].sort((a, b) => b.count - a.count)
|
||||
|
|
@ -159,7 +167,15 @@ function BreakdownList({
|
|||
>
|
||||
{sorted.map((item, i) => {
|
||||
const pct = computedTotal > 0 ? (item.count / computedTotal) * 100 : 0
|
||||
const displayLabel = formatAnalyticsLabel(item.label)
|
||||
const displayLabel = formatRowLabel
|
||||
? formatRowLabel(item.label)
|
||||
: formatAnalyticsLabel(item.label)
|
||||
const titleText =
|
||||
typeof displayLabel === "string"
|
||||
? displayLabel
|
||||
: isUnassignedLabel(item.label) || item.label.toUpperCase() === "OTHER"
|
||||
? "unassigned"
|
||||
: formatAnalyticsLabel(item.label)
|
||||
return (
|
||||
<div key={`${item.label}-${i}`}>
|
||||
<div className="mb-1 flex items-center justify-between gap-2 text-xs">
|
||||
|
|
@ -168,7 +184,7 @@ function BreakdownList({
|
|||
className="h-2 w-2 shrink-0 rounded-full"
|
||||
style={{ backgroundColor: PIE_COLORS[i % PIE_COLORS.length] }}
|
||||
/>
|
||||
<span className="truncate text-grayScale-600" title={displayLabel}>
|
||||
<span className="truncate text-grayScale-600" title={titleText}>
|
||||
{displayLabel}
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -198,68 +214,6 @@ function BreakdownList({
|
|||
)
|
||||
}
|
||||
|
||||
function AmountBreakdownList({
|
||||
title,
|
||||
data,
|
||||
}: {
|
||||
title: string
|
||||
data: { label: string; count: number; amount: number }[]
|
||||
}) {
|
||||
const totalAmount = data.reduce((s, d) => s + d.amount, 0)
|
||||
const sorted = [...data].sort((a, b) => b.amount - a.amount)
|
||||
return (
|
||||
<Card className="shadow-none flex flex-col">
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm">{title}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="p-4 pt-0 flex-1 flex flex-col">
|
||||
{sorted.length > 0 ? (
|
||||
<div className="space-y-2.5 flex-1 overflow-y-auto overscroll-contain pr-1 max-h-[320px]">
|
||||
{sorted.map((item, i) => {
|
||||
const pct = totalAmount > 0 ? (item.amount / totalAmount) * 100 : 0
|
||||
const displayLabel = formatAnalyticsLabel(item.label)
|
||||
return (
|
||||
<div key={`${item.label}-${i}`}>
|
||||
<div className="mb-1 flex items-center justify-between gap-2 text-xs">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span
|
||||
className="h-2 w-2 shrink-0 rounded-full"
|
||||
style={{ backgroundColor: PIE_COLORS[i % PIE_COLORS.length] }}
|
||||
/>
|
||||
<span className="truncate text-grayScale-600" title={displayLabel}>
|
||||
{displayLabel}
|
||||
</span>
|
||||
</div>
|
||||
<span className="font-semibold text-grayScale-700">
|
||||
<SensitiveValue showToggle={false}>
|
||||
ETB {item.amount.toLocaleString()}
|
||||
</SensitiveValue>
|
||||
<span className="ml-1 font-normal text-grayScale-400">
|
||||
({item.count.toLocaleString()} · {pct.toFixed(0)}%)
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="h-1.5 w-full overflow-hidden rounded-full bg-grayScale-100">
|
||||
<div
|
||||
className="h-full rounded-full transition-all"
|
||||
style={{
|
||||
width: `${pct}%`,
|
||||
backgroundColor: PIE_COLORS[i % PIE_COLORS.length],
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<div className="py-4 text-center text-xs text-grayScale-400">No data available</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
function DonutCard({
|
||||
title,
|
||||
data,
|
||||
|
|
@ -453,54 +407,19 @@ export function AnalyticsPage() {
|
|||
count: d.count,
|
||||
}))
|
||||
|
||||
const snapshot = subscriptions.snapshot
|
||||
const renewal = subscriptions.renewal
|
||||
const periodFilterLabel = getDashboardFilterLabel(filters)
|
||||
const newThisPeriod =
|
||||
renewal && renewal.first_time_subscriptions + renewal.returning_subscriptions > 0
|
||||
? renewal.first_time_subscriptions + renewal.returning_subscriptions
|
||||
: subscriptions.total_subscriptions
|
||||
|
||||
const subscriptionData = subscriptions.new_subscriptions_last_30_days.map((d) => ({
|
||||
date: formatDate(d.date),
|
||||
count: d.count,
|
||||
}))
|
||||
|
||||
const snapshot = subscriptions.snapshot
|
||||
const renewal = subscriptions.renewal
|
||||
const cancelByDate = new Map(
|
||||
(subscriptions.cancellations_last_30_days ?? []).map((d) => [d.date, d.count]),
|
||||
)
|
||||
const expireByDate = new Map(
|
||||
(subscriptions.expirations_last_30_days ?? []).map((d) => [d.date, d.count]),
|
||||
)
|
||||
const resubByDate = new Map(
|
||||
(subscriptions.resubscriptions_last_30_days ?? []).map((d) => [d.date, d.count]),
|
||||
)
|
||||
const churnDates = [
|
||||
...new Set([
|
||||
...(subscriptions.cancellations_last_30_days ?? []).map((d) => d.date),
|
||||
...(subscriptions.expirations_last_30_days ?? []).map((d) => d.date),
|
||||
...(subscriptions.resubscriptions_last_30_days ?? []).map((d) => d.date),
|
||||
]),
|
||||
].sort()
|
||||
const churnSeries = churnDates.map((date) => ({
|
||||
date: formatDate(date),
|
||||
cancellations: cancelByDate.get(date) ?? 0,
|
||||
expirations: expireByDate.get(date) ?? 0,
|
||||
resubscriptions: resubByDate.get(date) ?? 0,
|
||||
}))
|
||||
|
||||
const activeCategoryPie = (subscriptions.active_by_category ?? []).map((s, i) => ({
|
||||
name: formatAnalyticsLabel(s.label),
|
||||
value: s.count,
|
||||
color: PIE_COLORS[i % PIE_COLORS.length],
|
||||
}))
|
||||
|
||||
const acquisitionPie = (subscriptions.acquisition_by_source ?? []).map((s, i) => ({
|
||||
name: formatAnalyticsLabel(s.label),
|
||||
value: s.count,
|
||||
color: PIE_COLORS[i % PIE_COLORS.length],
|
||||
}))
|
||||
|
||||
const cohortPie = (subscriptions.new_by_cohort ?? []).map((s, i) => ({
|
||||
name: formatAnalyticsLabel(s.label),
|
||||
value: s.count,
|
||||
color: PIE_COLORS[i % PIE_COLORS.length],
|
||||
}))
|
||||
|
||||
const revenueData = payments.revenue_last_30_days.map((d) => ({
|
||||
date: formatDate(d.date),
|
||||
revenue: d.revenue,
|
||||
|
|
@ -510,7 +429,8 @@ export function AnalyticsPage() {
|
|||
const useMonthlyRevenueTrend =
|
||||
dateFilter?.mode === "year" ||
|
||||
dateFilter?.mode === "all_time" ||
|
||||
(filters.mode === "year" || filters.mode === "all_time")
|
||||
filters.mode === "year" ||
|
||||
filters.mode === "all_time"
|
||||
const monthlyTrendYear =
|
||||
(dateFilter?.mode === "year" && dateFilter.year) ||
|
||||
(filters.mode === "year" && filters.year) ||
|
||||
|
|
@ -519,10 +439,6 @@ export function AnalyticsPage() {
|
|||
? aggregateRevenueByMonth(payments.revenue_last_30_days, monthlyTrendYear)
|
||||
: revenueData
|
||||
|
||||
const subscriptionStatusPie = buildSubscriptionStatusPie(
|
||||
subscriptions.by_status,
|
||||
PIE_COLORS,
|
||||
)
|
||||
const notifByTypePie = notifications.by_type.slice(0, 8).map((s, i) => ({
|
||||
name: s.label,
|
||||
value: s.count,
|
||||
|
|
@ -738,6 +654,7 @@ export function AnalyticsPage() {
|
|||
title="Gender"
|
||||
data={users.by_gender ?? []}
|
||||
total={users.total_users}
|
||||
formatRowLabel={genderAnalyticsRowLabel}
|
||||
/>
|
||||
<BreakdownList
|
||||
title="Education level"
|
||||
|
|
@ -754,16 +671,6 @@ export function AnalyticsPage() {
|
|||
data={users.by_region ?? []}
|
||||
total={users.total_users}
|
||||
/>
|
||||
<BreakdownList
|
||||
title="Account role"
|
||||
data={users.by_role ?? []}
|
||||
total={users.total_users}
|
||||
/>
|
||||
<BreakdownList
|
||||
title="Account status"
|
||||
data={users.by_status ?? []}
|
||||
total={users.total_users}
|
||||
/>
|
||||
{(users.by_knowledge_level?.length ?? 0) > 0 ? (
|
||||
<BreakdownList
|
||||
title="Knowledge level"
|
||||
|
|
@ -797,182 +704,103 @@ export function AnalyticsPage() {
|
|||
|
||||
{/* ─── Subscriptions & Revenue ─── */}
|
||||
<Section title="Subscriptions & Revenue" icon={DollarSign} defaultOpen={false}>
|
||||
{snapshot && (
|
||||
<div className="mb-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<KpiCard
|
||||
icon={BadgeCheck}
|
||||
label="Active Now"
|
||||
value={formatNumber(snapshot.active_now)}
|
||||
sub={`${formatNumber(snapshot.active_learners)} learners · ${formatNumber(snapshot.lifetime_active)} lifetime · ${formatNumber(snapshot.term_active)} term`}
|
||||
trend="neutral"
|
||||
/>
|
||||
<KpiCard
|
||||
icon={TrendingDown}
|
||||
label="Expiring Soon"
|
||||
value={formatNumber(snapshot.expiring_within_7_days)}
|
||||
sub={`${formatNumber(snapshot.expiring_within_30_days)} within 30 days · ${formatNumber(snapshot.auto_renew_enabled)} auto-renew`}
|
||||
trend={snapshot.expiring_within_7_days > 0 ? "down" : "neutral"}
|
||||
/>
|
||||
<KpiCard
|
||||
icon={RotateCcw}
|
||||
label="Churn Stock"
|
||||
value={formatNumber(snapshot.expired_now + snapshot.cancelled_now)}
|
||||
sub={`${formatNumber(snapshot.expired_now)} expired · ${formatNumber(snapshot.cancelled_now)} cancelled · ${formatNumber(snapshot.pending_now)} pending`}
|
||||
trend="neutral"
|
||||
/>
|
||||
<KpiCard
|
||||
icon={CreditCard}
|
||||
label="New (period)"
|
||||
value={formatNumber(subscriptions.total_subscriptions)}
|
||||
sub={`+${subscriptions.new_today} today · +${subscriptions.new_week} week · +${subscriptions.new_month} month`}
|
||||
trend={subscriptions.new_month > 0 ? "up" : "neutral"}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{renewal && (
|
||||
<div className="mb-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<KpiCard
|
||||
icon={RotateCcw}
|
||||
label="Renewal Rate"
|
||||
value={formatPercentRate(renewal.renewal_rate)}
|
||||
sub={`${formatNumber(renewal.renewed_after_expiry)} renewed of ${formatNumber(renewal.expired_in_period)} expired`}
|
||||
trend={renewal.renewal_rate >= 0.3 ? "up" : renewal.expired_in_period > 0 ? "down" : "neutral"}
|
||||
/>
|
||||
<KpiCard
|
||||
icon={BadgeCheck}
|
||||
label="Resubscribe After Expiry"
|
||||
value={formatNumber(renewal.resubscribe_after_expiry)}
|
||||
sub={`${formatNumber(renewal.returning_subscriptions)} returning · ${formatNumber(renewal.first_time_subscriptions)} first-time`}
|
||||
trend={renewal.resubscribe_after_expiry > 0 ? "up" : "neutral"}
|
||||
/>
|
||||
<KpiCard
|
||||
icon={TrendingUp}
|
||||
label="Avg Days to Resubscribe"
|
||||
value={renewal.avg_days_to_resubscribe.toFixed(1)}
|
||||
sub={`Median ${renewal.median_days_to_resubscribe.toFixed(1)} days after expiry`}
|
||||
trend="neutral"
|
||||
/>
|
||||
<KpiCard
|
||||
icon={Users}
|
||||
label="Returning Share"
|
||||
value={formatPercentRate(
|
||||
renewal.first_time_subscriptions + renewal.returning_subscriptions > 0
|
||||
? renewal.returning_subscriptions /
|
||||
(renewal.first_time_subscriptions + renewal.returning_subscriptions)
|
||||
: 0,
|
||||
)}
|
||||
sub={`${formatNumber(renewal.returning_subscriptions)} of ${formatNumber(renewal.first_time_subscriptions + renewal.returning_subscriptions)} new subs`}
|
||||
trend={renewal.returning_subscriptions > 0 ? "up" : "neutral"}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="mb-4 space-y-4">
|
||||
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<KpiCard
|
||||
icon={BadgeCheck}
|
||||
label="Active Now"
|
||||
value={formatNumber(snapshot?.active_now ?? subscriptionMetrics.active)}
|
||||
sub={`${formatNumber(snapshot?.active_learners ?? 0)} learners with access`}
|
||||
trend="neutral"
|
||||
/>
|
||||
<KpiCard
|
||||
icon={TrendingDown}
|
||||
label="Expiring Soon"
|
||||
value={formatNumber(snapshot?.expiring_within_7_days ?? 0)}
|
||||
sub={`${formatNumber(snapshot?.expiring_within_30_days ?? 0)} within 30 days`}
|
||||
trend={(snapshot?.expiring_within_7_days ?? 0) > 0 ? "down" : "neutral"}
|
||||
/>
|
||||
<KpiCard
|
||||
icon={RotateCcw}
|
||||
label="Expired"
|
||||
value={formatNumber(snapshot?.expired_now ?? 0)}
|
||||
sub={`${formatNumber(snapshot?.cancelled_now ?? 0)} cancelled · ${formatNumber(snapshot?.pending_now ?? 0)} pending`}
|
||||
trend="neutral"
|
||||
/>
|
||||
<KpiCard
|
||||
icon={CreditCard}
|
||||
label="New This Period"
|
||||
value={formatNumber(newThisPeriod)}
|
||||
sub={periodFilterLabel}
|
||||
trend={newThisPeriod > 0 ? "up" : "neutral"}
|
||||
/>
|
||||
<KpiCard
|
||||
icon={Users}
|
||||
label="First-time"
|
||||
value={formatNumber(renewal?.first_time_subscriptions ?? 0)}
|
||||
sub="New subscribers in period"
|
||||
trend={(renewal?.first_time_subscriptions ?? 0) > 0 ? "up" : "neutral"}
|
||||
/>
|
||||
<KpiCard
|
||||
icon={BadgeCheck}
|
||||
label="Resubscribed"
|
||||
value={formatNumber(renewal?.returning_subscriptions ?? 0)}
|
||||
sub={`${formatNumber(renewal?.resubscribe_after_expiry ?? 0)} after expiry`}
|
||||
trend={(renewal?.returning_subscriptions ?? 0) > 0 ? "up" : "neutral"}
|
||||
/>
|
||||
<KpiCard
|
||||
icon={TrendingUp}
|
||||
label="Average Days to Resubscribe"
|
||||
value={(renewal?.avg_days_to_resubscribe ?? 0).toFixed(1)}
|
||||
sub={`Median ${(renewal?.median_days_to_resubscribe ?? 0).toFixed(1)} days`}
|
||||
trend="neutral"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="mt-6 space-y-4">
|
||||
<MonthlyRevenueTrendPanel
|
||||
subtitle={
|
||||
useMonthlyRevenueTrend
|
||||
? `Revenue growth over ${monthlyTrendYear}`
|
||||
? `Revenue over ${monthlyTrendYear}`
|
||||
: `Revenue over ${seriesPeriodLabel.toLowerCase()}`
|
||||
}
|
||||
ytdValue={<SensitiveYtdValue amount={payments.total_revenue} />}
|
||||
ytdLabel={useMonthlyRevenueTrend ? "YTD" : "Period"}
|
||||
ytdLabel="Period total"
|
||||
>
|
||||
<MonthlyRevenueAreaChart
|
||||
data={monthlyRevenueTrendData}
|
||||
xKey={useMonthlyRevenueTrend ? "month" : "date"}
|
||||
gradientId="analyticsMonthlyRevenueFill"
|
||||
gradientId="analyticsSubsRevenueFill"
|
||||
height={260}
|
||||
yTickFormatter={formatRevenueAxisTick}
|
||||
/>
|
||||
</MonthlyRevenueTrendPanel>
|
||||
|
||||
<div className="grid gap-4 lg:grid-cols-2">
|
||||
<ActivePlansBreakdownCard
|
||||
data={labelCountsToPieSlices(
|
||||
(subscriptions.active_by_plan?.length
|
||||
? subscriptions.active_by_plan
|
||||
: subscriptions.by_status
|
||||
).map((row) => ({ label: row.label, count: row.count })),
|
||||
)}
|
||||
/>
|
||||
<RenewalRateCard
|
||||
renewalRate={renewal?.renewal_rate ?? 0}
|
||||
autoRenewCount={snapshot?.auto_renew_enabled ?? 0}
|
||||
cancelledCount={snapshot?.cancelled_now ?? 0}
|
||||
activeNow={snapshot?.active_now ?? subscriptionMetrics.active}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-4 lg:grid-cols-2">
|
||||
<Card className={analyticsSoftCardClass}>
|
||||
<CardHeader className="pb-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<CardTitle>New Subscriptions</CardTitle>
|
||||
<div className="mt-1 text-2xl font-semibold tracking-tight">
|
||||
{subscriptions.total_subscriptions.toLocaleString()}
|
||||
</div>
|
||||
<div className="text-xs text-grayScale-400">
|
||||
+{subscriptions.new_today} today · +{subscriptions.new_week} this week
|
||||
<Card className={analyticsSoftCardClass}>
|
||||
<CardHeader className="pb-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<CardTitle>New Subscriptions</CardTitle>
|
||||
<div className="mt-1 text-xs text-grayScale-400">
|
||||
Daily new subscriptions · {periodFilterLabel}
|
||||
</div>
|
||||
</div>
|
||||
<Badge variant="secondary">{seriesPeriodLabel}</Badge>
|
||||
</div>
|
||||
<Badge variant="secondary">{seriesPeriodLabel}</Badge>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="h-[240px] p-6 pt-2">
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<AreaChart data={subscriptionData} margin={{ left: 8, right: 8, top: 8, bottom: 0 }}>
|
||||
<defs>
|
||||
<linearGradient id="gradSub" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stopColor="#8E248D" stopOpacity={0.22} />
|
||||
<stop offset="100%" stopColor="#8E248D" stopOpacity={0.02} />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<CartesianGrid vertical={false} stroke="#EEEEEE" strokeDasharray="4 4" />
|
||||
<XAxis dataKey="date" tickLine={false} axisLine={false} fontSize={11} tick={{ fill: "#9E9E9E" }} />
|
||||
<YAxis tickLine={false} axisLine={false} fontSize={11} width={30} allowDecimals={false} tick={{ fill: "#9E9E9E" }} />
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
borderRadius: 10,
|
||||
border: "1px solid #E8E8E8",
|
||||
boxShadow: "0 8px 24px rgba(0,0,0,0.08)",
|
||||
fontSize: 12,
|
||||
}}
|
||||
/>
|
||||
<Area
|
||||
type="monotone"
|
||||
dataKey="count"
|
||||
stroke="#8E248D"
|
||||
strokeWidth={2.5}
|
||||
fill="url(#gradSub)"
|
||||
dot={{ r: 3.5, fill: "#8E248D", strokeWidth: 0 }}
|
||||
/>
|
||||
</AreaChart>
|
||||
</ResponsiveContainer>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className={analyticsSoftCardClass}>
|
||||
<CardHeader className="pb-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<CardTitle>Daily Revenue Detail</CardTitle>
|
||||
<div className="mt-1 text-xs text-grayScale-400">
|
||||
Same period as filters · ETB
|
||||
</div>
|
||||
</div>
|
||||
<Badge variant="secondary">{seriesPeriodLabel}</Badge>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="h-[240px] p-6 pt-2">
|
||||
<SensitiveChart>
|
||||
</CardHeader>
|
||||
<CardContent className="h-[240px] p-6 pt-2">
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart data={revenueData} margin={{ left: 8, right: 8, top: 8 }}>
|
||||
<AreaChart data={subscriptionData} margin={{ left: 8, right: 8, top: 8, bottom: 0 }}>
|
||||
<defs>
|
||||
<linearGradient id="gradSubAnalytics" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stopColor="#8E248D" stopOpacity={0.22} />
|
||||
<stop offset="100%" stopColor="#8E248D" stopOpacity={0.02} />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<CartesianGrid vertical={false} stroke="#EEEEEE" strokeDasharray="4 4" />
|
||||
<XAxis dataKey="date" tickLine={false} axisLine={false} fontSize={11} tick={{ fill: "#9E9E9E" }} />
|
||||
<YAxis tickLine={false} axisLine={false} fontSize={11} width={42} tick={{ fill: "#9E9E9E" }} />
|
||||
<YAxis tickLine={false} axisLine={false} fontSize={11} width={30} allowDecimals={false} tick={{ fill: "#9E9E9E" }} />
|
||||
<Tooltip
|
||||
formatter={(v) => [`ETB ${Number(v).toLocaleString()}`, "Revenue"]}
|
||||
contentStyle={{
|
||||
borderRadius: 10,
|
||||
border: "1px solid #E8E8E8",
|
||||
|
|
@ -980,130 +808,55 @@ export function AnalyticsPage() {
|
|||
fontSize: 12,
|
||||
}}
|
||||
/>
|
||||
<Bar dataKey="revenue" radius={[6, 6, 0, 0]} fill="#8E248D" />
|
||||
</BarChart>
|
||||
<Area
|
||||
type="monotone"
|
||||
dataKey="count"
|
||||
name="Subscriptions"
|
||||
stroke="#8E248D"
|
||||
strokeWidth={2.5}
|
||||
fill="url(#gradSubAnalytics)"
|
||||
dot={{ r: 3.5, fill: "#8E248D", strokeWidth: 0 }}
|
||||
/>
|
||||
</AreaChart>
|
||||
</ResponsiveContainer>
|
||||
</SensitiveChart>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{churnSeries.length > 0 && (
|
||||
<Card className="mt-4 shadow-none">
|
||||
<CardHeader className="pb-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<CardTitle>Cancellations, Expirations & Resubscribes</CardTitle>
|
||||
<div className="text-xs text-grayScale-400">
|
||||
Churn vs win-back over {seriesPeriodLabel.toLowerCase()}
|
||||
<Card className={analyticsSoftCardClass}>
|
||||
<CardHeader className="pb-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<CardTitle>Daily Revenue</CardTitle>
|
||||
<div className="mt-1 text-xs text-grayScale-400">
|
||||
Successful payments · ETB · {periodFilterLabel}
|
||||
</div>
|
||||
</div>
|
||||
<Badge variant="secondary">{seriesPeriodLabel}</Badge>
|
||||
</div>
|
||||
<Badge variant="secondary">{seriesPeriodLabel}</Badge>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="h-[240px] p-6 pt-2">
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<LineChart data={churnSeries} margin={{ left: 8, right: 8, top: 8, bottom: 0 }}>
|
||||
<CartesianGrid vertical={false} stroke="#E0E0E0" strokeDasharray="4 4" />
|
||||
<XAxis dataKey="date" tickLine={false} axisLine={false} fontSize={11} />
|
||||
<YAxis tickLine={false} axisLine={false} fontSize={11} width={30} allowDecimals={false} />
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
borderRadius: 12,
|
||||
border: "1px solid #E0E0E0",
|
||||
boxShadow: "0 10px 30px rgba(0,0,0,0.08)",
|
||||
fontSize: 12,
|
||||
}}
|
||||
/>
|
||||
<Legend />
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="cancellations"
|
||||
name="Cancellations"
|
||||
stroke="#EF4444"
|
||||
strokeWidth={2}
|
||||
dot={false}
|
||||
/>
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="expirations"
|
||||
name="Expirations"
|
||||
stroke="#F97316"
|
||||
strokeWidth={2}
|
||||
dot={false}
|
||||
/>
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="resubscriptions"
|
||||
name="Resubscribes"
|
||||
stroke="#14B8A6"
|
||||
strokeWidth={2}
|
||||
dot={false}
|
||||
/>
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
<div className="mt-4 grid items-start gap-4 lg:grid-cols-3">
|
||||
<DonutCard
|
||||
title="Subscription Status"
|
||||
data={subscriptionStatusPie}
|
||||
centerValue={subscriptions.total_subscriptions.toString()}
|
||||
centerLabel="Total"
|
||||
/>
|
||||
<DonutCard
|
||||
title="Active by Category"
|
||||
data={activeCategoryPie}
|
||||
centerValue={(snapshot?.active_now ?? subscriptionMetrics.active).toString()}
|
||||
centerLabel="Active"
|
||||
/>
|
||||
<DonutCard
|
||||
title="First-time vs Returning"
|
||||
data={cohortPie}
|
||||
centerValue={(
|
||||
(renewal?.first_time_subscriptions ?? 0) + (renewal?.returning_subscriptions ?? 0) ||
|
||||
subscriptions.total_subscriptions
|
||||
).toString()}
|
||||
centerLabel="New"
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-4 grid items-start gap-4 lg:grid-cols-3">
|
||||
<DonutCard
|
||||
title="Acquisition Source"
|
||||
data={acquisitionPie}
|
||||
centerValue={(
|
||||
(subscriptions.acquisition_by_source ?? []).reduce((s, r) => s + r.count, 0) ||
|
||||
subscriptions.total_subscriptions
|
||||
).toString()}
|
||||
centerLabel="Subs"
|
||||
/>
|
||||
<BreakdownList
|
||||
title="Active by Plan"
|
||||
data={subscriptions.active_by_plan ?? []}
|
||||
total={snapshot?.active_now}
|
||||
/>
|
||||
<BreakdownList
|
||||
title="Lifetime vs Term"
|
||||
data={subscriptions.active_by_lifetime ?? []}
|
||||
total={snapshot?.active_now}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-4 grid items-start gap-4 lg:grid-cols-3">
|
||||
<AmountBreakdownList
|
||||
title="Revenue by Category"
|
||||
data={subscriptions.revenue_by_category ?? []}
|
||||
/>
|
||||
<BreakdownList title="Payments by Method" data={payments.by_method} total={payments.total_payments} />
|
||||
<BreakdownList title="Payments by Status" data={payments.by_status} total={payments.total_payments} />
|
||||
</div>
|
||||
<div className="mt-4 grid items-start gap-4 lg:grid-cols-3">
|
||||
<BreakdownList
|
||||
title="Subscriptions by Status"
|
||||
data={subscriptions.by_status}
|
||||
total={subscriptions.total_subscriptions}
|
||||
/>
|
||||
</CardHeader>
|
||||
<CardContent className="h-[240px] p-6 pt-2">
|
||||
<SensitiveChart>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart data={revenueData} margin={{ left: 8, right: 8, top: 8 }}>
|
||||
<CartesianGrid vertical={false} stroke="#EEEEEE" strokeDasharray="4 4" />
|
||||
<XAxis dataKey="date" tickLine={false} axisLine={false} fontSize={11} tick={{ fill: "#9E9E9E" }} />
|
||||
<YAxis tickLine={false} axisLine={false} fontSize={11} width={42} tick={{ fill: "#9E9E9E" }} />
|
||||
<Tooltip
|
||||
formatter={(v) => [`ETB ${Number(v).toLocaleString()}`, "Revenue"]}
|
||||
contentStyle={{
|
||||
borderRadius: 10,
|
||||
border: "1px solid #E8E8E8",
|
||||
boxShadow: "0 8px 24px rgba(0,0,0,0.08)",
|
||||
fontSize: 12,
|
||||
}}
|
||||
/>
|
||||
<Bar dataKey="revenue" radius={[6, 6, 0, 0]} fill="#8E248D" />
|
||||
</BarChart>
|
||||
</ResponsiveContainer>
|
||||
</SensitiveChart>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
|
|
@ -1187,7 +940,7 @@ export function AnalyticsPage() {
|
|||
)}
|
||||
{examPrep && (
|
||||
<BreakdownList
|
||||
title="Exam prep"
|
||||
title="Duolingo/IELTS"
|
||||
data={[
|
||||
{ label: "Catalog courses", count: examPrep.catalog_courses },
|
||||
{ label: "Units", count: examPrep.units },
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ export function AddPracticeFlow() {
|
|||
const programLabel = isExamPrep
|
||||
? programType === "skill"
|
||||
? "Skill-Based Courses"
|
||||
: "English Proficiency Exams"
|
||||
: "Duolingo/IELTS"
|
||||
: level
|
||||
? `Program ${level}`
|
||||
: null;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export function AttachPracticeFlow() {
|
|||
program:
|
||||
programType === "skill"
|
||||
? "Skill-Based Courses"
|
||||
: "English Proficiency Exams",
|
||||
: "Duolingo/IELTS",
|
||||
module: "Module 4: Interactive Speaking",
|
||||
video: "Intro to Interactive Speaking",
|
||||
questionType: "speaking",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export function AttachProgramPracticeFlow() {
|
|||
const [isPublished, setIsPublished] = useState(false);
|
||||
|
||||
const [formData, setFormData] = useState({
|
||||
program: "English Proficiency Exams",
|
||||
program: "Duolingo/IELTS",
|
||||
test: "Mock Exam 1",
|
||||
questionType: "Speaking Practice",
|
||||
version: "V 1.0",
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ export function CourseCategoryPage() {
|
|||
Category name
|
||||
</label>
|
||||
<Input
|
||||
placeholder="e.g. Beginner English, Exam Prep"
|
||||
placeholder="e.g. Beginner English, Duolingo/IELTS"
|
||||
value={newCategoryName}
|
||||
onChange={(e) => setNewCategoryName(e.target.value)}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ export function EditPracticeFlow() {
|
|||
const programLabel = isExamPrep
|
||||
? programType === "skill"
|
||||
? "Skill-Based Courses"
|
||||
: "English Proficiency Exams"
|
||||
: "Duolingo/IELTS"
|
||||
: level
|
||||
? `Program ${level}`
|
||||
: null;
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ export function NewContentPage() {
|
|||
<CardContent className="border-t border-grayScale-200 bg-white p-8 text-center">
|
||||
<h3 className="text-xl font-bold text-grayScale-700">Courses</h3>
|
||||
<p className="mt-3 text-sm leading-relaxed text-grayScale-500">
|
||||
Manage skill-based and exam preparation courses such as Duolingo
|
||||
and IELTS.
|
||||
Manage skill-based and Duolingo/IELTS courses.
|
||||
</p>
|
||||
<Link to="/new-content/courses" className="block w-full">
|
||||
<Button className="mt-8 h-12 w-full rounded-[6px] bg-brand-500 text-base font-semibold ">
|
||||
|
|
|
|||
|
|
@ -90,9 +90,9 @@ export function ProgramDetailPage() {
|
|||
// Mock data for "proficiency" program type
|
||||
const programs: Record<string, any> = {
|
||||
proficiency: {
|
||||
title: "English Proficiency Exams",
|
||||
title: "Duolingo/IELTS",
|
||||
description:
|
||||
"Manage exam-based learning programs such as Duolingo and IELTS.",
|
||||
"Manage Duolingo/IELTS learning programs.",
|
||||
courses: [],
|
||||
},
|
||||
"skill-based": {
|
||||
|
|
@ -667,7 +667,7 @@ export function ProgramDetailPage() {
|
|||
No catalog courses yet
|
||||
</p>
|
||||
<p className="mt-1 text-sm text-grayScale-400">
|
||||
Create your first exam-prep catalog course to start organizing units, modules, and lessons.
|
||||
Create your first Duolingo/IELTS catalog course to start organizing units, modules, and lessons.
|
||||
</p>
|
||||
</div>
|
||||
) : programType === "proficiency" && filteredProficiencyCourses.length === 0 ? (
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ export function ProgramTypeSelectionPage() {
|
|||
</div>
|
||||
</Link>
|
||||
|
||||
{/* English Proficiency Exams Card */}
|
||||
{/* Duolingo/IELTS Card */}
|
||||
<Link to="/new-content/courses/proficiency" className="group h-full">
|
||||
<div className="bg-white w-[500px] rounded-[6px] border border-grayScale-100 px-10 py-12 h-full transition-all flex flex-col items-start gap-10">
|
||||
<div className="h-16 w-16 rounded-full bg-brand-50/10 flex items-center justify-center">
|
||||
|
|
@ -63,11 +63,11 @@ export function ProgramTypeSelectionPage() {
|
|||
|
||||
<div className="space-y-3 flex-1">
|
||||
<h3 className="text-[20px] font-bold text-grayScale-900 transition-colors">
|
||||
English Proficiency Exams
|
||||
Duolingo/IELTS
|
||||
</h3>
|
||||
<p className="text-[15px] leading-relaxed text-grayScale-500 font-medium">
|
||||
Exam preparation courses such as IELTS, and Duolingo. Structure
|
||||
content by band scores, sections, and mock tests.
|
||||
Duolingo/IELTS courses. Structure content by band scores,
|
||||
sections, and mock tests.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ export function ExamPrepContentHierarchyList() {
|
|||
setLessons(fetchedLessons)
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch exam prep hierarchy:", error)
|
||||
notifyApiError(error, "Failed to load exam prep content")
|
||||
notifyApiError(error, "Failed to load Duolingo/IELTS content")
|
||||
} finally {
|
||||
setLoading({})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export function AttachPracticeStep1({
|
|||
>
|
||||
<option value="">Choose Program</option>
|
||||
<option value="skill">Skill-Based Courses</option>
|
||||
<option value="exams">English Proficiency Exams</option>
|
||||
<option value="exams">Duolingo/IELTS</option>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export function ProgramAttachStep1({
|
|||
}
|
||||
>
|
||||
<option value="">Choose Program</option>
|
||||
<option value="exams">English Proficiency Exams</option>
|
||||
<option value="exams">Duolingo/IELTS</option>
|
||||
<option value="skill">Skill-Based Courses</option>
|
||||
</Select>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ export function SelectPracticeToAttachStep({
|
|||
<p className="max-w-sm text-xs text-grayScale-500">
|
||||
{unlinkedOnly
|
||||
? isExamPrep
|
||||
? "No unlinked exam-prep practices match your search. Try all practices or create a new shell first."
|
||||
? "No unlinked Duolingo/IELTS practices match your search. Try all practices or create a new shell first."
|
||||
: "No unlinked practices match your search. Try all practices or create a new shell from Question Types."
|
||||
: "Try a different search, switch to unlinked only, or create a new practice instead."}
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ export function PersonasPage() {
|
|||
<h1 className="text-2xl font-semibold tracking-tight text-grayScale-800">Personas</h1>
|
||||
<p className="mt-1 max-w-2xl text-sm text-grayScale-500">
|
||||
Manage coach and character profiles linked to practice shells in Learn English and
|
||||
exam-prep content.
|
||||
Duolingo/IELTS content.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ export function UserLearningActivitySection({
|
|||
<div>
|
||||
<CardTitle className="text-base">Learning activity</CardTitle>
|
||||
<p className="mt-0.5 text-xs text-grayScale-500">
|
||||
LMS and exam prep progress trees for this learner.
|
||||
LMS and Duolingo/IELTS progress trees for this learner.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -307,7 +307,7 @@ export function UserLearningActivitySection({
|
|||
)}
|
||||
onClick={() => setTrack("exam_prep")}
|
||||
>
|
||||
Exam prep
|
||||
Duolingo/IELTS
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -373,7 +373,7 @@ export function UserLearningActivitySection({
|
|||
{!loading && !error && activity && track === "exam_prep" ? (
|
||||
<>
|
||||
<div className="grid gap-2 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<Metric label="Exam prep courses" value={catalogCourses.length} />
|
||||
<Metric label="Duolingo/IELTS courses" value={catalogCourses.length} />
|
||||
<Metric
|
||||
label="Accessible courses"
|
||||
value={catalogCourses.filter((course) => course.access.is_accessible).length}
|
||||
|
|
@ -393,7 +393,7 @@ export function UserLearningActivitySection({
|
|||
disabled={catalogCourses.length === 0}
|
||||
>
|
||||
<option value="">
|
||||
{catalogCourses.length === 0 ? "No exam prep courses" : "Select exam prep course..."}
|
||||
{catalogCourses.length === 0 ? "No Duolingo/IELTS courses" : "Select Duolingo/IELTS course..."}
|
||||
</option>
|
||||
{catalogCourses.map((course) => (
|
||||
<option key={course.id} value={course.id}>
|
||||
|
|
@ -406,7 +406,7 @@ export function UserLearningActivitySection({
|
|||
{selectedCatalogCourse ? (
|
||||
<CourseBlock course={selectedCatalogCourse} examPrep />
|
||||
) : (
|
||||
<p className="py-6 text-center text-sm text-grayScale-400">No exam prep activity yet.</p>
|
||||
<p className="py-6 text-center text-sm text-grayScale-400">No Duolingo/IELTS activity yet.</p>
|
||||
)}
|
||||
</>
|
||||
) : null}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user