@webex/contact-center 0.0.0-next.1

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.
Files changed (177) hide show
  1. package/README.md +81 -0
  2. package/__mocks__/workerMock.js +15 -0
  3. package/babel.config.js +15 -0
  4. package/dist/cc.js +1416 -0
  5. package/dist/cc.js.map +1 -0
  6. package/dist/config.js +72 -0
  7. package/dist/config.js.map +1 -0
  8. package/dist/constants.js +58 -0
  9. package/dist/constants.js.map +1 -0
  10. package/dist/index.js +142 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/logger-proxy.js +115 -0
  13. package/dist/logger-proxy.js.map +1 -0
  14. package/dist/metrics/MetricsManager.js +474 -0
  15. package/dist/metrics/MetricsManager.js.map +1 -0
  16. package/dist/metrics/behavioral-events.js +322 -0
  17. package/dist/metrics/behavioral-events.js.map +1 -0
  18. package/dist/metrics/constants.js +134 -0
  19. package/dist/metrics/constants.js.map +1 -0
  20. package/dist/services/WebCallingService.js +323 -0
  21. package/dist/services/WebCallingService.js.map +1 -0
  22. package/dist/services/agent/index.js +177 -0
  23. package/dist/services/agent/index.js.map +1 -0
  24. package/dist/services/agent/types.js +137 -0
  25. package/dist/services/agent/types.js.map +1 -0
  26. package/dist/services/config/Util.js +203 -0
  27. package/dist/services/config/Util.js.map +1 -0
  28. package/dist/services/config/constants.js +221 -0
  29. package/dist/services/config/constants.js.map +1 -0
  30. package/dist/services/config/index.js +607 -0
  31. package/dist/services/config/index.js.map +1 -0
  32. package/dist/services/config/types.js +334 -0
  33. package/dist/services/config/types.js.map +1 -0
  34. package/dist/services/constants.js +117 -0
  35. package/dist/services/constants.js.map +1 -0
  36. package/dist/services/core/Err.js +43 -0
  37. package/dist/services/core/Err.js.map +1 -0
  38. package/dist/services/core/GlobalTypes.js +6 -0
  39. package/dist/services/core/GlobalTypes.js.map +1 -0
  40. package/dist/services/core/Utils.js +126 -0
  41. package/dist/services/core/Utils.js.map +1 -0
  42. package/dist/services/core/WebexRequest.js +96 -0
  43. package/dist/services/core/WebexRequest.js.map +1 -0
  44. package/dist/services/core/aqm-reqs.js +246 -0
  45. package/dist/services/core/aqm-reqs.js.map +1 -0
  46. package/dist/services/core/constants.js +109 -0
  47. package/dist/services/core/constants.js.map +1 -0
  48. package/dist/services/core/types.js +6 -0
  49. package/dist/services/core/types.js.map +1 -0
  50. package/dist/services/core/websocket/WebSocketManager.js +187 -0
  51. package/dist/services/core/websocket/WebSocketManager.js.map +1 -0
  52. package/dist/services/core/websocket/connection-service.js +111 -0
  53. package/dist/services/core/websocket/connection-service.js.map +1 -0
  54. package/dist/services/core/websocket/keepalive.worker.js +94 -0
  55. package/dist/services/core/websocket/keepalive.worker.js.map +1 -0
  56. package/dist/services/core/websocket/types.js +6 -0
  57. package/dist/services/core/websocket/types.js.map +1 -0
  58. package/dist/services/index.js +78 -0
  59. package/dist/services/index.js.map +1 -0
  60. package/dist/services/task/AutoWrapup.js +88 -0
  61. package/dist/services/task/AutoWrapup.js.map +1 -0
  62. package/dist/services/task/TaskManager.js +369 -0
  63. package/dist/services/task/TaskManager.js.map +1 -0
  64. package/dist/services/task/constants.js +58 -0
  65. package/dist/services/task/constants.js.map +1 -0
  66. package/dist/services/task/contact.js +464 -0
  67. package/dist/services/task/contact.js.map +1 -0
  68. package/dist/services/task/dialer.js +60 -0
  69. package/dist/services/task/dialer.js.map +1 -0
  70. package/dist/services/task/index.js +1188 -0
  71. package/dist/services/task/index.js.map +1 -0
  72. package/dist/services/task/types.js +214 -0
  73. package/dist/services/task/types.js.map +1 -0
  74. package/dist/types/cc.d.ts +676 -0
  75. package/dist/types/config.d.ts +66 -0
  76. package/dist/types/constants.d.ts +45 -0
  77. package/dist/types/index.d.ts +178 -0
  78. package/dist/types/logger-proxy.d.ts +71 -0
  79. package/dist/types/metrics/MetricsManager.d.ts +223 -0
  80. package/dist/types/metrics/behavioral-events.d.ts +29 -0
  81. package/dist/types/metrics/constants.d.ts +127 -0
  82. package/dist/types/services/WebCallingService.d.ts +1 -0
  83. package/dist/types/services/agent/index.d.ts +46 -0
  84. package/dist/types/services/agent/types.d.ts +413 -0
  85. package/dist/types/services/config/Util.d.ts +19 -0
  86. package/dist/types/services/config/constants.d.ts +203 -0
  87. package/dist/types/services/config/index.d.ts +171 -0
  88. package/dist/types/services/config/types.d.ts +1113 -0
  89. package/dist/types/services/constants.d.ts +97 -0
  90. package/dist/types/services/core/Err.d.ts +119 -0
  91. package/dist/types/services/core/GlobalTypes.d.ts +33 -0
  92. package/dist/types/services/core/Utils.d.ts +36 -0
  93. package/dist/types/services/core/WebexRequest.d.ts +22 -0
  94. package/dist/types/services/core/aqm-reqs.d.ts +16 -0
  95. package/dist/types/services/core/constants.d.ts +85 -0
  96. package/dist/types/services/core/types.d.ts +47 -0
  97. package/dist/types/services/core/websocket/WebSocketManager.d.ts +34 -0
  98. package/dist/types/services/core/websocket/connection-service.d.ts +27 -0
  99. package/dist/types/services/core/websocket/keepalive.worker.d.ts +2 -0
  100. package/dist/types/services/core/websocket/types.d.ts +37 -0
  101. package/dist/types/services/index.d.ts +52 -0
  102. package/dist/types/services/task/AutoWrapup.d.ts +40 -0
  103. package/dist/types/services/task/TaskManager.d.ts +1 -0
  104. package/dist/types/services/task/constants.d.ts +46 -0
  105. package/dist/types/services/task/contact.d.ts +59 -0
  106. package/dist/types/services/task/dialer.d.ts +28 -0
  107. package/dist/types/services/task/index.d.ts +569 -0
  108. package/dist/types/services/task/types.d.ts +1041 -0
  109. package/dist/types/types.d.ts +452 -0
  110. package/dist/types/webex-config.d.ts +53 -0
  111. package/dist/types/webex.d.ts +7 -0
  112. package/dist/types.js +292 -0
  113. package/dist/types.js.map +1 -0
  114. package/dist/webex-config.js +60 -0
  115. package/dist/webex-config.js.map +1 -0
  116. package/dist/webex.js +99 -0
  117. package/dist/webex.js.map +1 -0
  118. package/jest.config.js +45 -0
  119. package/package.json +83 -0
  120. package/src/cc.ts +1618 -0
  121. package/src/config.ts +65 -0
  122. package/src/constants.ts +51 -0
  123. package/src/index.ts +220 -0
  124. package/src/logger-proxy.ts +110 -0
  125. package/src/metrics/MetricsManager.ts +512 -0
  126. package/src/metrics/behavioral-events.ts +332 -0
  127. package/src/metrics/constants.ts +135 -0
  128. package/src/services/WebCallingService.ts +351 -0
  129. package/src/services/agent/index.ts +149 -0
  130. package/src/services/agent/types.ts +440 -0
  131. package/src/services/config/Util.ts +261 -0
  132. package/src/services/config/constants.ts +249 -0
  133. package/src/services/config/index.ts +743 -0
  134. package/src/services/config/types.ts +1117 -0
  135. package/src/services/constants.ts +111 -0
  136. package/src/services/core/Err.ts +126 -0
  137. package/src/services/core/GlobalTypes.ts +34 -0
  138. package/src/services/core/Utils.ts +132 -0
  139. package/src/services/core/WebexRequest.ts +103 -0
  140. package/src/services/core/aqm-reqs.ts +272 -0
  141. package/src/services/core/constants.ts +106 -0
  142. package/src/services/core/types.ts +48 -0
  143. package/src/services/core/websocket/WebSocketManager.ts +196 -0
  144. package/src/services/core/websocket/connection-service.ts +142 -0
  145. package/src/services/core/websocket/keepalive.worker.js +88 -0
  146. package/src/services/core/websocket/types.ts +40 -0
  147. package/src/services/index.ts +71 -0
  148. package/src/services/task/AutoWrapup.ts +86 -0
  149. package/src/services/task/TaskManager.ts +420 -0
  150. package/src/services/task/constants.ts +52 -0
  151. package/src/services/task/contact.ts +429 -0
  152. package/src/services/task/dialer.ts +52 -0
  153. package/src/services/task/index.ts +1375 -0
  154. package/src/services/task/types.ts +1113 -0
  155. package/src/types.ts +639 -0
  156. package/src/webex-config.ts +54 -0
  157. package/src/webex.js +96 -0
  158. package/test/unit/spec/cc.ts +1985 -0
  159. package/test/unit/spec/metrics/MetricsManager.ts +491 -0
  160. package/test/unit/spec/metrics/behavioral-events.ts +102 -0
  161. package/test/unit/spec/services/WebCallingService.ts +416 -0
  162. package/test/unit/spec/services/agent/index.ts +65 -0
  163. package/test/unit/spec/services/config/index.ts +1035 -0
  164. package/test/unit/spec/services/core/Utils.ts +279 -0
  165. package/test/unit/spec/services/core/WebexRequest.ts +144 -0
  166. package/test/unit/spec/services/core/aqm-reqs.ts +570 -0
  167. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +378 -0
  168. package/test/unit/spec/services/core/websocket/connection-service.ts +178 -0
  169. package/test/unit/spec/services/task/TaskManager.ts +1351 -0
  170. package/test/unit/spec/services/task/contact.ts +204 -0
  171. package/test/unit/spec/services/task/dialer.ts +157 -0
  172. package/test/unit/spec/services/task/index.ts +1474 -0
  173. package/tsconfig.json +6 -0
  174. package/typedoc.json +37 -0
  175. package/typedoc.md +240 -0
  176. package/umd/contact-center.min.js +3 -0
  177. package/umd/contact-center.min.js.map +1 -0
package/dist/cc.js ADDED
@@ -0,0 +1,1416 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _webexCore = require("@webex/webex-core");
8
+ var _events = _interopRequireDefault(require("events"));
9
+ var _uuid = require("uuid");
10
+ var _types = require("./types");
11
+ var _constants = require("./constants");
12
+ var _constants2 = require("./services/constants");
13
+ var _services = _interopRequireDefault(require("./services"));
14
+ var _WebexRequest = _interopRequireDefault(require("./services/core/WebexRequest"));
15
+ var _loggerProxy = _interopRequireDefault(require("./logger-proxy"));
16
+ var _types2 = require("./services/agent/types");
17
+ var _Utils = require("./services/core/Utils");
18
+ var _types3 = require("./services/config/types");
19
+ var _constants3 = require("./services/config/constants");
20
+ var _TaskManager = _interopRequireDefault(require("./services/task/TaskManager"));
21
+ var _WebCallingService = _interopRequireDefault(require("./services/WebCallingService"));
22
+ var _types4 = require("./services/task/types");
23
+ var _MetricsManager = _interopRequireDefault(require("./metrics/MetricsManager"));
24
+ var _constants4 = require("./metrics/constants");
25
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
+ /**
27
+ * @module CCPlugin
28
+ * @packageDocumentation
29
+ * Contact Center Plugin module that provides functionality for managing contact center agents,
30
+ * handling tasks, and interacting with contact center services. This module enables integration
31
+ * with Webex Contact Center features through the WebexSDK.
32
+ */
33
+
34
+ /**
35
+ * The main Contact Center plugin class that enables integration with Webex Contact Center.
36
+ *
37
+ * @class ContactCenter
38
+ * @extends WebexPlugin
39
+ * @implements IContactCenter
40
+ * @description
41
+ * Features:
42
+ *
43
+ * 1. Session Management:
44
+ * - {@link register} - Initialize and register SDK with contact center
45
+ * - {@link deregister} - Cleanup and disconnect SDK resources
46
+ *
47
+ * 2. Agent Login/Logout:
48
+ * - {@link stationLogin} - Login with browser or desk phone
49
+ * - {@link stationLogout} - Logout from current station
50
+ * - {@link updateAgentProfile} - Update device type and settings
51
+ *
52
+ * 3. Agent State Control:
53
+ * - {@link setAgentState} - Change agent state (Available/Idle)
54
+ *
55
+ * 4. Task Management:
56
+ * - Inbound task handling via events
57
+ * - {@link startOutdial} - Make outbound calls
58
+ *
59
+ * 5. Routing & Distribution:
60
+ * - {@link getQueues} - Get available queues for routing
61
+ * - {@link getBuddyAgents} - Get available buddy agents
62
+ *
63
+ * 6. Diagnostics:
64
+ * - {@link uploadLogs} - Upload logs for troubleshooting
65
+ *
66
+ * * Key Events:
67
+ * - Agent State Events:
68
+ * - `agent:stateChange` - Agent's state has changed (Available, Idle, etc.)
69
+ * - `agent:stateChangeSuccess` - Agent state change was successful
70
+ * - `agent:stateChangeFailed` - Agent state change failed
71
+ *
72
+ * - Session Events:
73
+ * - `agent:stationLoginSuccess` - Agent login was successful
74
+ * - `agent:stationLoginFailed` - Agent login failed
75
+ * - `agent:logoutSuccess` - Agent logout was successful
76
+ * - `agent:logoutFailed` - Agent logout failed
77
+ *
78
+ * - Task Events:
79
+ * - `task:incoming` - New task is being offered
80
+ * - `task:hydrate` - Task data has been updated
81
+ * - `task:established` - Task/call has been connected
82
+ * - `task:ended` - Task/call has ended
83
+ * - `task:error` - An error occurred during task handling
84
+ *
85
+ * @public
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * import Webex from 'webex';
90
+ *
91
+ * // Initialize SDK with access token
92
+ * const webex = new Webex({
93
+ * credentials: 'YOUR_ACCESS_TOKEN'
94
+ * });
95
+ *
96
+ * // Get Contact Center plugin instance
97
+ * const cc = webex.cc;
98
+ *
99
+ * // Setup event handlers
100
+ * cc.on('agent:stateChange', (event) => {
101
+ * console.log('Agent state changed:', event.state);
102
+ * });
103
+ *
104
+ * cc.on('task:incoming', (task) => {
105
+ * console.log('New task received:', task.interactionId);
106
+ * });
107
+ *
108
+ * // Initialize agent session
109
+ * async function initializeAgent() {
110
+ * try {
111
+ * // Register with contact center
112
+ * const profile = await cc.register();
113
+ *
114
+ * // Login with browser-based calling
115
+ * await cc.stationLogin({
116
+ * teamId: profile.teams[0].teamId,
117
+ * loginOption: 'BROWSER'
118
+ * });
119
+ *
120
+ * // Set agent to Available state
121
+ * await cc.setAgentState({
122
+ * state: 'Available',
123
+ * auxCodeId: '0'
124
+ * });
125
+ *
126
+ * console.log('Agent initialized and ready');
127
+ * } catch (error) {
128
+ * console.error('Initialization failed:', error);
129
+ * await cc.uploadLogs(); // Upload logs for troubleshooting
130
+ * }
131
+ * }
132
+ *
133
+ * initializeAgent();
134
+ * ```
135
+ *
136
+ * @public
137
+ */
138
+ class ContactCenter extends _webexCore.WebexPlugin {
139
+ /**
140
+ * The plugin's unique namespace identifier in the Webex SDK.
141
+ * Used to access the plugin via webex.cc
142
+ * @type {string}
143
+ * @public
144
+ */
145
+ namespace = 'cc';
146
+
147
+ /**
148
+ * Plugin configuration settings including connection and authentication options
149
+ * @type {CCPluginConfig}
150
+ * @private
151
+ */
152
+
153
+ /**
154
+ * Reference to the parent Webex SDK instance
155
+ * Used to access core Webex functionality and credentials
156
+ * @type {WebexSDK}
157
+ * @private
158
+ */
159
+
160
+ /**
161
+ * Event emitter for handling internal plugin events
162
+ * Manages event subscriptions and notifications
163
+ * @type {EventEmitter}
164
+ * @private
165
+ */
166
+
167
+ /**
168
+ * Agent's profile and configuration data
169
+ * Includes capabilities, teams, settings, and current state
170
+ * @type {Profile}
171
+ * @private
172
+ */
173
+
174
+ /**
175
+ * Service for managing browser-based calling (WebRTC)
176
+ * Handles audio/video streaming and device management
177
+ * @type {WebCallingService}
178
+ * @private
179
+ */
180
+
181
+ /**
182
+ * Core service managers for Contact Center operations
183
+ * Includes agent, connection, and configuration services
184
+ * @type {Services}
185
+ * @private
186
+ */
187
+
188
+ /**
189
+ * Service for making authenticated HTTP requests to Webex APIs
190
+ * Handles request/response lifecycle and error handling
191
+ * @type {WebexRequest}
192
+ * @private
193
+ */
194
+
195
+ /**
196
+ * Manager for handling contact center tasks (calls, chats, etc.)
197
+ * Coordinates task lifecycle events and state
198
+ * @type {TaskManager}
199
+ * @private
200
+ */
201
+
202
+ /**
203
+ * Manager for tracking and reporting SDK metrics and analytics
204
+ * Monitors performance, errors, and usage patterns
205
+ * @type {MetricsManager}
206
+ * @private
207
+ */
208
+
209
+ /**
210
+ * Logger utility for Contact Center plugin
211
+ * Provides consistent logging across the plugin
212
+ * @type {LoggerProxy}
213
+ * @public
214
+ */
215
+ LoggerProxy = _loggerProxy.default;
216
+
217
+ /**
218
+ * @ignore
219
+ * Creates an instance of ContactCenter plugin
220
+ * @param {any[]} args Arguments passed to plugin constructor
221
+ */
222
+ constructor(...args) {
223
+ super(...args);
224
+ this.eventEmitter = new _events.default();
225
+ // @ts-ignore
226
+ this.$webex = this.webex;
227
+ this.$webex.once(_constants.READY, () => {
228
+ // @ts-ignore
229
+ this.$config = this.config;
230
+
231
+ /**
232
+ * This is used for handling the async requests by sending webex.request and wait for corresponding websocket event.
233
+ */
234
+ this.webexRequest = _WebexRequest.default.getInstance({
235
+ webex: this.$webex
236
+ });
237
+ this.services = _services.default.getInstance({
238
+ webex: this.$webex,
239
+ connectionConfig: this.getConnectionConfig()
240
+ });
241
+ this.services.webSocketManager.on('message', this.handleWebsocketMessage);
242
+ this.webCallingService = new _WebCallingService.default(this.$webex);
243
+ this.metricsManager = _MetricsManager.default.getInstance({
244
+ webex: this.$webex
245
+ });
246
+ this.taskManager = _TaskManager.default.getTaskManager(this.services.contact, this.webCallingService, this.services.webSocketManager);
247
+ this.incomingTaskListener();
248
+ _loggerProxy.default.initialize(this.$webex.logger);
249
+ });
250
+ }
251
+
252
+ /**
253
+ * Handles incoming task events and triggers appropriate notifications
254
+ * @private
255
+ * @param {ITask} task The incoming task object containing task details
256
+ */
257
+ handleIncomingTask = task => {
258
+ // @ts-ignore
259
+ this.trigger(_types4.TASK_EVENTS.TASK_INCOMING, task);
260
+ };
261
+
262
+ /**
263
+ * Handles task hydration events for updating task data
264
+ * @private
265
+ * @param {ITask} task The task object to be hydrated with additional data
266
+ */
267
+ handleTaskHydrate = task => {
268
+ // @ts-ignore
269
+ this.trigger(_types4.TASK_EVENTS.TASK_HYDRATE, task);
270
+ };
271
+
272
+ /**
273
+ * Sets up event listeners for incoming tasks and task hydration
274
+ * Subscribes to task events from the task manager
275
+ * @private
276
+ */
277
+ incomingTaskListener() {
278
+ this.taskManager.on(_types4.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);
279
+ this.taskManager.on(_types4.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);
280
+ }
281
+
282
+ /**
283
+ * Initializes the Contact Center SDK by setting up the web socket connections.
284
+ * This method must be called before performing any agent operations such as login, state change, or handling tasks.
285
+ *
286
+ * @returns {Promise<Profile>} Agent profile information after successful registration.
287
+ * The returned `Profile` object contains details such as:
288
+ * - `agentId`: The unique identifier for the agent.
289
+ * - `defaultDn`: The default dial number associated with the agent.
290
+ * - `teams`: Array of teams the agent belongs to.
291
+ * - `webRtcEnabled`: Indicates if WebRTC (browser calling) is enabled.
292
+ * - `loginVoiceOptions`: Supported login options for the agent (e.g., BROWSER, EXTENSION).
293
+ * - ...and other agent configuration details.
294
+ *
295
+ * @throws {Error} If registration fails.
296
+ *
297
+ * @public
298
+ * @example
299
+ * ```typescript
300
+ * import Webex from 'webex';
301
+ *
302
+ * const webex = Webex.init({ credentials: 'YOUR_ACCESS_TOKEN' });
303
+ * const cc = webex.cc;
304
+ *
305
+ * // Register the SDK and fetch agent profile
306
+ * const profile = await cc.register();
307
+ *
308
+ * console.log('Agent ID:', profile.agentId);
309
+ * console.log('Default DN:', profile.defaultDn);
310
+ * console.log('Teams:', profile.teams.map(t => t.teamId));
311
+ * console.log('WebRTC Enabled:', profile.webRtcEnabled);
312
+ * console.log('Supported Login Options:', profile.loginVoiceOptions);
313
+ *
314
+ * // Now you can proceed with station login, state changes, etc.
315
+ * await cc.stationLogin({ teamId: profile.teams[0].teamId, loginOption: 'BROWSER' });
316
+ * ```
317
+ */
318
+ async register() {
319
+ _loggerProxy.default.info('Starting CC SDK registration', {
320
+ module: _constants.CC_FILE,
321
+ method: _constants.METHODS.REGISTER
322
+ });
323
+ try {
324
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_SUCCESS, _constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_FAILED]);
325
+ this.setupEventListeners();
326
+ const resp = await this.connectWebsocket();
327
+ // Ensure 'dn' is always populated from 'defaultDn'
328
+ resp.dn = resp.defaultDn;
329
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_SUCCESS, {
330
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),
331
+ deviceType: resp.deviceType || _constants.EMPTY_STRING
332
+ }, ['operational']);
333
+ _loggerProxy.default.log(`CC SDK registration completed successfully with agentId: ${resp.agentId}`, {
334
+ module: _constants.CC_FILE,
335
+ method: _constants.METHODS.REGISTER
336
+ });
337
+ return resp;
338
+ } catch (error) {
339
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_FAILED, {
340
+ orgId: error.orgId
341
+ }, ['operational']);
342
+ _loggerProxy.default.error(`Error during register: ${error}`, {
343
+ module: _constants.CC_FILE,
344
+ method: _constants.METHODS.REGISTER
345
+ });
346
+ this.webexRequest.uploadLogs({
347
+ correlationId: error?.trackingId
348
+ });
349
+ throw error;
350
+ }
351
+ }
352
+
353
+ /**
354
+ * Unregisters the Contact Center SDK by closing all web socket connections, removing event listeners,
355
+ * and cleaning up internal state.
356
+ *
357
+ * @remarks
358
+ * This method only disconnects the SDK from the backend and cleans up resources. It does NOT perform a station logout
359
+ * (i.e., the agent remains logged in to the contact center unless you explicitly call {@link stationLogout}).
360
+ * Use this when you want to fully tear down the SDK instance, such as during application shutdown or user sign-out.
361
+ *
362
+ * @returns {Promise<void>} Resolves when deregistration and cleanup are complete.
363
+ * @throws {Error} If deregistration fails.
364
+ *
365
+ * @public
366
+ * @example
367
+ * // Typical usage: clean up SDK before application exit or user logout
368
+ * import Webex from 'webex';
369
+ *
370
+ * const webex = Webex.init({ credentials: 'YOUR_ACCESS_TOKEN' });
371
+ * const cc = webex.cc;
372
+ *
373
+ * await cc.register();
374
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
375
+ * // ... perform agent operations ...
376
+ *
377
+ * // If you want to log out the agent as well, call:
378
+ * // await cc.stationLogout({ logoutReason: 'User signed out' });
379
+ * // On application shutdown or user sign-out:
380
+ * await cc.deregister();
381
+ *
382
+ */
383
+ async deregister() {
384
+ try {
385
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.WEBSOCKET_DEREGISTER_SUCCESS, _constants4.METRIC_EVENT_NAMES.WEBSOCKET_DEREGISTER_FAIL]);
386
+ this.taskManager.off(_types4.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);
387
+ this.taskManager.off(_types4.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);
388
+ this.taskManager.unregisterIncomingCallEvent();
389
+ this.services.webSocketManager.off('message', this.handleWebsocketMessage);
390
+ this.services.connectionService.off('connectionLost', this.handleConnectionLost);
391
+ if (this.agentConfig.webRtcEnabled && this.agentConfig.loginVoiceOptions.includes(_types.LoginOption.BROWSER)) {
392
+ if (this.$webex.internal.mercury.connected) {
393
+ this.$webex.internal.mercury.off('online');
394
+ this.$webex.internal.mercury.off('offline');
395
+ await this.$webex.internal.mercury.disconnect();
396
+ // @ts-ignore
397
+ await this.$webex.internal.device.unregister();
398
+ _loggerProxy.default.log(_constants.MERCURY_DISCONNECTED_SUCCESS, {
399
+ module: _constants.CC_FILE,
400
+ method: _constants.METHODS.DEREGISTER
401
+ });
402
+ }
403
+ }
404
+ if (!this.services.webSocketManager.isSocketClosed) {
405
+ this.services.webSocketManager.close(false, 'Unregistering the SDK');
406
+ }
407
+
408
+ // Clear any cached agent configuration
409
+ this.agentConfig = null;
410
+ _loggerProxy.default.log('Deregistered successfully', {
411
+ module: _constants.CC_FILE,
412
+ method: _constants.METHODS.DEREGISTER
413
+ });
414
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WEBSOCKET_DEREGISTER_SUCCESS, {}, ['operational']);
415
+ } catch (error) {
416
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WEBSOCKET_DEREGISTER_FAIL, {
417
+ error: error.message || _constants.UNKNOWN_ERROR
418
+ }, ['operational']);
419
+ _loggerProxy.default.error(`Error during deregister: ${error}`, {
420
+ module: _constants.CC_FILE,
421
+ method: _constants.METHODS.DEREGISTER
422
+ });
423
+ throw error;
424
+ }
425
+ }
426
+
427
+ /**
428
+ * Returns the list of buddy agents who are in the given user state and media type based on their agent profile settings
429
+ * @param {BuddyAgents} data The data required to fetch buddy agents
430
+ * @returns {Promise<BuddyAgentsResponse>} A promise resolving to the buddy agents information
431
+ * @throws {Error} If fetching buddy agents fails
432
+ * @example
433
+ * ```typescript
434
+ * // Get list of available agents for consultation or transfer
435
+ * const cc = webex.cc;
436
+ *
437
+ * // First ensure you're registered and logged in
438
+ * await cc.register();
439
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
440
+ *
441
+ * // Get buddy agents filtered by state and media type
442
+ * const response = await cc.getBuddyAgents({
443
+ * state: 'Available', // Filter by agent state ('Available', 'Idle', etc.)
444
+ * mediaType: 'telephony' // Filter by media type ('telephony', 'chat', 'email', 'social')
445
+ * });
446
+ *
447
+ * // Process the buddy agents list
448
+ * if (response.data.agentList.length > 0) {
449
+ * const buddyAgents = response.data.agentList;
450
+ * console.log(`Found ${buddyAgents.length} available agents`);
451
+ *
452
+ * // Access agent details
453
+ * buddyAgents.forEach(agent => {
454
+ * console.log(`Agent ID: ${agent.agentId}`);
455
+ * console.log(`Name: ${agent.firstName} ${agent.lastName}`);
456
+ * console.log(`State: ${agent.state}`);
457
+ * console.log(`Team: ${agent.teamName}`);
458
+ * });
459
+ * }
460
+ * ```
461
+ */
462
+ async getBuddyAgents(data) {
463
+ _loggerProxy.default.info('Fetching buddy agents', {
464
+ module: _constants.CC_FILE,
465
+ method: _constants.METHODS.GET_BUDDY_AGENTS
466
+ });
467
+ try {
468
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_SUCCESS, _constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_FAILED]);
469
+ const resp = await this.services.agent.buddyAgents({
470
+ data: {
471
+ agentProfileId: this.agentConfig.agentProfileID,
472
+ ...data
473
+ }
474
+ });
475
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_SUCCESS, {
476
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),
477
+ mediaType: data.mediaType,
478
+ buddyAgentState: data.state,
479
+ buddyAgentCount: resp.data.agentList.length
480
+ }, ['operational']);
481
+ _loggerProxy.default.log(`Successfully retrieved ${resp.data.agentList.length} buddy agents`, {
482
+ module: _constants.CC_FILE,
483
+ method: _constants.METHODS.GET_BUDDY_AGENTS,
484
+ trackingId: resp.trackingId
485
+ });
486
+ return resp;
487
+ } catch (error) {
488
+ const failureResp = error.details;
489
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_FAILED, {
490
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failureResp),
491
+ mediaType: data.mediaType,
492
+ buddyAgentState: data.state
493
+ }, ['operational']);
494
+ const {
495
+ error: detailedError
496
+ } = (0, _Utils.getErrorDetails)(error, _constants.METHODS.GET_BUDDY_AGENTS, _constants.CC_FILE);
497
+ throw detailedError;
498
+ }
499
+ }
500
+
501
+ /**
502
+ * Connects to the websocket and fetches the agent profile
503
+ * @returns {Promise<Profile>} Agent profile information
504
+ * @throws {Error} If connection fails or profile cannot be fetched
505
+ * @private
506
+ */
507
+ async connectWebsocket() {
508
+ _loggerProxy.default.info('Connecting to websocket', {
509
+ module: _constants.CC_FILE,
510
+ method: _constants.METHODS.CONNECT_WEBSOCKET
511
+ });
512
+ try {
513
+ return this.services.webSocketManager.initWebSocket({
514
+ body: this.getConnectionConfig()
515
+ }).then(async data => {
516
+ const agentId = data.agentId;
517
+ const orgId = this.$webex.credentials.getOrgId();
518
+ this.agentConfig = await this.services.config.getAgentConfig(orgId, agentId);
519
+ _loggerProxy.default.log(`Agent config is fetched successfully`, {
520
+ module: _constants.CC_FILE,
521
+ method: _constants.METHODS.CONNECT_WEBSOCKET
522
+ });
523
+ // TODO: Make profile a singleton to make it available throughout app/sdk so we dont need to inject info everywhere
524
+ this.taskManager.setWrapupData(this.agentConfig.wrapUpData);
525
+ if (this.agentConfig.webRtcEnabled && this.agentConfig.loginVoiceOptions.includes(_types.LoginOption.BROWSER)) {
526
+ this.$webex.internal.mercury.connect().then(() => {
527
+ _loggerProxy.default.log('Authentication: webex.internal.mercury.connect successful', {
528
+ module: _constants.CC_FILE,
529
+ method: _constants.METHODS.CONNECT_WEBSOCKET
530
+ });
531
+ }).catch(error => {
532
+ _loggerProxy.default.error(`Error occurred during mercury.connect() ${error}`, {
533
+ module: _constants.CC_FILE,
534
+ method: _constants.METHODS.CONNECT_WEBSOCKET
535
+ });
536
+ });
537
+ }
538
+ if (this.$config && this.$config.allowAutomatedRelogin) {
539
+ await this.silentRelogin();
540
+ }
541
+ return this.agentConfig;
542
+ }).catch(error => {
543
+ throw error;
544
+ });
545
+ } catch (error) {
546
+ _loggerProxy.default.error(`Error during register: ${error}`, {
547
+ module: _constants.CC_FILE,
548
+ method: _constants.METHODS.CONNECT_WEBSOCKET
549
+ });
550
+ throw error;
551
+ }
552
+ }
553
+
554
+ /**
555
+ * Performs agent login with specified credentials and device type
556
+ * @param {AgentLogin} data Login parameters including teamId, loginOption and dialNumber
557
+ * @returns {Promise<StationLoginResponse>} Response containing login status and profile
558
+ * @throws {Error} If login fails
559
+ * @public
560
+ * @example
561
+ * ```typescript
562
+ * const cc = webex.cc;
563
+ * await cc.register();
564
+ *
565
+ * // Primary usage: using Promise response
566
+ * try {
567
+ * const response = await cc.stationLogin({
568
+ * teamId: 'team123',
569
+ * loginOption: 'EXTENSION',
570
+ * dialNumber: '1002'
571
+ * });
572
+ * console.log('Login successful:', response);
573
+ * } catch (error) {
574
+ * console.error('Login failed:', error);
575
+ * }
576
+ *
577
+ * // Optional: Also listen for events elsewhere in your application
578
+ * // cc.on('agent:stationLoginSuccess', (data) => { ... });
579
+ * // cc.on('agent:stationLoginFailed', (error) => { ... });
580
+ * ```
581
+ */
582
+ async stationLogin(data) {
583
+ _loggerProxy.default.info('Starting agent station login', {
584
+ module: _constants.CC_FILE,
585
+ method: _constants.METHODS.STATION_LOGIN
586
+ });
587
+ try {
588
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.STATION_LOGIN_SUCCESS, _constants4.METRIC_EVENT_NAMES.STATION_LOGIN_FAILED]);
589
+ if (data.loginOption === _types.LoginOption.AGENT_DN && !(0, _Utils.isValidDialNumber)(data.dialNumber)) {
590
+ const error = new Error('INVALID_DIAL_NUMBER');
591
+ // @ts-ignore - adding custom key to the error object
592
+ error.details = {
593
+ data: {
594
+ reason: 'INVALID_DIAL_NUMBER'
595
+ }
596
+ };
597
+ throw error;
598
+ }
599
+ const loginResponse = this.services.agent.stationLogin({
600
+ data: {
601
+ dialNumber: data.loginOption === _types.LoginOption.BROWSER ? this.agentConfig.agentId : data.dialNumber,
602
+ teamId: data.teamId,
603
+ deviceType: data.loginOption,
604
+ isExtension: data.loginOption === _types.LoginOption.EXTENSION,
605
+ deviceId: this.getDeviceId(data.loginOption, data.dialNumber),
606
+ roles: [_constants2.AGENT],
607
+ teamName: _constants.EMPTY_STRING,
608
+ siteId: _constants.EMPTY_STRING,
609
+ usesOtherDN: false,
610
+ auxCodeId: _constants.EMPTY_STRING
611
+ }
612
+ });
613
+ if (this.agentConfig.webRtcEnabled && data.loginOption === _types.LoginOption.BROWSER) {
614
+ await this.webCallingService.registerWebCallingLine();
615
+ }
616
+ const resp = await loginResponse;
617
+ const {
618
+ channelsMap,
619
+ ...loginData
620
+ } = resp.data;
621
+ this.agentConfig.currentTeamId = resp.data.teamId;
622
+ const response = {
623
+ ...loginData,
624
+ mmProfile: {
625
+ chat: channelsMap.chat?.length,
626
+ email: channelsMap.email?.length,
627
+ social: channelsMap.social?.length,
628
+ telephony: channelsMap.telephony?.length
629
+ },
630
+ notifsTrackingId: resp.trackingId
631
+ };
632
+ this.webCallingService.setLoginOption(data.loginOption);
633
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGIN_SUCCESS, {
634
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),
635
+ loginType: data.loginOption,
636
+ status: resp.data.status,
637
+ type: resp.data.type,
638
+ roles: resp.data.roles?.join(',') || _constants.EMPTY_STRING
639
+ }, ['behavioral', 'business', 'operational']);
640
+ _loggerProxy.default.log(`Agent station login completed successfully agentId: ${resp.data.agentId} loginOption: ${data.loginOption} teamId: ${data.teamId}`, {
641
+ module: _constants.CC_FILE,
642
+ method: _constants.METHODS.STATION_LOGIN,
643
+ trackingId: resp.trackingId
644
+ });
645
+ return response;
646
+ } catch (error) {
647
+ const failure = error.details;
648
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGIN_FAILED, {
649
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),
650
+ loginType: data.loginOption
651
+ }, ['behavioral', 'business', 'operational']);
652
+ error.loginOption = data.loginOption;
653
+ const {
654
+ error: detailedError
655
+ } = (0, _Utils.getErrorDetails)(error, _constants.METHODS.STATION_LOGIN, _constants.CC_FILE);
656
+ throw detailedError;
657
+ }
658
+ }
659
+
660
+ /**
661
+ * Performs a station logout operation for the agent
662
+ * @remarks
663
+ * A logout operation cannot happen if the agent is in an interaction or haven't logged in yet.
664
+ * @param {Logout} data Logout parameters with logoutReason - a string explaining why the agent is logging out
665
+ * @returns {Promise<StationLogoutResponse>} Response indicating logout status
666
+ * @throws {Error} If logout fails
667
+ * @public
668
+ * @example
669
+ * ```typescript
670
+ * // Basic logout
671
+ * try {
672
+ * await cc.stationLogout({
673
+ * logoutReason: 'End of shift'
674
+ * });
675
+ * console.log('Logged out successfully');
676
+ * } catch (error) {
677
+ * console.error('Logout failed:', error);
678
+ * }
679
+ * ```
680
+ */
681
+ async stationLogout(data) {
682
+ _loggerProxy.default.info('Starting agent station logout', {
683
+ module: _constants.CC_FILE,
684
+ method: _constants.METHODS.STATION_LOGOUT
685
+ });
686
+ try {
687
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_SUCCESS, _constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_FAILED]);
688
+ const logoutResponse = this.services.agent.logout({
689
+ data
690
+ });
691
+ const resp = await logoutResponse;
692
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_SUCCESS, {
693
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),
694
+ logoutReason: data.logoutReason
695
+ }, ['behavioral', 'business', 'operational']);
696
+ if (this.webCallingService) {
697
+ this.webCallingService.deregisterWebCallingLine();
698
+ }
699
+ _loggerProxy.default.log(`Agent station logout completed successfully`, {
700
+ module: _constants.CC_FILE,
701
+ method: _constants.METHODS.STATION_LOGOUT,
702
+ trackingId: resp.trackingId
703
+ });
704
+ return resp;
705
+ } catch (error) {
706
+ const failure = error.details;
707
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_FAILED, {
708
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),
709
+ logoutReason: data.logoutReason
710
+ }, ['behavioral', 'business', 'operational']);
711
+ const {
712
+ error: detailedError
713
+ } = (0, _Utils.getErrorDetails)(error, _constants.METHODS.STATION_LOGOUT, _constants.CC_FILE);
714
+ throw detailedError;
715
+ }
716
+ }
717
+
718
+ /**
719
+ * Gets the device ID based on login option and dial number
720
+ * @param {string} loginOption The login option (BROWSER, EXTENSION, etc)
721
+ * @param {string} dialNumber The dial number if applicable
722
+ * @returns {string} The device ID
723
+ * @private
724
+ */
725
+ getDeviceId(loginOption, dialNumber) {
726
+ if (loginOption === _types.LoginOption.EXTENSION || loginOption === _types.LoginOption.AGENT_DN) {
727
+ return dialNumber;
728
+ }
729
+ return _constants2.WEB_RTC_PREFIX + this.agentConfig.agentId;
730
+ }
731
+
732
+ /**
733
+ * Sets the state of the agent to Available or any of the Idle states.
734
+ * After a state change attempt, one of the following events will be emitted:
735
+ * - agent:stateChange: Emitted when agent's state changes (triggered for both local and remote changes)
736
+ * - agent:stateChangeSuccess: Emitted when agent state change is successful
737
+ * - agent:stateChangeFailed: Emitted when agent state change attempt fails
738
+ *
739
+ * @param {StateChange} data State change parameters including the new state
740
+ * @returns {Promise<SetStateResponse>} Response with updated state information
741
+ * @throws {Error} If state change fails
742
+ * @public
743
+ * @example
744
+ * ```typescript
745
+ * const cc = webex.cc;
746
+ * await cc.register();
747
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
748
+ *
749
+ * // Using promise-based approach
750
+ * try {
751
+ * await cc.setAgentState({
752
+ * state: 'Available',
753
+ * auxCodeId: '12345',
754
+ * lastStateChangeReason: 'Manual state change',
755
+ * agentId: 'agent123',
756
+ * });
757
+ * } catch (error) {
758
+ * console.error('State change failed:', error);
759
+ * }
760
+ *
761
+ * // Optionally, listen for events
762
+ * cc.on('agent:stateChange', (eventData) => {
763
+ * // Triggered for both local and remote state changes
764
+ * console.log('State changed:', eventData);
765
+ * });
766
+ *
767
+ * cc.on('agent:stateChangeSuccess', (eventData) => {
768
+ * console.log('State change succeeded:', eventData);
769
+ * });
770
+ *
771
+ * cc.on('agent:stateChangeFailed', (error) => {
772
+ * console.error('State change failed:', error);
773
+ * });
774
+ * ```
775
+ */
776
+ async setAgentState(data) {
777
+ _loggerProxy.default.info('Setting agent state', {
778
+ module: _constants.CC_FILE,
779
+ method: _constants.METHODS.SET_AGENT_STATE
780
+ });
781
+ try {
782
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_SUCCESS, _constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_FAILED]);
783
+ const agentStatusResponse = await this.services.agent.stateChange({
784
+ data: {
785
+ ...data,
786
+ agentId: data.agentId || this.agentConfig.agentId
787
+ }
788
+ });
789
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_SUCCESS, {
790
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(agentStatusResponse),
791
+ requestedState: data.state,
792
+ teamId: this.agentConfig?.teams[0]?.teamId ?? _constants.EMPTY_STRING,
793
+ status: agentStatusResponse.data?.status,
794
+ subStatus: agentStatusResponse.data?.subStatus,
795
+ auxCodeId: data.auxCodeId,
796
+ lastStateChangeReason: data.lastStateChangeReason || _constants.EMPTY_STRING
797
+ }, ['behavioral', 'business', 'operational']);
798
+ _loggerProxy.default.log(`Agent state changed successfully to auxCodeId: ${agentStatusResponse.data.auxCodeId}`, {
799
+ module: _constants.CC_FILE,
800
+ method: _constants.METHODS.SET_AGENT_STATE,
801
+ trackingId: agentStatusResponse.trackingId
802
+ });
803
+ return agentStatusResponse;
804
+ } catch (error) {
805
+ const failure = error.details;
806
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_FAILED, {
807
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),
808
+ state: data.state,
809
+ auxCodeId: data.auxCodeId,
810
+ lastStateChangeReason: data.lastStateChangeReason || _constants.EMPTY_STRING
811
+ }, ['behavioral', 'business', 'operational']);
812
+ const {
813
+ error: detailedError
814
+ } = (0, _Utils.getErrorDetails)(error, _constants.METHODS.SET_AGENT_STATE, _constants.CC_FILE);
815
+ throw detailedError;
816
+ }
817
+ }
818
+
819
+ /**
820
+ * Processes incoming websocket messages and emits corresponding events
821
+ * Handles various event types including agent state changes, login events,
822
+ * and other agent-related notifications
823
+ * @private
824
+ * @param {string} event The raw websocket event message
825
+ */
826
+ handleWebsocketMessage = event => {
827
+ const eventData = JSON.parse(event);
828
+ // Re-emit all the events related to agent except keep-alives
829
+ if (!eventData.keepalive && eventData.data && eventData.data.type) {
830
+ // @ts-ignore
831
+ this.emit(eventData.data.type, eventData.data);
832
+ }
833
+ if (!eventData.type) {
834
+ return;
835
+ }
836
+ _loggerProxy.default.log(`Received event: ${eventData.type}`, {
837
+ module: _constants.CC_FILE,
838
+ method: _constants.METHODS.HANDLE_WEBSOCKET_MESSAGE
839
+ });
840
+ switch (eventData.type) {
841
+ case _types3.CC_EVENTS.AGENT_MULTI_LOGIN:
842
+ // @ts-ignore
843
+ this.emit(_types2.AGENT_EVENTS.AGENT_MULTI_LOGIN, eventData.data);
844
+ break;
845
+ case _types3.CC_EVENTS.AGENT_STATE_CHANGE:
846
+ // @ts-ignore
847
+ this.emit(_types2.AGENT_EVENTS.AGENT_STATE_CHANGE, eventData.data);
848
+ break;
849
+ default:
850
+ break;
851
+ }
852
+ if (!(eventData.data && eventData.data.type)) {
853
+ return;
854
+ }
855
+ switch (eventData.data.type) {
856
+ case _types3.CC_EVENTS.AGENT_STATION_LOGIN_SUCCESS:
857
+ {
858
+ const {
859
+ channelsMap,
860
+ ...loginData
861
+ } = eventData.data;
862
+ const stationLoginData = {
863
+ ...loginData,
864
+ mmProfile: {
865
+ chat: channelsMap.chat?.length,
866
+ email: channelsMap.email?.length,
867
+ social: channelsMap.social?.length,
868
+ telephony: channelsMap.telephony?.length
869
+ },
870
+ notifsTrackingId: eventData.trackingId
871
+ };
872
+ this.webCallingService.setLoginOption(loginData.deviceType);
873
+ // @ts-ignore
874
+ this.emit(_types2.AGENT_EVENTS.AGENT_STATION_LOGIN_SUCCESS, stationLoginData);
875
+ break;
876
+ }
877
+ case _types3.CC_EVENTS.AGENT_RELOGIN_SUCCESS:
878
+ {
879
+ const {
880
+ channelsMap,
881
+ ...loginData
882
+ } = eventData.data;
883
+ const stationReLoginData = {
884
+ ...loginData,
885
+ mmProfile: {
886
+ chat: channelsMap.chat?.length,
887
+ email: channelsMap.email?.length,
888
+ social: channelsMap.social?.length,
889
+ telephony: channelsMap.telephony?.length
890
+ },
891
+ notifsTrackingId: eventData.trackingId
892
+ };
893
+ // @ts-ignore
894
+ this.emit(_types2.AGENT_EVENTS.AGENT_RELOGIN_SUCCESS, stationReLoginData);
895
+ }
896
+ break;
897
+ case _types3.CC_EVENTS.AGENT_STATE_CHANGE_SUCCESS:
898
+ // @ts-ignore
899
+ this.emit(_types2.AGENT_EVENTS.AGENT_STATE_CHANGE_SUCCESS, eventData.data);
900
+ break;
901
+ case _types3.CC_EVENTS.AGENT_STATE_CHANGE_FAILED:
902
+ // @ts-ignore
903
+ this.emit(_types2.AGENT_EVENTS.AGENT_STATE_CHANGE_FAILED, eventData.data);
904
+ break;
905
+ case _types3.CC_EVENTS.AGENT_STATION_LOGIN_FAILED:
906
+ // @ts-ignore
907
+ this.emit(_types2.AGENT_EVENTS.AGENT_STATION_LOGIN_FAILED, eventData.data);
908
+ break;
909
+ case _types3.CC_EVENTS.AGENT_LOGOUT_SUCCESS:
910
+ // @ts-ignore
911
+ this.emit(_types2.AGENT_EVENTS.AGENT_LOGOUT_SUCCESS, eventData.data);
912
+ break;
913
+ case _types3.CC_EVENTS.AGENT_LOGOUT_FAILED:
914
+ // @ts-ignore
915
+ this.emit(_types2.AGENT_EVENTS.AGENT_LOGOUT_FAILED, eventData.data);
916
+ break;
917
+ case _types3.CC_EVENTS.AGENT_DN_REGISTERED:
918
+ // @ts-ignore
919
+ this.emit(_types2.AGENT_EVENTS.AGENT_DN_REGISTERED, eventData.data);
920
+ break;
921
+ default:
922
+ break;
923
+ }
924
+ };
925
+
926
+ /**
927
+ * Initializes event listeners for the Contact Center service
928
+ * Sets up handlers for connection state changes and other core events
929
+ * @private
930
+ */
931
+ setupEventListeners() {
932
+ this.services.connectionService.on('connectionLost', this.handleConnectionLost.bind(this));
933
+ }
934
+
935
+ /**
936
+ * Returns the connection configuration
937
+ * @returns {SubscribeRequest} Connection configuration
938
+ * @private
939
+ */
940
+ getConnectionConfig() {
941
+ return {
942
+ force: this.$config?.force ?? true,
943
+ isKeepAliveEnabled: this.$config?.isKeepAliveEnabled ?? false,
944
+ clientType: this.$config?.clientType ?? 'WebexCCSDK',
945
+ allowMultiLogin: this.$config?.allowMultiLogin ?? true
946
+ };
947
+ }
948
+
949
+ /**
950
+ * Handles connection lost events and reconnection attempts
951
+ * @param {ConnectionLostDetails} msg Connection lost details
952
+ * @private
953
+ */
954
+ async handleConnectionLost(msg) {
955
+ if (msg.isConnectionLost) {
956
+ // TODO: Emit an event saying connection is lost
957
+ _loggerProxy.default.info('event=handleConnectionLost | Connection lost', {
958
+ module: _constants.CC_FILE,
959
+ method: _constants.METHODS.HANDLE_CONNECTION_LOST
960
+ });
961
+ } else if (msg.isSocketReconnected) {
962
+ // TODO: Emit an event saying connection is re-estabilished
963
+ _loggerProxy.default.info('event=handleConnectionReconnect | Connection reconnected attempting to request silent relogin', {
964
+ module: _constants.CC_FILE,
965
+ method: _constants.METHODS.HANDLE_CONNECTION_LOST
966
+ });
967
+ if (this.$config && this.$config.allowAutomatedRelogin) {
968
+ await this.silentRelogin();
969
+ }
970
+ }
971
+ }
972
+
973
+ /**
974
+ * Handles silent relogin after registration completion
975
+ * @private
976
+ */
977
+ async silentRelogin() {
978
+ _loggerProxy.default.info('Starting silent relogin process', {
979
+ module: _constants.CC_FILE,
980
+ method: _constants.METHODS.SILENT_RELOGIN
981
+ });
982
+ try {
983
+ const reLoginResponse = await this.services.agent.reload();
984
+ const {
985
+ agentId,
986
+ lastStateChangeReason,
987
+ deviceType,
988
+ dn,
989
+ lastStateChangeTimestamp,
990
+ lastIdleCodeChangeTimestamp
991
+ } = reLoginResponse.data;
992
+ let {
993
+ auxCodeId
994
+ } = reLoginResponse.data;
995
+ this.agentConfig.lastStateChangeTimestamp = lastStateChangeTimestamp;
996
+ this.agentConfig.lastIdleCodeChangeTimestamp = lastIdleCodeChangeTimestamp;
997
+ this.agentConfig.currentTeamId = reLoginResponse.data.teamId;
998
+ await this.handleDeviceType(deviceType, dn);
999
+ if (lastStateChangeReason === 'agent-wss-disconnect') {
1000
+ _loggerProxy.default.info('event=requestAutoStateChange | Requesting state change to available on socket reconnect', {
1001
+ module: _constants.CC_FILE,
1002
+ method: _constants.METHODS.SILENT_RELOGIN
1003
+ });
1004
+ auxCodeId = _constants3.AGENT_STATE_AVAILABLE_ID;
1005
+ const stateChangeData = {
1006
+ state: _constants3.AGENT_STATE_AVAILABLE,
1007
+ auxCodeId,
1008
+ lastStateChangeReason,
1009
+ agentId
1010
+ };
1011
+ try {
1012
+ const agentStatusResponse = await this.setAgentState(stateChangeData);
1013
+ this.agentConfig.lastStateChangeTimestamp = agentStatusResponse.data.lastStateChangeTimestamp;
1014
+ this.agentConfig.lastIdleCodeChangeTimestamp = agentStatusResponse.data.lastIdleCodeChangeTimestamp;
1015
+ } catch (error) {
1016
+ _loggerProxy.default.error(`event=requestAutoStateChange | Error requesting state change to available on socket reconnect: ${error}`, {
1017
+ module: _constants.CC_FILE,
1018
+ method: _constants.METHODS.SILENT_RELOGIN
1019
+ });
1020
+ }
1021
+ }
1022
+ this.agentConfig.lastStateAuxCodeId = auxCodeId;
1023
+ this.agentConfig.isAgentLoggedIn = true;
1024
+ // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there
1025
+ this.services.webSocketManager.on('message', this.handleWebsocketMessage);
1026
+ _loggerProxy.default.log(`Silent relogin process completed successfully with login Option: ${reLoginResponse.data.deviceType} teamId: ${reLoginResponse.data.teamId}`, {
1027
+ module: _constants.CC_FILE,
1028
+ method: _constants.METHODS.SILENT_RELOGIN,
1029
+ trackingId: reLoginResponse.trackingId
1030
+ });
1031
+ } catch (error) {
1032
+ const {
1033
+ reason,
1034
+ error: detailedError
1035
+ } = (0, _Utils.getErrorDetails)(error, _constants.METHODS.SILENT_RELOGIN, _constants.CC_FILE);
1036
+ if (reason === 'AGENT_NOT_FOUND') {
1037
+ _loggerProxy.default.log('Agent not found during relogin, handling silently', {
1038
+ module: _constants.CC_FILE,
1039
+ method: _constants.METHODS.SILENT_RELOGIN
1040
+ });
1041
+ return;
1042
+ }
1043
+ throw detailedError;
1044
+ }
1045
+ }
1046
+
1047
+ /**
1048
+ * Handles device type specific configuration and setup
1049
+ * Configures services and settings based on the login device type
1050
+ * @param {LoginOption} deviceType The type of device being used for login
1051
+ * @param {string} dn The dial number associated with the device
1052
+ * @returns {Promise<void>}
1053
+ * @private
1054
+ */
1055
+ async handleDeviceType(deviceType, dn) {
1056
+ this.webCallingService.setLoginOption(deviceType);
1057
+ this.agentConfig.deviceType = deviceType;
1058
+ switch (deviceType) {
1059
+ case _types.LoginOption.BROWSER:
1060
+ try {
1061
+ await this.webCallingService.registerWebCallingLine();
1062
+ } catch (error) {
1063
+ _loggerProxy.default.error(`Error registering web calling line: ${error}`, {
1064
+ module: _constants.CC_FILE,
1065
+ method: _constants.METHODS.HANDLE_DEVICE_TYPE
1066
+ });
1067
+ throw error;
1068
+ }
1069
+ break;
1070
+ case _types.LoginOption.AGENT_DN:
1071
+ case _types.LoginOption.EXTENSION:
1072
+ this.agentConfig.defaultDn = dn;
1073
+ this.agentConfig.dn = dn;
1074
+ break;
1075
+ default:
1076
+ _loggerProxy.default.error(`Unsupported device type: ${deviceType}`, {
1077
+ module: _constants.CC_FILE,
1078
+ method: _constants.METHODS.HANDLE_DEVICE_TYPE
1079
+ });
1080
+ throw new Error(`Unsupported device type: ${deviceType}`);
1081
+ }
1082
+ }
1083
+
1084
+ /**
1085
+ * Makes an outbound call to a specified phone number.
1086
+ *
1087
+ * @param {string} destination - The phone number to dial (e.g., '+1234567890').
1088
+ * Should include country code and be in E.164 format.
1089
+ * @returns {Promise<TaskResponse>} Resolves with the task response containing:
1090
+ * - interactionId: Unique identifier for the outbound call
1091
+ * - taskId: Identifier for the task instance
1092
+ * - data: Task details including state, queue info, and media properties
1093
+ * @throws {Error} If the outdial operation fails:
1094
+ * - "Agent not configured for outbound calls" if isOutboundEnabledForAgent is false
1095
+ * - "Invalid phone number format" if destination is not in E.164 format
1096
+ * - "Agent not in Available state" if agent's state is not Available
1097
+ * @public
1098
+ * @example
1099
+ * ```typescript
1100
+ * // Initialize and prepare agent
1101
+ * const cc = webex.cc;
1102
+ * await cc.register();
1103
+ * await cc.stationLogin({
1104
+ * teamId: 'team123',
1105
+ * loginOption: 'BROWSER'
1106
+ * });
1107
+ *
1108
+ * // Set Available state before outbound call
1109
+ * await cc.setAgentState({
1110
+ * state: 'Available',
1111
+ * auxCodeId: '0'
1112
+ * });
1113
+ *
1114
+ * // Make outbound call with full error handling
1115
+ * try {
1116
+ * // Verify agent is properly configured for outdial
1117
+ * if (!cc.agentConfig.isOutboundEnabledForAgent) {
1118
+ * throw new Error('Agent not configured for outbound calls');
1119
+ * }
1120
+ *
1121
+ * // Start the outbound call
1122
+ * const destination = '+1234567890';
1123
+ * const task = await cc.startOutdial(destination);
1124
+ *
1125
+ * // Listen for all relevant task events
1126
+ * task.on('task:ringing', () => {
1127
+ * console.log('Call is ringing');
1128
+ * updateCallStatus('Ringing...');
1129
+ * });
1130
+ *
1131
+ * task.on('task:established', () => {
1132
+ * console.log('Call connected');
1133
+ * updateCallStatus('Connected');
1134
+ * enableCallControls(); // Show mute, hold, transfer buttons
1135
+ * });
1136
+ *
1137
+ * task.on('task:hold', () => {
1138
+ * console.log('Call placed on hold');
1139
+ * updateCallStatus('On Hold');
1140
+ * });
1141
+ *
1142
+ * task.on('task:error', (error) => {
1143
+ * console.error('Call error:', error);
1144
+ * updateCallStatus('Error');
1145
+ * showErrorDialog(error.message);
1146
+ * });
1147
+ *
1148
+ * task.on('task:ended', () => {
1149
+ * console.log('Call ended');
1150
+ * updateCallStatus('Call Ended');
1151
+ * resetCallControls();
1152
+ *
1153
+ * // Handle wrap-up if required
1154
+ * if (task.data.wrapUpRequired) {
1155
+ * showWrapupForm();
1156
+ * }
1157
+ * });
1158
+ *
1159
+ * // Example call control usage
1160
+ * function handleMuteToggle() {
1161
+ * await task.toggleMute();
1162
+ * }
1163
+ *
1164
+ * function handleHoldToggle() {
1165
+ * if (task.data.isOnHold) {
1166
+ * await task.resume();
1167
+ * } else {
1168
+ * await task.hold();
1169
+ * }
1170
+ * }
1171
+ *
1172
+ * async function handleTransfer() {
1173
+ * // Get available queues for transfer
1174
+ * const queues = await cc.getQueues();
1175
+ *
1176
+ * // Transfer to first available queue
1177
+ * if (queues.length > 0) {
1178
+ * await task.transfer({
1179
+ * to: queues[0].queueId,
1180
+ * destinationType: 'QUEUE'
1181
+ * });
1182
+ * }
1183
+ * }
1184
+ *
1185
+ * } catch (error) {
1186
+ * console.error('Outdial failed:', error);
1187
+ * showErrorNotification('Failed to place call: ' + error.message);
1188
+ * }
1189
+ * ```
1190
+ */
1191
+ async startOutdial(destination) {
1192
+ _loggerProxy.default.info('Starting outbound dial', {
1193
+ module: _constants.CC_FILE,
1194
+ method: _constants.METHODS.START_OUTDIAL
1195
+ });
1196
+ try {
1197
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_SUCCESS, _constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_FAILED]);
1198
+
1199
+ // Construct the outdial payload.
1200
+ const outDialPayload = {
1201
+ destination,
1202
+ entryPointId: this.agentConfig.outDialEp,
1203
+ direction: _constants.OUTDIAL_DIRECTION,
1204
+ attributes: _constants.ATTRIBUTES,
1205
+ mediaType: _constants.OUTDIAL_MEDIA_TYPE,
1206
+ outboundType: _constants.OUTBOUND_TYPE
1207
+ };
1208
+ const result = await this.services.dialer.startOutdial({
1209
+ data: outDialPayload
1210
+ });
1211
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_SUCCESS, {
1212
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(result),
1213
+ destination,
1214
+ mediaType: _constants.OUTDIAL_MEDIA_TYPE
1215
+ }, ['behavioral', 'business', 'operational']);
1216
+ _loggerProxy.default.log(`Outbound dial completed successfully`, {
1217
+ module: _constants.CC_FILE,
1218
+ method: _constants.METHODS.START_OUTDIAL,
1219
+ trackingId: result.trackingId,
1220
+ interactionId: result.data?.interactionId
1221
+ });
1222
+ return result;
1223
+ } catch (error) {
1224
+ const failure = error.details;
1225
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_FAILED, {
1226
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),
1227
+ destination,
1228
+ mediaType: _constants.OUTDIAL_MEDIA_TYPE
1229
+ }, ['behavioral', 'business', 'operational']);
1230
+ const {
1231
+ error: detailedError
1232
+ } = (0, _Utils.getErrorDetails)(error, _constants.METHODS.START_OUTDIAL, _constants.CC_FILE);
1233
+ throw detailedError;
1234
+ }
1235
+ }
1236
+
1237
+ /**
1238
+ * This is used for getting the list of queues to which a task can be consulted or transferred.
1239
+ * @param {string} [search] - Optional search string to filter queues by name
1240
+ * @param {string} [filter] - Optional OData filter expression (e.g., 'teamId eq "team123"')
1241
+ * @param {number} [page=0] - Page number for paginated results, starting at 0
1242
+ * @param {number} [pageSize=100] - Number of queues to return per page
1243
+ * @returns Promise<ContactServiceQueue[]> Resolves with the list of queues
1244
+ * @throws Error If the operation fails
1245
+ * @public
1246
+ * @example
1247
+ * ```typescript
1248
+ * const cc = webex.cc;
1249
+ * await cc.register();
1250
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
1251
+ *
1252
+ * // Basic usage - get all queues
1253
+ * const allQueues = await cc.getQueues();
1254
+ *
1255
+ * // Search for specific queues
1256
+ * const salesQueues = await cc.getQueues('sales'); // Search for 'sales' in queue names
1257
+ *
1258
+ * // Use filtering and pagination
1259
+ * const filteredQueues = await cc.getQueues(
1260
+ * '', // No search term
1261
+ * 'teamId eq "team123"', // Filter by team
1262
+ * 0, // First page
1263
+ * 50 // 50 items per page
1264
+ * );
1265
+ *
1266
+ * // Process queue results
1267
+ * queues.forEach(queue => {
1268
+ * console.log('Queue:', {
1269
+ * id: queue.queueId,
1270
+ * name: queue.queueName,
1271
+ * channelType: queue.channelType,
1272
+ * isActive: queue.isActive,
1273
+ * description: queue.description
1274
+ * });
1275
+ * });
1276
+ * ```
1277
+ */
1278
+ async getQueues(search, filter, page = _constants3.DEFAULT_PAGE, pageSize = _constants3.DEFAULT_PAGE_SIZE) {
1279
+ _loggerProxy.default.info('Fetching queues', {
1280
+ module: _constants.CC_FILE,
1281
+ method: _constants.METHODS.GET_QUEUES
1282
+ });
1283
+ const orgId = this.$webex.credentials.getOrgId();
1284
+ if (!orgId) {
1285
+ _loggerProxy.default.error('Org ID not found.', {
1286
+ module: _constants.CC_FILE,
1287
+ method: _constants.METHODS.GET_QUEUES
1288
+ });
1289
+ throw new Error('Org ID not found.');
1290
+ }
1291
+ const result = await this.services.config.getQueues(orgId, page, pageSize, search, filter);
1292
+ _loggerProxy.default.log(`Successfully retrieved ${result?.length} queues`, {
1293
+ module: _constants.CC_FILE,
1294
+ method: _constants.METHODS.GET_QUEUES
1295
+ });
1296
+ return result;
1297
+ }
1298
+
1299
+ /**
1300
+ * Uploads logs to help troubleshoot SDK issues.
1301
+ *
1302
+ * This method collects the current SDK logs including network requests, WebSocket
1303
+ * messages, and client-side events, then securely submits them to Webex's diagnostics
1304
+ * service. The returned tracking ID, feedbackID can be provided to Webex support for faster
1305
+ * issue resolution.
1306
+ * @returns Promise<UploadLogsResponse> Resolves with the upload logs response
1307
+ * @throws Error If the upload fails
1308
+ * @public
1309
+ * @example
1310
+ * ```typescript
1311
+ * const cc = webex.cc;
1312
+ * try {
1313
+ * await cc.register();
1314
+ * } catch (error) {
1315
+ * console.error('Error:', error);
1316
+ * const result = await cc.uploadLogs();
1317
+ * console.log('Logs uploaded. Tracking ID:', result.trackingId);
1318
+ * }
1319
+ * ```
1320
+ */
1321
+ async uploadLogs() {
1322
+ return this.webexRequest.uploadLogs();
1323
+ }
1324
+
1325
+ /**
1326
+ * Updates the agent device type and login configuration.
1327
+ * Use this method to change how an agent connects to the contact center system (e.g., switching from browser-based calling to a desk phone extension).
1328
+ *
1329
+ * @param {AgentDeviceUpdate} data Configuration containing:
1330
+ * - loginOption: New device type ('BROWSER', 'EXTENSION', 'AGENT_DN')
1331
+ * - dialNumber: Required phone number when using EXTENSION or AGENT_DN
1332
+ * - teamId: Optional team ID (defaults to current team if not specified)
1333
+ * @returns Promise<UpdateDeviceTypeResponse> Resolves with the device type update response
1334
+ * @throws Error If the update fails
1335
+ * @example
1336
+ * ```typescript
1337
+ * const cc = webex.cc;
1338
+ *
1339
+ * // Switch from browser to extension
1340
+ * try {
1341
+ * await cc.updateAgentProfile({
1342
+ * loginOption: 'EXTENSION',
1343
+ * dialNumber: '1234', // Required for EXTENSION
1344
+ * teamId: 'currentTeam' // Optional: uses current team if not specified
1345
+ * });
1346
+ * } catch (error) {
1347
+ * console.error('Failed to update device:', error.message);
1348
+ * }
1349
+ * ```
1350
+ * @public
1351
+ */
1352
+ async updateAgentProfile(data) {
1353
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.AGENT_DEVICE_TYPE_UPDATE_SUCCESS, _constants4.METRIC_EVENT_NAMES.AGENT_DEVICE_TYPE_UPDATE_FAILED]);
1354
+ const trackingId = `WX_CC_SDK_${(0, _uuid.v4)()}`;
1355
+ _loggerProxy.default.info(`starting profile update`, {
1356
+ module: _constants.CC_FILE,
1357
+ method: _constants.METHODS.UPDATE_AGENT_PROFILE,
1358
+ trackingId
1359
+ });
1360
+ try {
1361
+ // Only block if both loginOption AND teamId remain unchanged
1362
+ if (this.webCallingService?.loginOption === data.loginOption && data.teamId === this.agentConfig.currentTeamId) {
1363
+ const message = 'Will not proceed with device update as new Device type is same as current device type and teamId is same as current teamId';
1364
+ const err = new Error(message);
1365
+ err.details = {
1366
+ type: 'Identical Device Change Failure',
1367
+ orgId: this.$webex.credentials.getOrgId(),
1368
+ trackingId,
1369
+ data: {
1370
+ agentId: this.agentConfig.agentId,
1371
+ reasonCode: 'R002',
1372
+ reason: message
1373
+ }
1374
+ };
1375
+ throw err;
1376
+ }
1377
+ await this.stationLogout({
1378
+ logoutReason: 'User requested agent device change'
1379
+ });
1380
+ const loginPayload = {
1381
+ teamId: data.teamId,
1382
+ loginOption: data.loginOption,
1383
+ dialNumber: data.dialNumber
1384
+ };
1385
+ const resp = await this.stationLogin(loginPayload);
1386
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.AGENT_DEVICE_TYPE_UPDATE_SUCCESS, {
1387
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),
1388
+ loginType: data.loginOption
1389
+ }, ['behavioral', 'business', 'operational']);
1390
+ _loggerProxy.default.log(`profile updated successfully with ${loginPayload.loginOption} teamId: ${loginPayload.teamId}`, {
1391
+ module: _constants.CC_FILE,
1392
+ method: _constants.METHODS.UPDATE_AGENT_PROFILE,
1393
+ trackingId
1394
+ });
1395
+ const deviceTypeUpdateResponse = {
1396
+ ...resp,
1397
+ type: 'AgentDeviceTypeUpdateSuccess'
1398
+ };
1399
+ return deviceTypeUpdateResponse;
1400
+ } catch (error) {
1401
+ const failure = error.details;
1402
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.AGENT_DEVICE_TYPE_UPDATE_FAILED, {
1403
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),
1404
+ loginType: data.loginOption
1405
+ }, ['behavioral', 'business', 'operational']);
1406
+ _loggerProxy.default.error(`error updating profile: ${error}`, {
1407
+ module: _constants.CC_FILE,
1408
+ method: _constants.METHODS.UPDATE_AGENT_PROFILE,
1409
+ trackingId
1410
+ });
1411
+ throw error;
1412
+ }
1413
+ }
1414
+ }
1415
+ exports.default = ContactCenter;
1416
+ //# sourceMappingURL=cc.js.map