@ada-support/embed2 1.4.8 → 1.4.11

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.
@@ -15811,7 +15811,7 @@ const client = new error_tracker_BrowserClient({
15811
15811
  },
15812
15812
 
15813
15813
  environment: "production",
15814
- release: "1.4.8-86c6c1d",
15814
+ release: "1.4.11-b2dd6e8",
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
@@ -16432,7 +16432,7 @@ function getEmbedURL(_ref) {
16432
16432
  host = "http://".concat(window.location.hostname, ":9001");
16433
16433
  }
16434
16434
 
16435
- return "".concat(host, "/embed/").concat(frameName, "/").concat("86c6c1d", "/index.html");
16435
+ return "".concat(host, "/embed/").concat(frameName, "/").concat("b2dd6e8", "/index.html");
16436
16436
  }
16437
16437
 
16438
16438
  function constructQueryString(query) {
@@ -17663,7 +17663,7 @@ function readRollout(handle) {
17663
17663
 
17664
17664
  try {
17665
17665
  rollout.group = window.localStorage.getItem("".concat(handle, "_ada_chap_rollout_group"));
17666
- rollout.lastProb = JSON.parse(window.localStorage.getItem("".concat(handle, "_ada_chap_rollout_last_prob")));
17666
+ rollout.lastProb = JSON.parse(window.localStorage.getItem("".concat(handle, "_ada_chap_rollout_last_prob")) || "null");
17667
17667
  return rollout;
17668
17668
  } catch (e) {
17669
17669
  // Failed to read localStorage
@@ -17672,7 +17672,7 @@ function readRollout(handle) {
17672
17672
  }
17673
17673
 
17674
17674
  function checkRollout(rollout, handle) {
17675
- if (typeof rollout === "number" && rollout >= 0 && rollout <= 1) {
17675
+ if (rollout >= 0 && rollout <= 1) {
17676
17676
  // We should first check the storage to see if this user is already grouped
17677
17677
  const rg = readRollout(handle);
17678
17678
  const rand = Math.random();
@@ -17683,8 +17683,7 @@ function checkRollout(rollout, handle) {
17683
17683
  // B is variant (sees chat button)
17684
17684
  const roll = rand <= rollout;
17685
17685
  const group = roll ? "B" : "A";
17686
- const lastProb = rollout;
17687
- storeRollout(handle, group, lastProb);
17686
+ storeRollout(handle, group, rollout);
17688
17687
  return roll;
17689
17688
  }
17690
17689
 
@@ -18247,13 +18246,22 @@ const getChatVersionFromManifest = manifest => {
18247
18246
  persistence.set("ada-embed_chat-manifest-cache", manifestString);
18248
18247
  return hash;
18249
18248
  };
18250
- const getChatVersion = async () => {
18251
- const manifest = await loadChatManifest();
18252
-
18249
+ const getChatVersion = async adaSettings => {
18250
+ // allow versioning using global variable
18253
18251
  if (window.__AdaChatVersion) {
18254
18252
  return window.__AdaChatVersion;
18255
18253
  }
18256
18254
 
18255
+ const {
18256
+ cluster,
18257
+ domain
18258
+ } = adaSettings; // Skip automatic versioning for ATT and dev/stage clusters but allow override through __AdaChatVersion
18259
+
18260
+ if (cluster === "att" || domain !== null && domain !== void 0 && domain.match(/ada-(dev|dev2|stage)/)) {
18261
+ return undefined;
18262
+ }
18263
+
18264
+ const manifest = await loadChatManifest();
18257
18265
  return getChatVersionFromManifest(manifest);
18258
18266
  };
18259
18267
  // EXTERNAL MODULE: ./node_modules/lodash.memoize/index.js
@@ -18299,9 +18307,9 @@ async function log(message, extra, options) {
18299
18307
  service: "embed",
18300
18308
  env: "production",
18301
18309
  embedVersion: 2,
18302
- version: "1.4.8",
18310
+ version: "1.4.11",
18303
18311
  isNpm: true,
18304
- commitHash: "86c6c1d"
18312
+ commitHash: "b2dd6e8"
18305
18313
  }))
18306
18314
  });
18307
18315
  }
@@ -18743,7 +18751,7 @@ class ChatFrame extends d {
18743
18751
  const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
18744
18752
  const smsToken = hostPageUrlParams.get("adaSMSToken");
18745
18753
  const queryParams = {
18746
- embedVersion: "86c6c1d".slice(0, 7),
18754
+ embedVersion: "b2dd6e8".slice(0, 7),
18747
18755
  greeting,
18748
18756
  language,
18749
18757
  skipGreeting,
@@ -19673,15 +19681,8 @@ class Container extends d {
19673
19681
  this.notificationPermHandler();
19674
19682
  bindLocationChangeOverrides();
19675
19683
  addServiceWorkerListeners();
19676
- window.addEventListener("locationchange", this.locationChangeHandlerBound); // Get chat version. Skip for ATT cluster.
19677
-
19678
- const chatVersion = await (async () => {
19679
- if (adaSettings.cluster === "att") {
19680
- return undefined;
19681
- }
19682
-
19683
- return getChatVersion();
19684
- })();
19684
+ window.addEventListener("locationchange", this.locationChangeHandlerBound);
19685
+ const chatVersion = await getChatVersion(adaSettings);
19685
19686
  this.setState({
19686
19687
  chatVersion,
19687
19688
  // We shouldn't try to render chat frame until version is attempted to be retrieved.
@@ -20925,7 +20926,7 @@ class Embed {
20925
20926
 
20926
20927
  }
20927
20928
 
20928
- _defineProperty(Embed, "embed2Version", "86c6c1d");
20929
+ _defineProperty(Embed, "embed2Version", "b2dd6e8");
20929
20930
  ;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
20930
20931
 
20931
20932
 
@@ -1,3 +1,4 @@
1
+ import type { StartOptions } from "@ada-support/embed-types";
1
2
  import type { Manifest } from "./manifest";
2
3
  export declare const getChatVersionFromManifest: (manifest: Manifest | unknown) => string;
3
- export declare const getChatVersion: () => Promise<string>;
4
+ export declare const getChatVersion: (adaSettings: StartOptions) => Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.4.8",
3
+ "version": "1.4.11",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",
@@ -83,7 +83,7 @@
83
83
  "webpack-dev-server": "^4.3.1"
84
84
  },
85
85
  "dependencies": {
86
- "@ada-support/embed-types": "^1.1.1",
86
+ "@ada-support/embed-types": "^1.1.2",
87
87
  "@babel/core": "^7.16.12",
88
88
  "@babel/plugin-proposal-class-properties": "^7.16.7",
89
89
  "@babel/plugin-proposal-numeric-separator": "^7.16.7",