2021-05-24 10:05:37 +00:00
|
|
|
import logger from './logger';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends feedback metadata to JaaS endpoints.
|
|
|
|
*
|
|
|
|
* @param {string} url - The JaaS metadata endpoint URL.
|
|
|
|
* @param {Object} feedbackData - The feedback data object.
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
2022-10-07 08:39:18 +00:00
|
|
|
export async function sendFeedbackToJaaSRequest(url: string, feedbackData: {
|
|
|
|
jwt?: string; meetingFqn: string; message?: string; score?: number;
|
|
|
|
sessionId: string; tenant?: string; userId?: string;
|
|
|
|
}) {
|
2021-05-24 10:05:37 +00:00
|
|
|
const {
|
|
|
|
jwt,
|
|
|
|
sessionId,
|
|
|
|
meetingFqn,
|
|
|
|
score,
|
|
|
|
message,
|
|
|
|
userId,
|
|
|
|
tenant
|
|
|
|
} = feedbackData;
|
|
|
|
const headers = {
|
|
|
|
'Authorization': `Bearer ${jwt}`,
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
};
|
|
|
|
const data = {
|
|
|
|
sessionId,
|
|
|
|
meetingFqn,
|
|
|
|
userId,
|
|
|
|
tenant,
|
|
|
|
submitted: new Date().getTime(),
|
|
|
|
rating: score,
|
|
|
|
comments: message
|
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
|
|
|
const res = await fetch(url, {
|
|
|
|
method: 'POST',
|
|
|
|
headers,
|
|
|
|
body: JSON.stringify(data)
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!res.ok) {
|
|
|
|
logger.error('Status error:', res.status);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
logger.error('Could not send request', err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|