@ada-support/embed2 1.0.55 → 1.0.56

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.
@@ -20,6 +20,7 @@ export interface Features {
20
20
  developer_proactive?: boolean;
21
21
  afm_business_events?: boolean;
22
22
  afm_proactive_messaging?: boolean;
23
+ afm_dont_show_proactive_messages_in_chat?: boolean;
23
24
  embed_test_bot?: boolean;
24
25
  rtl_language_support?: boolean;
25
26
  translations?: boolean;
@@ -29,7 +29,8 @@ export interface TrackEventParams {
29
29
  meta?: {};
30
30
  }
31
31
  export interface SendGreetingParams {
32
- responseId: string;
32
+ responseId?: string;
33
+ isChatEmpty?: boolean;
33
34
  }
34
35
  export interface TriggerCampaignParams {
35
36
  campaignKey: string;
@@ -71,6 +71,8 @@ export interface StoreState extends StartOptionsNoFunction {
71
71
  chatterInLiveChat: boolean;
72
72
  language?: string;
73
73
  adaSettings: StartOptions;
74
+ wasCampaignShownButNowClosed: boolean;
75
+ isChatEmpty: boolean;
74
76
  }
75
77
  export interface StartOptionsNoFunction {
76
78
  handle?: string;
@@ -8788,7 +8788,7 @@ var client = new error_tracker_BrowserClient({
8788
8788
  return event;
8789
8789
  },
8790
8790
  environment: "production",
8791
- release: "1.0.55-68d18b3",
8791
+ release: "1.0.56-e4890fa",
8792
8792
  sampleRate: 0.25,
8793
8793
  autoSessionTracking: false,
8794
8794
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -9487,7 +9487,7 @@ function getEmbedURL(_ref) {
9487
9487
  polyfillVersionString = "legacy";
9488
9488
  }
9489
9489
 
9490
- return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "68d18b3", "/index.html");
9490
+ return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "e4890fa", "/index.html");
9491
9491
  }
9492
9492
  /**
9493
9493
  * Generate the Chat / API URL
@@ -9962,7 +9962,9 @@ var state = {
9962
9962
  latestCampaignKey: undefined,
9963
9963
  hasChatOpenedAfterProactiveMessagesShown: false,
9964
9964
  chatterInLiveChat: false,
9965
- adaSettings: {}
9965
+ adaSettings: {},
9966
+ wasCampaignShownButNowClosed: false,
9967
+ isChatEmpty: false
9966
9968
  };
9967
9969
  /* harmony default export */ var store_state = (state);
9968
9970
  ;// CONCATENATED MODULE: ./src/client/store/index.ts
@@ -12718,7 +12720,8 @@ var Container = /*#__PURE__*/function (_Component) {
12718
12720
  chatHasBeenRendered: false,
12719
12721
  hideChatOverride: false,
12720
12722
  hideIntroOverride: false,
12721
- followUpResponseId: null
12723
+ followUpResponseId: null,
12724
+ wasCampaignShownButNowClosed: false
12722
12725
  });
12723
12726
 
12724
12727
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "resetChatBound", _this.resetChat.bind((0,assertThisInitialized/* default */.Z)(_this)));
@@ -12781,7 +12784,10 @@ var Container = /*#__PURE__*/function (_Component) {
12781
12784
  isChatWebsocketConnected = _this$props2.isChatWebsocketConnected,
12782
12785
  adaSettings = _this$props2.adaSettings,
12783
12786
  chatterInLiveChat = _this$props2.chatterInLiveChat,
12784
- messageService = _this$props2.messageService;
12787
+ messageService = _this$props2.messageService,
12788
+ wasCampaignShownButNowClosed = _this$props2.wasCampaignShownButNowClosed,
12789
+ isChatEmpty = _this$props2.isChatEmpty,
12790
+ setState = _this$props2.setState;
12785
12791
  var adaReadyCallback = adaSettings.adaReadyCallback,
12786
12792
  toggleCallback = adaSettings.toggleCallback;
12787
12793
 
@@ -12847,9 +12853,22 @@ var Container = /*#__PURE__*/function (_Component) {
12847
12853
  var chatChannel = messageService.getChannel(CHAT_IFRAME);
12848
12854
 
12849
12855
  if (chatChannel) {
12850
- chatChannel.postMessage(SEND_GREETING, {
12851
- responseId: followUpResponseId
12852
- });
12856
+ if (!wasCampaignShownButNowClosed) {
12857
+ chatChannel.postMessage(SEND_GREETING, {
12858
+ responseId: followUpResponseId
12859
+ }); // If the campaign has not been closed (i.e. is still visible), send the follow up response
12860
+ } else if (isChatEmpty) {
12861
+ chatChannel.postMessage(SEND_GREETING);
12862
+ } // We want to reset the state because there's a possibility
12863
+ // that a user might engage with another campaign on another page path
12864
+
12865
+
12866
+ if (followUpResponseId && wasCampaignShownButNowClosed) {
12867
+ setState({
12868
+ wasCampaignShownButNowClosed: false
12869
+ });
12870
+ }
12871
+
12853
12872
  this.setState({
12854
12873
  followUpResponseId: null
12855
12874
  });
@@ -13010,6 +13029,12 @@ var Container = /*#__PURE__*/function (_Component) {
13010
13029
  throw new errors/* AdaEmbedError */.S("Could not find campaign with key: ".concat(campaignKey));
13011
13030
  }
13012
13031
 
13032
+ var followUpResponseId = campaign.follow_up_response_id;
13033
+
13034
+ if (client !== null && client !== void 0 && client.features.afm_dont_show_proactive_messages_in_chat && !followUpResponseId) {
13035
+ followUpResponseId = campaign.response_id;
13036
+ }
13037
+
13013
13038
  setState({
13014
13039
  latestCampaignKey: campaignKey,
13015
13040
  hasChatOpenedAfterProactiveMessagesShown: false
@@ -13018,7 +13043,7 @@ var Container = /*#__PURE__*/function (_Component) {
13018
13043
  // Only need to load chat for engage campaigns, not free tier (message_text) campaigns
13019
13044
  chatHasBeenRendered: chatHasBeenRendered || !campaign.message_text,
13020
13045
  campaignToTrigger: campaign,
13021
- followUpResponseId: campaign.follow_up_response_id,
13046
+ followUpResponseId: followUpResponseId,
13022
13047
  campaignTriggerOptions: {
13023
13048
  ignoreFrequency: ignoreFrequency,
13024
13049
  ignoreStatus: ignoreStatus
@@ -13722,7 +13747,9 @@ function Container_mapStateToProps(storeState) {
13722
13747
  chatterInLiveChat = storeState.chatterInLiveChat,
13723
13748
  chatDimensions = storeState.chatDimensions,
13724
13749
  isIntroShown = storeState.isIntroShown,
13725
- language = storeState.language;
13750
+ language = storeState.language,
13751
+ wasCampaignShownButNowClosed = storeState.wasCampaignShownButNowClosed,
13752
+ isChatEmpty = storeState.isChatEmpty;
13726
13753
  return {
13727
13754
  client: client,
13728
13755
  hideMask: hideMask,
@@ -13736,7 +13763,9 @@ function Container_mapStateToProps(storeState) {
13736
13763
  chatterInLiveChat: chatterInLiveChat,
13737
13764
  chatDimensions: chatDimensions,
13738
13765
  isIntroShown: isIntroShown,
13739
- language: language
13766
+ language: language,
13767
+ wasCampaignShownButNowClosed: wasCampaignShownButNowClosed,
13768
+ isChatEmpty: isChatEmpty
13740
13769
  };
13741
13770
  }
13742
13771
 
@@ -14302,7 +14331,7 @@ window.__AdaEmbedConstructor = Embed;
14302
14331
  /* harmony export */ });
14303
14332
  var isModern = new RegExp("((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(15|(1[6-9]|[2-9]\\d|\\d{3,}))[_.]\\d+(?:[_.]\\d+)?)|((Chromium|Chrome)\\/(97|(9[8-9]|\\d{3,}))\\.\\d+(?:\\.\\d+)?)|(Version\\/(15|(1[6-9]|[2-9]\\d|\\d{3,}))\\.\\d+(?:\\.\\d+)? Safari\\/)|(Firefox\\/(96|(9[7-9]|\\d{3,}))\\.\\d+\\.\\d+)|(Firefox\\/(96|(9[7-9]|\\d{3,}))\\.\\d+(pre|[ab]\\d+[a-z]*)?)").test(navigator.userAgent);
14304
14333
  var isProduction = "production" === "production";
14305
- var embed2Version = "68d18b3";
14334
+ var embed2Version = "e4890fa";
14306
14335
 
14307
14336
  /***/ }),
14308
14337
 
@@ -14644,9 +14673,9 @@ function _log() {
14644
14673
  service: "embed",
14645
14674
  env: "production",
14646
14675
  embedVersion: 2,
14647
- version: "1.0.55",
14676
+ version: "1.0.56",
14648
14677
  isNpm: true,
14649
- commitHash: "68d18b3"
14678
+ commitHash: "e4890fa"
14650
14679
  }))
14651
14680
  });
14652
14681
 
@@ -24193,7 +24222,7 @@ function _loadEmbed() {
24193
24222
  polyfillVersionString = "legacy";
24194
24223
  }
24195
24224
 
24196
- embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "68d18b3", "/index.js");
24225
+ embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "e4890fa", "/index.js");
24197
24226
  }
24198
24227
 
24199
24228
  clientScriptExists = Boolean( true || // The client script is bundled with npm module
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.0.55",
3
+ "version": "1.0.56",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index.d.ts",