@ada-support/embed2 1.2.18 → 1.3.2

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.
@@ -27,6 +27,7 @@ interface OwnProps {
27
27
  setChatHasBeenRendered: () => void;
28
28
  resetChat: () => void;
29
29
  skipGreeting: boolean;
30
+ chatVersion?: string;
30
31
  }
31
32
  interface PropsFromDispatch {
32
33
  setConnectionState: (payload: MessagePayload) => Promise<StoreState>;
@@ -11,5 +11,5 @@ interface OwnProps {
11
11
  initializationResolve?: () => void;
12
12
  initializationReject?: (error: Error) => void;
13
13
  }
14
- declare const _default: (ownProps: OwnProps) => h.JSX.Element;
15
- export default _default;
14
+ export declare const ConnectedContainer: (ownProps: OwnProps) => h.JSX.Element;
15
+ export {};
@@ -4,4 +4,15 @@ export interface Hosts {
4
4
  export interface Ports {
5
5
  [key: string]: number;
6
6
  }
7
- export declare const ports: Hosts;
7
+ export declare const ports: {
8
+ readonly localhost: {
9
+ readonly api: 8000;
10
+ readonly chat: 8002;
11
+ readonly default: 9001;
12
+ };
13
+ readonly e2ereference: {
14
+ readonly api: 8000;
15
+ readonly chat: 8002;
16
+ readonly default: 9001;
17
+ };
18
+ };
@@ -4,15 +4,16 @@ interface GetEmbedUrlParams {
4
4
  cluster?: string;
5
5
  domain?: string;
6
6
  }
7
+ interface QueryParams {
8
+ [key: string]: string | boolean | number | null | undefined;
9
+ }
7
10
  export interface CSInterface {
8
- name: "api" | "chat";
11
+ name: "api";
9
12
  handle: string;
10
13
  cluster?: string;
11
14
  domain?: string;
12
15
  route?: string;
13
- qp?: {
14
- [key: string]: string | boolean | number | null | undefined;
15
- };
16
+ qp?: QueryParams;
16
17
  isEmbedFramed?: boolean;
17
18
  }
18
19
  export declare function getClientCacheUrl(handle: string, cluster?: string, domain?: string): string;
@@ -21,4 +22,11 @@ export declare function getEmbedURL({ frameName, handle, cluster, domain, }: Get
21
22
  * Generate the Chat / API URL
22
23
  */
23
24
  export declare function getURL({ name, handle, cluster, domain, route, qp, }: CSInterface): string;
25
+ export declare function getChatURL({ handle, version, cluster, domain, qp, }: {
26
+ handle: string;
27
+ version?: string;
28
+ cluster?: string;
29
+ domain?: string;
30
+ qp?: QueryParams;
31
+ }): string;
24
32
  export {};
@@ -15811,7 +15811,7 @@ const client = new error_tracker_BrowserClient({
15811
15811
  },
15812
15812
 
15813
15813
  environment: "production",
15814
- release: "1.2.18-946b98d",
15814
+ release: "1.3.2-6bc9054",
15815
15815
  sampleRate: 0.25,
15816
15816
  autoSessionTracking: false,
15817
15817
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -16398,6 +16398,12 @@ const ports = {
16398
16398
  ;// CONCATENATED MODULE: ./src/common/helpers/url/index.ts
16399
16399
 
16400
16400
 
16401
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16402
+
16403
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16404
+
16405
+
16406
+
16401
16407
 
16402
16408
  const DEFAULT_ADA_DOMAIN = "ada";
16403
16409
  function getClientCacheUrl(handle, cluster, domain) {
@@ -16426,12 +16432,25 @@ function getEmbedURL(_ref) {
16426
16432
  host = "http://".concat(window.location.hostname, ":9001");
16427
16433
  }
16428
16434
 
16429
- return "".concat(host, "/embed/").concat(frameName, "/").concat("946b98d", "/index.html");
16435
+ return "".concat(host, "/embed/").concat(frameName, "/").concat("6bc9054", "/index.html");
16436
+ }
16437
+
16438
+ function constructQueryString(query) {
16439
+ return Object.keys(query).map(key => {
16440
+ const value = query[key];
16441
+
16442
+ if (value === undefined || value === null) {
16443
+ return null;
16444
+ }
16445
+
16446
+ return "".concat(key, "=").concat(window.encodeURIComponent(value));
16447
+ }).filter(v => v !== null).join("&");
16430
16448
  }
16431
16449
  /**
16432
16450
  * Generate the Chat / API URL
16433
16451
  */
16434
16452
 
16453
+
16435
16454
  function getURL(_ref2) {
16436
16455
  var _context;
16437
16456
 
@@ -16443,15 +16462,7 @@ function getURL(_ref2) {
16443
16462
  route,
16444
16463
  qp = {}
16445
16464
  } = _ref2;
16446
- const queryString = Object.keys(qp).map(key => {
16447
- const value = qp[key];
16448
-
16449
- if (value === undefined || value === null) {
16450
- return null;
16451
- }
16452
-
16453
- return "".concat(key, "=").concat(window.encodeURIComponent(value));
16454
- }).filter(v => v !== null).join("&");
16465
+ const queryString = constructQueryString(qp);
16455
16466
  const questionSym = queryString.length ? "?" : "";
16456
16467
  const routeString = route ? "".concat(route, "/") : "";
16457
16468
  const clusterString = cluster ? ".".concat(cluster) : "";
@@ -16465,22 +16476,51 @@ function getURL(_ref2) {
16465
16476
  if (includes_default()(_context = window.location.hostname).call(_context, "localhost") || handle === "e2ereference") {
16466
16477
  var _context2;
16467
16478
 
16468
- let host = window.location.hostname;
16469
16479
  const domainName = includes_default()(_context2 = window.location.hostname).call(_context2, "localhost") ? "localhost" : "e2ereference";
16480
+ const host = "".concat(window.location.hostname, ":").concat(ports[domainName].api);
16481
+ return "http://".concat(host, "/").concat(routeString).concat(questionSym).concat(queryString);
16482
+ }
16483
+
16484
+ return prodUrl;
16485
+ }
16486
+ function getChatURL(_ref3) {
16487
+ var _context3;
16488
+
16489
+ let {
16490
+ handle,
16491
+ version,
16492
+ cluster,
16493
+ domain,
16494
+ qp
16495
+ } = _ref3;
16496
+
16497
+ const queryParams = _objectSpread(_objectSpread({}, qp), {}, {
16498
+ version
16499
+ });
16470
16500
 
16471
- if (domainName === "localhost" && name === "chat") {
16501
+ const queryString = constructQueryString(queryParams);
16502
+ const questionSym = queryString.length ? "?" : "";
16503
+ const clusterString = cluster ? ".".concat(cluster) : "";
16504
+ const domainString = domain || DEFAULT_ADA_DOMAIN;
16505
+ const prodUrl = "https://".concat(handle).concat(clusterString, ".").concat(domainString, ".support/chat/").concat(questionSym).concat(queryString);
16506
+
16507
+ if (isProduction || false || domain) {
16508
+ return prodUrl;
16509
+ }
16510
+
16511
+ if (includes_default()(_context3 = window.location.hostname).call(_context3, "localhost") || handle === "e2ereference") {
16512
+ var _context4;
16513
+
16514
+ const domainName = includes_default()(_context4 = window.location.hostname).call(_context4, "localhost") ? "localhost" : "e2ereference";
16515
+
16516
+ if (domainName === "localhost") {
16472
16517
  // Chat should be on a different domain (even though the port is different).
16473
16518
  // We need this to test Embed+Chat behaviour when third-party cookies are disabled (incognito mode).
16474
- return "".concat(window.location.protocol, "//").concat(handle, ".chat:8002/").concat(routeString).concat(questionSym).concat(queryString);
16475
- }
16476
-
16477
- if (name === "api" || name === "chat") {
16478
- host += ":".concat(ports[domainName][name]);
16479
- } else {
16480
- host += ":".concat(ports[domainName].default);
16519
+ return "".concat(window.location.protocol, "//").concat(handle, ".chat:8002/").concat(questionSym).concat(queryString);
16481
16520
  }
16482
16521
 
16483
- return "http://".concat(host, "/").concat(routeString).concat(questionSym).concat(queryString);
16522
+ const host = "".concat(window.location.hostname, ":").concat(ports[domainName].chat);
16523
+ return "http://".concat(host, "/").concat(questionSym).concat(queryString);
16484
16524
  }
16485
16525
 
16486
16526
  return prodUrl;
@@ -16695,9 +16735,9 @@ const safeSessionStorage = new SafeStorage(StorageTypes.Session);
16695
16735
  ;// CONCATENATED MODULE: ./src/client/store/mutations/index.ts
16696
16736
 
16697
16737
 
16698
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16738
+ function mutations_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16699
16739
 
16700
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16740
+ function mutations_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? mutations_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : mutations_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16701
16741
 
16702
16742
 
16703
16743
 
@@ -16720,7 +16760,7 @@ const mutations = (state, action) => {
16720
16760
  }
16721
16761
 
16722
16762
  safeLocalStorage.setItem(IS_DRAWER_OPEN_STORAGE_KEY, !state.isDrawerOpen);
16723
- return _objectSpread(_objectSpread({}, state), {}, {
16763
+ return mutations_objectSpread(mutations_objectSpread({}, state), {}, {
16724
16764
  isDrawerOpen: !state.isDrawerOpen,
16725
16765
  isIntroShown: false,
16726
16766
  drawerHasBeenOpened: true,
@@ -16730,7 +16770,7 @@ const mutations = (state, action) => {
16730
16770
  }
16731
16771
 
16732
16772
  case ActionTypes.SET_STATE_TYPE:
16733
- return _objectSpread(_objectSpread({}, state), action.payload);
16773
+ return mutations_objectSpread(mutations_objectSpread({}, state), action.payload);
16734
16774
 
16735
16775
  case ActionTypes.INCREMENT_MESSAGE_COUNT_TYPE:
16736
16776
  {
@@ -16739,14 +16779,14 @@ const mutations = (state, action) => {
16739
16779
  } = action.payload; // Filter out Proactive Messages
16740
16780
 
16741
16781
  const nonProactive = messages.filter(message => !message.campaign_key);
16742
- return _objectSpread(_objectSpread({}, state), {}, {
16782
+ return mutations_objectSpread(mutations_objectSpread({}, state), {}, {
16743
16783
  unreadMessageCount: nonProactive.length
16744
16784
  });
16745
16785
  }
16746
16786
 
16747
16787
  case ActionTypes.SET_CONNECTION_STATE_TYPE:
16748
16788
  {
16749
- const newConnections = _objectSpread(_objectSpread({}, state.connections), action.payload);
16789
+ const newConnections = mutations_objectSpread(mutations_objectSpread({}, state.connections), action.payload);
16750
16790
 
16751
16791
  const connectionValues = Object.values(newConnections);
16752
16792
  let appConnectionState;
@@ -16764,7 +16804,7 @@ const mutations = (state, action) => {
16764
16804
  appConnectionState = ConnectionState.Uninitiated;
16765
16805
  }
16766
16806
 
16767
- return _objectSpread(_objectSpread({}, state), {}, {
16807
+ return mutations_objectSpread(mutations_objectSpread({}, state), {}, {
16768
16808
  connections: newConnections,
16769
16809
  appConnectionState
16770
16810
  });
@@ -17958,6 +17998,135 @@ function retrieveStorage(key, client, privateMode) {
17958
17998
 
17959
17999
  return null;
17960
18000
  }
18001
+ ;// CONCATENATED MODULE: ./src/services/persistence/index.ts
18002
+ const persistence = {
18003
+ get: item => {
18004
+ try {
18005
+ return localStorage.getItem(item);
18006
+ } catch (e) {
18007
+ /* istanbul ignore next */
18008
+ return null;
18009
+ }
18010
+ },
18011
+ set: (item, value) => {
18012
+ try {
18013
+ localStorage.setItem(item, value);
18014
+ } catch (e) {// Do nothing
18015
+ }
18016
+ }
18017
+ };
18018
+ ;// CONCATENATED MODULE: ./src/services/chat-versioning/manifest.ts
18019
+
18020
+ const CHAT_MANIFEST_PATH = "https://static.ada.support/chat-manifest.json";
18021
+ const loadChatManifest = async () => {
18022
+ const r = await fetch(CHAT_MANIFEST_PATH);
18023
+ return r.json();
18024
+ }; // Use one message for different errors to reduce the bundle size
18025
+
18026
+ const MANIFEST_VALIDATION_ERROR_MESSAGE = "The format of manifest file is incorrect";
18027
+ const isManifest = input => {
18028
+ if (!(typeof input === "object")) {
18029
+ throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
18030
+ }
18031
+
18032
+ if (input === null) {
18033
+ throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
18034
+ }
18035
+
18036
+ const objectInput = input;
18037
+
18038
+ if (!Array.isArray(objectInput.versions)) {
18039
+ throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
18040
+ }
18041
+
18042
+ if (!objectInput.versions.length) {
18043
+ throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
18044
+ }
18045
+
18046
+ if (!(typeof objectInput.versions[0].hash === "string")) {
18047
+ throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
18048
+ }
18049
+
18050
+ if (!objectInput.versions[0].hash) {
18051
+ throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
18052
+ }
18053
+
18054
+ if (!(typeof objectInput.versions[0].weight === "number")) {
18055
+ throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
18056
+ }
18057
+
18058
+ if (objectInput.versions.reduce((s, v) => s + v.weight, 0) !== 1) {
18059
+ throw new AdaEmbedError("The sum of version weights must be \"1\"");
18060
+ }
18061
+
18062
+ return true;
18063
+ };
18064
+ ;// CONCATENATED MODULE: ./src/services/chat-versioning/index.ts
18065
+
18066
+
18067
+ // Somewhat inefficient, but more than adequate shuffle algorithm for small arrays
18068
+
18069
+ const arrayShuffle = array => array.map(value => ({
18070
+ value,
18071
+ sort: Math.random()
18072
+ })).sort((a, b) => a.sort - b.sort).map(_ref => {
18073
+ let {
18074
+ value
18075
+ } = _ref;
18076
+ return value;
18077
+ });
18078
+
18079
+ const getChatVersionFromManifest = manifest => {
18080
+ /* istanbul ignore next */
18081
+ if (!isManifest(manifest)) {
18082
+ // This should never happen since isManifest throws an error for invalid input
18083
+ throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
18084
+ }
18085
+
18086
+ const manifestString = JSON.stringify(manifest);
18087
+ const manifestCache = persistence.get("ada-embed_chat-manifest-cache");
18088
+
18089
+ if (manifestString === manifestCache) {
18090
+ const assignedVersion = persistence.get("ada-embed_chat-assigned-version");
18091
+ /* istanbul ignore else */
18092
+
18093
+ if (assignedVersion) {
18094
+ return assignedVersion;
18095
+ }
18096
+ }
18097
+
18098
+ const random = Math.random();
18099
+ const {
18100
+ versions
18101
+ } = manifest;
18102
+ const shuffledVersions = arrayShuffle(versions); // Use hash from last version in array by default
18103
+
18104
+ let {
18105
+ hash
18106
+ } = shuffledVersions[shuffledVersions.length - 1]; // Loop through shuffledVersions
18107
+
18108
+ for (let i = 0; i < shuffledVersions.length; i += 1) {
18109
+ const v = shuffledVersions[i]; // If random falls into version weight
18110
+
18111
+ if (random <= v.weight) {
18112
+ hash = v.hash;
18113
+ break;
18114
+ }
18115
+ }
18116
+
18117
+ persistence.set("ada-embed_chat-assigned-version", hash);
18118
+ persistence.set("ada-embed_chat-manifest-cache", manifestString);
18119
+ return hash;
18120
+ };
18121
+ const getChatVersion = async () => {
18122
+ const manifest = await loadChatManifest();
18123
+
18124
+ if (window.__AdaChatVersion) {
18125
+ return window.__AdaChatVersion;
18126
+ }
18127
+
18128
+ return getChatVersionFromManifest(manifest);
18129
+ };
17961
18130
  // EXTERNAL MODULE: ./node_modules/lodash.memoize/index.js
17962
18131
  var lodash_memoize = __webpack_require__(773);
17963
18132
  var lodash_memoize_default = /*#__PURE__*/__webpack_require__.n(lodash_memoize);
@@ -18001,9 +18170,9 @@ async function log(message, extra, options) {
18001
18170
  service: "embed",
18002
18171
  env: "production",
18003
18172
  embedVersion: 2,
18004
- version: "1.2.18",
18173
+ version: "1.3.2",
18005
18174
  isNpm: true,
18006
- commitHash: "946b98d"
18175
+ commitHash: "6bc9054"
18007
18176
  }))
18008
18177
  });
18009
18178
  }
@@ -18413,13 +18582,14 @@ class ChatFrame extends d {
18413
18582
  wasIntroShown,
18414
18583
  privateMode,
18415
18584
  testMode,
18416
- adaSettings
18585
+ adaSettings,
18586
+ chatVersion
18417
18587
  } = this.props; // check the host page URL for an adaSMSToken and add it as a chatterToken query param for chat's iframe URL
18418
18588
 
18419
18589
  const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
18420
18590
  const smsToken = hostPageUrlParams.get("adaSMSToken");
18421
18591
  const queryParams = {
18422
- embedVersion: "946b98d".slice(0, 7),
18592
+ embedVersion: "6bc9054".slice(0, 7),
18423
18593
  greeting,
18424
18594
  language,
18425
18595
  skipGreeting,
@@ -18434,8 +18604,8 @@ class ChatFrame extends d {
18434
18604
  queryParams.adaSMSToken = smsToken;
18435
18605
  }
18436
18606
 
18437
- return getURL({
18438
- name: "chat",
18607
+ return getChatURL({
18608
+ version: chatVersion,
18439
18609
  handle,
18440
18610
  cluster,
18441
18611
  domain,
@@ -19297,6 +19467,7 @@ function Container_objectSpread(target) { for (var i = 1; i < arguments.length;
19297
19467
 
19298
19468
 
19299
19469
 
19470
+
19300
19471
 
19301
19472
 
19302
19473
  class Container extends d {
@@ -19312,7 +19483,9 @@ class Container extends d {
19312
19483
  chatHasBeenRendered: false,
19313
19484
  hideChatOverride: false,
19314
19485
  hideIntroOverride: false,
19315
- followUpResponseId: null
19486
+ followUpResponseId: null,
19487
+ chatVersion: undefined,
19488
+ readyToRenderChatFrame: false
19316
19489
  });
19317
19490
 
19318
19491
  _defineProperty(this, "resetChatBound", this.resetChat.bind(this));
@@ -19334,7 +19507,7 @@ class Container extends d {
19334
19507
  })());
19335
19508
  }
19336
19509
 
19337
- componentDidMount() {
19510
+ async componentDidMount() {
19338
19511
  const {
19339
19512
  adaSettings,
19340
19513
  setState
@@ -19355,7 +19528,20 @@ class Container extends d {
19355
19528
  this.notificationPermHandler();
19356
19529
  bindLocationChangeOverrides();
19357
19530
  addServiceWorkerListeners();
19358
- window.addEventListener("locationchange", this.locationChangeHandlerBound);
19531
+ window.addEventListener("locationchange", this.locationChangeHandlerBound); // Get chat version. Skip for ATT cluster.
19532
+
19533
+ const chatVersion = await (async () => {
19534
+ if (adaSettings.cluster === "att") {
19535
+ return undefined;
19536
+ }
19537
+
19538
+ return getChatVersion();
19539
+ })();
19540
+ this.setState({
19541
+ chatVersion,
19542
+ // We shouldn't try to render chat frame until version is attempted to be retrieved.
19543
+ readyToRenderChatFrame: true
19544
+ });
19359
19545
  }
19360
19546
  /** To be called when `props.appConnectionState` value changes */
19361
19547
 
@@ -19515,9 +19701,14 @@ class Container extends d {
19515
19701
  } = adaSettings;
19516
19702
  const {
19517
19703
  chatHasBeenRendered,
19518
- hideChatOverride
19704
+ hideChatOverride,
19705
+ readyToRenderChatFrame
19519
19706
  } = this.state;
19520
19707
 
19708
+ if (!readyToRenderChatFrame) {
19709
+ return false;
19710
+ }
19711
+
19521
19712
  if (hideChatOverride) {
19522
19713
  return false;
19523
19714
  }
@@ -20136,7 +20327,15 @@ class Container extends d {
20136
20327
  const {
20137
20328
  chatHasBeenRendered
20138
20329
  } = this.state;
20139
- messageService.getChannel(XSTORAGE_IFRAME).postMessage(DELETE_HISTORY_EVENT);
20330
+ const xStorageChannel = messageService.getChannel(XSTORAGE_IFRAME);
20331
+ /* istanbul ignore next */
20332
+
20333
+ if (!xStorageChannel) {
20334
+ // This should never happen (ideally).
20335
+ throw new AdaEmbedError("`xStorageChannel` is null");
20336
+ }
20337
+
20338
+ xStorageChannel.postMessage(DELETE_HISTORY_EVENT);
20140
20339
 
20141
20340
  if (chatHasBeenRendered) {
20142
20341
  this.setState({
@@ -20168,21 +20367,23 @@ class Container extends d {
20168
20367
  } = this.props;
20169
20368
  const {
20170
20369
  campaignToTrigger,
20171
- followUpResponseId
20370
+ followUpResponseId,
20371
+ chatVersion
20172
20372
  } = this.state;
20173
20373
 
20174
- if (this.shouldRenderChatFrame) {
20175
- return v(components_ChatFrame, {
20176
- setChatHasBeenRendered: this.setChatHasBeenRenderedBound,
20177
- adaSettings: adaSettings,
20178
- store: store,
20179
- messageService: messageService,
20180
- resetChat: this.resetChatBound,
20181
- skipGreeting: Boolean(campaignToTrigger || followUpResponseId)
20182
- });
20374
+ if (!this.shouldRenderChatFrame) {
20375
+ return null;
20183
20376
  }
20184
20377
 
20185
- return null;
20378
+ return v(components_ChatFrame, {
20379
+ chatVersion: chatVersion,
20380
+ setChatHasBeenRendered: this.setChatHasBeenRenderedBound,
20381
+ adaSettings: adaSettings,
20382
+ store: store,
20383
+ messageService: messageService,
20384
+ resetChat: this.resetChatBound,
20385
+ skipGreeting: Boolean(campaignToTrigger || followUpResponseId)
20386
+ });
20186
20387
  }
20187
20388
 
20188
20389
  renderIntroFrame() {
@@ -20348,7 +20549,7 @@ function Container_mapDispatchToProps(dispatch) {
20348
20549
  };
20349
20550
  }
20350
20551
 
20351
- /* harmony default export */ var components_Container = (connect(Container_mapStateToProps, Container_mapDispatchToProps)(Container));
20552
+ const ConnectedContainer = connect(Container_mapStateToProps, Container_mapDispatchToProps)(Container);
20352
20553
  ;// CONCATENATED MODULE: ./src/client/embed.tsx
20353
20554
 
20354
20555
 
@@ -20438,7 +20639,7 @@ class Embed {
20438
20639
  value: this.store
20439
20640
  }, v(MessageServiceContext.Provider, {
20440
20641
  value: this.messageService
20441
- }, v(components_Container, {
20642
+ }, v(ConnectedContainer, {
20442
20643
  store: this.store,
20443
20644
  messageService: this.messageService,
20444
20645
  adaSettings: this.adaSettings,
@@ -20578,7 +20779,7 @@ class Embed {
20578
20779
 
20579
20780
  }
20580
20781
 
20581
- _defineProperty(Embed, "embed2Version", "946b98d");
20782
+ _defineProperty(Embed, "embed2Version", "6bc9054");
20582
20783
  ;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
20583
20784
 
20584
20785
 
@@ -0,0 +1,3 @@
1
+ import type { Manifest } from "./manifest";
2
+ export declare const getChatVersionFromManifest: (manifest: Manifest | unknown) => string;
3
+ export declare const getChatVersion: () => Promise<string>;
@@ -0,0 +1,10 @@
1
+ export declare const CHAT_MANIFEST_PATH = "https://static.ada.support/chat-manifest.json";
2
+ export interface Manifest {
3
+ versions: {
4
+ hash: string;
5
+ weight: number;
6
+ }[];
7
+ }
8
+ export declare const loadChatManifest: () => Promise<Manifest>;
9
+ export declare const MANIFEST_VALIDATION_ERROR_MESSAGE = "The format of manifest file is incorrect";
10
+ export declare const isManifest: (input: unknown) => input is Manifest;
@@ -0,0 +1,6 @@
1
+ declare type PersistenceKey = ("ada-embed_chat-manifest-cache" | "ada-embed_chat-assigned-version");
2
+ export declare const persistence: {
3
+ get: (item: PersistenceKey) => string;
4
+ set: (item: PersistenceKey, value: string) => void;
5
+ };
6
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.2.18",
3
+ "version": "1.3.2",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",
@@ -11,9 +11,9 @@
11
11
  "build": "TS_NODE_PROJECT=wp.tsconfig.json NODE_ENV=production npx webpack --config webpack.prod.ts",
12
12
  "build:npm-types": "tsc --project tsconfig.npm.json --declaration --outDir dist/npm-entry --emitDeclarationOnly --allowJs false --checkJs false",
13
13
  "build:npm": "./npm-build.sh",
14
- "lint": "tsc --noEmit --strict false && ./node_modules/.bin/eslint --report-unused-disable-directives --ext .js,.jsx,.ts,.tsx . --max-warnings 23",
14
+ "lint": "tsc --noEmit --strict false && ./node_modules/.bin/eslint --report-unused-disable-directives --ext .js,.jsx,.ts,.tsx . --max-warnings 22",
15
15
  "lint:fix": "yarn lint --fix",
16
- "test": "jest",
16
+ "test": "jest --detectOpenHandles",
17
17
  "check-types": "./node_modules/typescript/bin/tsc --project ./tsconfig.json --noEmit --strict false",
18
18
  "check-types-strict": "./node_modules/typescript/bin/tsc --project ./tsconfig.json --noEmit",
19
19
  "tc": "export $(cat .env | xargs) && testcafe",