@@ -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+ }
0 commit comments