amazon-connect-reference-dialer 1.0.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of amazon-connect-reference-dialer might be problematic. Click here for more details.
- package/.babelrc +10 -0
- package/.eslintrc +24 -0
- package/Dockerfile +12 -0
- package/LICENSE +21 -0
- package/README.md +8 -0
- package/README.salesforce.md +50 -0
- package/config/appconfig.json +10 -0
- package/config/config.js +46 -0
- package/docker-compose.yml +16 -0
- package/index.js +46 -0
- package/nodemon.json +3 -0
- package/package.json +5 -4
- package/src/client/App.js +20 -0
- package/src/client/api/acManager.js +79 -0
- package/src/client/api/agentHandler.js +46 -0
- package/src/client/api/audioFrequencyMonitor.js +62 -0
- package/src/client/api/csioHandler.js +204 -0
- package/src/client/api/databaseManager.js +59 -0
- package/src/client/api/eventhandler.js +278 -0
- package/src/client/api/feedbackHandler.js +21 -0
- package/src/client/api/manager/agent.js +203 -0
- package/src/client/api/manager/connection.js +181 -0
- package/src/client/api/manager/contact.js +114 -0
- package/src/client/api/mediaManager.js +138 -0
- package/src/client/api/networkStrengthMonitor.js +64 -0
- package/src/client/api/precalltest.js +37 -0
- package/src/client/api/sessionManager.js +312 -0
- package/src/client/configs/consts.js +158 -0
- package/src/client/container/agentduration/duration.js +63 -0
- package/src/client/container/agentduration/index.js +3 -0
- package/src/client/container/agentview/conferenceconnection/agentview.css +100 -0
- package/src/client/container/agentview/conferenceconnection/components/bothhold.js +20 -0
- package/src/client/container/agentview/conferenceconnection/components/bothjoined.js +25 -0
- package/src/client/container/agentview/conferenceconnection/components/dialnumber.js +21 -0
- package/src/client/container/agentview/conferenceconnection/components/holdall.js +20 -0
- package/src/client/container/agentview/conferenceconnection/components/join.js +21 -0
- package/src/client/container/agentview/conferenceconnection/components/oneHoldOtherConnected.js +37 -0
- package/src/client/container/agentview/conferenceconnection/components/resumeall.js +21 -0
- package/src/client/container/agentview/conferenceconnection/components/swap.js +21 -0
- package/src/client/container/agentview/conferenceconnection/components/togglemute.js +23 -0
- package/src/client/container/agentview/conferenceconnection/index.js +3 -0
- package/src/client/container/agentview/conferenceconnection/lowerBody.js +154 -0
- package/src/client/container/agentview/conferenceconnection/main.js +22 -0
- package/src/client/container/agentview/conferenceconnection/primaryconnection.js +109 -0
- package/src/client/container/agentview/conferenceconnection/quickFeedback.js +118 -0
- package/src/client/container/agentview/conferenceconnection/thirdpartyconnection.js +107 -0
- package/src/client/container/agentview/conferenceconnection/upperBody.js +36 -0
- package/src/client/container/agentview/footer.js +190 -0
- package/src/client/container/agentview/index.js +3 -0
- package/src/client/container/agentview/main.js +39 -0
- package/src/client/container/agentview/primaryconnection/agentMutedLabel.js +23 -0
- package/src/client/container/agentview/primaryconnection/agentStatusAndAudioLabel.js +28 -0
- package/src/client/container/agentview/primaryconnection/agentview.css +73 -0
- package/src/client/container/agentview/primaryconnection/index.js +3 -0
- package/src/client/container/agentview/primaryconnection/lowerBody.js +159 -0
- package/src/client/container/agentview/primaryconnection/main.js +22 -0
- package/src/client/container/agentview/primaryconnection/peerAndAgentDuration.js +48 -0
- package/src/client/container/agentview/primaryconnection/quickFeedback.js +123 -0
- package/src/client/container/agentview/primaryconnection/upperBody.js +59 -0
- package/src/client/container/agentview/thirdparyconnection/agentMutedLabel.js +23 -0
- package/src/client/container/agentview/thirdparyconnection/agentStatusAndAudioLabel.js +28 -0
- package/src/client/container/agentview/thirdparyconnection/agentview.css +73 -0
- package/src/client/container/agentview/thirdparyconnection/index.js +3 -0
- package/src/client/container/agentview/thirdparyconnection/lowerBody.js +139 -0
- package/src/client/container/agentview/thirdparyconnection/main.js +22 -0
- package/src/client/container/agentview/thirdparyconnection/peerAndAgentDuration.js +49 -0
- package/src/client/container/agentview/thirdparyconnection/quickFeedback.js +118 -0
- package/src/client/container/agentview/thirdparyconnection/upperBody.js +59 -0
- package/src/client/container/audiolabelview/controller.js +104 -0
- package/src/client/container/audiolabelview/localaudiolevel.js +157 -0
- package/src/client/container/audiolabelview/noaudio.js +86 -0
- package/src/client/container/audiolabelview/remoteaudiolevel.js +110 -0
- package/src/client/container/audiolabelview/settingpageaudiolevel.js +154 -0
- package/src/client/container/common/contactField.js +30 -0
- package/src/client/container/common/each.contact.js +41 -0
- package/src/client/container/common/findContact.js +31 -0
- package/src/client/container/connectivitycheckview/body.js +113 -0
- package/src/client/container/connectivitycheckview/components/fractionalLoss.js +57 -0
- package/src/client/container/connectivitycheckview/components/mediaConnectivity.js +41 -0
- package/src/client/container/connectivitycheckview/components/roundTripTime.js +57 -0
- package/src/client/container/connectivitycheckview/components/rttgraph/rttgraph.js +176 -0
- package/src/client/container/connectivitycheckview/components/rttgraph/utils.js +96 -0
- package/src/client/container/connectivitycheckview/components/throughput.js +53 -0
- package/src/client/container/connectivitycheckview/components/throughputMessage.js +36 -0
- package/src/client/container/connectivitycheckview/connectivitycheck.css +44 -0
- package/src/client/container/connectivitycheckview/footer.js +43 -0
- package/src/client/container/connectivitycheckview/index.js +3 -0
- package/src/client/container/connectivitycheckview/loading/loading.css +73 -0
- package/src/client/container/connectivitycheckview/loading/loading.js +15 -0
- package/src/client/container/connectivitycheckview/main.js +19 -0
- package/src/client/container/dialerview/body.js +135 -0
- package/src/client/container/dialerview/dialpad.css +104 -0
- package/src/client/container/dialerview/dialpad.js +29 -0
- package/src/client/container/dialerview/index.js +3 -0
- package/src/client/container/dialerview/main.js +19 -0
- package/src/client/container/errors/error.css +30 -0
- package/src/client/container/errors/error.js +58 -0
- package/src/client/container/errors/index.js +3 -0
- package/src/client/container/footer/components/acceptOrReject.js +26 -0
- package/src/client/container/footer/components/availableOrEnd.js +28 -0
- package/src/client/container/footer/components/connectivitycheck.js +21 -0
- package/src/client/container/footer/components/downloadlogs.js +23 -0
- package/src/client/container/footer/components/info.js +22 -0
- package/src/client/container/footer/components/language.js +22 -0
- package/src/client/container/footer/components/reportcall.js +35 -0
- package/src/client/container/footer/components/version.js +22 -0
- package/src/client/container/header/header.css +46 -0
- package/src/client/container/header/header.js +135 -0
- package/src/client/container/header/index.js +3 -0
- package/src/client/container/home.js +129 -0
- package/src/client/container/login/body.js +67 -0
- package/src/client/container/login/ccpinputbox.js +23 -0
- package/src/client/container/login/footer.js +19 -0
- package/src/client/container/login/index.js +2 -0
- package/src/client/container/login/login.css +134 -0
- package/src/client/container/login/main.js +23 -0
- package/src/client/container/networkstrengthview/index.js +3 -0
- package/src/client/container/networkstrengthview/loading/loading.css +74 -0
- package/src/client/container/networkstrengthview/loading/loading.js +15 -0
- package/src/client/container/networkstrengthview/networkstrength.js +102 -0
- package/src/client/container/popups/confirmreport/confirmreport.css +47 -0
- package/src/client/container/popups/confirmreport/confirmreport.js +55 -0
- package/src/client/container/popups/quality/quality.css +32 -0
- package/src/client/container/popups/quality/quality.js +44 -0
- package/src/client/container/quickconnects/body.js +141 -0
- package/src/client/container/quickconnects/close.js +23 -0
- package/src/client/container/quickconnects/index.js +3 -0
- package/src/client/container/quickconnects/main.js +18 -0
- package/src/client/container/quickconnects/quickconnects.css +95 -0
- package/src/client/container/reportissueview/body.js +73 -0
- package/src/client/container/reportissueview/feedbackRatings.js +37 -0
- package/src/client/container/reportissueview/footer.js +20 -0
- package/src/client/container/reportissueview/index.js +3 -0
- package/src/client/container/reportissueview/issueNotes.js +22 -0
- package/src/client/container/reportissueview/issues.js +44 -0
- package/src/client/container/reportissueview/main.js +105 -0
- package/src/client/container/reportissueview/predefinedIssues.js +38 -0
- package/src/client/container/reportissueview/reportissue.css +102 -0
- package/src/client/container/settingsview/body.js +156 -0
- package/src/client/container/settingsview/components/audiooutputdevice.js +25 -0
- package/src/client/container/settingsview/components/deskphone.js +29 -0
- package/src/client/container/settingsview/components/desktopsettings.js +38 -0
- package/src/client/container/settingsview/components/dropdown-options.js +44 -0
- package/src/client/container/settingsview/components/phonetype.js +14 -0
- package/src/client/container/settingsview/components/settings.js +23 -0
- package/src/client/container/settingsview/components/softphone.js +30 -0
- package/src/client/container/settingsview/components/softphonesettings.js +35 -0
- package/src/client/container/settingsview/footer.js +96 -0
- package/src/client/container/settingsview/index.js +3 -0
- package/src/client/container/settingsview/main.js +20 -0
- package/src/client/container/settingsview/settings.css +126 -0
- package/src/client/container/statechangeview/body.js +61 -0
- package/src/client/container/statechangeview/footer.js +43 -0
- package/src/client/container/statechangeview/index.js +3 -0
- package/src/client/container/statechangeview/main.js +21 -0
- package/src/client/container/statechangeview/statuschange.css +47 -0
- package/src/client/container/transfercall/body.js +139 -0
- package/src/client/container/transfercall/close.js +23 -0
- package/src/client/container/transfercall/index.js +3 -0
- package/src/client/container/transfercall/main.js +18 -0
- package/src/client/container/transfercall/transfercall.css +99 -0
- package/src/client/index.js +13 -0
- package/src/client/reducers/acReducer.js +277 -0
- package/src/client/reducers/reducer.js +8 -0
- package/src/client/reducers.js +2 -0
- package/src/client/res/images/agent-voice-freq-icon.svg +61 -0
- package/src/client/res/images/change-status-icon.svg +16 -0
- package/src/client/res/images/csio-logo.png +0 -0
- package/src/client/res/images/csioLogo.png +0 -0
- package/src/client/res/images/dialer-setting-icon.svg +15 -0
- package/src/client/res/images/fa-circle-mark.svg +3 -0
- package/src/client/res/images/fa-circle-unmark.svg +3 -0
- package/src/client/res/images/fa-close-or-dismiss.svg +17 -0
- package/src/client/res/images/fa-danger.svg +3 -0
- package/src/client/res/images/fa-dial-button.svg +13 -0
- package/src/client/res/images/fa-dial-number.svg +15 -0
- package/src/client/res/images/fa-download.svg +3 -0
- package/src/client/res/images/fa-hold.svg +13 -0
- package/src/client/res/images/fa-ico-join.svg +27 -0
- package/src/client/res/images/fa-ico-swap.svg +27 -0
- package/src/client/res/images/fa-info.svg +3 -0
- package/src/client/res/images/fa-input-sound.svg +5 -0
- package/src/client/res/images/fa-language.svg +3 -0
- package/src/client/res/images/fa-mark-false.svg +3 -0
- package/src/client/res/images/fa-mark-true.svg +3 -0
- package/src/client/res/images/fa-mic-freq-temporary.gif +0 -0
- package/src/client/res/images/fa-mic.svg +3 -0
- package/src/client/res/images/fa-mini-endcall.svg +48 -0
- package/src/client/res/images/fa-mini-hold.svg +47 -0
- package/src/client/res/images/fa-mini-resume.svg +45 -0
- package/src/client/res/images/fa-mute.svg +13 -0
- package/src/client/res/images/fa-network-strength-1.svg +5 -0
- package/src/client/res/images/fa-network-strength-2.svg +6 -0
- package/src/client/res/images/fa-network-strength-3.svg +6 -0
- package/src/client/res/images/fa-network-strength-4.svg +6 -0
- package/src/client/res/images/fa-network-strength-5.svg +5 -0
- package/src/client/res/images/fa-network-strength-unknown-2.svg +9 -0
- package/src/client/res/images/fa-network-strength-unknown.svg +6 -0
- package/src/client/res/images/fa-quick-connect.svg +15 -0
- package/src/client/res/images/fa-refresh.svg +3 -0
- package/src/client/res/images/fa-resume.svg +3 -0
- package/src/client/res/images/fa-return.svg +3 -0
- package/src/client/res/images/fa-three-dots.svg +32 -0
- package/src/client/res/images/fa-tick-green.svg +3 -0
- package/src/client/res/images/fa-tick-mark.svg +3 -0
- package/src/client/res/images/fa-transfer.svg +3 -0
- package/src/client/res/images/fa-version.svg +4 -0
- package/src/client/res/images/fa-voice-no-freq.svg +5 -0
- package/src/client/res/images/favicon.ico +0 -0
- package/src/client/res/images/muted-icon.svg +13 -0
- package/src/client/res/images/network-strength-icon.svg +13 -0
- package/src/client/res/images/peer-voice-freq-icon.svg +26 -0
- package/src/client/res/images/star-white.svg +6 -0
- package/src/client/res/images/star-yellow.svg +6 -0
- package/src/client/res/scss/global.css +14 -0
- package/src/client/router.js +17 -0
- package/src/client/store.js +11 -0
- package/src/client/utils/acutils.js +114 -0
- package/src/client/utils/agetStateMap.js +36 -0
- package/src/client/utils/feedback.js +3 -0
- package/src/client/utils/initialStateManager.js +14 -0
- package/src/server/index.js +53 -0
- package/src/server/logger.js +93 -0
- package/src/server/public/fonts/AmazonEmber_Lt.ttf +0 -0
- package/src/server/public/fonts/AmazonEmber_Rg.ttf +0 -0
- package/src/server/public/img/favicon.ico +0 -0
- package/src/server/public/js/amazon-connect-pre-shim.js +2 -0
- package/src/server/router/compare.js +36 -0
- package/src/server/router/index.js +36 -0
- package/src/server/router/stock.js +33 -0
- package/src/server/views/_heap_prod.ejs +8 -0
- package/src/server/views/_hotjar_prod.ejs +14 -0
- package/src/server/views/_hotjar_test.ejs +12 -0
- package/src/server/views/compare.ejs +69 -0
- package/src/server/views/index.ejs +69 -0
- package/src/server/views/stock.ejs +101 -0
- package/webpack.common.config.js +48 -0
- package/webpack.dev.config.js +21 -0
- package/webpack.prod.config.js +10 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import networkStrengthMonitor from './networkStrengthMonitor';
|
|
3
|
+
import audioFrequencyMonitor from './audioFrequencyMonitor';
|
|
4
|
+
|
|
5
|
+
import lo from 'lodash';
|
|
6
|
+
import databaseManager from './databaseManager';
|
|
7
|
+
import {
|
|
8
|
+
getRandomInt
|
|
9
|
+
} from './../utils/acutils';
|
|
10
|
+
import mediaManager from './mediaManager';
|
|
11
|
+
|
|
12
|
+
const appId = APP_ID || WEB_PACK_APP_ID;
|
|
13
|
+
const appSecret = APP_SECRET || WEB_PACK_APP_SECRET;
|
|
14
|
+
const enableJabraCollection = ENABLE_JABRA_COLLECTION === 'enable';
|
|
15
|
+
const siteIds = ['HQ', 'Remote', 'Home'];
|
|
16
|
+
|
|
17
|
+
const ccpUrl = () => {
|
|
18
|
+
const connectURL = databaseManager.getDefaultConnectURL(CONNECT_URL || WEB_PACK_CONNECT_URL);
|
|
19
|
+
return `https://${connectURL}/connect/ccp#/`;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
class CSIOHandler {
|
|
23
|
+
constructor () {
|
|
24
|
+
this.callstatsac = undefined;
|
|
25
|
+
this.dispatch = undefined;
|
|
26
|
+
this.localUserId = undefined;
|
|
27
|
+
// eslint-disable-next-line new-cap
|
|
28
|
+
this.agentMonitor = new callstatsAgentMonitor();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
33
|
+
* @return {string} Return a site id from given site id list
|
|
34
|
+
*/
|
|
35
|
+
getRandomSiteId () {
|
|
36
|
+
return siteIds[ getRandomInt(1, siteIds.length) - 1 ];
|
|
37
|
+
}
|
|
38
|
+
// eslint-disable-next-line handle-callback-err
|
|
39
|
+
onCSIOInitialize (err, msg) {
|
|
40
|
+
// console.warn('->', 'onCSIOInitialize', new Date(), err, msg);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
onCSIOStats (stats) {
|
|
44
|
+
// console.warn('->onCSIOStats', stats);
|
|
45
|
+
if (stats && stats.fabricState === 'terminated') {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (stats && stats.mediaStreamTracks) {
|
|
50
|
+
let track1 = lo.first(stats.mediaStreamTracks);
|
|
51
|
+
let track2 = lo.last(stats.mediaStreamTracks);
|
|
52
|
+
|
|
53
|
+
// console.warn('~', stats);
|
|
54
|
+
let audioIntputLevel = parseInt(track1.audioIntputLevel || track2.audioIntputLevel || 0, 10);
|
|
55
|
+
let audioOutputLevel = parseInt(track1.audioOutputLevel || track2.audioOutputLevel || 0, 10);
|
|
56
|
+
|
|
57
|
+
let track1Bitrate = parseInt(track1.bitrate || 0, 10);
|
|
58
|
+
let track2Bitrate = parseInt(track2.bitrate || 0, 10);
|
|
59
|
+
let track1RTT = parseInt(track1.rtt || 0, 10);
|
|
60
|
+
// no rtt for inbound tracks.
|
|
61
|
+
// let track2RTT = parseInt(track1.rtt || 0, 10);
|
|
62
|
+
|
|
63
|
+
let track1Fl = parseInt(track1.fractionLoss || 0, 10);
|
|
64
|
+
let track2Fl = parseInt(track2.fractionLoss || 0, 10);
|
|
65
|
+
|
|
66
|
+
// console.warn('-> ', 'on csio stats', stats);
|
|
67
|
+
networkStrengthMonitor.addThroughput(track1Bitrate, track2Bitrate);
|
|
68
|
+
networkStrengthMonitor.addRTT(track1RTT, track1RTT);
|
|
69
|
+
networkStrengthMonitor.addRTT(track1Fl, track2Fl);
|
|
70
|
+
audioFrequencyMonitor.addAudioLevel(audioIntputLevel, false);
|
|
71
|
+
audioFrequencyMonitor.addAudioLevel(audioOutputLevel, true);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getRemoteStream () {
|
|
76
|
+
const pc = CallstatsAmazonShim && CallstatsAmazonShim.getPeerConnection();
|
|
77
|
+
if (!pc) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const remoteStreams = pc.getRemoteStreams();
|
|
81
|
+
return remoteStreams && lo.get(remoteStreams, 0, undefined);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
doPrecallTest () {
|
|
85
|
+
return new Promise((resolve) => {
|
|
86
|
+
if (CallstatsAmazonShim) {
|
|
87
|
+
CallstatsAmazonShim.makePrecallTest((status, result) => {
|
|
88
|
+
// console.warn('-> ', 'on precall test', status, result);
|
|
89
|
+
let testResult = databaseManager.savePrecalltestResult(result);
|
|
90
|
+
|
|
91
|
+
let throughput = lo.get(result, 'throughput', 0);
|
|
92
|
+
let rtt = lo.get(result, 'rtt', 0);
|
|
93
|
+
let fractionalLoss = lo.get(result, 'fractionalLoss', 0);
|
|
94
|
+
networkStrengthMonitor.addThroughput(throughput, throughput);
|
|
95
|
+
networkStrengthMonitor.addRTT(rtt, rtt);
|
|
96
|
+
networkStrengthMonitor.addFractionalLoss(fractionalLoss, fractionalLoss);
|
|
97
|
+
resolve(testResult);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
onCSIORecommendedConfigCallback (config) {
|
|
104
|
+
// console.warn('->', 'onCSIORecommendedConfigCallback', new Date(), config);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
onCSIOPrecalltestCallback (status, result) {
|
|
108
|
+
// console.warn('-> ', 'on precall test', status, result);
|
|
109
|
+
databaseManager.savePrecalltestResult(result);
|
|
110
|
+
let throughput = lo.get(result, 'throughput', 0);
|
|
111
|
+
let rtt = lo.get(result, 'rtt', 0);
|
|
112
|
+
let fractionalLoss = lo.get(result, 'fractionalLoss', 0);
|
|
113
|
+
networkStrengthMonitor.addThroughput(throughput, throughput);
|
|
114
|
+
networkStrengthMonitor.addRTT(rtt, rtt);
|
|
115
|
+
networkStrengthMonitor.addFractionalLoss(fractionalLoss, fractionalLoss);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
dispose () {
|
|
119
|
+
this.dispatch = undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
register (dispatch = undefined, agent = undefined) {
|
|
123
|
+
this.dispatch && this.dispose();
|
|
124
|
+
this.dispatch = dispatch;
|
|
125
|
+
|
|
126
|
+
if (!agent) {
|
|
127
|
+
// console.error('agent object cannot be empty');
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (!CallstatsAmazonShim) {
|
|
131
|
+
// console.error('CallstatsAmazonShim object cannot be empty');
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const localUserId = agent.getName();
|
|
135
|
+
this.localUserId = localUserId;
|
|
136
|
+
const configParams = {
|
|
137
|
+
siteID: this.getRandomSiteId(),
|
|
138
|
+
enableJabraCollection: enableJabraCollection
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
if (this.callstatsac) {
|
|
142
|
+
this.callstatsac = undefined;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this.callstatsac = CallstatsAmazonShim.initialize(connect, appId, appSecret, localUserId, configParams, this.onCSIOInitialize, this.onCSIOStats);
|
|
146
|
+
this.callstatsac.on('recommendedConfig', this.onCSIORecommendedConfigCallback.bind(this));
|
|
147
|
+
this.callstatsac.on('preCallTestResults', this.onCSIOPrecalltestCallback.bind(this));
|
|
148
|
+
|
|
149
|
+
// add agent monitor
|
|
150
|
+
if (this.agentMonitor && typeof this.agentMonitor.initialize === 'function') {
|
|
151
|
+
this.agentMonitor.initialize(connect, ccpUrl(), appId, appSecret, localUserId, configParams);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Quick hack to send feedback in structural way before we have a API for that
|
|
156
|
+
postProcessFeedback (feedbackJSON = {}) {
|
|
157
|
+
let markedFeedback = [];
|
|
158
|
+
for (let currentIssue of feedbackJSON.issueList || []) {
|
|
159
|
+
for (let issue of currentIssue.items || []) {
|
|
160
|
+
if (issue.marked === true) {
|
|
161
|
+
markedFeedback.push(issue.text);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return markedFeedback;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
sendFeedback (feedbackJSON = {}) {
|
|
169
|
+
let markedFeedbackList = this.postProcessFeedback(feedbackJSON);
|
|
170
|
+
let feedbackText = `${[feedbackJSON.feedbackText, ...markedFeedbackList].join(' ,')}`;
|
|
171
|
+
const feedback = {
|
|
172
|
+
userId: this.localUserId,
|
|
173
|
+
overall: Math.max(feedbackJSON.feedbackRatings, 1),
|
|
174
|
+
comment: feedbackText
|
|
175
|
+
};
|
|
176
|
+
CallstatsAmazonShim.sendUserFeedback(feedback, msg => {
|
|
177
|
+
// console.warn('on submitted feedback ', msg);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
sendFeedbackRating (feedbackRating = 1) {
|
|
182
|
+
const feedback = {
|
|
183
|
+
userId: this.localUserId,
|
|
184
|
+
overall: Math.max(feedbackRating, 1)
|
|
185
|
+
};
|
|
186
|
+
CallstatsAmazonShim.sendUserFeedback(feedback, msg => {
|
|
187
|
+
// console.warn('on submitted rating ', msg);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
sendActiveDeviceList () {
|
|
192
|
+
mediaManager.getDefaultOrPreferredAudioInputDevice()
|
|
193
|
+
.then(activeAudioDevice => {
|
|
194
|
+
const eventData = {
|
|
195
|
+
deviceList: [activeAudioDevice]
|
|
196
|
+
};
|
|
197
|
+
CallstatsAmazonShim.sendFabricEvent(this.callstatsac.fabricEvent.activeDeviceList, eventData);
|
|
198
|
+
})
|
|
199
|
+
.catch(() => {});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const csioHandler = new CSIOHandler();
|
|
204
|
+
export default csioHandler;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const maxElement = 500;
|
|
4
|
+
|
|
5
|
+
class DatabaseManager {
|
|
6
|
+
// eslint-disable-next-line no-useless-constructor
|
|
7
|
+
constructor () {
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
savePrecalltestResult (result) {
|
|
11
|
+
const epochTime = (new Date()).getTime();
|
|
12
|
+
let retval = this.getPrecallTestResult();
|
|
13
|
+
if (retval) {
|
|
14
|
+
if (retval.length > maxElement) {
|
|
15
|
+
retval.shift();
|
|
16
|
+
}
|
|
17
|
+
retval.push({ ...result, epochTime });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
window.localStorage.setItem('rttResult', JSON.stringify(retval));
|
|
21
|
+
return retval;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getPrecallTestResult () {
|
|
25
|
+
let result = window.localStorage.getItem('rttResult') || undefined;
|
|
26
|
+
if (result) {
|
|
27
|
+
return JSON.parse(result);
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
saveDefaultDevice (defaultAudioDevice = undefined) {
|
|
33
|
+
window.localStorage.setItem('defaultDevice', JSON.stringify(defaultAudioDevice));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getSelectedAudioDevice () {
|
|
37
|
+
return window.localStorage.getItem('defaultDevice') || undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
setDefaultConnectURL (ccpURL = '') {
|
|
41
|
+
window.localStorage.setItem('defaultConnectURL', ccpURL);
|
|
42
|
+
return ccpURL;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getDefaultConnectURL (ccpURL = '') {
|
|
46
|
+
return window.localStorage.getItem('defaultConnectURL') || ccpURL || undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setDefaultCountry (defaultCountry = '') {
|
|
50
|
+
window.localStorage.setItem('defaultCountry', defaultCountry);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getDefaultCountry () {
|
|
54
|
+
return window.localStorage.getItem('defaultCountry');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const databaseManager = new DatabaseManager();
|
|
59
|
+
export default databaseManager;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import {
|
|
2
|
+
onCCPError,
|
|
3
|
+
onInitializationStateChange,
|
|
4
|
+
onRemoteStream,
|
|
5
|
+
onStateChange
|
|
6
|
+
} from '../reducers/acReducer';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
isCallbackMissed
|
|
10
|
+
} from '../utils/acutils';
|
|
11
|
+
|
|
12
|
+
import csioHandler from './csioHandler';
|
|
13
|
+
import acManager from './acManager';
|
|
14
|
+
import sessionManage from './sessionManager';
|
|
15
|
+
import mediaManager from './mediaManager';
|
|
16
|
+
|
|
17
|
+
// Outbound call = connection.isActive() && connection.isConnecting() && connection.getType() === 'outbound'
|
|
18
|
+
// Incoming call = connection.isActive() && connection.isConnecting() && connection.getType() === 'inbound'
|
|
19
|
+
// Connected = connection.isActive() && connection.isConnected() && isMultipartyCall() === false;
|
|
20
|
+
// Joined = connection.isActive() && connection.isConnected() && isMultipartyCall();
|
|
21
|
+
// Hold = connection.isActive() && connection.isOnHold()
|
|
22
|
+
// Duration = connection.isActive() && connection.getState() && connection.getState().duration
|
|
23
|
+
|
|
24
|
+
let currentAgent;
|
|
25
|
+
let currentContact;
|
|
26
|
+
let currentState;
|
|
27
|
+
|
|
28
|
+
const knownAgentStates = ['Init', 'Default', 'Available', 'Offline', 'AfterCallWork', 'FailedConnectCustomer', 'FailedConnectAgent', 'Quality Issue', 'AgentHungUp'];
|
|
29
|
+
const isError = (e) => {
|
|
30
|
+
if (e && e.errorType && e.errorMessage) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const getAgentState = (e) => {
|
|
36
|
+
let { agent, newState } = e;
|
|
37
|
+
const currentAgentStates = sessionManage.getAgentStates();
|
|
38
|
+
// merge the known state and dynamic agent states
|
|
39
|
+
const agentStates = [ ...knownAgentStates, ...currentAgentStates.map(state => state.name) ];
|
|
40
|
+
if (!agentStates.includes(newState)) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const duration = agent.getStateDuration();
|
|
44
|
+
if (isCallbackMissed(agent, newState)) {
|
|
45
|
+
newState = 'Callback missed';
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
state: newState,
|
|
49
|
+
duration: duration,
|
|
50
|
+
agent: agent
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// eslint-disable-next-line no-unused-vars
|
|
55
|
+
const isMultipartyCall = (contact) => {
|
|
56
|
+
return !!((contact && contact.getActiveInitialConnection() && contact.getSingleActiveThirdPartyConnection()));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const isAgentError = (agent = undefined) => {
|
|
60
|
+
const agentState = agent && agent.getState();
|
|
61
|
+
return agentState && agentState.type === 'error';
|
|
62
|
+
};
|
|
63
|
+
const isOutbound = (connection) => {
|
|
64
|
+
return connection && connection.isActive() && connection.isConnected() === false &&
|
|
65
|
+
connection.isConnecting() === true && connection.getType() === 'outbound';
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const isInbound = (connection) => {
|
|
69
|
+
return connection && connection.isActive() && connection.isConnected() &&
|
|
70
|
+
connection.getType() === 'inbound' &&
|
|
71
|
+
currentAgent.agent.getState().name === 'PendingBusy';
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const isConnecting = (connection) => {
|
|
75
|
+
return connection && connection.isActive() && connection.isConnected() === false &&
|
|
76
|
+
connection.isConnecting() === true && connection.getType() === 'inbound' &&
|
|
77
|
+
currentAgent.agent.getState().name === 'CallingCustomer';
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const isInboundCallback = (connection) => {
|
|
81
|
+
return connection && connection.isActive() && connection.isConnected() &&
|
|
82
|
+
connection.getType() === 'inbound' &&
|
|
83
|
+
currentAgent.agent.getState().name === 'Pending';
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const isMissedCall = (connection) => {
|
|
87
|
+
return connection && connection.isActive() && connection.isConnected() &&
|
|
88
|
+
connection.getType() === 'inbound' &&
|
|
89
|
+
currentAgent.agent.getState().name === 'MissedCallAgent';
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const isConnected = (connection) => {
|
|
93
|
+
return connection && connection.isActive() && connection.isConnected() &&
|
|
94
|
+
currentAgent.agent.getState().name === 'Busy';
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const isJoined = (primaryConnectionState, thirdPartyConnectionState) => {
|
|
98
|
+
return primaryConnectionState && thirdPartyConnectionState &&
|
|
99
|
+
['connected', 'Connected'].includes(primaryConnectionState.state) &&
|
|
100
|
+
primaryConnectionState.state === thirdPartyConnectionState.state;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const isHold = (connection) => {
|
|
104
|
+
return connection && connection.isActive() && connection.isOnHold();
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const getStateDuration = (connection) => {
|
|
108
|
+
let duration = connection && connection.getStatusDuration();
|
|
109
|
+
return duration;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const getConnectionState = (contact = undefined, isPrimary = true) => {
|
|
113
|
+
const connection = isPrimary ? contact.getActiveInitialConnection() : contact.getSingleActiveThirdPartyConnection();
|
|
114
|
+
if (!connection) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
// console.warn('~', connection.isActive(), connection.isConnected(), connection.isConnecting(), connection.getType(), currentAgent.agent.getState());
|
|
118
|
+
let state;
|
|
119
|
+
if (isOutbound(connection)) {
|
|
120
|
+
state = 'Outbound call';
|
|
121
|
+
} else if (isInbound(connection)) {
|
|
122
|
+
state = 'Inbound call';
|
|
123
|
+
} else if (isMissedCall(connection)) {
|
|
124
|
+
state = 'Missed call';
|
|
125
|
+
} else if (isConnected(connection)) {
|
|
126
|
+
state = 'Connected';
|
|
127
|
+
} else if (isHold(connection)) {
|
|
128
|
+
state = 'On hold';
|
|
129
|
+
} else if (isInboundCallback(connection)) {
|
|
130
|
+
state = 'Callback incoming';
|
|
131
|
+
} else if (isConnecting(connection)) {
|
|
132
|
+
state = 'Connecting';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let duration = getStateDuration(connection);
|
|
136
|
+
return {
|
|
137
|
+
state: state,
|
|
138
|
+
duration: duration,
|
|
139
|
+
connection: connection
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const mayBeUpdateToJoined = (primaryConnectionState = undefined, thirdPartyConnectionState = undefined) => {
|
|
144
|
+
if (isJoined(primaryConnectionState, thirdPartyConnectionState)) {
|
|
145
|
+
primaryConnectionState.state = 'Joined';
|
|
146
|
+
thirdPartyConnectionState.state = 'Joined';
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
primaryConnectionState,
|
|
150
|
+
thirdPartyConnectionState
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
class EventHandler {
|
|
155
|
+
constructor () {
|
|
156
|
+
this.dispatch = undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
dispose () {
|
|
160
|
+
this.dispatch = undefined;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
register (dispatch, connect) {
|
|
164
|
+
if (this.dispatch) {
|
|
165
|
+
this.dispose();
|
|
166
|
+
}
|
|
167
|
+
this.dispatch = dispatch;
|
|
168
|
+
|
|
169
|
+
if (connect && connect.core) {
|
|
170
|
+
let bus = connect.core.getEventBus();
|
|
171
|
+
|
|
172
|
+
bus.subscribe('<<all>>', e => {
|
|
173
|
+
if (isError(e)) {
|
|
174
|
+
this.dispatch(onCCPError({ ...e }));
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// get the agent init to set logged in
|
|
179
|
+
bus.subscribe(connect.AgentEvents.INIT, (e) => {
|
|
180
|
+
// close the login window, since at this stage agent is already initialized
|
|
181
|
+
sessionManage.disposeLoginWindow();
|
|
182
|
+
acManager.setIsLoggedIn(true);
|
|
183
|
+
this.dispatch(onInitializationStateChange(true));
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// handle shared worker terminated to set agent logged out
|
|
187
|
+
bus.subscribe(connect.EventType.TERMINATED, (e) => {
|
|
188
|
+
acManager.setIsLoggedIn(false);
|
|
189
|
+
window.location.reload();
|
|
190
|
+
});
|
|
191
|
+
bus.subscribe(connect.AgentEvents.ERROR, e => {
|
|
192
|
+
// console.warn('error', e);
|
|
193
|
+
});
|
|
194
|
+
bus.subscribe(connect.AgentEvents.STATE_CHANGE, e => {
|
|
195
|
+
currentAgent = e;
|
|
196
|
+
// console.warn('~agent state change ', getAgentState(e));
|
|
197
|
+
let payload = {
|
|
198
|
+
primaryConnectionState: getAgentState(e),
|
|
199
|
+
thirdPartyConnectionState: undefined
|
|
200
|
+
};
|
|
201
|
+
currentState = payload;
|
|
202
|
+
this.dispatch(onStateChange(payload));
|
|
203
|
+
});
|
|
204
|
+
bus.subscribe(connect.ContactEvents.REFRESH, e => {
|
|
205
|
+
currentContact = e;
|
|
206
|
+
const connection1 = getConnectionState(e, true);
|
|
207
|
+
const connection2 = getConnectionState(e, false);
|
|
208
|
+
const { primaryConnectionState, thirdPartyConnectionState } = mayBeUpdateToJoined(connection1, connection2);
|
|
209
|
+
// console.warn('~REFRESH', primaryConnectionState, thirdPartyConnectionState, isMultipartyCall(e));
|
|
210
|
+
// if there is a agent side error
|
|
211
|
+
// ignore checking connections
|
|
212
|
+
const parseAgentState = () => {
|
|
213
|
+
if (isAgentError(currentAgent.agent)) {
|
|
214
|
+
const agentState = getAgentState(currentAgent);
|
|
215
|
+
if (!agentState) {
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
let payload = {
|
|
219
|
+
primaryConnectionState: agentState,
|
|
220
|
+
thirdPartyConnectionState: undefined
|
|
221
|
+
};
|
|
222
|
+
return payload;
|
|
223
|
+
}
|
|
224
|
+
return undefined;
|
|
225
|
+
};
|
|
226
|
+
const parseConnectState = () => {
|
|
227
|
+
let payload = {
|
|
228
|
+
primaryConnectionState: primaryConnectionState,
|
|
229
|
+
thirdPartyConnectionState: thirdPartyConnectionState
|
|
230
|
+
};
|
|
231
|
+
if ((primaryConnectionState && primaryConnectionState.state) || (thirdPartyConnectionState && thirdPartyConnectionState.state)) {
|
|
232
|
+
return payload;
|
|
233
|
+
}
|
|
234
|
+
return undefined;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const parseRest = () => {
|
|
238
|
+
let payload = {
|
|
239
|
+
primaryConnectionState: getAgentState(currentAgent),
|
|
240
|
+
thirdPartyConnectionState: undefined
|
|
241
|
+
};
|
|
242
|
+
return payload;
|
|
243
|
+
};
|
|
244
|
+
let payload = parseAgentState() || parseConnectState() || parseRest();
|
|
245
|
+
currentState = payload;
|
|
246
|
+
this.dispatch(onStateChange(payload));
|
|
247
|
+
});
|
|
248
|
+
bus.subscribe(connect.ContactEvents.ENDED, () => {
|
|
249
|
+
currentContact = undefined;
|
|
250
|
+
mediaManager.setRemoteStream(undefined);
|
|
251
|
+
});
|
|
252
|
+
bus.subscribe(connect.ContactEvents.DESTROYED, () => {
|
|
253
|
+
currentContact = undefined;
|
|
254
|
+
mediaManager.setRemoteStream(undefined);
|
|
255
|
+
});
|
|
256
|
+
bus.subscribe(connect.ContactEvents.CONNECTED, e => {
|
|
257
|
+
const remoteStream = csioHandler.getRemoteStream();
|
|
258
|
+
if (remoteStream) {
|
|
259
|
+
this.dispatch(onRemoteStream(remoteStream));
|
|
260
|
+
mediaManager.setRemoteStream(remoteStream);
|
|
261
|
+
}
|
|
262
|
+
// send active device list
|
|
263
|
+
csioHandler.sendActiveDeviceList();
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
getCurrentContact () {
|
|
269
|
+
return currentContact;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
getCurrentState () {
|
|
273
|
+
return currentState;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const eventHandler = new EventHandler();
|
|
278
|
+
export default eventHandler;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class FeedbackHandler {
|
|
2
|
+
constructor () {
|
|
3
|
+
this.feedbackRatings = 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
showFeedbackReports () {
|
|
7
|
+
return this.feedbackRatings >= 1 && this.feedbackRatings <= 3;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
updateFeedback (feedbackRatings = 0) {
|
|
11
|
+
this.feedbackRatings = feedbackRatings;
|
|
12
|
+
return this.feedbackRatings;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getFeedbackRatings () {
|
|
16
|
+
return this.feedbackRatings;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const feedbackHandler = new FeedbackHandler();
|
|
21
|
+
export default feedbackHandler;
|