Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 40 additions & 3 deletions packages/client/src/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import type {
EndCallResponse,
GetCallReportResponse,
GetCallResponse,
GetCallSessionParticipantStatsDetailsResponse,
GetOrCreateCallRequest,
GetOrCreateCallResponse,
GoLiveRequest,
Expand All @@ -55,6 +56,8 @@ import type {
PinResponse,
QueryCallMembersRequest,
QueryCallMembersResponse,
QueryCallSessionParticipantStatsResponse,
QueryCallSessionParticipantStatsTimelineResponse,
RejectCallRequest,
RejectCallResponse,
RequestPermissionRequest,
Expand Down Expand Up @@ -2238,13 +2241,10 @@ export class Call {

/**
* Allows you to grant or revoke a specific permission to a user in a call. The permissions are specific to the call experience and do not survive the call itself.
*
* When revoking a permission, this endpoint will also mute the relevant track from the user. This is similar to muting a user with the difference that the user will not be able to unmute afterwards.
*
* Supported permissions that can be granted or revoked: `send-audio`, `send-video` and `screenshare`.
*
* `call.permissions_updated` event is sent to all members of the call.
*
*/
updateUserPermissions = async (data: UpdateUserPermissionsRequest) => {
return this.streamClient.post<
Expand Down Expand Up @@ -2561,6 +2561,43 @@ export class Call {
return this.streamClient.get<GetCallReportResponse>(endpoint, params);
};

/**
* Loads the call participant stats for the given parameters.
*/
getCallParticipantsStats = async (opts: {
sessionId?: string;
userId?: string;
userSessionId?: string;
kind?: 'timeline' | 'details';
}): Promise<
| QueryCallSessionParticipantStatsResponse
| GetCallSessionParticipantStatsDetailsResponse
| QueryCallSessionParticipantStatsTimelineResponse
| undefined
> => {
const {
sessionId = this.state.session?.id,
userId = this.currentUserId,
userSessionId = this.unifiedSessionId,
kind = 'details',
} = opts;
if (!sessionId) return;
const base = `${this.streamClient.baseURL}/call_stats/${this.type}/${this.id}/${sessionId}`;
if (!userId || !userSessionId) {
return this.streamClient.get<QueryCallSessionParticipantStatsResponse>(
`${base}/participants`,
);
}
if (kind === 'details') {
return this.streamClient.get<GetCallSessionParticipantStatsDetailsResponse>(
`${base}/participant/${userId}/${userSessionId}/details`,
);
}
return this.streamClient.get<QueryCallSessionParticipantStatsTimelineResponse>(
`${base}/participants/${userId}/${userSessionId}/timeline`,
);
};

/**
* Submit user feedback for the call
*
Expand Down
Loading
Loading