@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
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Default configuration for the Webex Contact Center SDK.
3
+ *
4
+ * @public
5
+ * @example
6
+ * import config from './config';
7
+ * const allowMultiLogin = config.cc.allowMultiLogin;
8
+ * @ignore
9
+ */
10
+ declare const _default: {
11
+ /**
12
+ * Contact Center configuration options.
13
+ * @public
14
+ */
15
+ cc: {
16
+ /**
17
+ * Whether to allow multiple logins from different devices.
18
+ * @type {boolean}
19
+ * @default false
20
+ */
21
+ allowMultiLogin: boolean;
22
+ /**
23
+ * Whether to automatically attempt relogin on connection loss.
24
+ * @type {boolean}
25
+ * @default true
26
+ */
27
+ allowAutomatedRelogin: boolean;
28
+ /**
29
+ * The type of client making the connection.
30
+ * @type {string}
31
+ * @default 'WebexCCSDK'
32
+ */
33
+ clientType: string;
34
+ /**
35
+ * Whether to enable keep-alive messages.
36
+ * @type {boolean}
37
+ * @default false
38
+ */
39
+ isKeepAliveEnabled: boolean;
40
+ /**
41
+ * Whether to force registration.
42
+ * @type {boolean}
43
+ * @default true
44
+ */
45
+ force: boolean;
46
+ /**
47
+ * Metrics configuration for the client.
48
+ * @public
49
+ */
50
+ metrics: {
51
+ /**
52
+ * Name of the client for metrics.
53
+ * @type {string}
54
+ * @default 'WEBEX_JS_SDK'
55
+ */
56
+ clientName: string;
57
+ /**
58
+ * Type of client for metrics.
59
+ * @type {string}
60
+ * @default 'WebexCCSDK'
61
+ */
62
+ clientType: string;
63
+ };
64
+ };
65
+ };
66
+ export default _default;
@@ -0,0 +1,45 @@
1
+ export declare const EVENT = "event";
2
+ export declare const READY = "ready";
3
+ export declare const TIMEOUT_DURATION = 20000;
4
+ export declare const EMPTY_STRING = "";
5
+ export declare const PRODUCT_NAME = "wxcc_sdk";
6
+ export declare const LOG_PREFIX = "PLUGIN_CC";
7
+ export declare const WEB_CALLING_SERVICE_FILE = "WebCallingService";
8
+ export declare const CONFIG_FILE_NAME = "config-index";
9
+ export declare const CC_FILE = "cc";
10
+ export declare const CONNECTION_SERVICE_FILE = "connection-service";
11
+ export declare const WEB_SOCKET_MANAGER_FILE = "WebSocketManager";
12
+ export declare const AQM_REQS_FILE = "aqm-reqs";
13
+ export declare const WEBEX_REQUEST_FILE = "WebexRequest";
14
+ export declare const TASK_MANAGER_FILE = "TaskManager";
15
+ export declare const TASK_FILE = "Task";
16
+ export declare const OUTDIAL_DIRECTION = "OUTBOUND";
17
+ export declare const ATTRIBUTES: {};
18
+ export declare const OUTDIAL_MEDIA_TYPE = "telephony";
19
+ export declare const OUTBOUND_TYPE = "OUTDIAL";
20
+ export declare const UNKNOWN_ERROR = "Unknown error";
21
+ export declare const MERCURY_DISCONNECTED_SUCCESS = "Mercury disconnected successfully";
22
+ export declare const METHODS: {
23
+ REGISTER: string;
24
+ DEREGISTER: string;
25
+ GET_BUDDY_AGENTS: string;
26
+ CONNECT_WEBSOCKET: string;
27
+ STATION_LOGIN: string;
28
+ STATION_LOGOUT: string;
29
+ STATION_RELOGIN: string;
30
+ SET_AGENT_STATE: string;
31
+ HANDLE_WEBSOCKET_MESSAGE: string;
32
+ SETUP_EVENT_LISTENERS: string;
33
+ GET_CONNECTION_CONFIG: string;
34
+ HANDLE_CONNECTION_LOST: string;
35
+ SILENT_RELOGIN: string;
36
+ HANDLE_DEVICE_TYPE: string;
37
+ START_OUTDIAL: string;
38
+ GET_QUEUES: string;
39
+ UPLOAD_LOGS: string;
40
+ UPDATE_AGENT_PROFILE: string;
41
+ GET_DEVICE_ID: string;
42
+ HANDLE_INCOMING_TASK: string;
43
+ HANDLE_TASK_HYDRATE: string;
44
+ INCOMING_TASK_LISTENER: string;
45
+ };
@@ -0,0 +1,178 @@
1
+ import ContactCenter from './cc';
2
+ /** @module ContactCenterModule */
3
+ /**
4
+ * ContactCenter is the main plugin class for Webex Contact Center integration
5
+ * @category Core
6
+ */
7
+ export { default as ContactCenter } from './cc';
8
+ /**
9
+ * Task class represents a contact center task that can be managed by an agent
10
+ * @category Services
11
+ */
12
+ export { default as Task } from './services/task';
13
+ /**
14
+ * Agent routing service for Contact Center operations
15
+ * @category Services
16
+ */
17
+ export { default as routingAgent } from './services/agent';
18
+ /**
19
+ * Task Events for Contact Center operations
20
+ * @enum {string}
21
+ * @category Enums
22
+ */
23
+ export { TASK_EVENTS } from './services/task/types';
24
+ export type { TASK_EVENTS as TaskEvents } from './services/task/types';
25
+ /**
26
+ * Agent Events for Contact Center operations
27
+ * @enum {string}
28
+ * @category Enums
29
+ */
30
+ export { AGENT_EVENTS } from './services/agent/types';
31
+ export type { AGENT_EVENTS as AgentEvents } from './services/agent/types';
32
+ /**
33
+ * Contact Center Task Events
34
+ * @enum {string}
35
+ * @category Enums
36
+ */
37
+ export { CC_TASK_EVENTS } from './services/config/types';
38
+ /**
39
+ * Contact Center Agent Events
40
+ * @enum {string}
41
+ * @category Enums
42
+ */
43
+ export { CC_AGENT_EVENTS } from './services/config/types';
44
+ /**
45
+ * Combined Contact Center Events
46
+ * @enum {string}
47
+ * @category Enums
48
+ */
49
+ export { CC_EVENTS } from './services/config/types';
50
+ export type { CC_EVENTS as ContactCenterEvents } from './services/config/types';
51
+ /** Main types and interfaces for Contact Center functionality */
52
+ export type {
53
+ /** Interface for Contact Center plugin */
54
+ IContactCenter,
55
+ /** Configuration options for Contact Center plugin */
56
+ CCPluginConfig,
57
+ /** WebexSDK interface */
58
+ WebexSDK, } from './types';
59
+ /** Agent related types */
60
+ export type {
61
+ /** Login options for agents */
62
+ LoginOption,
63
+ /** Agent login information */
64
+ AgentLogin,
65
+ /** Agent device update information */
66
+ AgentProfileUpdate,
67
+ /** Station login response */
68
+ StationLoginResponse,
69
+ /** Station logout response */
70
+ StationLogoutResponse,
71
+ /** Buddy agents response */
72
+ BuddyAgentsResponse,
73
+ /** Buddy agents information */
74
+ BuddyAgents,
75
+ /** Subscribe request parameters */
76
+ SubscribeRequest,
77
+ /** Upload logs response */
78
+ UploadLogsResponse,
79
+ /** Update device type response */
80
+ UpdateDeviceTypeResponse,
81
+ /** Generic error interface */
82
+ GenericError,
83
+ /** Set state response */
84
+ SetStateResponse, } from './types';
85
+ /** Task related types */
86
+ export type { AgentContact,
87
+ /** Task interface */
88
+ ITask, TaskData,
89
+ /** Task response */
90
+ TaskResponse, ConsultPayload, ConsultEndPayload, ConsultTransferPayLoad,
91
+ /** Dialer payload */
92
+ DialerPayload, TransferPayLoad, ResumeRecordingPayload, WrapupPayLoad, } from './services/task/types';
93
+ /** Agent related types */
94
+ export type {
95
+ /** State change interface */
96
+ StateChange,
97
+ /** Logout interface */
98
+ Logout,
99
+ /** State change success response */
100
+ StateChangeSuccess,
101
+ /** Station login success response */
102
+ StationLoginSuccess,
103
+ /** Extended station login success response with notification tracking */
104
+ StationLoginSuccessResponse,
105
+ /** Device type update success response */
106
+ DeviceTypeUpdateSuccess,
107
+ /** Agent login success response */
108
+ LogoutSuccess,
109
+ /** Agent relogin success response */
110
+ ReloginSuccess,
111
+ /** Agent state type */
112
+ AgentState,
113
+ /** User station login parameters */
114
+ UserStationLogin,
115
+ /** Device type for agent login */
116
+ DeviceType,
117
+ /** Buddy agent details */
118
+ BuddyDetails,
119
+ /** Buddy agents success response */
120
+ BuddyAgentsSuccess, } from './services/agent/types';
121
+ /** Config related types */
122
+ export type {
123
+ /** Profile interface */
124
+ Profile,
125
+ /** Contact service queue interface */
126
+ ContactServiceQueue,
127
+ /** Response type from getUserUsingCI method */
128
+ AgentResponse,
129
+ /** Response from getDesktopProfileById */
130
+ DesktopProfileResponse,
131
+ /** Response from getMultimediaProfileById */
132
+ MultimediaProfileResponse,
133
+ /** Response from getListOfTeams */
134
+ ListTeamsResponse,
135
+ /** Response from getListOfAuxCodes */
136
+ ListAuxCodesResponse,
137
+ /** Response from getSiteInfo */
138
+ SiteInfo,
139
+ /** Response from getOrgInfo */
140
+ OrgInfo,
141
+ /** Response from getOrganizationSetting */
142
+ OrgSettings,
143
+ /** Response from getTenantData */
144
+ TenantData,
145
+ /** Response from getURLMapping */
146
+ URLMapping,
147
+ /** Response from getDialPlanData */
148
+ DialPlanEntity,
149
+ /** Auxiliary code information */
150
+ AuxCode,
151
+ /** Team information */
152
+ TeamList,
153
+ /** Wrap-up reason information */
154
+ WrapUpReason,
155
+ /** WebSocket event data */
156
+ WebSocketEvent,
157
+ /** Wrap-up configuration data */
158
+ WrapupData,
159
+ /** Base entity type */
160
+ Entity,
161
+ /** Dial plan configuration */
162
+ DialPlan,
163
+ /** Auxiliary code type (IDLE_CODE or WRAP_UP_CODE) */
164
+ AuxCodeType, } from './services/config/types';
165
+ /**
166
+ * Idle code constant
167
+ * @constant {string}
168
+ * @category Enums
169
+ */
170
+ export { IDLE_CODE } from './services/config/types';
171
+ /**
172
+ * Wrap up code constant
173
+ * @constant {string}
174
+ * @category Enums
175
+ */
176
+ export { WRAP_UP_CODE } from './services/config/types';
177
+ /** The Contact Center plugin default export */
178
+ export default ContactCenter;
@@ -0,0 +1,71 @@
1
+ import { Logger, LogContext } from './types';
2
+ /**
3
+ * LoggerProxy acts as a static proxy to route logging calls to an injected logger implementation.
4
+ * Ensures a consistent log format and centralizes logging behavior for the SDK.
5
+ * @ignore
6
+ */
7
+ export default class LoggerProxy {
8
+ /**
9
+ * The static logger instance to be used by the proxy.
10
+ * @ignore
11
+ */
12
+ static logger: Logger;
13
+ /**
14
+ * Initializes the logger proxy with a provided logger implementation.
15
+ *
16
+ * @param {Logger} logger - A logger object implementing standard logging methods.
17
+ * @ignore
18
+ */
19
+ static initialize(logger: Logger): void;
20
+ /**
21
+ * Logs a generic message using the default log level.
22
+ *
23
+ * @param {string} message - The log message.
24
+ * @param {LogContext} [context={}] - Optional context providing module and method names.
25
+ * @ignore
26
+ */
27
+ static log(message: string, context?: LogContext): void;
28
+ /**
29
+ * Logs an informational message.
30
+ *
31
+ * @param {string} message - The log message.
32
+ * @param {LogContext} [context={}] - Optional context providing module and method names.
33
+ * @ignore
34
+ */
35
+ static info(message: string, context?: LogContext): void;
36
+ /**
37
+ * Logs a warning message.
38
+ *
39
+ * @param {string} message - The warning message.
40
+ * @param {LogContext} [context={}] - Optional context providing module and method names.
41
+ * @ignore
42
+ */
43
+ static warn(message: string, context?: LogContext): void;
44
+ /**
45
+ * Logs a trace-level message, useful for debugging.
46
+ *
47
+ * @param {string} message - The trace message.
48
+ * @param {LogContext} [context={}] - Optional context providing module and method names.
49
+ * @ignore
50
+ */
51
+ static trace(message: string, context?: LogContext): void;
52
+ /**
53
+ * Logs an error message.
54
+ *
55
+ * @param {string} message - The error message.
56
+ * @param {LogContext} [context={}] - Optional context providing module and method names.
57
+ * @ignore
58
+ */
59
+ static error(message: string, context?: LogContext): void;
60
+ /**
61
+ * Formats a log message with timestamp, log level, and context details.
62
+ *
63
+ * @private
64
+ * @param {LOGGING_LEVEL} level - Logging level (e.g., info, error).
65
+ * @param {string} message - The message to be logged.
66
+ * @param {LogContext} context - Context containing module and method metadata.
67
+ * @returns {string} The formatted log string.
68
+ * @ignore
69
+ */
70
+ private static format;
71
+ }
@@ -0,0 +1,223 @@
1
+ import { EventPayload } from '@webex/internal-plugin-metrics/src/metrics.types';
2
+ import { WebexSDK } from '../types';
3
+ import { METRIC_EVENT_NAMES } from './constants';
4
+ import { Failure } from '../services/core/GlobalTypes';
5
+ export type MetricsType = 'behavioral' | 'operational' | 'business';
6
+ /**
7
+ * @class MetricsManager
8
+ * @classdesc Manages the collection, batching, and submission of behavioral, operational, and business metrics for the Webex SDK.
9
+ * Implements a singleton pattern to ensure a single instance throughout the application lifecycle.
10
+ *
11
+ * @remarks
12
+ * This class is responsible for tracking, batching, and submitting various types of metric events.
13
+ * It also provides utility methods for extracting common tracking fields from AQM responses.
14
+ * @ignore
15
+ */
16
+ export default class MetricsManager {
17
+ /**
18
+ * The Webex SDK instance used for submitting metrics.
19
+ * @private
20
+ */
21
+ private webex;
22
+ /**
23
+ * Stores currently running timed events.
24
+ * @private
25
+ */
26
+ private readonly runningEvents;
27
+ /**
28
+ * Queue for pending behavioral events.
29
+ * @private
30
+ */
31
+ private pendingBehavioralEvents;
32
+ /**
33
+ * Queue for pending operational events.
34
+ * @private
35
+ */
36
+ private pendingOperationalEvents;
37
+ /**
38
+ * Queue for pending business events.
39
+ * @private
40
+ */
41
+ private pendingBusinessEvents;
42
+ /**
43
+ * Indicates if the manager is ready to submit events.
44
+ * @private
45
+ */
46
+ private readyToSubmitEvents;
47
+ /**
48
+ * Lock to prevent concurrent submissions.
49
+ * @private
50
+ */
51
+ private submittingEvents;
52
+ /**
53
+ * Singleton instance of MetricsManager.
54
+ * @private
55
+ */
56
+ private static instance;
57
+ /**
58
+ * Flag to disable metrics collection.
59
+ * @private
60
+ */
61
+ private metricsDisabled;
62
+ /**
63
+ * Private constructor to enforce singleton pattern.
64
+ * @private
65
+ */
66
+ private constructor();
67
+ /**
68
+ * Marks the manager as ready to submit events and triggers submission.
69
+ * @private
70
+ */
71
+ private setReadyToSubmitEvents;
72
+ /**
73
+ * Submits all pending events if not already submitting.
74
+ * @private
75
+ */
76
+ private submitPendingEvents;
77
+ /**
78
+ * Submits all pending behavioral events if ready.
79
+ * @private
80
+ */
81
+ private submitPendingBehavioralEvents;
82
+ /**
83
+ * Submits all pending operational events if ready.
84
+ * @private
85
+ */
86
+ private submitPendingOperationalEvents;
87
+ /**
88
+ * Submits all pending business events if ready.
89
+ * @private
90
+ */
91
+ private submitPendingBusinessEvents;
92
+ /**
93
+ * Adds a duration property to the event payload if the event was timed.
94
+ * @param eventName - The name of the event.
95
+ * @param options - Optional event payload.
96
+ * @returns The event payload with duration if applicable.
97
+ * @private
98
+ */
99
+ private addDurationIfTimed;
100
+ /**
101
+ * Converts spaces in a string to underscores.
102
+ * @param str - The input string.
103
+ * @returns The string with spaces replaced by underscores.
104
+ * @public
105
+ * @example
106
+ * MetricsManager.spacesToUnderscore('my event name'); // 'my_event_name'
107
+ */
108
+ static spacesToUnderscore(str: string): string;
109
+ /**
110
+ * Prepares the event payload by removing empty or undefined fields and adding common metadata.
111
+ * @param obj - The original event payload.
112
+ * @returns The cleaned and enriched event payload.
113
+ * @private
114
+ */
115
+ private static preparePayload;
116
+ /**
117
+ * Checks if metrics collection is currently disabled.
118
+ * @returns True if metrics are disabled, false otherwise.
119
+ * @private
120
+ */
121
+ private isMetricsDisabled;
122
+ /**
123
+ * Enables or disables metrics collection. Clears pending events if disabled.
124
+ * @param disabled - Whether to disable metrics.
125
+ * @public
126
+ * @example
127
+ * MetricsManager.getInstance().setMetricsDisabled(true);
128
+ */
129
+ setMetricsDisabled(disabled: boolean): void;
130
+ /**
131
+ * Clears all pending events from the queues.
132
+ * @private
133
+ */
134
+ private clearPendingEvents;
135
+ /**
136
+ * Tracks a behavioral event and submits it if possible.
137
+ * @param name - The metric event name.
138
+ * @param options - Optional event payload.
139
+ * @public
140
+ * @example
141
+ * MetricsManager.getInstance().trackBehavioralEvent('AGENT_LOGIN', {agentId: '123'});
142
+ */
143
+ trackBehavioralEvent(name: METRIC_EVENT_NAMES, options?: EventPayload): void;
144
+ /**
145
+ * Tracks an operational event and submits it if possible.
146
+ * @param name - The metric event name.
147
+ * @param options - Optional event payload.
148
+ * @public
149
+ * @example
150
+ * MetricsManager.getInstance().trackOperationalEvent('AGENT_LOGOUT', {agentId: '123'});
151
+ */
152
+ trackOperationalEvent(name: METRIC_EVENT_NAMES, options?: EventPayload): void;
153
+ /**
154
+ * Tracks a business event and submits it if possible.
155
+ * @param name - The metric event name.
156
+ * @param options - Optional event payload.
157
+ * @public
158
+ * @example
159
+ * MetricsManager.getInstance().trackBusinessEvent('AGENT_TRANSFER', {agentId: '123'});
160
+ */
161
+ trackBusinessEvent(name: METRIC_EVENT_NAMES, options?: EventPayload): void;
162
+ /**
163
+ * Tracks an event across one or more metric services.
164
+ * @param name - The metric event name.
165
+ * @param payload - Optional event payload.
166
+ * @param metricServices - Array of metric types to track (default: ['behavioral']).
167
+ * @public
168
+ * @example
169
+ * MetricsManager.getInstance().trackEvent('AGENT_LOGIN', {agentId: '123'}, ['behavioral', 'operational']);
170
+ */
171
+ trackEvent(name: METRIC_EVENT_NAMES, payload?: EventPayload, metricServices?: MetricsType[]): void;
172
+ /**
173
+ * Starts timing for one or more event keys.
174
+ * @param keys - A string or array of strings representing event keys.
175
+ * @public
176
+ * @example
177
+ * MetricsManager.getInstance().timeEvent('AGENT_LOGIN');
178
+ * MetricsManager.getInstance().timeEvent(['AGENT_LOGIN', 'AGENT_LOGOUT']);
179
+ */
180
+ timeEvent(keys: string | string[]): void;
181
+ /**
182
+ * Sets the Webex SDK instance and marks the manager as ready when the SDK is ready.
183
+ * @param webex - The Webex SDK instance.
184
+ * @private
185
+ */
186
+ private setWebex;
187
+ /**
188
+ * Returns the singleton instance of MetricsManager, initializing it if necessary.
189
+ * @param options - Optional object containing the Webex SDK instance.
190
+ * @returns The singleton MetricsManager instance.
191
+ * @public
192
+ * @example
193
+ * const metrics = MetricsManager.getInstance({webex});
194
+ */
195
+ static getInstance(options?: {
196
+ webex: WebexSDK;
197
+ }): MetricsManager;
198
+ /**
199
+ * Resets the singleton instance of MetricsManager. Useful for testing.
200
+ * @public
201
+ * @example
202
+ * MetricsManager.resetInstance();
203
+ */
204
+ static resetInstance(): void;
205
+ /**
206
+ * Extracts common tracking fields from an AQM response object.
207
+ * @param response - The AQM response object.
208
+ * @returns An object containing common tracking fields.
209
+ * @public
210
+ * @example
211
+ * const fields = MetricsManager.getCommonTrackingFieldForAQMResponse(response);
212
+ */
213
+ static getCommonTrackingFieldForAQMResponse(response: any): Record<string, any>;
214
+ /**
215
+ * Extracts common tracking fields from an AQM failure response object.
216
+ * @param failureResponse - The AQM failure response object.
217
+ * @returns An object containing common tracking fields for failures.
218
+ * @public
219
+ * @example
220
+ * const fields = MetricsManager.getCommonTrackingFieldForAQMResponseFailed(failureResponse);
221
+ */
222
+ static getCommonTrackingFieldForAQMResponseFailed(failureResponse: Failure): Record<string, any>;
223
+ }
@@ -0,0 +1,29 @@
1
+ import { MetricEventAgent, MetricEventProduct, MetricEventVerb } from '@webex/internal-plugin-metrics/src/metrics.types';
2
+ import { METRIC_EVENT_NAMES } from './constants';
3
+ /**
4
+ * Represents the taxonomy for a behavioral event in the metrics system.
5
+ * @ignore
6
+ * @typedef BehavioralEventTaxonomy
7
+ * @property {MetricEventProduct} product - The product associated with the behavioral event.
8
+ * @property {MetricEventAgent} agent - The agent responsible for the behavioral event.
9
+ * @property {string} target - The target entity of the behavioral event.
10
+ * @property {MetricEventVerb} verb - The action or verb describing the behavioral event.
11
+ *
12
+ * @category Metrics
13
+ * @type BehavioralEvents
14
+ */
15
+ export type BehavioralEventTaxonomy = {
16
+ product: MetricEventProduct;
17
+ agent: MetricEventAgent;
18
+ target: string;
19
+ verb: MetricEventVerb;
20
+ };
21
+ /**
22
+ * Get the taxonomy information for a given behavioral event name.
23
+ * @ignore
24
+ * @param name - The name of the metric event to look up.
25
+ * @returns The corresponding {@link BehavioralEventTaxonomy} if found, otherwise `undefined`.
26
+ *
27
+ * @typedoc
28
+ */
29
+ export declare function getEventTaxonomy(name: METRIC_EVENT_NAMES): BehavioralEventTaxonomy | undefined;