@microsoft/omnichannel-chat-sdk
Advanced tools
Comparing version 0.1.1-main.db70035 to 0.1.1-main.eab8ba8
@@ -12,2 +12,5 @@ # Changelog | ||
- Add telemetry | ||
- Add `rehydrate` flag for `onNewMessage` to rehydrate all messages of existing conversation | ||
- Add `getConversationDetails` | ||
- Add ability to pass custom `ariaTelemetryKey` | ||
@@ -14,0 +17,0 @@ ### Changed |
@@ -387,5 +387,5 @@ "use strict"; | ||
this.addEventListener(eventName, function (params) { return __awaiter(_this, void 0, void 0, function () { | ||
var body; | ||
var _a, _b; | ||
return __generator(this, function (_c) { | ||
var body, exceptionDetails; | ||
var _a, _b, _c, _d, _e; | ||
return __generator(this, function (_f) { | ||
body = { | ||
@@ -395,8 +395,21 @@ SecondaryChannelType: SecondaryChannelType.Voice, | ||
}; | ||
(_a = this.scenarioMarker) === null || _a === void 0 ? void 0 : _a.startScenario(TelemetryEvent_1.default.OnCallDisconnected, { | ||
CallId: this.callId || '' | ||
}); | ||
try { | ||
(_a = this.callingParams) === null || _a === void 0 ? void 0 : _a.OCClient.makeSecondaryChannelEventRequest((_b = this.callingParams) === null || _b === void 0 ? void 0 : _b.chatToken.requestId, body); | ||
(_b = this.callingParams) === null || _b === void 0 ? void 0 : _b.OCClient.makeSecondaryChannelEventRequest((_c = this.callingParams) === null || _c === void 0 ? void 0 : _c.chatToken.requestId, body); | ||
this.debug && console.debug("[VoiceVideoCallingProxy][onCallDisconnected][makeSecondaryChannelEventRequest]"); | ||
(_d = this.scenarioMarker) === null || _d === void 0 ? void 0 : _d.completeScenario(TelemetryEvent_1.default.OnCallDisconnected, { | ||
CallId: this.callId || '' | ||
}); | ||
} | ||
catch (e) { | ||
console.error("[VoiceVideoCallingProxy][onCallDisconnected][makeSecondaryChannelEventRequest] Failure " + e); | ||
exceptionDetails = { | ||
response: 'OCClientMakeSecondaryChannelEventRequestFailed' | ||
}; | ||
(_e = this.scenarioMarker) === null || _e === void 0 ? void 0 : _e.failScenario(TelemetryEvent_1.default.OnCallDisconnected, { | ||
CallId: this.callId || '', | ||
ExceptionDetails: JSON.stringify(exceptionDetails) | ||
}); | ||
} | ||
@@ -403,0 +416,0 @@ this.clearRemoteVideoElementChildren(); |
@@ -14,2 +14,4 @@ import IChatConfig from "./core/IChatConfig"; | ||
import IStartChatOptionalParams from "./core/IStartChatOptionalParams"; | ||
import OnNewMessageOptionalParams from "./core/OnNewMessageOptionalParams"; | ||
import LiveWorkItemDetails from "./core/LiveWorkItemDetails"; | ||
declare class OmnichannelChatSDK { | ||
@@ -35,2 +37,4 @@ private debug; | ||
private scenarioMarker; | ||
private ic3ClientLogger; | ||
private ocSdkLogger; | ||
constructor(omnichannelConfig: IOmnichannelConfig, chatSDKConfig?: IChatSDKConfig); | ||
@@ -42,2 +46,3 @@ setDebug(flag: boolean): void; | ||
getCurrentLiveChatContext(): Promise<ILiveChatContext | {}>; | ||
getConversationDetails(): Promise<LiveWorkItemDetails>; | ||
/** | ||
@@ -53,7 +58,7 @@ * Gets PreChat Survey. | ||
sendMessage(message: IChatSDKMessage): Promise<void>; | ||
onNewMessage(onNewMessageCallback: CallableFunction): void; | ||
onNewMessage(onNewMessageCallback: CallableFunction, optionalParams?: OnNewMessageOptionalParams | unknown): Promise<void>; | ||
sendTypingEvent(): Promise<void>; | ||
onTypingEvent(onTypingEventCallback: CallableFunction): Promise<void>; | ||
onAgentEndSession(onAgentEndSessionCallback: (message: IRawThread) => void): Promise<void>; | ||
uploadFileAttachment(fileInfo: IFileInfo): Promise<IRawMessage>; | ||
uploadFileAttachment(fileInfo: IFileInfo | File): Promise<IRawMessage>; | ||
downloadFileAttachment(fileMetadata: IFileMetadata): Promise<Blob>; | ||
@@ -60,0 +65,0 @@ emailLiveChatTranscript(body: IChatTranscriptBody): Promise<any>; |
import { AWTEventData } from '../external/aria/webjs/AriaSDK'; | ||
import ScenarioType from '../telemetry/ScenarioType'; | ||
interface CDNPackagesInfo { | ||
@@ -13,14 +14,17 @@ IC3Client?: string; | ||
private static _disable; | ||
static initialize(key: string): void; | ||
static setDebug(flag: boolean): void; | ||
static disable(): void; | ||
static setCDNPackages(packages: CDNPackagesInfo): void; | ||
static info(properties: AWTEventData["properties"]): void; | ||
static debug(properties: AWTEventData["properties"]): void; | ||
static warn(properties: AWTEventData["properties"]): void; | ||
static error(properties: AWTEventData["properties"]): void; | ||
static log(properties: AWTEventData["properties"]): void; | ||
static info(properties: AWTEventData["properties"], scenarioType?: ScenarioType): void; | ||
static debug(properties: AWTEventData["properties"], scenarioType?: ScenarioType): void; | ||
static warn(properties: AWTEventData["properties"], scenarioType?: ScenarioType): void; | ||
static error(properties: AWTEventData["properties"], scenarioType?: ScenarioType): void; | ||
static log(properties: AWTEventData["properties"], scenarioType?: ScenarioType): void; | ||
private static get logger(); | ||
private static populateBaseProperties; | ||
private static fillMobilePlatformData; | ||
private static populateIC3ClientBaseProperties; | ||
private static populateOCSDKBaseProperties; | ||
} | ||
export default AriaTelemetry; |
@@ -19,5 +19,11 @@ "use strict"; | ||
var ScenarioType_1 = require("../telemetry/ScenarioType"); | ||
var settings_2 = require("../config/settings"); | ||
var AriaTelemetry = /** @class */ (function () { | ||
function AriaTelemetry() { | ||
} | ||
AriaTelemetry.initialize = function (key) { | ||
/* istanbul ignore next */ | ||
this._debug && console.log("[AriaTelemetry][logger][initialize][custom]"); | ||
AriaTelemetry._logger = AriaSDK_1.AWTLogManager.initialize(key); | ||
}; | ||
/* istanbul ignore next */ | ||
@@ -35,3 +41,4 @@ AriaTelemetry.setDebug = function (flag) { | ||
}; | ||
AriaTelemetry.info = function (properties) { | ||
AriaTelemetry.info = function (properties, scenarioType) { | ||
if (scenarioType === void 0) { scenarioType = ScenarioType_1.default.EVENTS; } | ||
var event = { | ||
@@ -42,9 +49,26 @@ name: ScenarioType_1.default.EVENTS, | ||
}; | ||
if (scenarioType == ScenarioType_1.default.IC3CLIENT) { | ||
event = { | ||
name: ScenarioType_1.default.IC3CLIENT, | ||
properties: __assign(__assign(__assign({}, AriaTelemetry.populateIC3ClientBaseProperties()), properties), { LogLevel: LogLevel_1.default.INFO }), | ||
priority: Enums_1.AWTEventPriority.High | ||
}; | ||
} | ||
if (scenarioType == ScenarioType_1.default.OCSDK) { | ||
event = { | ||
name: ScenarioType_1.default.OCSDK, | ||
properties: __assign(__assign(__assign({}, AriaTelemetry.populateOCSDKBaseProperties()), properties), { LogLevel: LogLevel_1.default.INFO }), | ||
priority: Enums_1.AWTEventPriority.High | ||
}; | ||
} | ||
/* istanbul ignore next */ | ||
this._debug && console.log("[AriaTelemetry][info]"); | ||
this._debug && console.log("[AriaTelemetry][info] " + scenarioType); | ||
/* istanbul ignore next */ | ||
this._debug && console.log(event); | ||
/* istanbul ignore next */ | ||
this._debug && console.log(event.properties.Event); | ||
!AriaTelemetry._disable && AriaTelemetry.logger.logEvent(event); | ||
}; | ||
AriaTelemetry.debug = function (properties) { | ||
AriaTelemetry.debug = function (properties, scenarioType) { | ||
if (scenarioType === void 0) { scenarioType = ScenarioType_1.default.EVENTS; } | ||
var event = { | ||
@@ -55,9 +79,26 @@ name: ScenarioType_1.default.EVENTS, | ||
}; | ||
if (scenarioType == ScenarioType_1.default.IC3CLIENT) { | ||
event = { | ||
name: ScenarioType_1.default.IC3CLIENT, | ||
properties: __assign(__assign(__assign({}, AriaTelemetry.populateIC3ClientBaseProperties()), properties), { LogLevel: LogLevel_1.default.DEBUG }), | ||
priority: Enums_1.AWTEventPriority.High | ||
}; | ||
} | ||
if (scenarioType == ScenarioType_1.default.OCSDK) { | ||
event = { | ||
name: ScenarioType_1.default.OCSDK, | ||
properties: __assign(__assign(__assign({}, AriaTelemetry.populateOCSDKBaseProperties()), properties), { LogLevel: LogLevel_1.default.DEBUG }), | ||
priority: Enums_1.AWTEventPriority.High | ||
}; | ||
} | ||
/* istanbul ignore next */ | ||
this._debug && console.log("[AriaTelemetry][debug]"); | ||
this._debug && console.log("[AriaTelemetry][debug] " + scenarioType); | ||
/* istanbul ignore next */ | ||
this._debug && console.log(event); | ||
/* istanbul ignore next */ | ||
this._debug && console.log(event.properties.Event); | ||
!AriaTelemetry._disable && AriaTelemetry.logger.logEvent(event); | ||
}; | ||
AriaTelemetry.warn = function (properties) { | ||
AriaTelemetry.warn = function (properties, scenarioType) { | ||
if (scenarioType === void 0) { scenarioType = ScenarioType_1.default.EVENTS; } | ||
var event = { | ||
@@ -68,9 +109,26 @@ name: ScenarioType_1.default.EVENTS, | ||
}; | ||
if (scenarioType == ScenarioType_1.default.IC3CLIENT) { | ||
event = { | ||
name: ScenarioType_1.default.IC3CLIENT, | ||
properties: __assign(__assign(__assign({}, AriaTelemetry.populateIC3ClientBaseProperties()), properties), { LogLevel: LogLevel_1.default.WARN }), | ||
priority: Enums_1.AWTEventPriority.High | ||
}; | ||
} | ||
if (scenarioType == ScenarioType_1.default.OCSDK) { | ||
event = { | ||
name: ScenarioType_1.default.OCSDK, | ||
properties: __assign(__assign(__assign({}, AriaTelemetry.populateOCSDKBaseProperties()), properties), { LogLevel: LogLevel_1.default.WARN }), | ||
priority: Enums_1.AWTEventPriority.High | ||
}; | ||
} | ||
/* istanbul ignore next */ | ||
this._debug && console.log("[AriaTelemetry][warn]"); | ||
this._debug && console.log("[AriaTelemetry][warn] " + scenarioType); | ||
/* istanbul ignore next */ | ||
this._debug && console.log(event); | ||
/* istanbul ignore next */ | ||
this._debug && console.log(event.properties.Event); | ||
!AriaTelemetry._disable && AriaTelemetry.logger.logEvent(event); | ||
}; | ||
AriaTelemetry.error = function (properties) { | ||
AriaTelemetry.error = function (properties, scenarioType) { | ||
if (scenarioType === void 0) { scenarioType = ScenarioType_1.default.EVENTS; } | ||
var event = { | ||
@@ -81,9 +139,26 @@ name: ScenarioType_1.default.EVENTS, | ||
}; | ||
if (scenarioType == ScenarioType_1.default.IC3CLIENT) { | ||
event = { | ||
name: ScenarioType_1.default.IC3CLIENT, | ||
properties: __assign(__assign(__assign({}, AriaTelemetry.populateIC3ClientBaseProperties()), properties), { LogLevel: LogLevel_1.default.ERROR }), | ||
priority: Enums_1.AWTEventPriority.High | ||
}; | ||
} | ||
if (scenarioType == ScenarioType_1.default.OCSDK) { | ||
event = { | ||
name: ScenarioType_1.default.OCSDK, | ||
properties: __assign(__assign(__assign({}, AriaTelemetry.populateOCSDKBaseProperties()), properties), { LogLevel: LogLevel_1.default.ERROR }), | ||
priority: Enums_1.AWTEventPriority.High | ||
}; | ||
} | ||
/* istanbul ignore next */ | ||
this._debug && console.log("[AriaTelemetry][error]"); | ||
this._debug && console.log("[AriaTelemetry][error] " + scenarioType); | ||
/* istanbul ignore next */ | ||
this._debug && console.log(event); | ||
/* istanbul ignore next */ | ||
this._debug && console.log(event.properties.Event); | ||
!AriaTelemetry._disable && AriaTelemetry.logger.logEvent(event); | ||
}; | ||
AriaTelemetry.log = function (properties) { | ||
AriaTelemetry.log = function (properties, scenarioType) { | ||
if (scenarioType === void 0) { scenarioType = ScenarioType_1.default.EVENTS; } | ||
var event = { | ||
@@ -94,2 +169,16 @@ name: ScenarioType_1.default.EVENTS, | ||
}; | ||
if (scenarioType == ScenarioType_1.default.IC3CLIENT) { | ||
event = { | ||
name: ScenarioType_1.default.IC3CLIENT, | ||
properties: __assign(__assign(__assign({}, AriaTelemetry.populateIC3ClientBaseProperties()), properties), { LogLevel: LogLevel_1.default.LOG }), | ||
priority: Enums_1.AWTEventPriority.High | ||
}; | ||
} | ||
if (scenarioType == ScenarioType_1.default.OCSDK) { | ||
event = { | ||
name: ScenarioType_1.default.OCSDK, | ||
properties: __assign(__assign(__assign({}, AriaTelemetry.populateOCSDKBaseProperties()), properties), { LogLevel: LogLevel_1.default.LOG }), | ||
priority: Enums_1.AWTEventPriority.High | ||
}; | ||
} | ||
/* istanbul ignore next */ | ||
@@ -99,2 +188,4 @@ this._debug && console.log("[AriaTelemetry][log]"); | ||
this._debug && console.log(event); | ||
/* istanbul ignore next */ | ||
this._debug && console.log(event.properties.Event); | ||
!AriaTelemetry._disable && AriaTelemetry.logger.logEvent(event); | ||
@@ -105,2 +196,3 @@ }; | ||
if (!AriaTelemetry._logger) { | ||
/* istanbul ignore next */ | ||
this._debug && console.log("[AriaTelemetry][logger][initialize]"); | ||
@@ -157,2 +249,34 @@ AriaTelemetry._logger = AriaSDK_1.AWTLogManager.initialize(settings_1.ariaTelemetryKey); | ||
}; | ||
AriaTelemetry.populateIC3ClientBaseProperties = function () { | ||
return { | ||
OrgId: '', | ||
OrgUrl: '', | ||
WidgetId: '', | ||
RequestId: '', | ||
ChatId: '', | ||
Event: '', | ||
Description: '', | ||
SubscriptionId: '', | ||
EndpointId: '', | ||
EndpointUrl: '', | ||
ErrorCode: '', | ||
ExceptionDetails: '', | ||
ElapsedTimeInMilliseconds: '', | ||
IC3ClientVersion: settings_2.ic3ClientVersion | ||
}; | ||
}; | ||
AriaTelemetry.populateOCSDKBaseProperties = function () { | ||
return { | ||
OrgId: '', | ||
OrgUrl: '', | ||
WidgetId: '', | ||
RequestId: '', | ||
ChatId: '', | ||
TransactionId: '', | ||
Event: '', | ||
ExceptionDetails: '', | ||
ElapsedTimeInMilliseconds: '', | ||
OCSDKVersion: require('@microsoft/ocsdk/package.json').version // eslint-disable-line @typescript-eslint/no-var-requires | ||
}; | ||
}; | ||
AriaTelemetry._debug = false; | ||
@@ -159,0 +283,0 @@ AriaTelemetry._disable = false; |
declare enum ScenarioType { | ||
EVENTS = "occhatsdk_events", | ||
IC3CLIENT = "occhatsdk_ic3clientevents", | ||
OCSDK = "occhatsdk_ocsdkevents", | ||
UNDEFINED = "undefined" | ||
} | ||
export default ScenarioType; |
@@ -6,2 +6,4 @@ "use strict"; | ||
ScenarioType["EVENTS"] = "occhatsdk_events"; | ||
ScenarioType["IC3CLIENT"] = "occhatsdk_ic3clientevents"; | ||
ScenarioType["OCSDK"] = "occhatsdk_ocsdkevents"; | ||
ScenarioType["UNDEFINED"] = "undefined"; | ||
@@ -8,0 +10,0 @@ })(ScenarioType || (ScenarioType = {})); |
@@ -9,5 +9,6 @@ declare enum TelemetryEvent { | ||
GetChatToken = "GetChatToken", | ||
GetConversationDetails = "GetConversationDetails", | ||
SendTypingEvent = "SendTypingEvent", | ||
OnAgentEndSession = "OnAgentEndSession", | ||
UploadFileAttachment = "UpdateFileAttachment", | ||
UploadFileAttachment = "UploadFileAttachment", | ||
DownloadFileAttachment = "DownloadFileAttachment", | ||
@@ -25,3 +26,3 @@ EmailLiveChatTranscript = "EmailLiveChatTranscript", | ||
StopCall = "StopCall", | ||
onCallDisconnected = "onCallDisconnected" | ||
OnCallDisconnected = "OnCallDisconnected" | ||
} | ||
@@ -28,0 +29,0 @@ export declare const startEvent: (event: TelemetryEvent) => string; |
@@ -13,5 +13,6 @@ "use strict"; | ||
TelemetryEvent["GetChatToken"] = "GetChatToken"; | ||
TelemetryEvent["GetConversationDetails"] = "GetConversationDetails"; | ||
TelemetryEvent["SendTypingEvent"] = "SendTypingEvent"; | ||
TelemetryEvent["OnAgentEndSession"] = "OnAgentEndSession"; | ||
TelemetryEvent["UploadFileAttachment"] = "UpdateFileAttachment"; | ||
TelemetryEvent["UploadFileAttachment"] = "UploadFileAttachment"; | ||
TelemetryEvent["DownloadFileAttachment"] = "DownloadFileAttachment"; | ||
@@ -29,3 +30,3 @@ TelemetryEvent["EmailLiveChatTranscript"] = "EmailLiveChatTranscript"; | ||
TelemetryEvent["StopCall"] = "StopCall"; | ||
TelemetryEvent["onCallDisconnected"] = "onCallDisconnected"; | ||
TelemetryEvent["OnCallDisconnected"] = "OnCallDisconnected"; | ||
})(TelemetryEvent || (TelemetryEvent = {})); | ||
@@ -32,0 +33,0 @@ exports.startEvent = function (event) { |
{ | ||
"name": "@microsoft/omnichannel-chat-sdk", | ||
"version": "0.1.1-main.db70035", | ||
"version": "0.1.1-main.eab8ba8", | ||
"description": "Microsoft Omnichannel Chat SDK", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -69,2 +69,3 @@ # Omnichannel Chat SDK | ||
| OmnichannelChatSDK.getCurrentLiveChatContext() | Get current live chat context information to reconnect to the same chat | | | ||
| OmnichannelChatSDK.getConversationDetails() | Get details of the current conversation such as its state & when the agent joined the conversation | | | ||
| OmnichannelChatSDK.getChatToken() | Get chat token | | | ||
@@ -115,2 +116,7 @@ | OmnichannelChatSDK.getMessages() | Get all messages | | | ||
### Get Conversation Details | ||
```ts | ||
const conversationDetails = await chatSDK.getConversationDetails(); | ||
``` | ||
### Get Chat Token | ||
@@ -165,6 +171,10 @@ ```ts | ||
```ts | ||
const optionalParams = { | ||
rehydrate: true, // Rehydrate all previous messages of existing conversation (false by default) | ||
} | ||
chatSDK.onNewMessage((message) => { | ||
console.log(`[NewMessage] ${message.content}`); // IC3 protocol message data | ||
console.log(message); | ||
}); | ||
}, optionalParams); | ||
``` | ||
@@ -171,0 +181,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
716855
186
8854
555
1