@microsoft/omnichannel-chat-widget 1.3.0 → 1.3.1-main.da9dc59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,7 +55,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
55
55
  const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
56
56
 
57
57
  //Setting PreChat and intiate chat
58
- await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, undefined, props);
58
+ await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
59
59
  };
60
60
 
61
61
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -326,7 +326,27 @@ const LiveChatWidgetStateful = props => {
326
326
  });
327
327
 
328
328
  // Start chat from SDK Event
329
- _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
329
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(msg => {
330
+ var _msg$payload4;
331
+ let stateWithUpdatedContext = state;
332
+ if (msg !== null && msg !== void 0 && (_msg$payload4 = msg.payload) !== null && _msg$payload4 !== void 0 && _msg$payload4.customContext) {
333
+ var _msg$payload5, _msg$payload6;
334
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
335
+ Event: _TelemetryConstants.TelemetryEvent.CustomContextReceived,
336
+ Description: "CustomContext received through startChat event."
337
+ });
338
+ dispatch({
339
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
340
+ payload: msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.customContext
341
+ });
342
+ stateWithUpdatedContext = {
343
+ ...state,
344
+ domainStates: {
345
+ ...state.domainStates,
346
+ customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload6 = msg.payload) === null || _msg$payload6 === void 0 ? void 0 : _msg$payload6.customContext
347
+ }
348
+ };
349
+ }
330
350
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
331
351
  Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
332
352
  Description: "Start chat event received."
@@ -340,7 +360,7 @@ const LiveChatWidgetStateful = props => {
340
360
  _omnichannelChatComponents.BroadcastService.postMessage({
341
361
  eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
342
362
  });
343
- (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
363
+ (0, _startChat.prepareStartChat)(props, chatSDK, stateWithUpdatedContext, dispatch, setAdapter);
344
364
  return;
345
365
  }
346
366
 
@@ -352,7 +372,7 @@ const LiveChatWidgetStateful = props => {
352
372
  _omnichannelChatComponents.BroadcastService.postMessage({
353
373
  eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
354
374
  });
355
- (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
375
+ (0, _startChat.prepareStartChat)(props, chatSDK, stateWithUpdatedContext, dispatch, setAdapter);
356
376
  return;
357
377
  }
358
378
 
@@ -50,7 +50,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
50
50
  const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
51
51
 
52
52
  //Setting PreChat and intiate chat
53
- await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, undefined, props);
53
+ await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
54
54
  };
55
55
 
56
56
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -318,7 +318,27 @@ export const LiveChatWidgetStateful = props => {
318
318
  });
319
319
 
320
320
  // Start chat from SDK Event
321
- BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(() => {
321
+ BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
322
+ var _msg$payload4;
323
+ let stateWithUpdatedContext = state;
324
+ if (msg !== null && msg !== void 0 && (_msg$payload4 = msg.payload) !== null && _msg$payload4 !== void 0 && _msg$payload4.customContext) {
325
+ var _msg$payload5, _msg$payload6;
326
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
327
+ Event: TelemetryEvent.CustomContextReceived,
328
+ Description: "CustomContext received through startChat event."
329
+ });
330
+ dispatch({
331
+ type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
332
+ payload: msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.customContext
333
+ });
334
+ stateWithUpdatedContext = {
335
+ ...state,
336
+ domainStates: {
337
+ ...state.domainStates,
338
+ customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload6 = msg.payload) === null || _msg$payload6 === void 0 ? void 0 : _msg$payload6.customContext
339
+ }
340
+ };
341
+ }
322
342
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
323
343
  Event: TelemetryEvent.StartChatEventRecevied,
324
344
  Description: "Start chat event received."
@@ -332,7 +352,7 @@ export const LiveChatWidgetStateful = props => {
332
352
  BroadcastService.postMessage({
333
353
  eventName: BroadcastEvent.ChatInitiated
334
354
  });
335
- prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
355
+ prepareStartChat(props, chatSDK, stateWithUpdatedContext, dispatch, setAdapter);
336
356
  return;
337
357
  }
338
358
 
@@ -344,7 +364,7 @@ export const LiveChatWidgetStateful = props => {
344
364
  BroadcastService.postMessage({
345
365
  eventName: BroadcastEvent.ChatInitiated
346
366
  });
347
- prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
367
+ prepareStartChat(props, chatSDK, stateWithUpdatedContext, dispatch, setAdapter);
348
368
  return;
349
369
  }
350
370
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.3.0",
3
+ "version": "1.3.1-main.da9dc59",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",