-
Notifications
You must be signed in to change notification settings - Fork 559
add analytics to insight page #7488
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ import type { | |
EcosystemWalletStats, | ||
EngineCloudStats, | ||
InAppWalletStats, | ||
InsightChainStats, | ||
InsightEndpointStats, | ||
InsightStatusCodeStats, | ||
InsightUsageStats, | ||
RpcMethodStats, | ||
TransactionStats, | ||
UniversalBridgeStats, | ||
|
@@ -424,3 +428,95 @@ export async function getEngineCloudMethodUsage( | |
const json = await res.json(); | ||
return json.data as EngineCloudStats[]; | ||
} | ||
|
||
export async function getInsightChainUsage( | ||
params: AnalyticsQueryParams, | ||
): Promise<InsightChainStats[]> { | ||
const searchParams = buildSearchParams(params); | ||
const res = await fetchAnalytics( | ||
`v2/insight/usage/by-chain?${searchParams.toString()}`, | ||
{ | ||
method: "GET", | ||
}, | ||
); | ||
|
||
if (res?.status !== 200) { | ||
const reason = await res?.text(); | ||
console.error( | ||
`Failed to fetch Insight chain usage: ${res?.status} - ${res.statusText} - ${reason}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is silently failing. we won't know if there's something wrong or not in the frontend if the request is failing or just returning empty data please return |
||
); | ||
return []; | ||
} | ||
|
||
const json = await res.json(); | ||
return json.data as InsightChainStats[]; | ||
} | ||
|
||
export async function getInsightStatusCodeUsage( | ||
params: AnalyticsQueryParams, | ||
): Promise<InsightStatusCodeStats[]> { | ||
const searchParams = buildSearchParams(params); | ||
const res = await fetchAnalytics( | ||
`v2/insight/usage/by-status-code?${searchParams.toString()}`, | ||
{ | ||
method: "GET", | ||
}, | ||
); | ||
|
||
if (res?.status !== 200) { | ||
const reason = await res?.text(); | ||
console.error( | ||
`Failed to fetch Insight status code usage: ${res?.status} - ${res.statusText} - ${reason}`, | ||
); | ||
return []; | ||
} | ||
|
||
const json = await res.json(); | ||
return json.data as InsightStatusCodeStats[]; | ||
} | ||
|
||
export async function getInsightEndpointUsage( | ||
params: AnalyticsQueryParams, | ||
): Promise<InsightEndpointStats[]> { | ||
const searchParams = buildSearchParams(params); | ||
const res = await fetchAnalytics( | ||
`v2/insight/usage/by-endpoint?${searchParams.toString()}`, | ||
{ | ||
method: "GET", | ||
}, | ||
); | ||
|
||
if (res?.status !== 200) { | ||
const reason = await res?.text(); | ||
console.error( | ||
`Failed to fetch Insight endpoint usage: ${res?.status} - ${res.statusText} - ${reason}`, | ||
); | ||
return []; | ||
} | ||
|
||
const json = await res.json(); | ||
return json.data as InsightEndpointStats[]; | ||
} | ||
|
||
export async function getInsightUsage( | ||
params: AnalyticsQueryParams, | ||
): Promise<InsightUsageStats[]> { | ||
const searchParams = buildSearchParams(params); | ||
const res = await fetchAnalytics( | ||
`v2/insight/usage?${searchParams.toString()}`, | ||
{ | ||
method: "GET", | ||
}, | ||
); | ||
|
||
if (res?.status !== 200) { | ||
const reason = await res?.text(); | ||
console.error( | ||
`Failed to fetch Insight usage: ${res?.status} - ${res.statusText} - ${reason}`, | ||
); | ||
return []; | ||
} | ||
|
||
const json = await res.json(); | ||
return json.data as InsightUsageStats[]; | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: please move the types in this file next to the functions it is created for