-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
234 additions
and
97 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
service_account.json | ||
*.db | ||
.vscode | ||
*.log |
This file contains 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { NextRequest } from "next/server" | ||
|
||
import { fetchData, getRangeKey } from "../utils" | ||
import { getUserActivity } from "./getUserActivity" | ||
import { getUserActivityStats } from "./getUserActivity" | ||
|
||
export const GET = (request: NextRequest) => { | ||
const profileId = request.nextUrl.searchParams.get("profile_id") || null | ||
return fetchData(getUserActivity, getRangeKey(request), profileId) | ||
return fetchData(getUserActivityStats, getRangeKey(request), profileId) | ||
} |
This file contains 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 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
Binary file not shown.
This file contains 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,39 @@ | ||
"use client" | ||
|
||
import { useState } from "react" | ||
import { BarChart } from "@tremor/react" | ||
|
||
import { ChartCard } from "./chart-card" | ||
|
||
interface ActiveUserStatsProps { | ||
className?: string | ||
title: string | ||
allStats: any | ||
} | ||
|
||
export default function ActiveUserStats({ | ||
className, | ||
title, | ||
allStats, | ||
}: ActiveUserStatsProps) { | ||
const [range, setRange] = useState("ALL") | ||
const data = allStats[range] | ||
|
||
return ( | ||
<ChartCard | ||
chartTitle={title} | ||
range={range} | ||
setRange={setRange} | ||
className={className} | ||
> | ||
<BarChart | ||
data={data?.stats} | ||
index="time" | ||
categories={data?.apps} | ||
// showAnimation | ||
showGridLines={false} | ||
stack | ||
/> | ||
</ChartCard> | ||
) | ||
} |
This file contains 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,37 @@ | ||
"use client" | ||
|
||
import { useState } from "react" | ||
import { BarChart } from "@tremor/react" | ||
|
||
import { ChartCard } from "./chart-card" | ||
|
||
interface UserActivityProps { | ||
className?: string | ||
allStats: any | ||
} | ||
|
||
export default function AllUserActivityStats({ | ||
className, | ||
allStats, | ||
}: UserActivityProps) { | ||
const [range, setRange] = useState("ALL") | ||
const data = allStats[range] | ||
|
||
return ( | ||
<ChartCard | ||
chartTitle="Users Activity" | ||
range={range} | ||
setRange={setRange} | ||
className={className} | ||
> | ||
<BarChart | ||
data={data} | ||
index="day" | ||
categories={["posts", "comments", "mirrors", "upvotes", "downvotes"]} | ||
// showAnimation | ||
showGridLines={false} | ||
stack | ||
/> | ||
</ChartCard> | ||
) | ||
} |
This file contains 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,17 @@ | ||
import { getAllUserActivity } from "@/app/api/analystics/user-activity/getUserActivity" | ||
|
||
import AllUserActivityStats from "./all-user-activity-stats" | ||
|
||
interface UserActivityProps { | ||
className?: string | ||
} | ||
|
||
export const revalidate = 60 * 60 * 5 | ||
|
||
export default async function AllUserActivity({ | ||
className, | ||
}: UserActivityProps) { | ||
const data = await getAllUserActivity() | ||
|
||
return <AllUserActivityStats allStats={data} className={className} /> | ||
} |
This file contains 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 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 |
---|---|---|
@@ -1,40 +1,21 @@ | ||
"use client" | ||
import { getAllAppUserStats } from "@/app/api/analystics/active-users/getActiveUserStats" | ||
|
||
import { useState } from "react" | ||
import { BarChart } from "@tremor/react" | ||
import useSWR from "swr" | ||
import ActiveUserStats from "./active-user-stats" | ||
|
||
import fetcher from "@/lib/fetcher" | ||
|
||
import { ChartCard } from "./chart-card" | ||
|
||
interface UserActivityProps { | ||
profileId?: string | null | ||
interface DAUStaticProps { | ||
className?: string | ||
} | ||
|
||
export default function DAU({ className }: UserActivityProps) { | ||
const [range, setRange] = useState("ALL") | ||
const queryString = `/api/analystics/active-users?range=${range}&statType=DAU` | ||
const { data, error } = useSWR(queryString, fetcher) | ||
export const revalidate = 60 * 60 * 5 | ||
|
||
console.log("data", data) | ||
export default async function DAU({ className }: DAUStaticProps) { | ||
const allStats = await getAllAppUserStats("DAU") | ||
|
||
return ( | ||
<ChartCard | ||
chartTitle="Daily Active Users" | ||
range={range} | ||
setRange={setRange} | ||
<ActiveUserStats | ||
title="Daily Active Users" | ||
allStats={allStats} | ||
className={className} | ||
> | ||
<BarChart | ||
data={data?.stats} | ||
index="time" | ||
categories={data?.apps} | ||
// showAnimation | ||
showGridLines={false} | ||
stack | ||
/> | ||
</ChartCard> | ||
/> | ||
) | ||
} |
This file contains 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,22 @@ | ||
"use client" | ||
|
||
import { useState } from "react" | ||
import { BarChart } from "@tremor/react" | ||
|
||
import { ChartCard } from "./chart-card" | ||
|
||
export default function HashTagsStats({ allStats }: any) { | ||
const [range, setRange] = useState("ALL") | ||
const data = allStats[range] | ||
|
||
return ( | ||
<ChartCard chartTitle="Popular Hashtags" range={range} setRange={setRange}> | ||
<BarChart | ||
data={data} | ||
index="hashtag" | ||
categories={["count"]} | ||
showAnimation | ||
/> | ||
</ChartCard> | ||
) | ||
} |
This file contains 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 |
---|---|---|
@@ -1,28 +1,11 @@ | ||
"use client" | ||
import { getAllPopularHashtags } from "@/app/api/analystics/popular-hashtags/getPopularHashtags" | ||
|
||
import { useState } from "react" | ||
import { BarChart } from "@tremor/react" | ||
import useSWR from "swr" | ||
import HashTagsStats from "./hashtags-stats" | ||
|
||
import fetcher from "@/lib/fetcher" | ||
export const revalidate = 60 * 60 * 5 | ||
|
||
import { ChartCard } from "./chart-card" | ||
export default async function HashTags() { | ||
const allStats = await getAllPopularHashtags() | ||
|
||
export default function HashTags() { | ||
const [range, setRange] = useState("ALL") | ||
const { data, error } = useSWR( | ||
`/api/analystics/popular-hashtags?range=${range}`, | ||
fetcher | ||
) | ||
|
||
return ( | ||
<ChartCard chartTitle="Popular Hashtags" range={range} setRange={setRange}> | ||
<BarChart | ||
data={data} | ||
index="hashtag" | ||
categories={["count"]} | ||
showAnimation | ||
/> | ||
</ChartCard> | ||
) | ||
return <HashTagsStats allStats={allStats} /> | ||
} |
Oops, something went wrong.