@ada-support/embed2 1.0.75 → 1.0.78

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.
@@ -74,7 +74,7 @@ export interface StoreState extends StartOptionsNoFunction {
74
74
  language?: string;
75
75
  adaSettings: StartOptions;
76
76
  wasCampaignShownButNowClosed: boolean;
77
- isChatEmpty: boolean;
77
+ proactiveCampaignHadMessages: boolean;
78
78
  }
79
79
  export interface StartOptionsNoFunction {
80
80
  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.75-b7ed156",
8791
+ release: "1.0.78-033c4a1",
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
@@ -9490,7 +9490,7 @@ function getEmbedURL(_ref) {
9490
9490
  polyfillVersionString = "legacy";
9491
9491
  }
9492
9492
 
9493
- return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "b7ed156", "/index.html");
9493
+ return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "033c4a1", "/index.html");
9494
9494
  }
9495
9495
  /**
9496
9496
  * Generate the Chat / API URL
@@ -9595,9 +9595,10 @@ var actions = {
9595
9595
  }
9596
9596
 
9597
9597
  var hasChatOpenedAfterProactiveMessagesShown = currentState.hasChatOpenedAfterProactiveMessagesShown,
9598
- wasCampaignShownButNowClosed = currentState.wasCampaignShownButNowClosed;
9598
+ wasCampaignShownButNowClosed = currentState.wasCampaignShownButNowClosed,
9599
+ proactiveCampaignHadMessages = currentState.proactiveCampaignHadMessages;
9599
9600
 
9600
- if (!currentState.isDrawerOpen && !hasChatOpenedAfterProactiveMessagesShown && !wasCampaignShownButNowClosed && currentState.latestCampaignKey) {
9601
+ if (!currentState.isDrawerOpen && !hasChatOpenedAfterProactiveMessagesShown && !wasCampaignShownButNowClosed && proactiveCampaignHadMessages && currentState.latestCampaignKey) {
9601
9602
  var _url = getURL({
9602
9603
  name: "api",
9603
9604
  handle: currentState.handle,
@@ -9971,7 +9972,7 @@ var state = {
9971
9972
  chatterInLiveChat: false,
9972
9973
  adaSettings: {},
9973
9974
  wasCampaignShownButNowClosed: false,
9974
- isChatEmpty: false
9975
+ proactiveCampaignHadMessages: false
9975
9976
  };
9976
9977
  /* harmony default export */ var store_state = (state);
9977
9978
  ;// CONCATENATED MODULE: ./src/client/store/index.ts
@@ -10397,8 +10398,20 @@ var get_browser_language_getBrowserLanguage = function getBrowserLanguage() {
10397
10398
 
10398
10399
  /* harmony default export */ var get_browser_language = (get_browser_language_getBrowserLanguage);
10399
10400
  ;// CONCATENATED MODULE: ./src/services/helpers.ts
10401
+
10400
10402
  var NO_OP_FUNCTION = function NO_OP_FUNCTION() {// Do nothing
10401
10403
  };
10404
+ function isStartOptions(input) {
10405
+ if (!(_typeof(input) === "object")) {
10406
+ return false;
10407
+ }
10408
+
10409
+ if (input === null) {
10410
+ return false;
10411
+ }
10412
+
10413
+ return typeof input.handle === "string";
10414
+ }
10402
10415
  ;// CONCATENATED MODULE: ./src/campaigns/campaign.ts
10403
10416
 
10404
10417
 
@@ -12762,8 +12775,7 @@ var Container = /*#__PURE__*/function (_Component) {
12762
12775
  adaSettings = _this$props2.adaSettings,
12763
12776
  chatterInLiveChat = _this$props2.chatterInLiveChat,
12764
12777
  messageService = _this$props2.messageService,
12765
- wasCampaignShownButNowClosed = _this$props2.wasCampaignShownButNowClosed,
12766
- isChatEmpty = _this$props2.isChatEmpty;
12778
+ wasCampaignShownButNowClosed = _this$props2.wasCampaignShownButNowClosed;
12767
12779
  var adaReadyCallback = adaSettings.adaReadyCallback,
12768
12780
  toggleCallback = adaSettings.toggleCallback;
12769
12781
 
@@ -12830,10 +12842,12 @@ var Container = /*#__PURE__*/function (_Component) {
12830
12842
 
12831
12843
  if (chatChannel) {
12832
12844
  if (!wasCampaignShownButNowClosed) {
12845
+ // If the campaign has not been closed (i.e. is still visible), send the follow up response
12833
12846
  chatChannel.postMessage(SEND_GREETING, {
12834
12847
  responseId: followUpResponseId
12835
- }); // If the campaign has not been closed (i.e. is still visible), send the follow up response
12836
- } else if (isChatEmpty) {
12848
+ });
12849
+ } else {
12850
+ // otherwise, send the bot's default greeting answer (if the conversation has messages already, `chat` will ignore this message)
12837
12851
  chatChannel.postMessage(SEND_GREETING);
12838
12852
  }
12839
12853
 
@@ -13003,7 +13017,8 @@ var Container = /*#__PURE__*/function (_Component) {
13003
13017
  setState({
13004
13018
  latestCampaignKey: campaignKey,
13005
13019
  hasChatOpenedAfterProactiveMessagesShown: false,
13006
- wasCampaignShownButNowClosed: false
13020
+ wasCampaignShownButNowClosed: false,
13021
+ proactiveCampaignHadMessages: false
13007
13022
  });
13008
13023
  this.setState({
13009
13024
  // Only need to load chat for engage campaigns, not free tier (message_text) campaigns
@@ -13723,8 +13738,7 @@ function Container_mapStateToProps(storeState) {
13723
13738
  chatDimensions = storeState.chatDimensions,
13724
13739
  isIntroShown = storeState.isIntroShown,
13725
13740
  language = storeState.language,
13726
- wasCampaignShownButNowClosed = storeState.wasCampaignShownButNowClosed,
13727
- isChatEmpty = storeState.isChatEmpty;
13741
+ wasCampaignShownButNowClosed = storeState.wasCampaignShownButNowClosed;
13728
13742
  return {
13729
13743
  client: client,
13730
13744
  hideMask: hideMask,
@@ -13739,8 +13753,7 @@ function Container_mapStateToProps(storeState) {
13739
13753
  chatDimensions: chatDimensions,
13740
13754
  isIntroShown: isIntroShown,
13741
13755
  language: language,
13742
- wasCampaignShownButNowClosed: wasCampaignShownButNowClosed,
13743
- isChatEmpty: isChatEmpty
13756
+ wasCampaignShownButNowClosed: wasCampaignShownButNowClosed
13744
13757
  };
13745
13758
  }
13746
13759
 
@@ -14335,7 +14348,7 @@ window.__AdaEmbedConstructor = Embed;
14335
14348
  /* harmony export */ });
14336
14349
  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)\\/(99|([1-9]\\d\\d|\\d{4,}))\\.\\d+(?:\\.\\d+)?)|(Version\\/(15|(1[6-9]|[2-9]\\d|\\d{3,}))\\.\\d+(?:\\.\\d+)? Safari\\/)|(Firefox\\/(98|(99|\\d{3,}))\\.\\d+\\.\\d+)|(Firefox\\/(98|(99|\\d{3,}))\\.\\d+(pre|[ab]\\d+[a-z]*)?)").test(navigator.userAgent);
14337
14350
  var isProduction = "production" === "production";
14338
- var embed2Version = "b7ed156";
14351
+ var embed2Version = "033c4a1";
14339
14352
 
14340
14353
  /***/ }),
14341
14354
 
@@ -14681,9 +14694,9 @@ function _log() {
14681
14694
  service: "embed",
14682
14695
  env: "production",
14683
14696
  embedVersion: 2,
14684
- version: "1.0.75",
14697
+ version: "1.0.78",
14685
14698
  isNpm: true,
14686
- commitHash: "b7ed156"
14699
+ commitHash: "033c4a1"
14687
14700
  }))
14688
14701
  });
14689
14702
 
@@ -25624,7 +25637,7 @@ function _loadEmbed() {
25624
25637
  polyfillVersionString = "legacy";
25625
25638
  }
25626
25639
 
25627
- embedScriptSource = concat_default()(_context17 = concat_default()(_context18 = "".concat(host, "/embed/")).call(_context18, polyfillVersionString, "/client/")).call(_context17, "b7ed156", "/index.js");
25640
+ embedScriptSource = concat_default()(_context17 = concat_default()(_context18 = "".concat(host, "/embed/")).call(_context18, polyfillVersionString, "/client/")).call(_context17, "033c4a1", "/index.js");
25628
25641
  }
25629
25642
 
25630
25643
  clientScriptExists = Boolean( true || // The client script is bundled with npm module
@@ -25750,7 +25763,10 @@ function createEmbedObject() {
25750
25763
  (0,logger/* log */.cM)("Embed start", {
25751
25764
  handle: adaSettings.handle,
25752
25765
  embedSettings: adaSettings,
25753
- hostPage: window.location.href
25766
+ hostPage: window.location.href,
25767
+ adaScriptURL: function (scriptElement) {
25768
+ return scriptElement ? scriptElement.src : null;
25769
+ }(document.getElementById("__ada"))
25754
25770
  });
25755
25771
  return _context2.abrupt("return", embed.initialized);
25756
25772
 
@@ -1 +1,3 @@
1
+ import type { StartOptions } from "common/types/store-state";
1
2
  export declare const NO_OP_FUNCTION: () => void;
3
+ export declare function isStartOptions(input: unknown): input is StartOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.0.75",
3
+ "version": "1.0.78",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index.d.ts",
@@ -76,7 +76,7 @@
76
76
  "eslint-plugin-cypress": "^2.11.3",
77
77
  "eslint-plugin-sonarjs": "^0.11.0",
78
78
  "husky": "^7.0.0",
79
- "jest": "^27.3.1",
79
+ "jest": "^27.5.1",
80
80
  "jest-localstorage-mock": "^2.4.0",
81
81
  "lint-staged": "^11.2.3",
82
82
  "npm-run-all": "^4.1.5",
@@ -100,7 +100,7 @@
100
100
  "@babel/preset-typescript": "^7.16.7",
101
101
  "@babel/runtime-corejs3": "^7.15.4",
102
102
  "@sentry/browser": "^6.17.1",
103
- "@sentry/webpack-plugin": "^1.18.4",
103
+ "@sentry/webpack-plugin": "^1.18.8",
104
104
  "babel-loader": "^8.2.3",
105
105
  "babel-preset-preact": "^2.0.0",
106
106
  "browserslist-useragent-regexp": "^3.0.2",