Родитель
22393d02d1
Коммит
616d826a5a
|
@ -1,4 +1,4 @@
|
|||
import createDeferred from 'p-defer';
|
||||
import createDeferred from 'p-defer-es5';
|
||||
|
||||
export default function checkpoint() {
|
||||
const { promise: promise1, resolve: resolve1 } = createDeferred();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import createDeferred from 'p-defer';
|
||||
import createDeferred from 'p-defer-es5';
|
||||
import Observable from 'core-js/features/observable';
|
||||
|
||||
import observableToArray from '../__jest__/observableToArray';
|
||||
|
|
|
@ -14,6 +14,8 @@ import createAsyncIterableQueue, { AsyncIterableQueue } from './utils/createAsyn
|
|||
import EventTarget from 'event-target-shim-es5';
|
||||
import createEvent from './utils/createEvent';
|
||||
import sealAdapter from './sealAdapter';
|
||||
import { StateKey } from './types/ic3/IC3AdapterState';
|
||||
import { TelemetryEvents } from './types/ic3/TelemetryEvents';
|
||||
|
||||
const DEFAULT_ENHANCER: AdapterEnhancer<any, any> = next => options => next(options);
|
||||
|
||||
|
@ -57,6 +59,13 @@ export default function createAdapter<TActivity, TAdapterState extends AdapterSt
|
|||
|
||||
activeSubscription && activeSubscription.unsubscribe();
|
||||
activeSubscription = null;
|
||||
|
||||
adapter.getState(StateKey.Logger)?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.DEBUG,
|
||||
{ Event: TelemetryEvents.ENDING_CONNECTION,
|
||||
Description: `Adapter: Conversation ended. Ending IC3 connection`
|
||||
});;
|
||||
const conv = adapter.getState(StateKey.Conversation);
|
||||
conv?.disconnect();
|
||||
},
|
||||
|
||||
// Egress middleware API
|
||||
|
|
|
@ -29,14 +29,6 @@ export default function createIC3Enhancer({
|
|||
featureConfig
|
||||
}: IIC3AdapterOptions & { sdkUrl?: string }): AdapterEnhancer<IC3DirectLineActivity, IC3AdapterState> {
|
||||
|
||||
if (!chatToken) {
|
||||
logger?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.ERROR,
|
||||
{ Event: TelemetryEvents.CHAT_TOKEN_NOT_FOUND,
|
||||
Description: `Adapter: "chatToken" must be specified`
|
||||
});
|
||||
throw new Error('"chatToken" must be specified.');
|
||||
}
|
||||
|
||||
if (sdkUrl && !sdkURL) {
|
||||
console.warn(
|
||||
'IC3: "sdkUrl" has been renamed to "sdkURL". Please rename accordingly to suppress this warning in the future.'
|
||||
|
@ -61,10 +53,6 @@ export default function createIC3Enhancer({
|
|||
|
||||
(async function () {
|
||||
if(!conversation){
|
||||
logger?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.DEBUG,
|
||||
{ Event: TelemetryEvents.IC3_SDK_INITIALIZE_STARTED,
|
||||
Description: `Adapter: No conversation found; initializing IC3 SDK`
|
||||
});
|
||||
const sdk = await initializeIC3SDK(
|
||||
sdkURL,
|
||||
{
|
||||
|
@ -81,7 +69,7 @@ export default function createIC3Enhancer({
|
|||
|
||||
logger?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.DEBUG,
|
||||
{ Event: TelemetryEvents.IC3_SDK_JOIN_CONVERSATION_STARTED,
|
||||
Description: `Adapter: No conversation found; joinging conversation`
|
||||
Description: `Adapter: No conversation found; joining conversation`
|
||||
});
|
||||
conversation = await sdk.joinConversation(chatToken.chatId, sendHeartBeat);
|
||||
logger?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.DEBUG,
|
||||
|
|
|
@ -52,7 +52,7 @@ export default function createEgressMessageActivityMiddleware(): EgressMiddlewar
|
|||
type: Microsoft.CRM.Omnichannel.IC3Client.Model.PersonType.User
|
||||
},
|
||||
timestamp: new Date(timestamp),
|
||||
tags: channelData.tags,
|
||||
tags: channelData.tags ?? [],
|
||||
clientmessageid: uniqueClientMessageId
|
||||
};
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ AsyncMapper<Microsoft.CRM.Omnichannel.IC3Client.Model.IThread, IC3DirectLineActi
|
|||
getState(StateKey.Logger)?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.ERROR,
|
||||
{
|
||||
Event: TelemetryEvents.CONVERSATION_NOT_FOUND,
|
||||
Description: `Adapter: Failed to ingress without an active conversation.`
|
||||
Description: `Adapter: Failed to ingress thread update without an active conversation.`
|
||||
}
|
||||
);
|
||||
throw new Error('IC3: Failed to ingress without an active conversation.');
|
||||
throw new Error('IC3: Failed to ingress thread update without an active conversation.');
|
||||
}
|
||||
|
||||
const { id, members, properties, type } = thread;
|
||||
|
|
|
@ -27,10 +27,10 @@ export default function createTypingMessageToDirectLineActivityMapper({
|
|||
getState(StateKey.Logger)?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.ERROR,
|
||||
{
|
||||
Event: TelemetryEvents.CONVERSATION_NOT_FOUND,
|
||||
Description: `Adapter: Failed to ingress without an active conversation.`
|
||||
Description: `Adapter: Failed to ingress typing without an active conversation.`
|
||||
}
|
||||
);
|
||||
throw new Error('IC3: Failed to ingress without an active conversation.');
|
||||
throw new Error('IC3: Failed to ingress typing without an active conversation.');
|
||||
}
|
||||
|
||||
const {
|
||||
|
|
|
@ -64,12 +64,6 @@ export default function createUserMessageToDirectLineActivityMapper({
|
|||
return next => async (message: Microsoft.CRM.Omnichannel.IC3Client.Model.IMessage) => {
|
||||
|
||||
if (message.messageType !== Microsoft.CRM.Omnichannel.IC3Client.Model.MessageType.UserMessage) {
|
||||
getState(StateKey.Logger)?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.ERROR,
|
||||
{
|
||||
Event: TelemetryEvents.CONVERSATION_NOT_FOUND,
|
||||
Description: `Adapter: Failed to ingress without an active conversation.`
|
||||
}
|
||||
);
|
||||
return next(message);
|
||||
}
|
||||
|
||||
|
@ -79,10 +73,10 @@ export default function createUserMessageToDirectLineActivityMapper({
|
|||
getState(StateKey.Logger)?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.ERROR,
|
||||
{
|
||||
Event: TelemetryEvents.CONVERSATION_NOT_FOUND,
|
||||
Description: `Adapter: Failed to ingress without an active conversation.`
|
||||
Description: `Adapter: Failed to ingress message without an active conversation.`
|
||||
}
|
||||
);
|
||||
throw new Error('IC3: Failed to ingress without an active conversation.');
|
||||
throw new Error('IC3: Failed to ingress message without an active conversation.');
|
||||
}
|
||||
|
||||
const {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/// <reference path="../types/ic3/external/Model.d.ts" />
|
||||
/// <reference path="../types/ic3/external/SDK.d.ts" />
|
||||
|
||||
import { IAdapterLogger } from "./telemetry/IAdapterLogger";
|
||||
import { TelemetryEvents } from "../types/ic3/TelemetryEvents";
|
||||
|
||||
const DEFAULT_SDK_URL = 'https://comms.omnichannelengagementhub.com/release/2019.12.27.1/Scripts/SDK/SDK.min.js';
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import getSDKFromURL from './getSDKFromURL';
|
||||
import { IAdapterLogger } from './telemetry/IAdapterLogger';
|
||||
import { TelemetryEvents } from '../types/ic3/TelemetryEvents';
|
||||
|
||||
let _sdk: Microsoft.CRM.Omnichannel.IC3Client.Model.ISDK | null = null;
|
||||
|
@ -18,12 +17,25 @@ export default async function initializeIC3SDK(
|
|||
sessionInfo: sessionInfo
|
||||
};
|
||||
try{
|
||||
if (!sessionInfo.token) {
|
||||
options?.logger?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.ERROR,
|
||||
{ Event: TelemetryEvents.CHAT_TOKEN_NOT_FOUND,
|
||||
Description: `Adapter: "chatToken" must be specified`
|
||||
});
|
||||
throw new Error('"chatToken" must be specified.');
|
||||
}
|
||||
|
||||
const sdk = await getSDKFromURL(sdkURL, options);
|
||||
options?.logger?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.DEBUG,
|
||||
{ Event: TelemetryEvents.IC3_SDK_INITIALIZE_STARTED,
|
||||
Description: `Adapter: No conversation found; initializing IC3 SDK`
|
||||
}
|
||||
);
|
||||
await sdk.initialize(sessionInfo);
|
||||
options?.logger?.logClientSdkTelemetryEvent(Microsoft.CRM.Omnichannel.IC3Client.Model.LogLevel.DEBUG,
|
||||
{
|
||||
Event: TelemetryEvents.IC3_SDK_INITIALIZE_SUCCESS,
|
||||
Description: `Adapter: IC3 SDK initialization success`
|
||||
Description: `Adapter: IC3 SDK initialization success`
|
||||
}
|
||||
);
|
||||
_sdk = sdk;
|
||||
|
|
|
@ -38,13 +38,12 @@ window.Microsoft || ((window as any ).Microsoft = {});
|
|||
(window.Microsoft as any).BotFramework = updateIn(
|
||||
(window.Microsoft as any).BotFramework || {},
|
||||
['WebChat', 'createIC3Adapter'],
|
||||
() => (options: IIC3AdapterOptions, logger: Microsoft.CRM.Omnichannel.IC3Client.Model.ILogger) =>
|
||||
// TODO: Why is logger separated out? In the original code, we can put it in options and make it look flushed.
|
||||
() => (options: IIC3AdapterOptions) =>
|
||||
createAdapter(
|
||||
{},
|
||||
compose(
|
||||
exportDLJSInterface(),
|
||||
createIC3AdapterEnhancer({ ...options, logger }),
|
||||
createIC3AdapterEnhancer(options),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -20,5 +20,6 @@ export enum TelemetryEvents {
|
|||
ADAPTIVE_CARD_PROCESSING_ERROR = "ADAPTER_ADAPTIVE_CARD_PROCESSING_ERROR",
|
||||
MESSAGE_RECEIVED = "ADAPTER_MESSAGE_RECEIVED",
|
||||
THREAD_UPDATE_RECEIVED = "ADAPTER_THREAD_UPDATE_RECEIVED",
|
||||
ADAPTER_NOT_READY = "ADAPTER_ADAPTER_NOT_READY"
|
||||
ADAPTER_NOT_READY = "ADAPTER_ADAPTER_NOT_READY",
|
||||
ENDING_CONNECTION = "ADAPTER_ENDING_CONNECTION"
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import createDeferred from 'p-defer';
|
||||
import createDeferred from 'p-defer-es5';
|
||||
|
||||
interface AbortSignal extends EventTarget {
|
||||
aborted: boolean;
|
||||
|
|
Загрузка…
Ссылка в новой задаче