@ada-support/embed2 1.4.10 → 1.4.13

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.10-6742da4",
15814
+ release: "1.4.13-3a3e7fe",
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("6742da4", "/index.html");
16435
+ return "".concat(host, "/embed/").concat(frameName, "/").concat("3a3e7fe", "/index.html");
16436
16436
  }
16437
16437
 
16438
16438
  function constructQueryString(query) {
@@ -18143,12 +18143,71 @@ const persistence = {
18143
18143
  }
18144
18144
  }
18145
18145
  };
18146
+ // EXTERNAL MODULE: ./node_modules/lodash.memoize/index.js
18147
+ var lodash_memoize = __webpack_require__(773);
18148
+ var lodash_memoize_default = /*#__PURE__*/__webpack_require__.n(lodash_memoize);
18149
+ ;// CONCATENATED MODULE: ./src/services/logger/index.ts
18150
+
18151
+
18152
+ function logger_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; }
18153
+
18154
+ function logger_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? logger_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : logger_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18155
+
18156
+
18157
+
18158
+ const DEFAULT_LOG_SAMPLE_RATE = 0.01; // 1% of logs will go through
18159
+
18160
+ const DD_BASE_URL = "https://browser-http-intake.logs.datadoghq.com/v1/input/";
18161
+ const DD_TOKEN = "pubfe23baedd2ea322bebb5ed2020fa2fa1"; // We need memoization to ensure consistency of logs
18162
+
18163
+ const shouldLog = lodash_memoize_default()(sampleRate => {
18164
+ if (!DD_TOKEN || sampleRate === 0) {
18165
+ return false;
18166
+ }
18167
+
18168
+ return Math.random() < (sampleRate || DEFAULT_LOG_SAMPLE_RATE);
18169
+ });
18170
+ /**
18171
+ * Sends log to Datadog
18172
+ */
18173
+
18174
+ async function log(message, extra, options) {
18175
+ if (!shouldLog(options === null || options === void 0 ? void 0 : options.sampleRate)) {
18176
+ return;
18177
+ }
18178
+
18179
+ await httpRequest({
18180
+ url: "".concat(DD_BASE_URL).concat(DD_TOKEN, "?ddsource=browser&ddtags=version:1.5.0,env:").concat("production"),
18181
+ method: "POST",
18182
+ body: JSON.stringify(logger_objectSpread(logger_objectSpread({
18183
+ message
18184
+ }, extra), {}, {
18185
+ sampleRate: (options === null || options === void 0 ? void 0 : options.sampleRate) || DEFAULT_LOG_SAMPLE_RATE,
18186
+ service: "embed",
18187
+ env: "production",
18188
+ embedVersion: 2,
18189
+ version: "1.4.13",
18190
+ isNpm: true,
18191
+ commitHash: "3a3e7fe"
18192
+ }))
18193
+ });
18194
+ }
18146
18195
  ;// CONCATENATED MODULE: ./src/services/chat-versioning/manifest.ts
18147
18196
 
18197
+
18148
18198
  const CHAT_MANIFEST_PATH = "https://static.ada.support/chat-manifest.json";
18149
18199
  const loadChatManifest = async () => {
18150
- const r = await fetch(CHAT_MANIFEST_PATH);
18151
- return r.json();
18200
+ try {
18201
+ const r = await fetch(CHAT_MANIFEST_PATH);
18202
+ return r.json();
18203
+ } catch (e) {
18204
+ // handling cases where r is undefined / other fetch errors
18205
+ // by returning undefined, we tell the server to load the unversioned index.html file for chat
18206
+ log("Failed to load chat manifest", {
18207
+ hostPage: window.location.href
18208
+ });
18209
+ return undefined;
18210
+ }
18152
18211
  }; // Use one message for different errors to reduce the bundle size
18153
18212
 
18154
18213
  const MANIFEST_VALIDATION_ERROR_MESSAGE = "The format of manifest file is incorrect";
@@ -18246,64 +18305,29 @@ const getChatVersionFromManifest = manifest => {
18246
18305
  persistence.set("ada-embed_chat-manifest-cache", manifestString);
18247
18306
  return hash;
18248
18307
  };
18249
- const getChatVersion = async () => {
18250
- const manifest = await loadChatManifest();
18251
-
18308
+ const getChatVersion = async adaSettings => {
18309
+ // allow versioning using global variable
18252
18310
  if (window.__AdaChatVersion) {
18253
18311
  return window.__AdaChatVersion;
18254
18312
  }
18255
18313
 
18256
- return getChatVersionFromManifest(manifest);
18257
- };
18258
- // EXTERNAL MODULE: ./node_modules/lodash.memoize/index.js
18259
- var lodash_memoize = __webpack_require__(773);
18260
- var lodash_memoize_default = /*#__PURE__*/__webpack_require__.n(lodash_memoize);
18261
- ;// CONCATENATED MODULE: ./src/services/logger/index.ts
18262
-
18263
-
18264
- function logger_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; }
18265
-
18266
- function logger_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? logger_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : logger_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18267
-
18268
-
18269
-
18270
- const DEFAULT_LOG_SAMPLE_RATE = 0.01; // 1% of logs will go through
18271
-
18272
- const DD_BASE_URL = "https://browser-http-intake.logs.datadoghq.com/v1/input/";
18273
- const DD_TOKEN = "pubfe23baedd2ea322bebb5ed2020fa2fa1"; // We need memoization to ensure consistency of logs
18314
+ const {
18315
+ cluster,
18316
+ domain
18317
+ } = adaSettings; // Skip automatic versioning for ATT and dev/stage clusters but allow override through __AdaChatVersion
18274
18318
 
18275
- const shouldLog = lodash_memoize_default()(sampleRate => {
18276
- if (!DD_TOKEN || sampleRate === 0) {
18277
- return false;
18319
+ if (cluster === "att" || domain !== null && domain !== void 0 && domain.match(/ada-(dev|dev2|stage)/)) {
18320
+ return undefined;
18278
18321
  }
18279
18322
 
18280
- return Math.random() < (sampleRate || DEFAULT_LOG_SAMPLE_RATE);
18281
- });
18282
- /**
18283
- * Sends log to Datadog
18284
- */
18323
+ const manifest = await loadChatManifest();
18285
18324
 
18286
- async function log(message, extra, options) {
18287
- if (!shouldLog(options === null || options === void 0 ? void 0 : options.sampleRate)) {
18288
- return;
18325
+ if (!manifest) {
18326
+ return undefined;
18289
18327
  }
18290
18328
 
18291
- await httpRequest({
18292
- url: "".concat(DD_BASE_URL).concat(DD_TOKEN, "?ddsource=browser&ddtags=version:1.5.0,env:").concat("production"),
18293
- method: "POST",
18294
- body: JSON.stringify(logger_objectSpread(logger_objectSpread({
18295
- message
18296
- }, extra), {}, {
18297
- sampleRate: (options === null || options === void 0 ? void 0 : options.sampleRate) || DEFAULT_LOG_SAMPLE_RATE,
18298
- service: "embed",
18299
- env: "production",
18300
- embedVersion: 2,
18301
- version: "1.4.10",
18302
- isNpm: true,
18303
- commitHash: "6742da4"
18304
- }))
18305
- });
18306
- }
18329
+ return getChatVersionFromManifest(manifest);
18330
+ };
18307
18331
  // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/url.js
18308
18332
  var url = __webpack_require__(9969);
18309
18333
  var url_default = /*#__PURE__*/__webpack_require__.n(url);
@@ -18742,7 +18766,7 @@ class ChatFrame extends d {
18742
18766
  const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
18743
18767
  const smsToken = hostPageUrlParams.get("adaSMSToken");
18744
18768
  const queryParams = {
18745
- embedVersion: "6742da4".slice(0, 7),
18769
+ embedVersion: "3a3e7fe".slice(0, 7),
18746
18770
  greeting,
18747
18771
  language,
18748
18772
  skipGreeting,
@@ -19672,15 +19696,8 @@ class Container extends d {
19672
19696
  this.notificationPermHandler();
19673
19697
  bindLocationChangeOverrides();
19674
19698
  addServiceWorkerListeners();
19675
- window.addEventListener("locationchange", this.locationChangeHandlerBound); // Get chat version. Skip for ATT cluster.
19676
-
19677
- const chatVersion = await (async () => {
19678
- if (adaSettings.cluster === "att") {
19679
- return undefined;
19680
- }
19681
-
19682
- return getChatVersion();
19683
- })();
19699
+ window.addEventListener("locationchange", this.locationChangeHandlerBound);
19700
+ const chatVersion = await getChatVersion(adaSettings);
19684
19701
  this.setState({
19685
19702
  chatVersion,
19686
19703
  // We shouldn't try to render chat frame until version is attempted to be retrieved.
@@ -20924,7 +20941,7 @@ class Embed {
20924
20941
 
20925
20942
  }
20926
20943
 
20927
- _defineProperty(Embed, "embed2Version", "6742da4");
20944
+ _defineProperty(Embed, "embed2Version", "3a3e7fe");
20928
20945
  ;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
20929
20946
 
20930
20947
 
@@ -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>;
@@ -5,6 +5,6 @@ export interface Manifest {
5
5
  weight: number;
6
6
  }[];
7
7
  }
8
- export declare const loadChatManifest: () => Promise<Manifest>;
8
+ export declare const loadChatManifest: () => Promise<Manifest | undefined>;
9
9
  export declare const MANIFEST_VALIDATION_ERROR_MESSAGE = "The format of manifest file is incorrect";
10
10
  export declare const isManifest: (input: unknown) => input is Manifest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.4.10",
3
+ "version": "1.4.13",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",