diff --git a/__tests__/call.test.ts b/__tests__/call.test.ts index 7a5fc26..9d7593f 100644 --- a/__tests__/call.test.ts +++ b/__tests__/call.test.ts @@ -144,6 +144,20 @@ describe('call API', () => { expect(response.calls).toBeDefined(); }); + it('query call stats', async () => { + const response = await client.video.queryCallStatistics(); + + expect(response.reports.length).toBeGreaterThan(0); + + await expect(() => + call.getSessionStatistics({ + session: '', + }), + ).rejects.toThrowError( + `Stream error code 16: GetCallStats failed with error: "call report not found for cid:default:${callId} session_id:"`, + ); + }); + describe('recording', () => { it('enable call recording', async () => { let response = await call.update({ diff --git a/src/StreamCall.ts b/src/StreamCall.ts index 96ec52f..8bcbbde 100644 --- a/src/StreamCall.ts +++ b/src/StreamCall.ts @@ -3,6 +3,7 @@ import { DeleteRecordingRequest, DeleteTranscriptionRequest, GetCallRequest, + GetCallStatsRequest, ProductvideoApi, VideoBlockUserRequest, VideoGetOrCreateCallRequest, @@ -57,6 +58,10 @@ export class StreamCall { }); }; + getSessionStatistics = (request: OmitTypeId) => { + return this.apiClient.getCallStats({ ...this.baseRequest, ...request }); + }; + create = (getOrCreateCallRequest?: VideoGetOrCreateCallRequest) => { return this.getOrCreate(getOrCreateCallRequest); }; diff --git a/src/StreamVideoClient.ts b/src/StreamVideoClient.ts index 1215eb5..1e19c5d 100644 --- a/src/StreamVideoClient.ts +++ b/src/StreamVideoClient.ts @@ -8,6 +8,7 @@ import { ProductvideoApi, VideoCreateCallTypeRequest, VideoCreateExternalStorageRequest, + VideoQueryCallStatsRequest, VideoQueryCallsRequest, VideoUpdateCallTypeRequest, VideoUpdateExternalStorageRequest, @@ -31,6 +32,14 @@ export class StreamVideoClient { }); }; + queryCallStatistics = ( + videoQueryCallStatsRequest?: VideoQueryCallStatsRequest, + ) => { + return this.apiClient.queryCallStats({ + videoQueryCallStatsRequest: videoQueryCallStatsRequest ?? {}, + }); + }; + createCallType = (videoCreateCallTypeRequest: VideoCreateCallTypeRequest) => { return this.apiClient.createCallType({ videoCreateCallTypeRequest,