@ada-support/embed2 1.0.44 → 1.0.46

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.
@@ -1,4 +1,4 @@
1
- import { AdaEmbedAPI } from "common/types/index";
1
+ import type { AdaEmbedAPI } from "common/types/index";
2
2
  /**
3
3
  * Returns the public Embed methods to be bound to the window object.
4
4
  */
@@ -1,8 +1,8 @@
1
- import { FetchEventStatusType } from "common/constants/events";
2
- import { AdaCustomEvent, Refhandler } from "common/types/events";
3
- import { EvaluateCampaignParams, ResetParams, SendGreetingParams, StoreDispatchPayload, StoreGetPayload, TrackEventParams } from "common/types/index";
4
- import { MetaFieldPayload } from "common/types/store";
5
- import { StoreState } from "common/types/store-state";
1
+ import type { FetchEventStatusType } from "common/constants/events";
2
+ import type { AdaCustomEvent, Refhandler } from "common/types/events";
3
+ import type { EvaluateCampaignParams, ResetParams, SendGreetingParams, StoreDispatchPayload, StoreGetPayload, TrackEventParams } from "common/types/index";
4
+ import type { MetaFieldPayload } from "common/types/store";
5
+ import type { StoreState } from "common/types/store-state";
6
6
  export interface EmbedRequestPayloadByEvent {
7
7
  CREATE_PROACTIVE: {
8
8
  body: string;
@@ -8500,7 +8500,7 @@ var client = new error_tracker_BrowserClient({
8500
8500
  return event;
8501
8501
  },
8502
8502
  environment: "production",
8503
- release: "b4c1ab7de28e3f1320658bfad5883ada73141b44",
8503
+ release: "1.0.46-1f14246",
8504
8504
  sampleRate: 0.25,
8505
8505
  autoSessionTracking: false,
8506
8506
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -8728,7 +8728,12 @@ var Channel = /*#__PURE__*/function () {
8728
8728
 
8729
8729
  _this.postMessage(requestEvent, payload, id);
8730
8730
  }).catch(function (e) {
8731
- // handling promise
8731
+ // We should NOT silently catch errors for "GET_STATE" request event - it is critical for application to work.
8732
+ if (requestEvent === "GET_STATE") {
8733
+ throw new errors/* AdaEmbedError */.S("Failed to respond to \"GET_STATE\" request. Reason: ".concat(e.message, "."));
8734
+ } // handling promise
8735
+
8736
+
8732
8737
  if (e.message !== "Could not connect frame channel.") {
8733
8738
  error_tracker.trackException(e);
8734
8739
  }
@@ -8893,11 +8898,20 @@ var FrameChannel = /*#__PURE__*/function (_Channel) {
8893
8898
  status: status
8894
8899
  });
8895
8900
  } catch (e) {
8896
- var _context2, _context3;
8901
+ var _context3, _context4;
8897
8902
 
8898
8903
  var reason = e instanceof Error ? e.message : "unknown";
8899
8904
  var payloadRootKeys = payload && (0,esm_typeof/* default */.Z)(payload) === "object" ? keys_default()(payload) : [];
8900
- throw new errors/* AdaEmbedError */.S(concat_default()(_context2 = concat_default()(_context3 = "Failed to stringify object to JSON. Reason: \"".concat(reason, "\". Event name: \"")).call(_context3, eventName, "\". Payload root keys: ")).call(_context2, payloadRootKeys.join(", "), "."));
8905
+
8906
+ if (eventName === "DISPATCH" && payload && (0,esm_typeof/* default */.Z)(payload) === "object") {
8907
+ var _context2;
8908
+
8909
+ var p = payload;
8910
+ var dispatchPayloadKeys = p.payload && (0,esm_typeof/* default */.Z)(p.payload) === "object" ? keys_default()(p.payload) : [];
8911
+ throw new errors/* AdaEmbedError */.S(concat_default()(_context2 = "Failed to stringify payload for \"DISPATCH\" event. Reason: \"".concat(reason, "\". Payload keys: ")).call(_context2, dispatchPayloadKeys.join(", "), "."));
8912
+ }
8913
+
8914
+ throw new errors/* AdaEmbedError */.S(concat_default()(_context3 = concat_default()(_context4 = "Failed to stringify object. Reason: \"".concat(reason, "\". Event: \"")).call(_context4, eventName, "\". Payload keys: ")).call(_context3, payloadRootKeys.join(", "), "."));
8901
8915
  }
8902
8916
  }
8903
8917
  }], [{
@@ -9187,7 +9201,7 @@ function getEmbedURL(_ref) {
9187
9201
  polyfillVersionString = "legacy";
9188
9202
  }
9189
9203
 
9190
- return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "b4c1ab7", "/index.html");
9204
+ return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "1f14246", "/index.html");
9191
9205
  }
9192
9206
  /**
9193
9207
  * Generate the Chat / API URL
@@ -12989,9 +13003,6 @@ var Container = /*#__PURE__*/function (_Component) {
12989
13003
  if (!newClient.features.chat_ui_v2) {
12990
13004
  (0,services_logger/* log */.c)("Clients on old UI", {
12991
13005
  clientHandle: newClient.handle
12992
- }, {
12993
- sampleRate: 0.01 // log 1 out of every 100
12994
-
12995
13006
  });
12996
13007
  }
12997
13008
 
@@ -13887,7 +13898,7 @@ window.__AdaEmbedConstructor = Embed;
13887
13898
  /* harmony export */ });
13888
13899
  var isModern = new RegExp("((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(14|(1[5-9]|[2-9]\\d|\\d{3,}))[_.]\\d+(?:[_.]\\d+)?)|((Chromium|Chrome)\\/(92|(9[3-9]|\\d{3,}))\\.\\d+(?:\\.\\d+)?)|(Version\\/(14|(1[5-9]|[2-9]\\d|\\d{3,}))\\.\\d+(?:\\.\\d+)? Safari\\/)|(Firefox\\/(91|(9[2-9]|\\d{3,}))\\.\\d+\\.\\d+)|(Firefox\\/(91|(9[2-9]|\\d{3,}))\\.\\d+(pre|[ab]\\d+[a-z]*)?)").test(navigator.userAgent);
13889
13900
  var isProduction = "production" === "production";
13890
- var embed2Version = "b4c1ab7";
13901
+ var embed2Version = "1f14246";
13891
13902
 
13892
13903
  /***/ }),
13893
13904
 
@@ -14175,12 +14186,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
14175
14186
 
14176
14187
 
14177
14188
 
14178
- var DEFAULT_LOG_SAMPLE_RATE = 0.1;
14189
+ var DEFAULT_LOG_SAMPLE_RATE = 0.01; // 1% of logs will go through
14190
+
14179
14191
  var DD_BASE_URL = "https://browser-http-intake.logs.datadoghq.com/v1/input/";
14180
14192
  var DD_TOKEN = "pubfe23baedd2ea322bebb5ed2020fa2fa1";
14181
14193
 
14182
14194
  var shouldLog = function shouldLog(sampleRate) {
14183
- if (!DD_TOKEN || sampleRate === undefined || sampleRate <= 0) {
14195
+ if (!DD_TOKEN || sampleRate !== undefined && sampleRate <= 0) {
14184
14196
  return false;
14185
14197
  }
14186
14198
 
@@ -14216,7 +14228,12 @@ function _log() {
14216
14228
  body: _babel_runtime_corejs3_core_js_stable_json_stringify__WEBPACK_IMPORTED_MODULE_8___default()(_objectSpread(_objectSpread({
14217
14229
  message: message
14218
14230
  }, extra), {}, {
14219
- env: "production"
14231
+ service: "embed",
14232
+ env: "production",
14233
+ embedVersion: 2,
14234
+ version: "1.0.46",
14235
+ isNpm: true,
14236
+ commitHash: "1f14246"
14220
14237
  }))
14221
14238
  });
14222
14239
 
@@ -23660,8 +23677,8 @@ function _loadEmbed() {
23660
23677
  while (1) {
23661
23678
  switch (_context18.prev = _context18.next) {
23662
23679
  case 0:
23663
- if (adaSettings !== null && adaSettings !== void 0 && adaSettings.customDomains) {
23664
- embedScriptSource = config_info/* isModern */.pX ? adaSettings === null || adaSettings === void 0 ? void 0 : adaSettings.customDomains.embedModern : adaSettings === null || adaSettings === void 0 ? void 0 : adaSettings.customDomains.embedLegacy;
23680
+ if (adaSettings.customDomains) {
23681
+ embedScriptSource = config_info/* isModern */.pX ? adaSettings.customDomains.embedModern : adaSettings.customDomains.embedLegacy;
23665
23682
  } else {
23666
23683
  if (config_info/* isProduction */.yv) {
23667
23684
  host = "https://static.ada.support";
@@ -23671,7 +23688,7 @@ function _loadEmbed() {
23671
23688
  polyfillVersionString = "legacy";
23672
23689
  }
23673
23690
 
23674
- embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "b4c1ab7", "/index.js");
23691
+ embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "1f14246", "/index.js");
23675
23692
  }
23676
23693
 
23677
23694
  clientScriptExists = Boolean( true || // The client script is bundled with npm module
@@ -23776,7 +23793,7 @@ function createEmbedObject() {
23776
23793
  return loadEmbed(adaSettings);
23777
23794
 
23778
23795
  case 5:
23779
- if (!(adaSettings !== null && adaSettings !== void 0 && adaSettings.customDomains && window.__AdaEmbedConstructor && window.__AdaEmbedConstructor.embed2Version !== config_info/* embed2Version */.Mk)) {
23796
+ if (!(adaSettings.customDomains && window.__AdaEmbedConstructor && window.__AdaEmbedConstructor.embed2Version !== config_info/* embed2Version */.Mk)) {
23780
23797
  _context2.next = 7;
23781
23798
  break;
23782
23799
  }
@@ -23796,15 +23813,8 @@ function createEmbedObject() {
23796
23813
  startEmbedResolve();
23797
23814
  (0,logger/* log */.c)("Embed start", {
23798
23815
  handle: adaSettings.handle,
23799
- embedVersion: 2,
23800
23816
  embedSettings: adaSettings,
23801
- version: "1.0.44",
23802
- isNpm: true,
23803
- hostPage: window.location.href,
23804
- commitHash: "b4c1ab7"
23805
- }, {
23806
- sampleRate: 0.01 // 1% of logs will go through
23807
-
23817
+ hostPage: window.location.href
23808
23818
  });
23809
23819
  return _context2.abrupt("return", embed.initialized);
23810
23820
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "build:modern": "NODE_ENV=production BROWSERSLIST_ENV=modern npx webpack --config webpack.prod.ts",
11
11
  "build:npm-types": "tsc --project tsconfig.npm.json --declaration --outDir dist/npm-entry --emitDeclarationOnly --allowJs false --checkJs false",
12
12
  "build:npm": "./npm-build.sh",
13
- "lint": "tsc --noEmit --strict false && ./node_modules/.bin/eslint --report-unused-disable-directives --ext .js,.jsx,.ts,.tsx . --max-warnings 129",
13
+ "lint": "tsc --noEmit --strict false && ./node_modules/.bin/eslint --report-unused-disable-directives --ext .js,.jsx,.ts,.tsx . --max-warnings 109",
14
14
  "lint:fix": "yarn lint --fix",
15
15
  "deploy-legacy": "TS_NODE_PROJECT=wp.tsconfig.json NODE_ENV=production BROWSERSLIST_ENV=legacy npx webpack --config webpack.prod.ts",
16
16
  "deploy-modern": "TS_NODE_PROJECT=wp.tsconfig.json NODE_ENV=production BROWSERSLIST_ENV=modern npx webpack --config webpack.prod.ts",
@@ -120,6 +120,7 @@
120
120
  "webpack-s3-plugin": "^1.2.0-rc.0"
121
121
  },
122
122
  "resolutions": {
123
+ "follow-redirects": ">=1.14.7",
123
124
  "json-schema": ">=0.4.0",
124
125
  "minimist": ">=0.2.1",
125
126
  "node-forge": ">=1.0.0",