@microsoft/omnichannel-chat-sdk
Advanced tools
Comparing version 0.1.1-main.c05dc32 to 0.1.1-main.c670083
@@ -9,2 +9,5 @@ # Changelog | ||
- React sample app using Omnichannel Chat SDK with [BotFramework-WebChat](https://github.com/microsoft/BotFramework-WebChat) | ||
- Expose `sessiontInit`'s `initContext` on `startChat`'s optional paramaters | ||
- Add ability to use custom `ic3Config` & `chatAdapterConfig` | ||
- Add telemetry | ||
@@ -16,5 +19,8 @@ ### Changed | ||
- Uptake [ts-jest@26.5.1](https://www.npmjs.com/package/ts-jest/v/26.5.1) | ||
- Uptake [IC3Client@2021.03.02.1](https://comms.omnichannelengagementhub.com/release/2021.03.02.1/Scripts/SDK/SDK.min.js) | ||
- Uptake [botframework-webchat-adapter-ic3@0.1.0-master.f4dfd7d](https://www.npmjs.com/package/botframework-webchat-adapter-ic3/v/0.1.0-master.f4dfd7d) | ||
### Fixed | ||
- onAgentEndSession triggered on accept voice & video call | ||
- Fix multiple instances of IC3Client initialized | ||
@@ -21,0 +27,0 @@ ### Security |
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 @@ }); |
@@ -1,3 +0,4 @@ | ||
declare const ic3ClientVersion = "2020.08.24.1"; | ||
declare const webChatIC3AdapterVersion = "0.1.0-master.86ac1a0"; | ||
export { ic3ClientVersion, webChatIC3AdapterVersion }; | ||
declare const ic3ClientVersion = "2021.03.02.1"; | ||
declare const webChatIC3AdapterVersion = "0.1.0-master.92b1505"; | ||
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; | ||
var ic3ClientVersion = '2020.08.24.1'; | ||
exports.ariaTelemetryKey = exports.webChatIC3AdapterVersion = exports.ic3ClientVersion = void 0; | ||
var ic3ClientVersion = '2021.03.02.1'; | ||
exports.ic3ClientVersion = ic3ClientVersion; | ||
var webChatIC3AdapterVersion = '0.1.0-master.86ac1a0'; | ||
var webChatIC3AdapterVersion = '0.1.0-master.92b1505'; | ||
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; |
@@ -0,1 +1,2 @@ | ||
import InitContext from "@microsoft/ocsdk/lib/Model/InitContext"; | ||
import ILiveChatContext from "./ILiveChatContext"; | ||
@@ -5,2 +6,8 @@ export default interface IStartChatOptionalParams { | ||
preChatResponse?: object; | ||
customContext?: object; | ||
browser?: string; | ||
os?: string; | ||
locale?: string; | ||
device?: string; | ||
initContext?: InitContext; | ||
} |
@@ -9,2 +9,3 @@ import IConversation from "@microsoft/omnichannel-ic3core/lib/model/IConversation"; | ||
sdkURL?: string; | ||
sdk?: any; | ||
} |
@@ -22,2 +22,3 @@ import IChatConfig from "./core/IChatConfig"; | ||
chatSDKConfig: IChatSDKConfig; | ||
isInitialized: boolean; | ||
requestId: string; | ||
@@ -32,2 +33,5 @@ private chatToken; | ||
private callingOption; | ||
private telemetry; | ||
private scenarioMarker; | ||
private ic3ClientLogger; | ||
constructor(omnichannelConfig: IOmnichannelConfig, chatSDKConfig?: IChatSDKConfig); | ||
@@ -61,3 +65,5 @@ setDebug(flag: boolean): void; | ||
private getChatConfig; | ||
private resolveIC3ClientUrl; | ||
private resolveChatAdapterUrl; | ||
} | ||
export default OmnichannelChatSDK; |
@@ -58,5 +58,10 @@ "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 loggers_1 = require("./utils/loggers"); | ||
var OmnichannelChatSDK = /** @class */ (function () { | ||
function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) { | ||
if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; } | ||
var _a, _b, _c; | ||
this.authSettings = null; | ||
@@ -66,5 +71,8 @@ this.authenticatedUserToken = null; | ||
this.callingOption = CallingOptionsOptionSetNumber_1.default.NoCalling; | ||
this.telemetry = null; | ||
this.ic3ClientLogger = null; | ||
this.debug = false; | ||
this.omnichannelConfig = omnichannelConfig; | ||
this.chatSDKConfig = chatSDKConfig; | ||
this.isInitialized = false; | ||
this.requestId = ocsdk_1.uuidv4(); | ||
@@ -76,25 +84,55 @@ this.chatToken = {}; | ||
this.preChatSurvey = null; | ||
this.telemetry = createTelemetry_1.default(this.debug); | ||
this.scenarioMarker = new ScenarioMarker_1.default(this.omnichannelConfig); | ||
this.ic3ClientLogger = loggers_1.createIC3ClientLogger(this.omnichannelConfig); | ||
this.scenarioMarker.useTelemetry(this.telemetry); | ||
this.ic3ClientLogger.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()); | ||
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setRequestId(this.requestId); | ||
} | ||
/* istanbul ignore next */ | ||
OmnichannelChatSDK.prototype.setDebug = function (flag) { | ||
var _a, _b; | ||
this.debug = flag; | ||
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setDebug(flag); | ||
this.scenarioMarker.setDebug(flag); | ||
(_b = this.ic3ClientLogger) === null || _b === void 0 ? void 0 : _b.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 OCClient, IC3Client, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeChatSDK); | ||
if (this.isInitialized) { | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK); | ||
return [2 /*return*/, this.liveChatConfig]; | ||
} | ||
_b.label = 1; | ||
case 1: | ||
_b.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 | ||
_b = this; | ||
case 2: | ||
OCClient = _b.sent(); | ||
return [4 /*yield*/, this.getIC3Client()]; | ||
case 2: | ||
_b.IC3Client = _c.sent(); | ||
return [2 /*return*/, this.getChatConfig()]; | ||
case 3: | ||
IC3Client = _b.sent(); | ||
// Assign & Update flag only if all dependencies have been initialized succesfully | ||
this.OCClient = OCClient; | ||
this.IC3Client = IC3Client; | ||
return [4 /*yield*/, this.getChatConfig()]; | ||
case 4: | ||
_b.sent(); | ||
this.isInitialized = true; | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK); | ||
return [3 /*break*/, 6]; | ||
case 5: | ||
_a = _b.sent(); | ||
this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDK); | ||
return [3 /*break*/, 6]; | ||
case 6: return [2 /*return*/, this.liveChatConfig]; | ||
} | ||
@@ -105,8 +143,12 @@ }); | ||
OmnichannelChatSDK.prototype.startChat = function (optionalParams) { | ||
var _a; | ||
if (optionalParams === void 0) { optionalParams = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var sessionInitOptionalParams, error_1, error_2, _a, error_3; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var sessionInitOptionalParams, error_1, exceptionDetails, error_2, exceptionDetails, _b, error_3, exceptionDetails; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, { | ||
RequestId: this.requestId | ||
}); | ||
if (optionalParams.liveChatContext) { | ||
@@ -119,27 +161,55 @@ this.chatToken = optionalParams.liveChatContext.chatToken || {}; | ||
case 1: | ||
_b.sent(); | ||
_b.label = 2; | ||
_c.sent(); | ||
_c.label = 2; | ||
case 2: | ||
(_a = this.ic3ClientLogger) === null || _a === void 0 ? void 0 : _a.setChatId(this.chatToken.chatId || ''); | ||
sessionInitOptionalParams = { | ||
initContext: {} | ||
}; | ||
if (optionalParams.customContext) { | ||
sessionInitOptionalParams.initContext.customContextData = optionalParams.customContext; // eslint-disable-line @typescript-eslint/no-explicit-any | ||
} | ||
if (optionalParams.browser) { | ||
sessionInitOptionalParams.initContext.browser = optionalParams.browser; | ||
} | ||
if (optionalParams.os) { | ||
sessionInitOptionalParams.initContext.os = optionalParams.os; | ||
} | ||
if (optionalParams.locale) { | ||
sessionInitOptionalParams.initContext.locale = optionalParams.locale; | ||
} | ||
if (optionalParams.device) { | ||
sessionInitOptionalParams.initContext.device = optionalParams.device; | ||
} | ||
if (optionalParams.preChatResponse) { | ||
sessionInitOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse; | ||
} | ||
// Override initContext completely | ||
if (optionalParams.initContext) { | ||
sessionInitOptionalParams.initContext = optionalParams.initContext; | ||
} | ||
if (this.authenticatedUserToken) { | ||
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken; | ||
} | ||
_b.label = 3; | ||
_c.label = 3; | ||
case 3: | ||
_b.trys.push([3, 5, , 6]); | ||
_c.trys.push([3, 5, , 6]); | ||
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)]; | ||
case 4: | ||
_b.sent(); | ||
_c.sent(); | ||
return [3 /*break*/, 6]; | ||
case 5: | ||
error_1 = _b.sent(); | ||
error_1 = _c.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); | ||
return [2 /*return*/, error_1]; | ||
case 6: | ||
_b.trys.push([6, 8, , 9]); | ||
_c.trys.push([6, 8, , 9]); | ||
return [4 /*yield*/, this.IC3Client.initialize({ | ||
@@ -151,17 +221,37 @@ token: this.chatToken.token, | ||
case 7: | ||
_b.sent(); | ||
_c.sent(); | ||
return [3 /*break*/, 9]; | ||
case 8: | ||
error_2 = _b.sent(); | ||
error_2 = _c.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); | ||
return [2 /*return*/, error_2]; | ||
case 9: | ||
_b.trys.push([9, 11, , 12]); | ||
_a = this; | ||
_c.trys.push([9, 11, , 12]); | ||
_b = this; | ||
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)]; | ||
case 10: | ||
_a.conversation = _b.sent(); | ||
_b.conversation = _c.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(); | ||
error_3 = _c.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); | ||
@@ -175,7 +265,12 @@ return [2 /*return*/, error_3]; | ||
OmnichannelChatSDK.prototype.endChat = function () { | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var sessionCloseOptionalParams, error_4; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var sessionCloseOptionalParams, error_4, exceptionDetails; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId | ||
}); | ||
sessionCloseOptionalParams = {}; | ||
@@ -185,8 +280,12 @@ if (this.authenticatedUserToken) { | ||
} | ||
_a.label = 1; | ||
_c.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
_c.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)]; | ||
case 2: | ||
_a.sent(); | ||
_c.sent(); | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, { | ||
RequestId: this.requestId, | ||
ChatId: this.chatToken.chatId | ||
}); | ||
this.conversation.disconnect(); | ||
@@ -196,5 +295,15 @@ this.conversation = null; | ||
this.chatToken = {}; | ||
(_a = this.ic3ClientLogger) === null || _a === void 0 ? void 0 : _a.setRequestId(this.requestId); | ||
(_b = this.ic3ClientLogger) === null || _b === void 0 ? void 0 : _b.setChatId(''); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
error_4 = _a.sent(); | ||
error_4 = _c.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); | ||
@@ -254,7 +363,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; | ||
@@ -280,8 +392,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]; | ||
} | ||
@@ -513,6 +644,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 () { | ||
@@ -525,11 +661,14 @@ /* istanbul ignore next */ | ||
userId: 'teamsvisitor', | ||
sdkURL: libraries_1.default.getIC3ClientCDNUrl() | ||
sdkURL: _this.resolveIC3ClientUrl(), | ||
sdk: _this.IC3Client | ||
}; | ||
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*/]; | ||
@@ -567,6 +706,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 () { | ||
@@ -576,7 +720,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 () { | ||
@@ -591,2 +744,4 @@ var VoiceVideoCalling; | ||
VoiceVideoCalling = _a.sent(); | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetVoiceVideoCalling); | ||
VoiceVideoCalling.useScenarioMarker(this.scenarioMarker); | ||
resolve(VoiceVideoCalling); | ||
@@ -597,3 +752,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'); | ||
@@ -604,3 +766,3 @@ return [2 /*return*/]; | ||
case 2: | ||
_a.sent(); | ||
_c.sent(); | ||
return [2 /*return*/]; | ||
@@ -625,2 +787,3 @@ } | ||
this.debug && console.debug('IC3Core'); | ||
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client); | ||
// Use FramelessBridge from IC3Core | ||
@@ -635,4 +798,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'); | ||
@@ -643,6 +808,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 () { | ||
@@ -661,6 +831,8 @@ var ic3sdk, IC3SDKProvider, IC3Client; | ||
hostType: HostType_1.default.IFrame, | ||
protocolType: ProtocoleType_1.default.IC3V1SDK | ||
protocolType: ProtocoleType_1.default.IC3V1SDK, | ||
logger: this.ic3ClientLogger | ||
})]; | ||
case 1: | ||
IC3Client = _a.sent(); | ||
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetIC3Client); | ||
resolve(IC3Client); | ||
@@ -672,8 +844,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*/]; | ||
@@ -728,2 +907,3 @@ } | ||
if (this.preChatSurvey) { | ||
/* istanbul ignore next */ | ||
this.debug && console.log('Prechat Survey!'); | ||
@@ -743,2 +923,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; | ||
@@ -745,0 +946,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 @@ }; |
@@ -45,30 +45,45 @@ "use strict"; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
var scriptElement = document.createElement('script'); | ||
scriptElement.setAttribute('src', scriptUrl); | ||
scriptElement.setAttribute('type', 'text/javascript'); | ||
document.head.appendChild(scriptElement); | ||
scriptElement.addEventListener('load', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, callbackOnload()]; | ||
case 1: | ||
_a.sent(); | ||
resolve(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
scriptElement.addEventListener('error', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, callbackError()]; | ||
case 1: | ||
_a.sent(); | ||
reject(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
})]; | ||
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () { | ||
var scriptElements, foundScriptElement, scriptElement; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
scriptElements = Array.from(document.getElementsByTagName('script')); | ||
foundScriptElement = scriptElements.filter(function (scriptElement) { return scriptElement.src == scriptUrl; }); | ||
if (!foundScriptElement.length) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, callbackOnload()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, resolve()]; | ||
case 2: | ||
scriptElement = document.createElement('script'); | ||
scriptElement.setAttribute('src', scriptUrl); | ||
scriptElement.setAttribute('type', 'text/javascript'); | ||
document.head.appendChild(scriptElement); | ||
scriptElement.addEventListener('load', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, callbackOnload()]; | ||
case 1: | ||
_a.sent(); | ||
resolve(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
scriptElement.addEventListener('error', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, callbackError()]; | ||
case 1: | ||
_a.sent(); | ||
reject(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); })]; | ||
}); | ||
@@ -75,0 +90,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.c05dc32", | ||
"version": "0.1.1-main.c670083", | ||
"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,2 +8,46 @@ # 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) | ||
- [API Examples](#api-examples) | ||
- [Sample Apps](samples/) | ||
- [Common Scenarios](#common-scenarios) | ||
- [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 | ||
@@ -15,6 +59,4 @@ | ||
## API | ||
## API Reference | ||
### High Level Overview | ||
| Method | Description | Notes | | ||
@@ -43,2 +85,4 @@ | ------ | ----------- | ----- | | ||
## API examples | ||
### Import | ||
@@ -58,3 +102,3 @@ ```ts | ||
const chatSDKConfig = { // Optional | ||
DataMasking: { | ||
dataMasking: { | ||
disable: false, | ||
@@ -102,5 +146,12 @@ maskingCharacter: '#' | ||
```ts | ||
const customContext = { | ||
'contextKey1': {'value': 'contextValue1', 'isDisplayable': true}, | ||
'contextKey2': {'value': 12.34, 'isDisplayable': false}, | ||
'contextKey3': {'value': true} | ||
}; | ||
const optionalParams = { | ||
preChatResponse: '', // PreChatSurvey response | ||
liveChatContext: {} // EXISTING chat context data | ||
liveChatContext: {}, // EXISTING chat context data | ||
customContext // Custom Context | ||
}; | ||
@@ -205,3 +256,3 @@ await chatSDK.startChat(optionalParams); | ||
## Samples | ||
## Common Scenarios | ||
@@ -439,3 +490,3 @@ ### PreChatSurvey | ||
| 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 | | ||
@@ -454,3 +505,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 | ||
@@ -457,0 +541,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
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
680171
177
8421
545
3014
2
0