-
Notifications
You must be signed in to change notification settings - Fork 636
2025 wrapped #8598
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
Open
Yash094
wants to merge
2
commits into
main
Choose a base branch
from
yash/2025-wrapped
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
2025 wrapped #8598
Changes from 1 commit
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| import "server-only"; | ||
| import { | ||
| getAggregateUserOpUsage, | ||
| getEOAAndInAppWalletConnections, | ||
| getRpcUsageByType, | ||
| } from "@/api/analytics"; | ||
|
|
||
| export type YearInReviewStats = { | ||
| totalRpcRequests: number; | ||
| totalWalletConnections: number; | ||
| totalMainnetSponsoredTransactions: number; | ||
| year: number; | ||
| }; | ||
|
|
||
| /** | ||
| * Get year-in-review statistics for the current user across all their teams | ||
| * Hardcoded to 2025 (Jan 1, 2025 - Dec 31, 2025) | ||
| */ | ||
| export async function getYearInReview( | ||
| authToken: string, | ||
| teamIds: string[], | ||
| ): Promise<YearInReviewStats> { | ||
| const year = 2025; | ||
|
|
||
| if (!authToken || teamIds.length === 0) { | ||
| return { | ||
| totalRpcRequests: 0, | ||
| totalWalletConnections: 0, | ||
| totalMainnetSponsoredTransactions: 0, | ||
| year, | ||
| }; | ||
| } | ||
|
|
||
| // Hardcoded to 2025: Jan 1, 2025 - Dec 31, 2025 | ||
| const yearStart = new Date(2025, 0, 1); | ||
| const yearEnd = new Date(2025, 11, 31, 23, 59, 59, 999); | ||
|
|
||
| // Fetch all data in parallel across all teams | ||
| const [rpcRequests, walletConnections, sponsoredTxs] = await Promise.all([ | ||
| // Get total RPC requests across all teams | ||
| getTotalRpcRequests(teamIds, authToken, yearStart, yearEnd), | ||
| // Get total wallet connections across all teams | ||
| getTotalWalletConnections(teamIds, authToken, yearStart, yearEnd), | ||
| // Get total mainnet sponsored transactions across all teams | ||
| getTotalMainnetSponsoredTransactions( | ||
| teamIds, | ||
| authToken, | ||
| yearStart, | ||
| yearEnd, | ||
| ), | ||
| ]); | ||
|
|
||
| return { | ||
| totalRpcRequests: rpcRequests, | ||
| totalWalletConnections: walletConnections, | ||
| totalMainnetSponsoredTransactions: sponsoredTxs, | ||
| year, | ||
| }; | ||
| } | ||
|
|
||
| async function getTotalRpcRequests( | ||
| teamIds: string[], | ||
| authToken: string, | ||
| from: Date, | ||
| to: Date, | ||
| ): Promise<number> { | ||
| try { | ||
| // Aggregate RPC requests across all teams using the same API as analytics | ||
| const requests = await Promise.all( | ||
| teamIds.map(async (teamId) => { | ||
| try { | ||
| // Use getRpcUsageByType without projectId to get team-level data | ||
| // This matches the format used in the analytics pages | ||
| const usageData = await getRpcUsageByType( | ||
| { | ||
| teamId, | ||
| from, | ||
| to, | ||
| period: "all", | ||
| }, | ||
| authToken, | ||
| ); | ||
|
|
||
| // Sum up all counts from the usage data | ||
| return usageData.reduce((sum, item) => sum + (item.count || 0), 0); | ||
| } catch (error) { | ||
| console.error(`Failed to fetch RPC usage for team ${teamId}:`, error); | ||
| return 0; | ||
| } | ||
| }), | ||
| ); | ||
|
|
||
| return requests.reduce((sum, count) => sum + count, 0); | ||
| } catch (error) { | ||
| console.error("Failed to fetch RPC requests:", error); | ||
| return 0; | ||
| } | ||
| } | ||
|
|
||
| async function getTotalWalletConnections( | ||
| teamIds: string[], | ||
| authToken: string, | ||
| from: Date, | ||
| to: Date, | ||
| ): Promise<number> { | ||
| try { | ||
| // Aggregate wallet connections across all teams | ||
| const connections = await Promise.all( | ||
| teamIds.map(async (teamId) => { | ||
| const walletStats = await getEOAAndInAppWalletConnections( | ||
| { | ||
| teamId, | ||
| from, | ||
| to, | ||
| period: "all", | ||
| }, | ||
| authToken, | ||
| ); | ||
|
|
||
| // Sum unique wallets connected (for "onboarded users" metric) | ||
| // Note: With period: "all", this should be a single aggregated stat, | ||
| // but we sum in case there are multiple stats (e.g., by wallet type) | ||
| return walletStats.reduce( | ||
| (sum, stat) => sum + (stat.uniqueWalletsConnected || 0), | ||
| 0, | ||
| ); | ||
| }), | ||
| ); | ||
|
|
||
| return connections.reduce((sum, count) => sum + count, 0); | ||
| } catch (error) { | ||
| console.error("Failed to fetch wallet connections:", error); | ||
| return 0; | ||
| } | ||
| } | ||
|
|
||
| async function getTotalMainnetSponsoredTransactions( | ||
| teamIds: string[], | ||
| authToken: string, | ||
| from: Date, | ||
| to: Date, | ||
| ): Promise<number> { | ||
| try { | ||
| // Aggregate mainnet sponsored transactions across all teams | ||
| // getAggregateUserOpUsage filters out testnets automatically | ||
| const transactions = await Promise.all( | ||
| teamIds.map(async (teamId) => { | ||
| const aggregateStats = await getAggregateUserOpUsage( | ||
| { | ||
| teamId, | ||
| from, | ||
| to, | ||
| }, | ||
| authToken, | ||
| ); | ||
|
|
||
| return aggregateStats.successful || 0; | ||
| }), | ||
| ); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return transactions.reduce((sum, count) => sum + count, 0); | ||
| } catch (error) { | ||
| console.error("Failed to fetch mainnet sponsored transactions:", error); | ||
| return 0; | ||
| } | ||
| } | ||
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
28 changes: 28 additions & 0 deletions
28
apps/dashboard/src/app/(app)/account/components/RewindBadge.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,28 @@ | ||
| "use client"; | ||
|
|
||
| import { ChevronsLeftIcon } from "lucide-react"; | ||
| import { useState } from "react"; | ||
| import { cn } from "@/lib/utils"; | ||
| import { RewindModal } from "../rewind/RewindModal"; | ||
|
|
||
| export function RewindBadge({ className }: { className?: string }) { | ||
| const [open, setOpen] = useState(false); | ||
| const year = 2025; // Hardcoded to 2025 | ||
|
|
||
| return ( | ||
| <> | ||
| <button | ||
| type="button" | ||
| onClick={() => setOpen(true)} | ||
| className={cn( | ||
| "inline-flex items-center gap-1.5 rounded-md bg-gradient-to-r from-blue-500 to-purple-500 px-2.5 py-1 text-xs font-semibold text-white transition-opacity hover:opacity-90", | ||
| className, | ||
| )} | ||
| > | ||
| <ChevronsLeftIcon className="h-3 w-3" /> | ||
| <span>{year.toString().slice(-2)}</span> | ||
| </button> | ||
| <RewindModal open={open} onOpenChange={setOpen} /> | ||
| </> | ||
| ); | ||
| } |
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
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.