-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dashboard] Feature: RPC Chart (#5504)
CNCT-2395 <img width="1161" alt="Screenshot 2024-11-22 at 9 52 09 PM" src="https://github.com/user-attachments/assets/e46f1645-11bb-42d5-abcf-147852a3e8ce"> <!-- start pr-codex --> --- ## PR-Codex overview This PR primarily focuses on refactoring the analytics data handling by shifting the source of types from the `@/api/analytics` module to a new `types/analytics` module. This change enhances type definitions and improves code organization. ### Detailed summary - Changed import paths for various analytics types to `types/analytics`. - Added new interfaces in `apps/dashboard/src/types/analytics.ts` for `WalletStats`, `WalletUserStats`, `InAppWalletStats`, `EcosystemWalletStats`, `UserOpStats`, `RpcMethodStats`, and `AnalyticsQueryParams`. - Updated multiple components and utilities to utilize the new type definitions. - Implemented a new RPC method usage function in `apps/dashboard/src/@/api/analytics.ts`. - Added `RpcMethodBarChartCard` component to visualize RPC method usage in `apps/dashboard/src/app/team/[team_slug]/[project_slug]/page.tsx`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
1 parent
7dd4298
commit dfc824d
Showing
26 changed files
with
406 additions
and
75 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
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
2 changes: 1 addition & 1 deletion
2
apps/dashboard/src/app/team/[team_slug]/(team)/_components/TotalSponsoredCard.tsx
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
2 changes: 1 addition & 1 deletion
2
.../app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/components/Summary.tsx
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
86 changes: 86 additions & 0 deletions
86
...m_slug]/[project_slug]/components/RpcMethodBarChartCard/RpcMethodBarChartCard.stories.tsx
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,86 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { BadgeContainer, mobileViewport } from "stories/utils"; | ||
import type { RpcMethodStats } from "types/analytics"; | ||
import { RpcMethodBarChartCardUI } from "./RpcMethodBarChartCardUI"; | ||
|
||
const meta = { | ||
title: "Analytics/RpcMethodBarChartCard", | ||
component: Component, | ||
parameters: { | ||
layout: "centered", | ||
}, | ||
} satisfies Meta<typeof Component>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Desktop: Story = { | ||
parameters: { | ||
viewport: { defaultViewport: "desktop" }, | ||
}, | ||
}; | ||
|
||
export const Mobile: Story = { | ||
parameters: { | ||
viewport: mobileViewport("iphone14"), | ||
}, | ||
}; | ||
|
||
const generateTimeSeriesData = ( | ||
days: number, | ||
methods: string[], | ||
emptyData = false, | ||
) => { | ||
const data: RpcMethodStats[] = []; | ||
const today = new Date(); | ||
|
||
for (let i = days - 1; i >= 0; i--) { | ||
const date = new Date(today); | ||
date.setDate(date.getDate() - i); | ||
|
||
for (const method of methods) { | ||
data.push({ | ||
date: date.toISOString(), | ||
evmMethod: method, | ||
count: emptyData ? 0 : Math.floor(Math.random() * 1000) + 100, | ||
}); | ||
} | ||
} | ||
|
||
return data; | ||
}; | ||
|
||
const commonMethods = [ | ||
"eth_call", | ||
"eth_getBalance", | ||
"eth_getTransactionReceipt", | ||
"eth_blockNumber", | ||
]; | ||
|
||
function Component() { | ||
return ( | ||
<div className="container space-y-8 py-8"> | ||
<BadgeContainer label="Normal Usage"> | ||
<RpcMethodBarChartCardUI | ||
rawData={generateTimeSeriesData(30, commonMethods)} | ||
/> | ||
</BadgeContainer> | ||
|
||
<BadgeContainer label="Empty Data"> | ||
<RpcMethodBarChartCardUI rawData={[]} /> | ||
</BadgeContainer> | ||
|
||
<BadgeContainer label="Zero Values"> | ||
<RpcMethodBarChartCardUI | ||
rawData={generateTimeSeriesData(30, commonMethods, true)} | ||
/> | ||
</BadgeContainer> | ||
|
||
<BadgeContainer label="Single Method"> | ||
<RpcMethodBarChartCardUI | ||
rawData={generateTimeSeriesData(30, ["eth_call"])} | ||
/> | ||
</BadgeContainer> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.