diff --git a/CHANGELOG.md b/CHANGELOG.md index ff501e3..3decc8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,16 +4,25 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +- Improve telemetry to uniformly log all errors for reconnectable chat and reconnect availability + ## [0.5.6] + ### Fixed + - Fix error propagation when a call to an endpoint timesout - Fix unit tests ### Added + - Error propagation when getchattoken returns an empty dashboard ## [0.5.5] + ### Security + - Uptake [axios@1.7.4](https://www.npmjs.com/package/axios/v/1.7.4) ## [0.5.3] - 2024-06-18 diff --git a/src/Common/Enums.ts b/src/Common/Enums.ts index b2f6057..5131c89 100644 --- a/src/Common/Enums.ts +++ b/src/Common/Enums.ts @@ -49,8 +49,12 @@ export enum OCSDKTelemetryEvent { GETCHATCONFIGFSTARTED = "GetChatConfig", GETCHATCONFIGSUCCEEDED = "GetChatConfigSucceeded", GETCHATCONFIGFAILED = "GetChatConfigFailed", - GETRECONNECTABLECHATS = "GetReconnnectableChats", - GETRECONNECTAVAILABILITY = "GetReconnnectableAvailability", + GETRECONNECTABLECHATSSTARTED = "GetReconnnectableChatsStarted", + GETRECONNECTABLECHATSSUCCEEDED = "GetReconnnectableChatsSucceeded", + GETRECONNECTABLECHATSFAILED = "GetReconnnectableChatsFailed", + GETRECONNECTAVAILABILITYSUCCEEDED = "GetReconnnectableAvailabilitySucceeded", + GETRECONNECTAVAILABILITYSTARTED = "GetReconnnectableAvailabilityStarted", + GETRECONNECTAVAILABILITYFAILED = "GetReconnnectableAvailabilityFailed", GETCHATTOKENSTARTED = "GetChatTokenStarted", GETCHATTOKENSUCCEEDED = "GetChatTokenSucceeded", GETCHATTOKENFAILED = "GetChatTokenFailed", diff --git a/src/SDK.ts b/src/SDK.ts index 0a3b493..c5ab058 100644 --- a/src/SDK.ts +++ b/src/SDK.ts @@ -419,7 +419,7 @@ export default class SDK implements ISDK { public async getReconnectableChats(reconnectableChatsParams: IReconnectableChatsParams): Promise { const timer = Timer.TIMER(); const { authenticatedUserToken } = reconnectableChatsParams; - this.logWithLogger(LogLevel.INFO, OCSDKTelemetryEvent.GETRECONNECTABLECHATS, "Get Reconnectable chat Started"); + this.logWithLogger(LogLevel.INFO, OCSDKTelemetryEvent.GETRECONNECTABLECHATSSTARTED, "Get Reconnectable chat Started"); const requestPath = `/${OmnichannelEndpoints.LiveChatGetReconnectableChatsPath}/${this.omnichannelConfiguration.orgId}/${this.omnichannelConfiguration.widgetId}/${this.omnichannelConfiguration.orgId}?channelId=${this.omnichannelConfiguration.channelId}`; const requestHeaders: StringMap = Constants.defaultHeaders; @@ -451,7 +451,7 @@ export default class SDK implements ISDK { // Resolves only if it contains reconnectable chats response which only happens on status 200 if (data) { - this.logWithLogger(LogLevel.INFO, OCSDKTelemetryEvent.GETRECONNECTABLECHATS, "Get Reconnectable Chats Succeeded and old session returned", requestId, response, elapsedTimeInMilliseconds, requestPath, method, undefined, undefined, requestHeaders); + this.logWithLogger(LogLevel.INFO, OCSDKTelemetryEvent.GETRECONNECTABLECHATSSUCCEEDED, "Get Reconnectable Chats Succeeded and old session returned", requestId, response, elapsedTimeInMilliseconds, requestPath, method, undefined, undefined, requestHeaders); resolve(data); return; } @@ -460,7 +460,7 @@ export default class SDK implements ISDK { return; } catch (error) { const elapsedTimeInMilliseconds = timer.milliSecondsElapsed; - this.logWithLogger(LogLevel.ERROR, OCSDKTelemetryEvent.GETRECONNECTABLECHATS, "Get Reconnectable Chats failed", requestId, undefined, elapsedTimeInMilliseconds, requestPath, method, error, undefined, requestHeaders); + this.logWithLogger(LogLevel.ERROR, OCSDKTelemetryEvent.GETRECONNECTABLECHATSFAILED, "Get Reconnectable Chats failed", requestId, undefined, elapsedTimeInMilliseconds, requestPath, method, error, undefined, requestHeaders); if (isExpectedAxiosError(error, Constants.axiosTimeoutErrorCode)) { reject( new Error(this.HTTPTimeOutErrorMessage)); } @@ -476,7 +476,7 @@ export default class SDK implements ISDK { */ public async getReconnectAvailability(reconnectId: string): Promise { const timer = Timer.TIMER(); - this.logWithLogger(LogLevel.INFO, OCSDKTelemetryEvent.GETRECONNECTAVAILABILITY, "Get Reconnectable availability Started"); + this.logWithLogger(LogLevel.INFO, OCSDKTelemetryEvent.GETRECONNECTAVAILABILITYSTARTED, "Get Reconnectable availability Started"); const requestPath = `/${OmnichannelEndpoints.LiveChatReconnectAvailabilityPath}/${this.omnichannelConfiguration.orgId}/${this.omnichannelConfiguration.widgetId}/${reconnectId}`; const requestHeaders: StringMap = Constants.defaultHeaders; @@ -500,19 +500,19 @@ export default class SDK implements ISDK { const elapsedTimeInMilliseconds = timer.milliSecondsElapsed; const { data } = response; if (data) { - this.logWithLogger(LogLevel.INFO, OCSDKTelemetryEvent.GETRECONNECTAVAILABILITY, "Get Reconnect availability succeeded", undefined, response, elapsedTimeInMilliseconds, requestPath, method, undefined, undefined, requestHeaders); + this.logWithLogger(LogLevel.INFO, OCSDKTelemetryEvent.GETRECONNECTAVAILABILITYSUCCEEDED, "Get Reconnect availability succeeded", undefined, response, elapsedTimeInMilliseconds, requestPath, method, undefined, undefined, requestHeaders); resolve(data); return; } // No data found so returning null - this.logWithLogger(LogLevel.WARN, OCSDKTelemetryEvent.GETRECONNECTAVAILABILITY, "Get Reconnect availability didn't send any valid data", undefined, response, elapsedTimeInMilliseconds, requestPath, method, undefined, undefined, requestHeaders); + this.logWithLogger(LogLevel.WARN, OCSDKTelemetryEvent.GETRECONNECTAVAILABILITYSUCCEEDED, "Get Reconnect availability didn't send any valid data", undefined, response, elapsedTimeInMilliseconds, requestPath, method, undefined, undefined, requestHeaders); resolve(); return; } catch (error) { const elapsedTimeInMilliseconds = timer.milliSecondsElapsed; - this.logWithLogger(LogLevel.ERROR, OCSDKTelemetryEvent.GETRECONNECTAVAILABILITY, "Get Reconnect Availability failed", undefined, undefined, elapsedTimeInMilliseconds, requestPath, method, error, undefined, requestHeaders); + this.logWithLogger(LogLevel.ERROR, OCSDKTelemetryEvent.GETRECONNECTAVAILABILITYFAILED, "Get Reconnect Availability failed", undefined, undefined, elapsedTimeInMilliseconds, requestPath, method, error, undefined, requestHeaders); if (isExpectedAxiosError(error, Constants.axiosTimeoutErrorCode)) { reject( new Error(this.HTTPTimeOutErrorMessage)); }