From 8a47fea491232e524b1de780c12c0d00e0f02bcd Mon Sep 17 00:00:00 2001 From: Suchith J N <41095737+su225@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:39:02 +0100 Subject: [PATCH] feat: Aggregate stats reports - request and response objects (#1614) Corresponding backend PR: https://github.com/GetStream/chat/pull/7583 - [x] Move manually created interfaces to shims.ts - [x] Create `queryAggregateCallStats` method for the client --------- Co-authored-by: Oliver Lazoroski --- packages/client/src/StreamVideoClient.ts | 17 + packages/client/src/gen/coordinator/index.ts | 351 ++++++++++++++++++- packages/client/src/gen/shims.ts | 40 +++ 3 files changed, 407 insertions(+), 1 deletion(-) diff --git a/packages/client/src/StreamVideoClient.ts b/packages/client/src/StreamVideoClient.ts index 6eb29840f5..5fd02b2473 100644 --- a/packages/client/src/StreamVideoClient.ts +++ b/packages/client/src/StreamVideoClient.ts @@ -11,6 +11,8 @@ import type { CreateGuestResponse, GetEdgesResponse, ListDevicesResponse, + QueryAggregateCallStatsRequest, + QueryAggregateCallStatsResponse, QueryCallsRequest, QueryCallsResponse, QueryCallStatsRequest, @@ -439,6 +441,21 @@ export class StreamVideoClient { >(`/call/stats`, data); }; + /** + * Retrieve the list of available reports aggregated from the call stats. + * + * @param data Specify filter conditions like from and to (within last 30 days) and the report types + * @returns Requested reports with (mostly) raw daily data for each report type requested + */ + queryAggregateCallStats = async ( + data: QueryAggregateCallStatsRequest = {}, + ) => { + return this.streamClient.post< + QueryAggregateCallStatsResponse, + QueryAggregateCallStatsRequest + >(`/stats`, data); + }; + /** * Returns a list of available data centers available for hosting calls. */ diff --git a/packages/client/src/gen/coordinator/index.ts b/packages/client/src/gen/coordinator/index.ts index db4af83134..64288fbfa6 100644 --- a/packages/client/src/gen/coordinator/index.ts +++ b/packages/client/src/gen/coordinator/index.ts @@ -1,5 +1,8 @@ /* tslint:disable */ /* eslint-disable */ + +import type { Bound, DailyAggregateCallStatsResponse } from '../shims'; + /** * * @export @@ -490,6 +493,32 @@ export interface CallDeletedEvent { */ type: string; } +/** + * + * @export + * @interface CallDurationReportResponse + */ +export interface CallDurationReportResponse { + /** + * + * @type {Array>} + * @memberof CallDurationReportResponse + */ + daily: Array>; +} +/** + * + * @export + * @interface CallDurationReport + */ +export interface CallDurationReport { + /** + * + * @type {Array} + * @memberof CallDurationReport + */ + histogram: Array; +} /** * This event is sent when a call is mark as ended for all its participants. Clients receiving this event should leave the call screen * @export @@ -978,6 +1007,32 @@ export interface CallParticipantResponse { */ user_session_id: string; } +/** + * + * @export + * @interface CallParticipantCountReportResponse + */ +export interface CallParticipantCountReportResponse { + /** + * + * @type {Array>} + * @memberof CallParticipantCountReportResponse + */ + daily: Array>; +} +/** + * + * @export + * @interface CallParticipantCountReport + */ +export interface CallParticipantCountReport { + /** + * + * @type {Array} + * @memberof CallParticipantCountReport + */ + histogram: Array; +} /** * This event is sent when a reaction is sent in a call, clients should use this to show the reaction in the call screen * @export @@ -1837,6 +1892,32 @@ export interface CallSettingsResponse { */ video: VideoSettingsResponse; } +/** + * + * @export + * @interface CallsPerDayReportResponse + */ +export interface CallsPerDayReportResponse { + /** + * + * @type {Array>} + * @memberof CallsPerDayReportResponse + */ + daily: Array>; +} +/** + * + * @export + * @interface CallsPerDayReport + */ +export interface CallsPerDayReport { + /** + * + * @type {number} + * @memberof CallsPerDayReport + */ + count: number; +} /** * * @export @@ -3424,6 +3505,12 @@ export interface GetCallResponse { * @interface GetCallStatsResponse */ export interface GetCallStatsResponse { + /** + * + * @type {number} + * @memberof GetCallStatsResponse + */ + average_connection_time?: number; /** * * @type {number} @@ -4217,6 +4304,37 @@ export interface MuteUsersResponse { */ duration: string; } +/** + * + * @export + * @interface NetworkMetricsReportResponse + */ +export interface NetworkMetricsReportResponse { + /** + * + * @type {number} + * @memberof NetworkMetricsReportResponse + */ + average_connection_time?: number; + /** + * + * @type {number} + * @memberof NetworkMetricsReportResponse + */ + average_jitter?: number; + /** + * + * @type {number} + * @memberof NetworkMetricsReportResponse + */ + average_latency?: number; + /** + * + * @type {number} + * @memberof NetworkMetricsReportResponse + */ + average_time_to_reconnect?: number; +} /** * * @export @@ -4667,6 +4785,25 @@ export interface PermissionRequestEvent { */ user: UserResponse; } +/** + * + * @export + * @interface PerSDKUsageReport + */ +export interface PerSDKUsageReport { + /** + * + * @type {{ [key: string]: number; }} + * @memberof PerSDKUsageReport + */ + by_version: { [key: string]: number }; + /** + * + * @type {number} + * @memberof PerSDKUsageReport + */ + total: number; +} /** * * @export @@ -4820,7 +4957,112 @@ export interface PushNotificationSettingsResponse { */ disabled_until?: string; } - +/** + * + * @export + * @interface QualityScoreReportResponse + */ +export interface QualityScoreReportResponse { + /** + * + * @type {Array>} + * @memberof QualityScoreReportResponse + */ + daily: Array>; +} +/** + * + * @export + * @interface QualityScoreReport + */ +export interface QualityScoreReport { + /** + * + * @type {Array} + * @memberof QualityScoreReport + */ + histogram: Array; +} +/** + * + * @export + * @interface QueryAggregateCallStatsRequest + */ +export interface QueryAggregateCallStatsRequest { + /** + * + * @type {string} + * @memberof QueryAggregateCallStatsRequest + */ + from?: string; + /** + * + * @type {Array} + * @memberof QueryAggregateCallStatsRequest + */ + report_types?: Array; + /** + * + * @type {string} + * @memberof QueryAggregateCallStatsRequest + */ + to?: string; +} +/** + * Basic response information + * @export + * @interface QueryAggregateCallStatsResponse + */ +export interface QueryAggregateCallStatsResponse { + /** + * + * @type {CallDurationReportResponse} + * @memberof QueryAggregateCallStatsResponse + */ + call_duration_report?: CallDurationReportResponse; + /** + * + * @type {CallParticipantCountReportResponse} + * @memberof QueryAggregateCallStatsResponse + */ + call_participant_count_report?: CallParticipantCountReportResponse; + /** + * + * @type {CallsPerDayReportResponse} + * @memberof QueryAggregateCallStatsResponse + */ + calls_per_day_report?: CallsPerDayReportResponse; + /** + * Duration of the request in milliseconds + * @type {string} + * @memberof QueryAggregateCallStatsResponse + */ + duration: string; + /** + * + * @type {NetworkMetricsReportResponse} + * @memberof QueryAggregateCallStatsResponse + */ + network_metrics_report?: NetworkMetricsReportResponse; + /** + * + * @type {QualityScoreReportResponse} + * @memberof QueryAggregateCallStatsResponse + */ + quality_score_report?: QualityScoreReportResponse; + /** + * + * @type {SDKUsageReportResponse} + * @memberof QueryAggregateCallStatsResponse + */ + sdk_usage_report?: SDKUsageReportResponse; + /** + * + * @type {UserFeedbackReportResponse} + * @memberof QueryAggregateCallStatsResponse + */ + user_feedback_report?: UserFeedbackReportResponse; +} /** * * @export @@ -5206,6 +5448,49 @@ export interface RejectCallResponse { */ duration: string; } +/** + * + * @export + * @interface ReportByHistogramBucket + */ +export interface ReportByHistogramBucket { + /** + * + * @type {string} + * @memberof ReportByHistogramBucket + */ + category: string; + /** + * + * @type {number} + * @memberof ReportByHistogramBucket + */ + count: number; + /** + * + * @type {Bound} + * @memberof ReportByHistogramBucket + */ + lower_bound?: Bound; + /** + * + * @type {number} + * @memberof ReportByHistogramBucket + */ + mean: number; + /** + * + * @type {number} + * @memberof ReportByHistogramBucket + */ + sum: number; + /** + * + * @type {Bound} + * @memberof ReportByHistogramBucket + */ + upper_bound?: Bound; +} /** * * @export @@ -5401,6 +5686,32 @@ export interface ScreensharingSettingsResponse { */ target_resolution?: TargetResolution; } +/** + * + * @export + * @interface SDKUsageReportResponse + */ +export interface SDKUsageReportResponse { + /** + * + * @type {Array>} + * @memberof SDKUsageReportResponse + */ + daily: Array>; +} +/** + * + * @export + * @interface SDKUsageReport + */ +export interface SDKUsageReport { + /** + * + * @type {{ [key: string]: PerSDKUsageReport; }} + * @memberof SDKUsageReport + */ + per_sdk_usage: { [key: string]: PerSDKUsageReport }; +} /** * * @export @@ -6270,6 +6581,38 @@ export interface UserDeletedEvent { */ user?: UserObject; } +/** + * + * @export + * @interface UserFeedbackReportResponse + */ +export interface UserFeedbackReportResponse { + /** + * + * @type {Array>} + * @memberof UserFeedbackReportResponse + */ + daily: Array>; +} +/** + * + * @export + * @interface UserFeedbackReport + */ +export interface UserFeedbackReport { + /** + * + * @type {{ [key: string]: number; }} + * @memberof UserFeedbackReport + */ + count_by_rating: { [key: string]: number }; + /** + * + * @type {number} + * @memberof UserFeedbackReport + */ + unreported_count: number; +} /** * * @export @@ -6736,6 +7079,12 @@ export interface UserResponse { * @interface UserSessionStats */ export interface UserSessionStats { + /** + * + * @type {number} + * @memberof UserSessionStats + */ + average_connection_time?: number; /** * * @type {string} diff --git a/packages/client/src/gen/shims.ts b/packages/client/src/gen/shims.ts index 39b0a86e74..0917f30757 100644 --- a/packages/client/src/gen/shims.ts +++ b/packages/client/src/gen/shims.ts @@ -2,3 +2,43 @@ import type { TargetResolution } from './coordinator'; export type TargetResolutionRequest = TargetResolution; export type TargetResolutionResponse = Required; + +/** + * + * @export + * @interface Bound + */ +export interface Bound { + /** + * + * @type {boolean} + * @memberof Bound + */ + inclusive: boolean; + /** + * + * @type {number} + * @memberof Bound + */ + value: number; +} + +/** + * + * @export + * @interface DailyAggregateCallStatsResponse + */ +export interface DailyAggregateCallStatsResponse { + /** + * + * @type {string} + * @memberof DailyAggregateCallStatsResponse + */ + date: string; + /** + * + * @type {T} + * @memberof DailyAggregateCallStatsResponse + */ + report: T; +}