feat(player): add agent id to assist con query

This commit is contained in:
nick-delirium 2023-10-02 11:51:05 +02:00
parent 44b4db1b38
commit 184dea26b4
3 changed files with 47 additions and 0 deletions

View file

@ -33,8 +33,20 @@ interface Props {
isCallActive: boolean;
agentIds: string[];
userDisplayName: string;
agentId: number,
}
const AssistActionsPing = {
control: {
start: 's_control_started',
end: 's_control_ended'
},
call: {
start: 's_call_started',
end: 's_call_ended'
},
} as const
function AssistActions({
userId,
hasPermission,
@ -42,6 +54,7 @@ function AssistActions({
isCallActive,
agentIds,
userDisplayName,
agentId,
}: Props) {
// @ts-ignore ???
const { player, store } = React.useContext<ILivePlayerContext>(PlayerContext);
@ -136,6 +149,7 @@ function AssistActions({
lStream,
addIncomeStream,
() => {
player.assistManager.ping(AssistActionsPing.call.end, agentId)
lStream.stop.bind(lStream);
},
onReject,
@ -164,11 +178,23 @@ function AssistActions({
};
const requestControl = () => {
if (remoteActive) player.assistManager.ping(AssistActionsPing.control.end, agentId)
setRemoteControlCallbacks({ onReject: onControlReject });
if (callRequesting || remoteRequesting) return;
requestReleaseRemoteControl();
};
React.useEffect(() => {
if (remoteActive) {
player.assistManager.ping(AssistActionsPing.control.start, agentId)
}
}, [remoteActive])
React.useEffect(() => {
if (onCall) {
player.assistManager.ping(AssistActionsPing.call.start, agentId)
}
}, [onCall])
return (
<div className="flex items-center">
{(onCall || remoteActive) && (
@ -262,6 +288,7 @@ const con = connect((state: any) => {
hasPermission: permissions.includes('ASSIST_CALL'),
isEnterprise: state.getIn(['user', 'account', 'edition']) === 'ee',
userDisplayName: state.getIn(['sessions', 'current']).userDisplayName,
agentId: state.getIn(['user', 'account', 'id'])
};
});

View file

@ -34,11 +34,13 @@ const supportedMessage = `Supported Browsers: ${supportedBrowsers.join(', ')}`;
function ScreenRecorder({
siteId,
sessionId,
agentId,
isEnterprise,
}: {
siteId: string;
sessionId: string;
isEnterprise: boolean;
agentId: number,
}) {
const { player, store } = React.useContext(PlayerContext) as ILivePlayerContext;
const recordingState = store.get().recordingState;
@ -96,6 +98,7 @@ function ScreenRecorder({
};
const stopRecordingHandler = () => {
player.assistManager.ping('s_recording_ended', agentId)
stopRecorderCb?.();
onStop();
};
@ -105,6 +108,12 @@ function ScreenRecorder({
player.assistManager.requestRecording({ onDeny });
};
React.useEffect(() => {
if (isRecording) {
player.assistManager.ping('s_recording_started', agentId)
}
}, [isRecording])
if (!isSupported() || !isEnterprise) {
return (
<div className="p-2">
@ -136,4 +145,5 @@ export default connect((state: any) => ({
isEnterprise: state.getIn(['user', 'account', 'edition']) === 'ee',
siteId: state.getIn(['site', 'siteId']),
sessionId: state.getIn(['sessions', 'current']).sessionId,
agentId: state.getIn(['user', 'account', 'id']),
}))(observer(ScreenRecorder));

View file

@ -25,6 +25,12 @@ export enum ConnectionStatus {
Closed,
}
type StatsEvent = 's_call_started'
| 's_call_ended'
| 's_control_started'
| 's_control_ended'
| 's_recording_started'
| 's_recording_ended'
export function getStatusText(status: ConnectionStatus): string {
switch(status) {
@ -272,6 +278,10 @@ export default class AssistManager {
})
}
public ping(event: StatsEvent, id: number) {
this.socket?.emit(event, id)
}
/* ==== ScreenRecording ==== */
private screenRecording: ScreenRecording | null = null