-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TOOL-3007] Dashboard: Replace chainsaw with insight (#5926)
<!-- start pr-codex --> ## PR-Codex overview This PR focuses on enhancing the analytics functionality within the `dashboard` application by introducing new utility functions, updating existing API calls, and improving the data handling for contract analytics. ### Detailed summary - Added export of `toEventSelector` from `thirdweb/utils`. - Introduced `INSIGHT_SERVICE_API_KEY` in environment constants. - Modified `ContractAnalyticsPageClient` to accept new props for function and event selectors. - Created new analytics functions for total contract events, unique wallets, and transactions. - Updated `isAnalyticsSupportedForChain` to use `INSIGHT_SERVICE_API_KEY`. - Refactored analytics components to use new hooks for contract events and functions. - Improved data fetching and error handling in analytics hooks. - Enhanced UI components for displaying analytics data with loading states. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
Showing
22 changed files
with
1,050 additions
and
655 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"thirdweb": patch | ||
--- | ||
|
||
Export `toEventSelector` utility function from "thirdweb/utils" |
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
28 changes: 13 additions & 15 deletions
28
...p/(dashboard)/(chain)/[chain_id]/[contractAddress]/_utils/isAnalyticsSupportedForChain.ts
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,35 +1,33 @@ | ||
import { isProd } from "@/constants/env"; | ||
import { INSIGHT_SERVICE_API_KEY } from "@/constants/env"; | ||
import { getVercelEnv } from "lib/vercel-utils"; | ||
|
||
const thirdwebDomain = | ||
getVercelEnv() !== "production" ? "thirdweb-dev" : "thirdweb"; | ||
|
||
export async function isAnalyticsSupportedForChain( | ||
chainId: number, | ||
): Promise<boolean> { | ||
try { | ||
if (!process.env.CHAINSAW_API_KEY) { | ||
throw new Error("Missing CHAINSAW_API_KEY env var"); | ||
} | ||
|
||
const res = await fetch( | ||
`https://chainsaw.${isProd ? "thirdweb" : "thirdweb-dev"}.com/service/chains/${chainId}`, | ||
`https://insight.${thirdwebDomain}.com/service/chains/${chainId}`, | ||
{ | ||
method: "GET", | ||
headers: { | ||
"content-type": "application/json", | ||
// pass the shared secret | ||
"x-service-api-key": process.env.CHAINSAW_API_KEY || "", | ||
// service api key required - because this is endpoint is internal | ||
"x-service-api-key": INSIGHT_SERVICE_API_KEY, | ||
}, | ||
}, | ||
); | ||
|
||
if (!res.ok) { | ||
// assume not supported if we get a non-200 response | ||
return false; | ||
} | ||
|
||
const { data } = await res.json(); | ||
return data; | ||
const json = (await res.json()) as { data: boolean }; | ||
|
||
return json.data; | ||
} catch (e) { | ||
console.error("Error checking if analytics is supported for chain", e); | ||
console.error(`Error checking analytics support for chain ${chainId}`); | ||
console.error(e); | ||
} | ||
|
||
return false; | ||
} |
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
Oops, something went wrong.