@microsoft/omnichannel-chat-sdk
Advanced tools
Comparing version 0.1.1-main.8cef1e8 to 0.1.1-main.9a18ebe
@@ -10,2 +10,4 @@ # Changelog | ||
- Expose `sessiontInit`'s `initContext` on `startChat`'s optional paramaters | ||
- Add ability to use custom `ic3Config` & `chatAdapterConfig` | ||
- Add telemetry | ||
@@ -12,0 +14,0 @@ ### Changed |
import IChatToken from "../external/IC3Adapter/IChatToken"; | ||
import ScenarioMarker from "../telemetry/ScenarioMarker"; | ||
interface IVoiceVideoCallingParams { | ||
@@ -21,5 +22,7 @@ environment?: string; | ||
private callId?; | ||
private scenarioMarker?; | ||
private constructor(); | ||
static getInstance(): VoiceVideoCallingProxy; | ||
setDebug(flag: boolean): void; | ||
useScenarioMarker(scenarioMarker: ScenarioMarker): void; | ||
load(params?: any): Promise<void>; | ||
@@ -26,0 +29,0 @@ isInitialized(): boolean; |
@@ -40,2 +40,3 @@ "use strict"; | ||
exports.VoiceVideoCallingProxy = void 0; | ||
var TelemetryEvent_1 = require("../telemetry/TelemetryEvent"); | ||
var SecondaryChannelType; | ||
@@ -70,2 +71,5 @@ (function (SecondaryChannelType) { | ||
}; | ||
VoiceVideoCallingProxy.prototype.useScenarioMarker = function (scenarioMarker) { | ||
this.scenarioMarker = scenarioMarker; | ||
}; | ||
VoiceVideoCallingProxy.prototype.load = function (params) { | ||
@@ -87,6 +91,7 @@ if (params === void 0) { params = {}; } | ||
VoiceVideoCallingProxy.prototype.initialize = function (params) { | ||
var _a, _b, _c, _d, _e, _f; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j; | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
var _k; | ||
return __generator(this, function (_l) { | ||
switch (_l.label) { | ||
case 0: | ||
@@ -97,2 +102,5 @@ /* istanbul ignore next */ | ||
this.callId = (_a = this.callingParams) === null || _a === void 0 ? void 0 : _a.chatToken.chatId; | ||
(_b = this.scenarioMarker) === null || _b === void 0 ? void 0 : _b.startScenario(TelemetryEvent_1.default.InitializeVoiceVideoCallingSDK, { | ||
CallId: this.callId || '' | ||
}); | ||
/* istanbul ignore next */ | ||
@@ -103,13 +111,26 @@ this.debug && console.debug("[VoiceVideoCallingProxy][initialize] _isLoaded: " + this.proxyInstance._isLoaded); | ||
case 1: | ||
_g.sent(); | ||
_g.label = 2; | ||
_l.sent(); | ||
_l.label = 2; | ||
case 2: | ||
this.proxyInstance.initialize({ | ||
skypeid: (_b = this.callingParams) === null || _b === void 0 ? void 0 : _b.chatToken.visitorId, | ||
accesstoken: (_c = this.callingParams) === null || _c === void 0 ? void 0 : _c.chatToken.token, | ||
environment: ((_d = this.callingParams) === null || _d === void 0 ? void 0 : _d.environment) || 'prod', | ||
selfVideoHTMLElementId: (_e = this.callingParams) === null || _e === void 0 ? void 0 : _e.selfVideoHTMLElementId, | ||
remoteVideoHTMLElementId: (_f = this.callingParams) === null || _f === void 0 ? void 0 : _f.remoteVideoHTMLElementId | ||
_l.trys.push([2, 4, , 5]); | ||
return [4 /*yield*/, this.proxyInstance.initialize({ | ||
skypeid: (_c = this.callingParams) === null || _c === void 0 ? void 0 : _c.chatToken.visitorId, | ||
accesstoken: (_d = this.callingParams) === null || _d === void 0 ? void 0 : _d.chatToken.token, | ||
environment: ((_e = this.callingParams) === null || _e === void 0 ? void 0 : _e.environment) || 'prod', | ||
selfVideoHTMLElementId: (_f = this.callingParams) === null || _f === void 0 ? void 0 : _f.selfVideoHTMLElementId, | ||
remoteVideoHTMLElementId: (_g = this.callingParams) === null || _g === void 0 ? void 0 : _g.remoteVideoHTMLElementId | ||
})]; | ||
case 3: | ||
_l.sent(); | ||
(_h = this.scenarioMarker) === null || _h === void 0 ? void 0 : _h.completeScenario(TelemetryEvent_1.default.InitializeVoiceVideoCallingSDK, { | ||
CallId: this.callId || '' | ||
}); | ||
return [2 /*return*/]; | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
_k = _l.sent(); | ||
(_j = this.scenarioMarker) === null || _j === void 0 ? void 0 : _j.failScenario(TelemetryEvent_1.default.InitializeVoiceVideoCallingSDK, { | ||
CallId: this.callId || '' | ||
}); | ||
return [3 /*break*/, 5]; | ||
case 5: return [2 /*return*/]; | ||
} | ||
@@ -137,26 +158,59 @@ }); | ||
VoiceVideoCallingProxy.prototype.acceptCall = function (params) { | ||
var _a, _b; | ||
var _a, _b, _c, _d, _e, _f; | ||
if (params === void 0) { params = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var callId, body; | ||
return __generator(this, function (_c) { | ||
callId = this.callId; | ||
/* istanbul ignore next */ | ||
this.debug && console.debug("[VoiceVideoCallingProxy][acceptCall] callId: " + callId); | ||
/* istanbul ignore next */ | ||
this.debug && console.debug(params); | ||
this.proxyInstance.acceptCall({ callId: callId, withVideo: params.withVideo || false }); | ||
body = { | ||
SecondaryChannelType: params.withVideo ? SecondaryChannelType.Video : SecondaryChannelType.Voice, | ||
SecondaryChannelEventType: SecondaryChannelEvents.Accept | ||
}; | ||
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); | ||
/* istanbul ignore next */ | ||
this.debug && console.debug("[VoiceVideoCallingProxy][acceptCall][makeSecondaryChannelEventRequest]"); | ||
var callId, _g, exceptionDetails, body, exceptionDetails; | ||
return __generator(this, function (_h) { | ||
switch (_h.label) { | ||
case 0: | ||
callId = this.callId; | ||
(_a = this.scenarioMarker) === null || _a === void 0 ? void 0 : _a.startScenario(params.withVideo ? TelemetryEvent_1.default.AcceptVideoCall : TelemetryEvent_1.default.AcceptVoiceCall, { | ||
CallId: callId || '' | ||
}); | ||
/* istanbul ignore next */ | ||
this.debug && console.debug("[VoiceVideoCallingProxy][acceptCall] callId: " + callId); | ||
/* istanbul ignore next */ | ||
this.debug && console.debug(params); | ||
_h.label = 1; | ||
case 1: | ||
_h.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.proxyInstance.acceptCall({ callId: callId, withVideo: params.withVideo || false })]; | ||
case 2: | ||
_h.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
_g = _h.sent(); | ||
exceptionDetails = { | ||
response: params.withVideo ? "AcceptVideoCallFailed" : "AcceptVoiceCallFailed" | ||
}; | ||
(_b = this.scenarioMarker) === null || _b === void 0 ? void 0 : _b.failScenario(params.withVideo ? TelemetryEvent_1.default.AcceptVideoCall : TelemetryEvent_1.default.AcceptVoiceCall, { | ||
CallId: callId || '', | ||
ExceptionDetails: JSON.stringify(exceptionDetails) | ||
}); | ||
return [3 /*break*/, 4]; | ||
case 4: | ||
body = { | ||
SecondaryChannelType: params.withVideo ? SecondaryChannelType.Video : SecondaryChannelType.Voice, | ||
SecondaryChannelEventType: SecondaryChannelEvents.Accept | ||
}; | ||
try { | ||
(_c = this.callingParams) === null || _c === void 0 ? void 0 : _c.OCClient.makeSecondaryChannelEventRequest((_d = this.callingParams) === null || _d === void 0 ? void 0 : _d.chatToken.requestId, body); | ||
(_e = this.scenarioMarker) === null || _e === void 0 ? void 0 : _e.completeScenario(params.withVideo ? TelemetryEvent_1.default.AcceptVideoCall : TelemetryEvent_1.default.AcceptVoiceCall, { | ||
CallId: callId || '' | ||
}); | ||
/* istanbul ignore next */ | ||
this.debug && console.debug("[VoiceVideoCallingProxy][acceptCall][makeSecondaryChannelEventRequest]"); | ||
} | ||
catch (e) { | ||
exceptionDetails = { | ||
response: "OCClientMakeSecondaryChannelEventRequestFailed" | ||
}; | ||
(_f = this.scenarioMarker) === null || _f === void 0 ? void 0 : _f.failScenario(params.withVideo ? TelemetryEvent_1.default.AcceptVideoCall : TelemetryEvent_1.default.AcceptVoiceCall, { | ||
CallId: callId || '', | ||
ExceptionDetails: JSON.stringify(exceptionDetails) | ||
}); | ||
console.error("[VoiceVideoCallingProxy][acceptCall][makeSecondaryChannelEventRequest] Failure " + e); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
catch (e) { | ||
console.error("[VoiceVideoCallingProxy][acceptCall][makeSecondaryChannelEventRequest] Failure " + e); | ||
} | ||
return [2 /*return*/]; | ||
}); | ||
@@ -166,24 +220,57 @@ }); | ||
VoiceVideoCallingProxy.prototype.rejectCall = function () { | ||
var _a, _b; | ||
var _a, _b, _c, _d, _e, _f; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var callId, body; | ||
return __generator(this, function (_c) { | ||
callId = this.callId; | ||
/* istanbul ignore next */ | ||
this.debug && console.debug("[VoiceVideoCallingProxy][rejectCall] callId: " + callId); | ||
this.proxyInstance.rejectCall({ callId: callId }); | ||
body = { | ||
SecondaryChannelType: this.isRemoteVideoEnabled() ? SecondaryChannelType.Video : SecondaryChannelType.Voice, | ||
SecondaryChannelEventType: SecondaryChannelEvents.Reject | ||
}; | ||
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); | ||
/* istanbul ignore next */ | ||
this.debug && console.debug("[VoiceVideoCallingProxy][rejectCall][makeSecondaryChannelEventRequest]"); | ||
var callId, _g, exceptionDetails, body, exceptionDetails; | ||
return __generator(this, function (_h) { | ||
switch (_h.label) { | ||
case 0: | ||
callId = this.callId; | ||
(_a = this.scenarioMarker) === null || _a === void 0 ? void 0 : _a.startScenario(TelemetryEvent_1.default.RejectCall, { | ||
CallId: callId || '' | ||
}); | ||
/* istanbul ignore next */ | ||
this.debug && console.debug("[VoiceVideoCallingProxy][rejectCall] callId: " + callId); | ||
_h.label = 1; | ||
case 1: | ||
_h.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.proxyInstance.rejectCall({ callId: callId })]; | ||
case 2: | ||
_h.sent(); | ||
(_b = this.scenarioMarker) === null || _b === void 0 ? void 0 : _b.completeScenario(TelemetryEvent_1.default.RejectCall, { | ||
CallId: callId || '' | ||
}); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
_g = _h.sent(); | ||
exceptionDetails = { | ||
response: "RejectCallFailed" | ||
}; | ||
(_c = this.scenarioMarker) === null || _c === void 0 ? void 0 : _c.failScenario(TelemetryEvent_1.default.RejectCall, { | ||
CallId: callId || '', | ||
ExceptionDetails: JSON.stringify(exceptionDetails) | ||
}); | ||
return [3 /*break*/, 4]; | ||
case 4: | ||
body = { | ||
SecondaryChannelType: this.isRemoteVideoEnabled() ? SecondaryChannelType.Video : SecondaryChannelType.Voice, | ||
SecondaryChannelEventType: SecondaryChannelEvents.Reject | ||
}; | ||
try { | ||
(_d = this.callingParams) === null || _d === void 0 ? void 0 : _d.OCClient.makeSecondaryChannelEventRequest((_e = this.callingParams) === null || _e === void 0 ? void 0 : _e.chatToken.requestId, body); | ||
/* istanbul ignore next */ | ||
this.debug && console.debug("[VoiceVideoCallingProxy][rejectCall][makeSecondaryChannelEventRequest]"); | ||
} | ||
catch (e) { | ||
exceptionDetails = { | ||
response: "OCClientMakeSecondaryChannelEventRequestFailed" | ||
}; | ||
(_f = this.scenarioMarker) === null || _f === void 0 ? void 0 : _f.failScenario(TelemetryEvent_1.default.RejectCall, { | ||
CallId: callId || '', | ||
ExceptionDetails: JSON.stringify(exceptionDetails) | ||
}); | ||
console.error("[VoiceVideoCallingProxy][rejectCall][makeSecondaryChannelEventRequest] Failure " + e); | ||
return [2 /*return*/, e]; | ||
} | ||
return [2 /*return*/]; | ||
} | ||
catch (e) { | ||
console.error("[VoiceVideoCallingProxy][rejectCall][makeSecondaryChannelEventRequest] Failure " + e); | ||
return [2 /*return*/, e]; | ||
} | ||
return [2 /*return*/]; | ||
}); | ||
@@ -193,10 +280,32 @@ }); | ||
VoiceVideoCallingProxy.prototype.stopCall = function () { | ||
var _a, _b, _c; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var callId; | ||
return __generator(this, function (_a) { | ||
callId = this.callId; | ||
/* istanbul ignore next */ | ||
this.debug && console.debug("[VoiceVideoCallingProxy][stopCall] callId: " + callId); | ||
this.clearRemoteVideoElementChildren(); | ||
return [2 /*return*/, this.proxyInstance.stopCall({ callId: callId })]; | ||
var callId, _d; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
callId = this.callId; | ||
(_a = this.scenarioMarker) === null || _a === void 0 ? void 0 : _a.startScenario(TelemetryEvent_1.default.StopCall, { | ||
CallId: callId || '' | ||
}); | ||
/* istanbul ignore next */ | ||
this.debug && console.debug("[VoiceVideoCallingProxy][stopCall] callId: " + callId); | ||
_e.label = 1; | ||
case 1: | ||
_e.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.proxyInstance.stopCall({ callId: callId })]; | ||
case 2: | ||
_e.sent(); | ||
(_b = this.scenarioMarker) === null || _b === void 0 ? void 0 : _b.completeScenario(TelemetryEvent_1.default.StopCall, { | ||
CallId: callId || '' | ||
}); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
_d = _e.sent(); | ||
(_c = this.scenarioMarker) === null || _c === void 0 ? void 0 : _c.failScenario(TelemetryEvent_1.default.StopCall, { | ||
CallId: callId || '', | ||
}); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
@@ -203,0 +312,0 @@ }); |
declare const ic3ClientVersion = "2020.08.24.1"; | ||
declare const webChatIC3AdapterVersion = "0.1.0-master.86ac1a0"; | ||
export { ic3ClientVersion, webChatIC3AdapterVersion }; | ||
declare const ariaTelemetryKey = "07172c8dd08d4de7a594b5b5cf81e668-92304109-4cd9-41b6-8806-714387b256e8-7337"; | ||
export { ic3ClientVersion, webChatIC3AdapterVersion, ariaTelemetryKey }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.webChatIC3AdapterVersion = exports.ic3ClientVersion = void 0; | ||
exports.ariaTelemetryKey = exports.webChatIC3AdapterVersion = exports.ic3ClientVersion = void 0; | ||
var ic3ClientVersion = '2020.08.24.1'; | ||
@@ -8,2 +8,4 @@ exports.ic3ClientVersion = ic3ClientVersion; | ||
exports.webChatIC3AdapterVersion = webChatIC3AdapterVersion; | ||
var ariaTelemetryKey = '07172c8dd08d4de7a594b5b5cf81e668-92304109-4cd9-41b6-8806-714387b256e8-7337'; | ||
exports.ariaTelemetryKey = ariaTelemetryKey; | ||
//# sourceMappingURL=settings.js.map |
@@ -0,1 +1,3 @@ | ||
import ChatAdapterConfig from "./ChatAdapterConfig"; | ||
import IC3Config from "./IC3Config"; | ||
interface IDataMaskingSDKConfig { | ||
@@ -5,7 +7,14 @@ disable: boolean; | ||
} | ||
interface TelemetrySDKConfig { | ||
disable: boolean; | ||
ariaTelemetryKey?: string; | ||
} | ||
interface IChatSDKConfig { | ||
dataMasking: IDataMaskingSDKConfig; | ||
dataMasking?: IDataMaskingSDKConfig; | ||
telemetry?: TelemetrySDKConfig; | ||
getAuthToken?: () => Promise<string | null>; | ||
ic3Config?: IC3Config; | ||
chatAdapterConfig?: ChatAdapterConfig; | ||
} | ||
export { IDataMaskingSDKConfig }; | ||
export default IChatSDKConfig; |
@@ -31,2 +31,4 @@ import IChatConfig from "./core/IChatConfig"; | ||
private callingOption; | ||
private telemetry; | ||
private scenarioMarker; | ||
constructor(omnichannelConfig: IOmnichannelConfig, chatSDKConfig?: IChatSDKConfig); | ||
@@ -60,3 +62,5 @@ setDebug(flag: boolean): void; | ||
private getChatConfig; | ||
private resolveIC3ClientUrl; | ||
private resolveChatAdapterUrl; | ||
} | ||
export default OmnichannelChatSDK; |
@@ -58,5 +58,9 @@ "use strict"; | ||
var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber"); | ||
var createTelemetry_1 = require("./utils/createTelemetry"); | ||
var TelemetryEvent_1 = require("./telemetry/TelemetryEvent"); | ||
var ScenarioMarker_1 = require("./telemetry/ScenarioMarker"); | ||
var OmnichannelChatSDK = /** @class */ (function () { | ||
function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) { | ||
if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; } | ||
var _a, _b; | ||
this.authSettings = null; | ||
@@ -66,2 +70,3 @@ this.authenticatedUserToken = null; | ||
this.callingOption = CallingOptionsOptionSetNumber_1.default.NoCalling; | ||
this.telemetry = null; | ||
this.debug = false; | ||
@@ -76,25 +81,45 @@ this.omnichannelConfig = omnichannelConfig; | ||
this.preChatSurvey = null; | ||
this.telemetry = createTelemetry_1.default(this.debug); | ||
this.scenarioMarker = new ScenarioMarker_1.default(this.omnichannelConfig); | ||
this.scenarioMarker.useTelemetry(this.telemetry); | ||
OmnichannelConfigValidator_1.default(omnichannelConfig); | ||
SDKConfigValidators_1.default(chatSDKConfig); | ||
((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable()); | ||
} | ||
/* istanbul ignore next */ | ||
OmnichannelChatSDK.prototype.setDebug = function (flag) { | ||
var _a; | ||
this.debug = flag; | ||
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setDebug(flag); | ||
this.scenarioMarker.setDebug(flag); | ||
}; | ||
OmnichannelChatSDK.prototype.initialize = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
var _a, _b, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeChatSDK); | ||
_d.label = 1; | ||
case 1: | ||
_d.trys.push([1, 5, , 6]); | ||
this.OCSDKProvider = ocsdk_1.SDKProvider; | ||
_a = this; | ||
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, undefined)]; | ||
case 1: | ||
_a.OCClient = _c.sent(); // eslint-disable-line @typescript-eslint/no-explicit-any | ||
case 2: | ||
_a.OCClient = _d.sent(); // eslint-disable-line @typescript-eslint/no-explicit-any | ||
_b = this; | ||
return [4 /*yield*/, this.getIC3Client()]; | ||
case 2: | ||
_b.IC3Client = _c.sent(); | ||
return [2 /*return*/, this.getChatConfig()]; | ||
case 3: | ||
_b.IC3Client = _d.sent(); | ||
return [4 /*yield*/, this.getChatConfig()]; | ||
case 4: | ||
_d.sent(); | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK); | ||
return [3 /*break*/, 6]; | ||
case 5: | ||
_c = _d.sent(); | ||
this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDK); | ||
return [3 /*break*/, 6]; | ||
case 6: return [2 /*return*/, this.liveChatConfig]; | ||
} | ||
@@ -107,6 +132,9 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var sessionInitOptionalParams, error_1, error_2, _a, error_3; | ||
var sessionInitOptionalParams, error_1, exceptionDetails, error_2, exceptionDetails, _a, error_3, exceptionDetails; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, { | ||
RequestId: this.requestId | ||
}); | ||
if (optionalParams.liveChatContext) { | ||
@@ -159,2 +187,10 @@ this.chatToken = optionalParams.liveChatContext.chatToken || {}; | ||
error_1 = _b.sent(); | ||
exceptionDetails = { | ||
response: "OCClientSessionInitFailed" | ||
}; | ||
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId, | ||
ExceptionDetails: JSON.stringify(exceptionDetails) | ||
}); | ||
console.error("OmnichannelChatSDK/startChat/sessionInit/error " + error_1); | ||
@@ -174,2 +210,10 @@ return [2 /*return*/, error_1]; | ||
error_2 = _b.sent(); | ||
exceptionDetails = { | ||
response: "IC3ClientInitializeFailed" | ||
}; | ||
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId, | ||
ExceptionDetails: JSON.stringify(exceptionDetails) | ||
}); | ||
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_2); | ||
@@ -183,5 +227,17 @@ return [2 /*return*/, error_2]; | ||
_a.conversation = _b.sent(); | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId | ||
}); | ||
return [3 /*break*/, 12]; | ||
case 11: | ||
error_3 = _b.sent(); | ||
exceptionDetails = { | ||
response: "IC3ClientJoinConversationFailed" | ||
}; | ||
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId, | ||
ExceptionDetails: JSON.stringify(exceptionDetails) | ||
}); | ||
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_3); | ||
@@ -196,6 +252,10 @@ return [2 /*return*/, error_3]; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var sessionCloseOptionalParams, error_4; | ||
var sessionCloseOptionalParams, error_4, exceptionDetails; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId | ||
}); | ||
sessionCloseOptionalParams = {}; | ||
@@ -211,2 +271,6 @@ if (this.authenticatedUserToken) { | ||
_a.sent(); | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId | ||
}); | ||
this.conversation.disconnect(); | ||
@@ -219,2 +283,10 @@ this.conversation = null; | ||
error_4 = _a.sent(); | ||
exceptionDetails = { | ||
response: "OCClientSessionCloseFailed" | ||
}; | ||
this.scenarioMarker.failScenario(TelemetryEvent_1.default.EndChat, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId, | ||
ExceptionDetails: JSON.stringify(exceptionDetails), | ||
}); | ||
console.error("OmnichannelChatSDK/endChat/error " + error_4); | ||
@@ -274,7 +346,10 @@ return [2 /*return*/, error_4]; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, error_5; | ||
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, error_5, exceptionDetails; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!!cached) return [3 /*break*/, 4]; | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetChatToken, { | ||
RequestId: this.requestId | ||
}); | ||
if (!!cached) return [3 /*break*/, 5]; | ||
_a.label = 1; | ||
@@ -300,8 +375,27 @@ case 1: | ||
}; | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetChatToken, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId | ||
}); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
error_5 = _a.sent(); | ||
exceptionDetails = { | ||
response: "OCClientGetChatTokenFailed" | ||
}; | ||
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetChatToken, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId, | ||
ExceptionDetails: JSON.stringify(exceptionDetails), | ||
}); | ||
console.error("OmnichannelChatSDK/getChatToken/error " + error_5); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/, this.chatToken]; | ||
case 4: return [3 /*break*/, 6]; | ||
case 5: | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetChatToken, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId | ||
}); | ||
_a.label = 6; | ||
case 6: return [2 /*return*/, this.chatToken]; | ||
} | ||
@@ -533,6 +627,11 @@ }); | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
ic3AdapterCDNUrl = libraries_1.default.getIC3AdapterCDNUrl(); | ||
ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol); | ||
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({ | ||
IC3Adapter: ic3AdapterCDNUrl | ||
}); | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.CreateIC3Adapter); | ||
return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () { | ||
@@ -545,11 +644,13 @@ /* istanbul ignore next */ | ||
userId: 'teamsvisitor', | ||
sdkURL: libraries_1.default.getIC3ClientCDNUrl() | ||
sdkURL: _this.resolveIC3ClientUrl(), | ||
}; | ||
var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig); | ||
_this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter); | ||
resolve(adapter); | ||
}, function () { | ||
_this.scenarioMarker.failScenario(TelemetryEvent_1.default.CreateIC3Adapter); | ||
reject('Failed to load IC3Adapter'); | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
_b.sent(); | ||
return [2 /*return*/]; | ||
@@ -587,6 +688,11 @@ } | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var _a, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
spoolSDKCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/spool-sdk/sdk.bundle.js"; | ||
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({ | ||
SpoolSDK: spoolSDKCDNUrl | ||
}); | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling); | ||
return [4 /*yield*/, WebUtils_1.loadScript(spoolSDKCDNUrl, function () { | ||
@@ -596,7 +702,16 @@ /* istanbul ignore next */ | ||
}, function () { | ||
var exceptionDetails = { | ||
response: "SpoolSDKLoadFailed" | ||
}; | ||
_this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, { | ||
ExceptionDetails: JSON.stringify(exceptionDetails) | ||
}); | ||
reject('Failed to load SpoolSDK'); | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
_c.sent(); | ||
LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/LiveChatWidgetLibs.min.js"; | ||
(_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setCDNPackages({ | ||
VoiceVideoCalling: LiveChatWidgetLibCDNUrl | ||
}); | ||
return [4 /*yield*/, WebUtils_1.loadScript(LiveChatWidgetLibCDNUrl, function () { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -611,2 +726,4 @@ var VoiceVideoCalling; | ||
VoiceVideoCalling = _a.sent(); | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetVoiceVideoCalling); | ||
VoiceVideoCalling.useScenarioMarker(this.scenarioMarker); | ||
resolve(VoiceVideoCalling); | ||
@@ -617,3 +734,10 @@ return [2 /*return*/]; | ||
}); }, function () { return __awaiter(_this, void 0, void 0, function () { | ||
var exceptionDetails; | ||
return __generator(this, function (_a) { | ||
exceptionDetails = { | ||
response: "VoiceVideoCallingLoadFailed" | ||
}; | ||
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, { | ||
ExceptionDetails: JSON.stringify(exceptionDetails) | ||
}); | ||
reject('Failed to load VoiceVideoCalling'); | ||
@@ -624,3 +748,3 @@ return [2 /*return*/]; | ||
case 2: | ||
_a.sent(); | ||
_c.sent(); | ||
return [2 /*return*/]; | ||
@@ -645,2 +769,3 @@ } | ||
this.debug && console.debug('IC3Core'); | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client); | ||
// Use FramelessBridge from IC3Core | ||
@@ -655,4 +780,6 @@ this.IC3SDKProvider = omnichannel_ic3core_1.SDKProvider; | ||
IC3Client.setDebug(this.debug); | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetIC3Client); | ||
return [2 /*return*/, IC3Client]; | ||
case 2: | ||
/* istanbul ignore next */ | ||
this.debug && console.debug('IC3Client'); | ||
@@ -663,6 +790,11 @@ // Use IC3Client if browser is detected | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
ic3ClientCDNUrl = libraries_1.default.getIC3ClientCDNUrl(); | ||
ic3ClientCDNUrl = this.resolveIC3ClientUrl(); | ||
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({ | ||
IC3Client: ic3ClientCDNUrl | ||
}); | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client); | ||
window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -685,2 +817,3 @@ var ic3sdk, IC3SDKProvider, IC3Client; | ||
IC3Client = _a.sent(); | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetIC3Client); | ||
resolve(IC3Client); | ||
@@ -692,8 +825,15 @@ return [2 /*return*/]; | ||
return [4 /*yield*/, WebUtils_1.loadScript(ic3ClientCDNUrl, function () { | ||
/* istanbul ignore next */ | ||
_this.debug && console.debug('IC3Client loaded!'); | ||
}, function () { | ||
reject('Failed to load IC3Adapter'); | ||
var exceptionDetails = { | ||
response: "IC3ClientLoadFailed" | ||
}; | ||
_this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetIC3Client, { | ||
ExceptionDetails: JSON.stringify(exceptionDetails) | ||
}); | ||
reject('Failed to load IC3Client'); | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
_b.sent(); | ||
return [2 /*return*/]; | ||
@@ -748,2 +888,3 @@ } | ||
if (this.preChatSurvey) { | ||
/* istanbul ignore next */ | ||
this.debug && console.log('Prechat Survey!'); | ||
@@ -763,2 +904,23 @@ } | ||
}; | ||
OmnichannelChatSDK.prototype.resolveIC3ClientUrl = function () { | ||
if (this.chatSDKConfig.ic3Config && 'ic3ClientCDNUrl' in this.chatSDKConfig.ic3Config) { | ||
return this.chatSDKConfig.ic3Config.ic3ClientCDNUrl; | ||
} | ||
if (this.chatSDKConfig.ic3Config && 'ic3ClientVersion' in this.chatSDKConfig.ic3Config) { | ||
return libraries_1.default.getIC3ClientCDNUrl(this.chatSDKConfig.ic3Config.ic3ClientVersion); | ||
} | ||
return libraries_1.default.getIC3ClientCDNUrl(); | ||
}; | ||
OmnichannelChatSDK.prototype.resolveChatAdapterUrl = function (protocol) { | ||
if (protocol !== ChatAdapterProtocols_1.default.IC3) { | ||
throw new Error("ChatAdapter for protocol " + protocol + " currently not supported"); | ||
} | ||
if (this.chatSDKConfig.chatAdapterConfig && 'webChatIC3AdapterCDNUrl' in this.chatSDKConfig.chatAdapterConfig) { | ||
return this.chatSDKConfig.chatAdapterConfig.webChatIC3AdapterCDNUrl; | ||
} | ||
if (this.chatSDKConfig.chatAdapterConfig && 'webChatIC3AdapterVersion' in this.chatSDKConfig.chatAdapterConfig) { | ||
return libraries_1.default.getIC3AdapterCDNUrl(this.chatSDKConfig.chatAdapterConfig.webChatIC3AdapterVersion); | ||
} | ||
return libraries_1.default.getIC3AdapterCDNUrl(); | ||
}; | ||
return OmnichannelChatSDK; | ||
@@ -765,0 +927,0 @@ }()); |
@@ -1,8 +0,8 @@ | ||
declare const getIC3ClientCDNUrl: () => string; | ||
declare const getIC3AdapterCDNUrl: () => string; | ||
declare const getIC3ClientCDNUrl: (version?: string) => string; | ||
declare const getIC3AdapterCDNUrl: (version?: string) => string; | ||
declare const _default: { | ||
getIC3ClientCDNUrl: () => string; | ||
getIC3AdapterCDNUrl: () => string; | ||
getIC3ClientCDNUrl: (version?: string) => string; | ||
getIC3AdapterCDNUrl: (version?: string) => string; | ||
}; | ||
export default _default; | ||
export { getIC3ClientCDNUrl, getIC3AdapterCDNUrl }; |
@@ -5,9 +5,11 @@ "use strict"; | ||
var settings_1 = require("../config/settings"); | ||
var getIC3ClientCDNUrl = function () { | ||
var IC3ClientCDNUrl = "https://comms.omnichannelengagementhub.com/release/" + settings_1.ic3ClientVersion + "/Scripts/SDK/SDK.min.js"; | ||
var getIC3ClientCDNUrl = function (version) { | ||
if (version === void 0) { version = settings_1.ic3ClientVersion; } | ||
var IC3ClientCDNUrl = "https://comms.omnichannelengagementhub.com/release/" + version + "/Scripts/SDK/SDK.min.js"; | ||
return IC3ClientCDNUrl; | ||
}; | ||
exports.getIC3ClientCDNUrl = getIC3ClientCDNUrl; | ||
var getIC3AdapterCDNUrl = function () { | ||
var IC3AdapterCDNUrl = "https://webchatic3.blob.core.windows.net/webchat-ic3adapter/" + settings_1.webChatIC3AdapterVersion + "/botframework-webchat-adapter-ic3.production.min.js"; | ||
var getIC3AdapterCDNUrl = function (version) { | ||
if (version === void 0) { version = settings_1.webChatIC3AdapterVersion; } | ||
var IC3AdapterCDNUrl = "https://webchatic3.blob.core.windows.net/webchat-ic3adapter/" + version + "/botframework-webchat-adapter-ic3.production.min.js"; | ||
return IC3AdapterCDNUrl; | ||
@@ -14,0 +16,0 @@ }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.defaultChatSDKConfig = void 0; | ||
var settings_1 = require("../config/settings"); | ||
var defaultChatSDKConfig = { | ||
@@ -8,2 +9,6 @@ dataMasking: { | ||
maskingCharacter: '#' | ||
}, | ||
telemetry: { | ||
disable: false, | ||
ariaTelemetryKey: settings_1.ariaTelemetryKey | ||
} | ||
@@ -18,6 +23,6 @@ }; | ||
if (typeof dataMaskingConfig.disable !== "boolean") { | ||
dataMaskingConfig.disable = defaultChatSDKConfig.dataMasking.disable; | ||
dataMaskingConfig.disable = defaultChatSDKConfig.dataMasking.disable; // eslint-disable-line @typescript-eslint/no-non-null-assertion | ||
} | ||
if (typeof dataMaskingConfig.maskingCharacter !== "string" || dataMaskingConfig.maskingCharacter.length !== 1) { | ||
dataMaskingConfig.maskingCharacter = defaultChatSDKConfig.dataMasking.maskingCharacter; | ||
dataMaskingConfig.maskingCharacter = defaultChatSDKConfig.dataMasking.maskingCharacter; // eslint-disable-line @typescript-eslint/no-non-null-assertion | ||
} | ||
@@ -24,0 +29,0 @@ }; |
{ | ||
"name": "@microsoft/omnichannel-chat-sdk", | ||
"version": "0.1.1-main.8cef1e8", | ||
"version": "0.1.1-main.9a18ebe", | ||
"description": "Microsoft Omnichannel Chat SDK", | ||
@@ -11,3 +11,3 @@ "files": [ | ||
"scripts": { | ||
"build:tsc": "tsc", | ||
"build:tsc": "tsc && cp -r src/external/aria lib/external/", | ||
"test": "jest", | ||
@@ -14,0 +14,0 @@ "lint": "eslint src --ext .ts" |
@@ -8,3 +8,7 @@ # Omnichannel Chat SDK | ||
Please make sure you have a chat widget configured before using this package or you can follow this [link](https://docs.microsoft.com/en-us/dynamics365/customer-service/configure-live-chat) | ||
## Table of Contents | ||
- [Live Chat Widget vs. Chat SDK](#live-chat-widget-vs-chat-sdk) | ||
- [Installation](#installation) | ||
- [API Reference](#api-reference) | ||
@@ -15,3 +19,36 @@ - [API Examples](#api-examples) | ||
- [Feature Comparisons](#feature-comparisons) | ||
- [Telemetry](#telemetry) | ||
## Live Chat Widget vs. Chat SDK | ||
Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SDK to build your custom chat widget if: | ||
- You want to fully customize the user interface of the chat widget to conform with your branding. | ||
- You want to integrate Omnichannel in your mobile app using React Native. | ||
- You want to integrate additional functionalities that LCW does not offer. | ||
- Some other cool ideas. Please share with us on what you've achieved with the Chat SDK! π | ||
### Feature Comparisons | ||
| Feature | Live Chat Widget | Chat SDK | Notes | | ||
| ----- | ----- | ----- | ----- | | ||
| Bring Your Own Widget | β | β | | | ||
| Web Support | β | β | | ||
| React Native Support | β | β | | ||
| Escalation to Voice & Video | β | Web Only | | ||
| Co-browse | β | β | | ||
| Screen Sharing | β | β | | ||
| Authenticated Chat | β | β | | ||
| Pre-chat Survey | β | β | | ||
| Post-chat Survey | β | β | | ||
| Queue Position | β | β | | ||
| Average Wait Time | β | β | | ||
| Download Transcript | β | β | | ||
| Email Transcript | β | β | | ||
| Data Masking | β | β | | ||
| File Attachments | β | β | | ||
| Custom Context | β | β | | ||
| Proactive Chat | β | BYOI **\*** | | ||
**\*** BYOI: Bring Your Own Implementation | ||
## Installation | ||
@@ -64,3 +101,3 @@ | ||
const chatSDKConfig = { // Optional | ||
DataMasking: { | ||
dataMasking: { | ||
disable: false, | ||
@@ -450,3 +487,3 @@ maskingCharacter: '#' | ||
| PreChat Survey | Requires Adaptive Cards renderer | Requires Adaptive Cards renderer | ||
| Display Attachments | Requires implementation | Provided & Customizable | | ||
| Display Attachments | Requires implementation | Basic interface provided & Customizable | | ||
| Incoming messages handling | IC3 protocol message data | DirectLine activity data | | ||
@@ -465,3 +502,36 @@ | ||
## Telemetry | ||
Omnichannel Chat SDK collects telemetry by default to improve the featureβs capabilities, reliability, and performance over time by helping Microsoft understand usage patterns, plan new features, and troubleshoot and fix problem areas. | ||
Some of the data being collected are the following: | ||
| Field | Sample | | ||
| --- | --- | | ||
| Organization Id | `e00e67ee-a60e-4b49-b28c-9d279bf42547` | | ||
| Organization Url | `org60082947.crm.oc.crmlivetie.com` | | ||
| Widget Id | `1893e4ae-2859-4ac4-9cf5-97cffbb9c01b` | | ||
| Browser Name | `Edge` | | ||
| Os Name | `Windows` | | ||
| Anonymized IP Address (last octet redacted) | `19.207.000.000` | | ||
If your organization is concerned about the data collected by the Chat SDK, you have the option to turn off automatic data collection by adding a flag in the `ChatSDKConfig`. | ||
```ts | ||
const omnichannelConfig = { | ||
orgUrl: "", | ||
orgId: "", | ||
widgetId: "" | ||
}; | ||
const chatSDKConfig = { | ||
telemetry: { | ||
disable: true // Disable telemetry | ||
} | ||
}; | ||
const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig); | ||
await chatSDK.initialize(); | ||
``` | ||
# Contributing | ||
@@ -468,0 +538,0 @@ |
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
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
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
Network access
Supply chain riskThis module accesses the network.
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
660421
171
8195
545
2