-
Notifications
You must be signed in to change notification settings - Fork 913
feat: add PostHog analytics to web and marketing apps #351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
apps/admin/src/app/(dashboard)/components/ActivationFunnel/ActivationFunnel.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| "use client"; | ||
|
|
||
| import { | ||
| Card, | ||
| CardContent, | ||
| CardDescription, | ||
| CardHeader, | ||
| CardTitle, | ||
| } from "@superset/ui/card"; | ||
| import { cn } from "@superset/ui/utils"; | ||
| import { LuArrowRight, LuLoaderCircle } from "react-icons/lu"; | ||
|
|
||
| interface FunnelStep { | ||
| name: string; | ||
| count: number; | ||
| conversionRate?: number; | ||
| } | ||
|
|
||
| interface ActivationFunnelProps { | ||
| steps: FunnelStep[]; | ||
| isLoading?: boolean; | ||
| error?: string; | ||
| } | ||
|
|
||
| export function ActivationFunnel({ | ||
| steps, | ||
| isLoading, | ||
| error, | ||
| }: ActivationFunnelProps) { | ||
| if (isLoading) { | ||
| return ( | ||
| <Card> | ||
| <CardHeader> | ||
| <CardTitle>Activation Funnel</CardTitle> | ||
| <CardDescription> | ||
| Signup → Download → First Task → Completed | ||
| </CardDescription> | ||
| </CardHeader> | ||
| <CardContent className="flex items-center justify-center py-12"> | ||
| <LuLoaderCircle className="text-muted-foreground h-8 w-8 animate-spin" /> | ||
| </CardContent> | ||
| </Card> | ||
| ); | ||
| } | ||
|
|
||
| if (error) { | ||
| return ( | ||
| <Card> | ||
| <CardHeader> | ||
| <CardTitle>Activation Funnel</CardTitle> | ||
| </CardHeader> | ||
| <CardContent className="text-muted-foreground py-12 text-center"> | ||
| <p>Failed to load funnel data</p> | ||
| <p className="text-sm">{error}</p> | ||
| </CardContent> | ||
| </Card> | ||
| ); | ||
| } | ||
|
|
||
| const maxCount = Math.max(...steps.map((s) => s.count), 1); | ||
|
|
||
| return ( | ||
| <Card> | ||
| <CardHeader> | ||
| <CardTitle>Activation Funnel</CardTitle> | ||
| <CardDescription> | ||
| Track users through signup to first completed task | ||
| </CardDescription> | ||
| </CardHeader> | ||
| <CardContent> | ||
| <div className="flex items-end justify-between gap-2"> | ||
| {steps.map((step, index) => ( | ||
| <div key={step.name} className="flex flex-1 items-center gap-2"> | ||
| <div className="flex flex-1 flex-col items-center"> | ||
| <div | ||
| className="bg-primary/20 mb-2 w-full rounded-t-md transition-all" | ||
| style={{ | ||
| height: `${Math.max((step.count / maxCount) * 120, 20)}px`, | ||
| }} | ||
| > | ||
| <div | ||
| className="bg-primary h-full w-full rounded-t-md" | ||
| style={{ | ||
| opacity: 1 - index * 0.15, | ||
| }} | ||
| /> | ||
| </div> | ||
| <div className="text-center"> | ||
| <div className="text-2xl font-bold"> | ||
| {step.count.toLocaleString()} | ||
| </div> | ||
| <div className="text-muted-foreground text-xs"> | ||
| {step.name} | ||
| </div> | ||
| {step.conversionRate !== undefined && index > 0 && ( | ||
| <div | ||
| className={cn( | ||
| "mt-1 text-xs font-medium", | ||
| step.conversionRate >= 50 | ||
| ? "text-green-600" | ||
| : step.conversionRate >= 25 | ||
| ? "text-yellow-600" | ||
| : "text-red-600", | ||
| )} | ||
| > | ||
| {step.conversionRate.toFixed(0)}% | ||
| </div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| {index < steps.length - 1 && ( | ||
| <LuArrowRight className="text-muted-foreground h-4 w-4 shrink-0" /> | ||
| )} | ||
| </div> | ||
| ))} | ||
| </div> | ||
| </CardContent> | ||
| </Card> | ||
| ); | ||
| } |
1 change: 1 addition & 0 deletions
1
apps/admin/src/app/(dashboard)/components/ActivationFunnel/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { ActivationFunnel } from "./ActivationFunnel"; |
77 changes: 77 additions & 0 deletions
77
apps/admin/src/app/(dashboard)/components/StatsCard/StatsCard.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| "use client"; | ||
|
|
||
| import { Card, CardContent, CardHeader, CardTitle } from "@superset/ui/card"; | ||
| import { cn } from "@superset/ui/utils"; | ||
| import { LuArrowDown, LuArrowUp, LuMinus } from "react-icons/lu"; | ||
|
|
||
| interface StatsCardProps { | ||
| title: string; | ||
| value: number | string; | ||
| description?: string; | ||
| trend?: { | ||
| value: number; | ||
| label: string; | ||
| }; | ||
| isLoading?: boolean; | ||
| } | ||
|
|
||
| export function StatsCard({ | ||
| title, | ||
| value, | ||
| description, | ||
| trend, | ||
| isLoading, | ||
| }: StatsCardProps) { | ||
| const trendDirection = | ||
| trend && trend.value > 0 | ||
| ? "up" | ||
| : trend && trend.value < 0 | ||
| ? "down" | ||
| : "neutral"; | ||
|
|
||
| return ( | ||
| <Card> | ||
| <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> | ||
| <CardTitle className="text-sm font-medium">{title}</CardTitle> | ||
| </CardHeader> | ||
| <CardContent> | ||
| {isLoading ? ( | ||
| <div className="space-y-2"> | ||
| <div className="bg-muted h-8 w-24 animate-pulse rounded" /> | ||
| <div className="bg-muted h-4 w-32 animate-pulse rounded" /> | ||
| </div> | ||
| ) : ( | ||
| <> | ||
| <div className="text-3xl font-bold">{value}</div> | ||
| {(trend || description) && ( | ||
| <div className="text-muted-foreground mt-1 flex items-center gap-1 text-xs"> | ||
| {trend && ( | ||
| <span | ||
| className={cn( | ||
| "flex items-center gap-0.5 font-medium", | ||
| trendDirection === "up" && "text-green-600", | ||
| trendDirection === "down" && "text-red-600", | ||
| )} | ||
| > | ||
| {trendDirection === "up" && ( | ||
| <LuArrowUp className="h-3 w-3" /> | ||
| )} | ||
| {trendDirection === "down" && ( | ||
| <LuArrowDown className="h-3 w-3" /> | ||
| )} | ||
| {trendDirection === "neutral" && ( | ||
| <LuMinus className="h-3 w-3" /> | ||
| )} | ||
| {Math.abs(trend.value)}% | ||
| </span> | ||
| )} | ||
| {trend && <span>{trend.label}</span>} | ||
| {!trend && description && <span>{description}</span>} | ||
| </div> | ||
| )} | ||
| </> | ||
| )} | ||
| </CardContent> | ||
| </Card> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { StatsCard } from "./StatsCard"; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.