Skip to content

Commit 748ba7d

Browse files
committed
add analytics to insight page
1 parent c2ef5eb commit 748ba7d

File tree

11 files changed

+935
-187
lines changed

11 files changed

+935
-187
lines changed

apps/dashboard/src/@/api/analytics.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import type {
66
EcosystemWalletStats,
77
EngineCloudStats,
88
InAppWalletStats,
9+
InsightChainStats,
10+
InsightEndpointStats,
11+
InsightStatusCodeStats,
12+
InsightUsageStats,
913
RpcMethodStats,
1014
TransactionStats,
1115
UniversalBridgeStats,
@@ -424,3 +428,95 @@ export async function getEngineCloudMethodUsage(
424428
const json = await res.json();
425429
return json.data as EngineCloudStats[];
426430
}
431+
432+
export async function getInsightChainUsage(
433+
params: AnalyticsQueryParams,
434+
): Promise<InsightChainStats[]> {
435+
const searchParams = buildSearchParams(params);
436+
const res = await fetchAnalytics(
437+
`v2/insight/usage/by-chain?${searchParams.toString()}`,
438+
{
439+
method: "GET",
440+
},
441+
);
442+
443+
if (res?.status !== 200) {
444+
const reason = await res?.text();
445+
console.error(
446+
`Failed to fetch Insight chain usage: ${res?.status} - ${res.statusText} - ${reason}`,
447+
);
448+
return [];
449+
}
450+
451+
const json = await res.json();
452+
return json.data as InsightChainStats[];
453+
}
454+
455+
export async function getInsightStatusCodeUsage(
456+
params: AnalyticsQueryParams,
457+
): Promise<InsightStatusCodeStats[]> {
458+
const searchParams = buildSearchParams(params);
459+
const res = await fetchAnalytics(
460+
`v2/insight/usage/by-status-code?${searchParams.toString()}`,
461+
{
462+
method: "GET",
463+
},
464+
);
465+
466+
if (res?.status !== 200) {
467+
const reason = await res?.text();
468+
console.error(
469+
`Failed to fetch Insight status code usage: ${res?.status} - ${res.statusText} - ${reason}`,
470+
);
471+
return [];
472+
}
473+
474+
const json = await res.json();
475+
return json.data as InsightStatusCodeStats[];
476+
}
477+
478+
export async function getInsightEndpointUsage(
479+
params: AnalyticsQueryParams,
480+
): Promise<InsightEndpointStats[]> {
481+
const searchParams = buildSearchParams(params);
482+
const res = await fetchAnalytics(
483+
`v2/insight/usage/by-endpoint?${searchParams.toString()}`,
484+
{
485+
method: "GET",
486+
},
487+
);
488+
489+
if (res?.status !== 200) {
490+
const reason = await res?.text();
491+
console.error(
492+
`Failed to fetch Insight endpoint usage: ${res?.status} - ${res.statusText} - ${reason}`,
493+
);
494+
return [];
495+
}
496+
497+
const json = await res.json();
498+
return json.data as InsightEndpointStats[];
499+
}
500+
501+
export async function getInsightUsage(
502+
params: AnalyticsQueryParams,
503+
): Promise<InsightUsageStats[]> {
504+
const searchParams = buildSearchParams(params);
505+
const res = await fetchAnalytics(
506+
`v2/insight/usage?${searchParams.toString()}`,
507+
{
508+
method: "GET",
509+
},
510+
);
511+
512+
if (res?.status !== 200) {
513+
const reason = await res?.text();
514+
console.error(
515+
`Failed to fetch Insight usage: ${res?.status} - ${res.statusText} - ${reason}`,
516+
);
517+
return [];
518+
}
519+
520+
const json = await res.json();
521+
return json.data as InsightUsageStats[];
522+
}

apps/dashboard/src/@/types/analytics.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,28 @@ export interface AnalyticsQueryParams {
7878
from?: Date;
7979
to?: Date;
8080
period?: "day" | "week" | "month" | "year" | "all";
81+
limit?: number;
82+
}
83+
84+
export interface InsightChainStats {
85+
date: string;
86+
chainId: string;
87+
totalRequests: number;
88+
}
89+
90+
export interface InsightStatusCodeStats {
91+
date: string;
92+
httpStatusCode: number;
93+
totalRequests: number;
94+
}
95+
96+
export interface InsightEndpointStats {
97+
date: string;
98+
endpoint: string;
99+
totalRequests: number;
100+
}
101+
102+
export interface InsightUsageStats {
103+
date: string;
104+
totalRequests: number;
81105
}

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/insight/blueprint-card.tsx

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)