@microsoft/omnichannel-amsclient
Advanced tools
Comparing version 0.1.3-main.5300b08 to 0.1.3
@@ -6,2 +6,6 @@ # Changelog | ||
## [0.1.3] - 2023-01-13 | ||
### Changed | ||
- Update `AMSLogData` to include `AMSClientRuntimeId`, `DocumentId` & `ElapsedTimeInMilliseconds` | ||
## [0.1.2] - 2022-09-23 | ||
@@ -8,0 +12,0 @@ ### Fixed |
export default interface AMSLogData { | ||
AMSClientRuntimeId: string; | ||
ChatId: string; | ||
DocumentId?: string; | ||
ElapsedTimeInMilliseconds?: number; | ||
@@ -4,0 +6,0 @@ Event?: string; |
@@ -26,3 +26,3 @@ "use strict"; | ||
var _a; | ||
var logData = __assign(__assign({}, customData), { Event: telemetryEvent }); | ||
var logData = __assign({ Event: telemetryEvent }, customData); | ||
/* istanbul ignore next */ | ||
@@ -29,0 +29,0 @@ this.debug && console.log(logData); |
@@ -1,1 +0,1 @@ | ||
exports.baseUrl = 'https://comms.omnichannelengagementhub.com/ams'; exports.sdkVersion = '0.1.3-main.5300b08'; | ||
exports.baseUrl = 'https://comms.omnichannelengagementhub.com/ams'; exports.sdkVersion = '0.1.3'; |
@@ -11,2 +11,3 @@ import AMSFileInfo from "./AMSFileInfo"; | ||
declare class FramedClient { | ||
private runtimeId; | ||
private clientId; | ||
@@ -13,0 +14,0 @@ private iframeId; |
@@ -62,2 +62,3 @@ "use strict"; | ||
if (framedClientConfig === void 0) { framedClientConfig = undefined; } | ||
this.runtimeId = uuid_1.uuidv4(); | ||
this.clientId = uuid_1.uuidv4(); | ||
@@ -282,3 +283,3 @@ this.origin = window.location.origin; | ||
} | ||
this.targetWindow.postMessage(__assign({ clientId: this.clientId, requestId: requestId, | ||
this.targetWindow.postMessage(__assign({ runtimeId: this.runtimeId, clientId: this.clientId, requestId: requestId, | ||
eventType: eventType, | ||
@@ -285,0 +286,0 @@ eventName: eventName }, data), '*'); |
@@ -9,5 +9,7 @@ import AMSCreateObjectResponse from "./AMSCreateObjectResponse"; | ||
declare class FramedlessClient { | ||
private runtimeId; | ||
private debug; | ||
private chatToken; | ||
private logger?; | ||
private scenarioMarker?; | ||
constructor(logger?: AMSLogger | undefined); | ||
@@ -14,0 +16,0 @@ setDebug(flag: boolean): void; |
@@ -40,9 +40,10 @@ "use strict"; | ||
var API_1 = require("./API"); | ||
var LogLevel_1 = require("./LogLevel"); | ||
var PostMessageEventName_1 = require("./PostMessageEventName"); | ||
var platform_1 = require("./utils/platform"); | ||
var config_1 = require("./config"); | ||
var ScenarioMarker_1 = require("./telemetry/ScenarioMarker"); | ||
var uuid_1 = require("./utils/uuid"); | ||
var FramedlessClient = /** @class */ (function () { | ||
function FramedlessClient(logger) { | ||
if (logger === void 0) { logger = undefined; } | ||
this.runtimeId = uuid_1.uuidv4(); | ||
this.debug = false; | ||
@@ -53,2 +54,6 @@ this.logger = logger; | ||
} | ||
if (logger) { | ||
this.scenarioMarker = new ScenarioMarker_1.default(logger); | ||
this.scenarioMarker.setRuntimeId(this.runtimeId); | ||
} | ||
} | ||
@@ -83,17 +88,21 @@ /* istanbul ignore next */ | ||
FramedlessClient.prototype.skypeTokenAuth = function (chatToken) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
if (chatToken === void 0) { chatToken = null; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, error_1; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
return __generator(this, function (_j) { | ||
switch (_j.label) { | ||
case 0: | ||
_d.trys.push([0, 2, , 3]); | ||
(_a = this.scenarioMarker) === null || _a === void 0 ? void 0 : _a.startScenario(PostMessageEventName_1.default.SkypeTokenAuth, { | ||
ChatId: chatToken ? chatToken.chatId : (_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId, | ||
}); | ||
_j.label = 1; | ||
case 1: | ||
_j.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, API_1.default.skypeTokenAuth(chatToken || this.chatToken)]; | ||
case 1: | ||
response = _d.sent(); | ||
case 2: | ||
response = _j.sent(); | ||
if (!response.ok) { | ||
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(LogLevel_1.default.ERROR, PostMessageEventName_1.default.SkypeTokenAuth, { | ||
ChatId: chatToken ? chatToken.chatId : (_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
(_c = this.scenarioMarker) === null || _c === void 0 ? void 0 : _c.failScenario(PostMessageEventName_1.default.SkypeTokenAuth, { | ||
ChatId: chatToken ? chatToken.chatId : (_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId, | ||
ExceptionDetails: { | ||
@@ -104,12 +113,14 @@ status: response.status | ||
} | ||
(_e = this.scenarioMarker) === null || _e === void 0 ? void 0 : _e.completeScenario(PostMessageEventName_1.default.SkypeTokenAuth, { | ||
ChatId: chatToken ? chatToken.chatId : (_f = this.chatToken) === null || _f === void 0 ? void 0 : _f.chatId | ||
}); | ||
return [2 /*return*/, response]; | ||
case 2: | ||
error_1 = _d.sent(); | ||
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.log(LogLevel_1.default.ERROR, PostMessageEventName_1.default.SkypeTokenAuth, { | ||
ChatId: chatToken ? chatToken.chatId : this.chatToken.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
case 3: | ||
error_1 = _j.sent(); | ||
(_g = this.scenarioMarker) === null || _g === void 0 ? void 0 : _g.failScenario(PostMessageEventName_1.default.SkypeTokenAuth, { | ||
ChatId: chatToken ? chatToken.chatId : (_h = this.chatToken) === null || _h === void 0 ? void 0 : _h.chatId, | ||
ExceptionDetails: error_1 | ||
}); | ||
throw new Error('skypeTokenAuth'); | ||
case 3: return [2 /*return*/]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -120,3 +131,3 @@ }); | ||
FramedlessClient.prototype.createObject = function (id, file, chatToken, supportedImagesMimeTypes) { | ||
var _a; | ||
var _a, _b, _c, _d, _e, _f; | ||
if (chatToken === void 0) { chatToken = null; } | ||
@@ -126,19 +137,27 @@ if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; } | ||
var response, error_2; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
(_a = this.scenarioMarker) === null || _a === void 0 ? void 0 : _a.startScenario(PostMessageEventName_1.default.CreateObject, { | ||
ChatId: chatToken ? chatToken.chatId : (_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId, | ||
}); | ||
_g.label = 1; | ||
case 1: | ||
_g.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, API_1.default.createObject(id, file, chatToken || this.chatToken, supportedImagesMimeTypes)]; | ||
case 1: | ||
response = _b.sent(); | ||
case 2: | ||
response = _g.sent(); | ||
(_c = this.scenarioMarker) === null || _c === void 0 ? void 0 : _c.completeScenario(PostMessageEventName_1.default.CreateObject, { | ||
ChatId: chatToken ? chatToken.chatId : (_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId, | ||
DocumentId: response === null || response === void 0 ? void 0 : response.id | ||
}); | ||
return [2 /*return*/, response]; | ||
case 2: | ||
error_2 = _b.sent(); | ||
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(LogLevel_1.default.ERROR, PostMessageEventName_1.default.CreateObject, { | ||
ChatId: chatToken ? chatToken.chatId : this.chatToken.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
case 3: | ||
error_2 = _g.sent(); | ||
(_e = this.scenarioMarker) === null || _e === void 0 ? void 0 : _e.failScenario(PostMessageEventName_1.default.CreateObject, { | ||
ChatId: chatToken ? chatToken.chatId : (_f = this.chatToken) === null || _f === void 0 ? void 0 : _f.chatId, | ||
ExceptionDetails: error_2 | ||
}); | ||
throw new Error('createObject'); | ||
case 3: return [2 /*return*/]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -149,3 +168,3 @@ }); | ||
FramedlessClient.prototype.uploadDocument = function (documentId, file, chatToken, supportedImagesMimeTypes) { | ||
var _a; | ||
var _a, _b, _c, _d, _e, _f; | ||
if (chatToken === void 0) { chatToken = null; } | ||
@@ -155,19 +174,29 @@ if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; } | ||
var response, error_3; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
(_a = this.scenarioMarker) === null || _a === void 0 ? void 0 : _a.startScenario(PostMessageEventName_1.default.UploadDocument, { | ||
ChatId: chatToken ? chatToken.chatId : (_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId, | ||
DocumentId: documentId | ||
}); | ||
_g.label = 1; | ||
case 1: | ||
_g.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, API_1.default.uploadDocument(documentId, file, chatToken || this.chatToken, supportedImagesMimeTypes)]; | ||
case 1: | ||
response = _b.sent(); | ||
case 2: | ||
response = _g.sent(); | ||
(_c = this.scenarioMarker) === null || _c === void 0 ? void 0 : _c.completeScenario(PostMessageEventName_1.default.UploadDocument, { | ||
ChatId: chatToken ? chatToken.chatId : (_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId, | ||
DocumentId: documentId | ||
}); | ||
return [2 /*return*/, response]; | ||
case 2: | ||
error_3 = _b.sent(); | ||
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(LogLevel_1.default.ERROR, PostMessageEventName_1.default.UploadDocument, { | ||
ChatId: chatToken ? chatToken.chatId : this.chatToken.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
case 3: | ||
error_3 = _g.sent(); | ||
(_e = this.scenarioMarker) === null || _e === void 0 ? void 0 : _e.failScenario(PostMessageEventName_1.default.UploadDocument, { | ||
ChatId: chatToken ? chatToken.chatId : (_f = this.chatToken) === null || _f === void 0 ? void 0 : _f.chatId, | ||
DocumentId: documentId, | ||
ExceptionDetails: error_3 | ||
}); | ||
throw new Error('uploadDocument'); | ||
case 3: return [2 /*return*/]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -178,3 +207,3 @@ }); | ||
FramedlessClient.prototype.getViewStatus = function (fileMetadata, chatToken, supportedImagesMimeTypes) { | ||
var _a; | ||
var _a, _b, _c, _d, _e, _f; | ||
if (chatToken === void 0) { chatToken = null; } | ||
@@ -184,19 +213,29 @@ if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; } | ||
var response, error_4; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
(_a = this.scenarioMarker) === null || _a === void 0 ? void 0 : _a.startScenario(PostMessageEventName_1.default.GetViewStatus, { | ||
ChatId: chatToken ? chatToken.chatId : (_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId, | ||
DocumentId: fileMetadata === null || fileMetadata === void 0 ? void 0 : fileMetadata.id | ||
}); | ||
_g.label = 1; | ||
case 1: | ||
_g.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, API_1.default.getViewStatus(fileMetadata, chatToken || this.chatToken, supportedImagesMimeTypes)]; | ||
case 1: | ||
response = _b.sent(); | ||
case 2: | ||
response = _g.sent(); | ||
(_c = this.scenarioMarker) === null || _c === void 0 ? void 0 : _c.completeScenario(PostMessageEventName_1.default.GetViewStatus, { | ||
ChatId: chatToken ? chatToken.chatId : (_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId, | ||
DocumentId: fileMetadata === null || fileMetadata === void 0 ? void 0 : fileMetadata.id | ||
}); | ||
return [2 /*return*/, response]; | ||
case 2: | ||
error_4 = _b.sent(); | ||
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(LogLevel_1.default.ERROR, PostMessageEventName_1.default.GetViewStatus, { | ||
ChatId: chatToken ? chatToken.chatId : this.chatToken.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
case 3: | ||
error_4 = _g.sent(); | ||
(_e = this.scenarioMarker) === null || _e === void 0 ? void 0 : _e.failScenario(PostMessageEventName_1.default.GetViewStatus, { | ||
ChatId: chatToken ? chatToken.chatId : (_f = this.chatToken) === null || _f === void 0 ? void 0 : _f.chatId, | ||
DocumentId: fileMetadata === null || fileMetadata === void 0 ? void 0 : fileMetadata.id, | ||
ExceptionDetails: error_4 | ||
}); | ||
throw new Error('getViewStatus'); | ||
case 3: return [2 /*return*/]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -207,3 +246,3 @@ }); | ||
FramedlessClient.prototype.getView = function (fileMetadata, viewLocation, chatToken, supportedImagesMimeTypes) { | ||
var _a; | ||
var _a, _b, _c, _d, _e, _f; | ||
if (chatToken === void 0) { chatToken = null; } | ||
@@ -213,19 +252,29 @@ if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; } | ||
var response, error_5; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
(_a = this.scenarioMarker) === null || _a === void 0 ? void 0 : _a.startScenario(PostMessageEventName_1.default.GetView, { | ||
ChatId: chatToken ? chatToken.chatId : (_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId, | ||
DocumentId: fileMetadata === null || fileMetadata === void 0 ? void 0 : fileMetadata.id | ||
}); | ||
_g.label = 1; | ||
case 1: | ||
_g.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, API_1.default.getView(fileMetadata, viewLocation, chatToken || this.chatToken, supportedImagesMimeTypes)]; | ||
case 1: | ||
response = _b.sent(); | ||
case 2: | ||
response = _g.sent(); | ||
(_c = this.scenarioMarker) === null || _c === void 0 ? void 0 : _c.completeScenario(PostMessageEventName_1.default.GetView, { | ||
ChatId: chatToken ? chatToken.chatId : (_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId, | ||
DocumentId: fileMetadata === null || fileMetadata === void 0 ? void 0 : fileMetadata.id | ||
}); | ||
return [2 /*return*/, response]; | ||
case 2: | ||
error_5 = _b.sent(); | ||
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(LogLevel_1.default.ERROR, PostMessageEventName_1.default.GetView, { | ||
ChatId: chatToken ? chatToken.chatId : this.chatToken.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
case 3: | ||
error_5 = _g.sent(); | ||
(_e = this.scenarioMarker) === null || _e === void 0 ? void 0 : _e.failScenario(PostMessageEventName_1.default.GetView, { | ||
ChatId: chatToken ? chatToken.chatId : (_f = this.chatToken) === null || _f === void 0 ? void 0 : _f.chatId, | ||
DocumentId: fileMetadata === null || fileMetadata === void 0 ? void 0 : fileMetadata.id, | ||
ExceptionDetails: error_5 | ||
}); | ||
throw new Error('getView'); | ||
case 3: return [2 /*return*/]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -232,0 +281,0 @@ }); |
@@ -11,2 +11,4 @@ import PostMessageEventName from "./PostMessageEventName"; | ||
private telemetryEnabled; | ||
private logger; | ||
private scenarioMarker; | ||
constructor(clientId: string); | ||
@@ -13,0 +15,0 @@ setDebug(flag: boolean): void; |
@@ -57,6 +57,7 @@ "use strict"; | ||
var PostMessageEventType_1 = require("./PostMessageEventType"); | ||
var LogLevel_1 = require("./LogLevel"); | ||
var config_1 = require("./config"); | ||
var ScenarioMarker_1 = require("./telemetry/ScenarioMarker"); | ||
var AMSLogger_1 = require("./AMSLogger"); | ||
var IframeCommunicator = /** @class */ (function () { | ||
function IframeCommunicator(clientId) { | ||
var _this = this; | ||
this.clientId = clientId; | ||
@@ -67,2 +68,8 @@ this.sourceWindow = window; | ||
this.telemetryEnabled = false; | ||
this.logger = { | ||
logClientSdkTelemetryEvent: function (logLevel, event) { | ||
_this.sendTelemetry(logLevel, event); | ||
} | ||
}; | ||
this.scenarioMarker = new ScenarioMarker_1.default(new AMSLogger_1.default(this.logger)); | ||
} | ||
@@ -97,6 +104,7 @@ IframeCommunicator.prototype.setDebug = function (flag) { | ||
IframeCommunicator.prototype.handleEvent = function (event) { | ||
var _a, _b, _c, _d, _e, _f; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, response, postMessageData, error_1, response, postMessageData, error_2, response, postMessageData, error_3, response, postMessageData, error_4, response, postMessageData, error_5; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
case 0: | ||
@@ -110,8 +118,12 @@ if (event.data.clientId !== this.clientId) { | ||
if (!(event.data.eventName === PostMessageEventName_1.default.SkypeTokenAuth)) return [3 /*break*/, 5]; | ||
_a.label = 1; | ||
this.scenarioMarker.startScenario(PostMessageEventName_1.default.SkypeTokenAuth, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId | ||
}); | ||
_g.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
_g.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, API_1.default.skypeTokenAuth(data.chatToken)]; | ||
case 2: | ||
response = _a.sent(); | ||
response = _g.sent(); | ||
postMessageData = { | ||
@@ -125,6 +137,5 @@ requestId: data.requestId, | ||
postMessageData.eventStatus = PostMessageEventStatus_1.default.Failure; | ||
this.sendTelemetry(LogLevel_1.default.ERROR, { | ||
this.scenarioMarker.failScenario(PostMessageEventName_1.default.SkypeTokenAuth, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
Event: PostMessageEventName_1.default.SkypeTokenAuth, | ||
ExceptionDetails: { | ||
@@ -135,11 +146,16 @@ status: response.status | ||
} | ||
else { | ||
this.scenarioMarker.completeScenario(PostMessageEventName_1.default.SkypeTokenAuth, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
}); | ||
} | ||
this.postMessage(PostMessageEventType_1.default.Response, PostMessageEventName_1.default.SkypeTokenAuth, postMessageData, PostMessageEventStatus_1.default.Success); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
error_1 = _a.sent(); | ||
error_1 = _g.sent(); | ||
this.postMessage(PostMessageEventType_1.default.Response, PostMessageEventName_1.default.SkypeTokenAuth, {}, PostMessageEventStatus_1.default.Failure); | ||
this.sendTelemetry(LogLevel_1.default.ERROR, { | ||
this.scenarioMarker.failScenario(PostMessageEventName_1.default.SkypeTokenAuth, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
Event: PostMessageEventName_1.default.SkypeTokenAuth, | ||
ExceptionDetails: error_1 | ||
@@ -151,8 +167,12 @@ }); | ||
if (!(event.data.eventName === PostMessageEventName_1.default.CreateObject)) return [3 /*break*/, 10]; | ||
_a.label = 6; | ||
this.scenarioMarker.startScenario(PostMessageEventName_1.default.CreateObject, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId | ||
}); | ||
_g.label = 6; | ||
case 6: | ||
_a.trys.push([6, 8, , 9]); | ||
_g.trys.push([6, 8, , 9]); | ||
return [4 /*yield*/, API_1.default.createObject(data.id, data.file, data.chatToken)]; | ||
case 7: | ||
response = _a.sent(); | ||
response = _g.sent(); | ||
postMessageData = { | ||
@@ -165,11 +185,15 @@ requestId: data.requestId, | ||
}; | ||
this.scenarioMarker.completeScenario(PostMessageEventName_1.default.CreateObject, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
DocumentId: response === null || response === void 0 ? void 0 : response.id | ||
}); | ||
this.postMessage(PostMessageEventType_1.default.Response, PostMessageEventName_1.default.CreateObject, postMessageData, PostMessageEventStatus_1.default.Success); | ||
return [3 /*break*/, 9]; | ||
case 8: | ||
error_2 = _a.sent(); | ||
error_2 = _g.sent(); | ||
this.postMessage(PostMessageEventType_1.default.Response, PostMessageEventName_1.default.CreateObject, {}, PostMessageEventStatus_1.default.Failure); | ||
this.sendTelemetry(LogLevel_1.default.ERROR, { | ||
this.scenarioMarker.failScenario(PostMessageEventName_1.default.CreateObject, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
Event: PostMessageEventName_1.default.CreateObject, | ||
ExceptionDetails: error_2 | ||
@@ -181,8 +205,13 @@ }); | ||
if (!(event.data.eventName === PostMessageEventName_1.default.UploadDocument)) return [3 /*break*/, 15]; | ||
_a.label = 11; | ||
this.scenarioMarker.startScenario(PostMessageEventName_1.default.UploadDocument, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
DocumentId: data.documentId | ||
}); | ||
_g.label = 11; | ||
case 11: | ||
_a.trys.push([11, 13, , 14]); | ||
_g.trys.push([11, 13, , 14]); | ||
return [4 /*yield*/, API_1.default.uploadDocument(data.documentId, data.file, data.chatToken)]; | ||
case 12: | ||
response = _a.sent(); | ||
response = _g.sent(); | ||
postMessageData = { | ||
@@ -196,11 +225,16 @@ requestId: data.requestId, | ||
}; | ||
this.scenarioMarker.completeScenario(PostMessageEventName_1.default.UploadDocument, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
DocumentId: data.documentId | ||
}); | ||
this.postMessage(PostMessageEventType_1.default.Response, PostMessageEventName_1.default.UploadDocument, postMessageData, PostMessageEventStatus_1.default.Success); | ||
return [3 /*break*/, 14]; | ||
case 13: | ||
error_3 = _a.sent(); | ||
error_3 = _g.sent(); | ||
this.postMessage(PostMessageEventType_1.default.Response, PostMessageEventName_1.default.UploadDocument, {}, PostMessageEventStatus_1.default.Failure); | ||
this.sendTelemetry(LogLevel_1.default.ERROR, { | ||
this.scenarioMarker.failScenario(PostMessageEventName_1.default.UploadDocument, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
Event: PostMessageEventName_1.default.UploadDocument, | ||
DocumentId: data.documentId, | ||
ExceptionDetails: error_3 | ||
@@ -212,8 +246,13 @@ }); | ||
if (!(event.data.eventName === PostMessageEventName_1.default.GetViewStatus)) return [3 /*break*/, 20]; | ||
_a.label = 16; | ||
this.scenarioMarker.startScenario(PostMessageEventName_1.default.GetViewStatus, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
DocumentId: (_a = data.fileMetadata) === null || _a === void 0 ? void 0 : _a.id | ||
}); | ||
_g.label = 16; | ||
case 16: | ||
_a.trys.push([16, 18, , 19]); | ||
_g.trys.push([16, 18, , 19]); | ||
return [4 /*yield*/, API_1.default.getViewStatus(data.fileMetadata, data.chatToken)]; | ||
case 17: | ||
response = _a.sent(); | ||
response = _g.sent(); | ||
postMessageData = { | ||
@@ -227,11 +266,16 @@ requestId: data.requestId, | ||
}; | ||
this.scenarioMarker.completeScenario(PostMessageEventName_1.default.GetViewStatus, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
DocumentId: (_b = data.fileMetadata) === null || _b === void 0 ? void 0 : _b.id | ||
}); | ||
this.postMessage(PostMessageEventType_1.default.Response, PostMessageEventName_1.default.GetViewStatus, postMessageData, PostMessageEventStatus_1.default.Success); | ||
return [3 /*break*/, 19]; | ||
case 18: | ||
error_4 = _a.sent(); | ||
error_4 = _g.sent(); | ||
this.postMessage(PostMessageEventType_1.default.Response, PostMessageEventName_1.default.GetViewStatus, {}, PostMessageEventStatus_1.default.Failure); | ||
this.sendTelemetry(LogLevel_1.default.ERROR, { | ||
this.scenarioMarker.failScenario(PostMessageEventName_1.default.GetViewStatus, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
Event: PostMessageEventName_1.default.GetViewStatus, | ||
DocumentId: (_c = data.fileMetadata) === null || _c === void 0 ? void 0 : _c.id, | ||
ExceptionDetails: error_4 | ||
@@ -243,8 +287,13 @@ }); | ||
if (!(event.data.eventName === PostMessageEventName_1.default.GetView)) return [3 /*break*/, 24]; | ||
_a.label = 21; | ||
this.scenarioMarker.startScenario(PostMessageEventName_1.default.GetView, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
DocumentId: (_d = data.fileMetadata) === null || _d === void 0 ? void 0 : _d.id | ||
}); | ||
_g.label = 21; | ||
case 21: | ||
_a.trys.push([21, 23, , 24]); | ||
_g.trys.push([21, 23, , 24]); | ||
return [4 /*yield*/, API_1.default.getView(data.fileMetadata, data.viewLocation, data.chatToken)]; | ||
case 22: | ||
response = _a.sent(); | ||
response = _g.sent(); | ||
postMessageData = { | ||
@@ -258,11 +307,16 @@ requestId: data.requestId, | ||
}; | ||
this.scenarioMarker.completeScenario(PostMessageEventName_1.default.GetView, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
DocumentId: (_e = data.fileMetadata) === null || _e === void 0 ? void 0 : _e.id | ||
}); | ||
this.postMessage(PostMessageEventType_1.default.Response, PostMessageEventName_1.default.GetView, postMessageData, PostMessageEventStatus_1.default.Success); | ||
return [3 /*break*/, 24]; | ||
case 23: | ||
error_5 = _a.sent(); | ||
error_5 = _g.sent(); | ||
this.postMessage(PostMessageEventType_1.default.Response, PostMessageEventName_1.default.GetView, {}, PostMessageEventStatus_1.default.Failure); | ||
this.sendTelemetry(LogLevel_1.default.ERROR, { | ||
this.scenarioMarker.failScenario(PostMessageEventName_1.default.GetView, { | ||
AMSClientRuntimeId: data.runtimeId, | ||
ChatId: data.chatToken.chatId, | ||
AMSClientVersion: config_1.sdkVersion, | ||
Event: PostMessageEventName_1.default.GetView, | ||
DocumentId: (_f = data.fileMetadata) === null || _f === void 0 ? void 0 : _f.id, | ||
ExceptionDetails: error_5 | ||
@@ -269,0 +323,0 @@ }); |
{ | ||
"name": "@microsoft/omnichannel-amsclient", | ||
"version": "0.1.3-main.5300b08", | ||
"version": "0.1.3", | ||
"description": "Microsoft Omnichannel AMSClient", | ||
@@ -5,0 +5,0 @@ "files": [ |
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
244336
101
1979