@ada-support/embed2 1.0.43 → 1.0.49

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.
@@ -2,7 +2,7 @@ import type { EventSubscriptionCallback } from "client/helpers/event-subscriptio
2
2
  import { MessageService } from "client/lib/message-service";
3
3
  import { StoreProxy } from "client/lib/store-proxy";
4
4
  import "client/lib/error-tracker";
5
- import type Client from "common/models/client";
5
+ import type { Client } from "common/models/client";
6
6
  import type { EvaluateCampaignParams, ResetParams, WindowInfo } from "common/types";
7
7
  import type { MetaFieldPayload } from "common/types/store";
8
8
  import type { StartOptions } from "common/types/store-state";
@@ -1,7 +1,7 @@
1
- import { ClientObject, ClientResponse } from "common/types/http";
2
- export declare function clientMatchesExpectedFormat(client: ClientObject): boolean;
1
+ import type { ClientObject, ClientResponse } from "common/types/http";
2
+ export declare function isClientObject(client: Record<string, unknown>): client is ClientObject;
3
3
  /**
4
4
  * Tries fetching the client from cache. If this fails, tries fetching it from API.
5
5
  * If this also fails, returns null.
6
6
  */
7
- export declare function fetchClient(handle: string, cluster: string, domain: string, language: string): Promise<ClientResponse>;
7
+ export declare function fetchClient(handle: string, cluster: string, domain: string, language: string): Promise<ClientResponse | null>;
@@ -1,5 +1,5 @@
1
- import { CurrentIntro, Intro } from "common/types/http";
1
+ import type { CurrentIntro, Intro } from "common/types/http";
2
2
  export declare function getProcessedPath(path: string): string;
3
3
  export declare function getPathSearchRegex(path: string): RegExp;
4
4
  export declare function doesUrlMatchPath(url: string, path: string): boolean;
5
- export declare function getIntroForCurrentUrl(intros: Intro[], language: string): CurrentIntro | null;
5
+ export declare function getIntroForCurrentUrl(intros: Intro[], language: string): CurrentIntro | undefined;
@@ -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;
@@ -15,7 +15,6 @@ export declare class FrameChannel extends Channel {
15
15
  name: string;
16
16
  targetWindow: Window;
17
17
  targetOrigin: string;
18
- eventTarget: Window;
19
18
  isConnected: boolean;
20
19
  constructor(name: string, targetWindow: Window, targetOrigin?: string);
21
20
  private static isMessageEvent;
@@ -1,14 +1,14 @@
1
- import { BusinessEvent } from "businessEvents/types";
2
- import { ChatButton, ClientResponse, CurrentIntro, Features } from "common/types/http";
3
- import { LanguageMap } from "common/types/languages";
4
- import { MarketingCampaign } from "src/campaigns/types";
5
- export default class Client {
1
+ import type { BusinessEvent } from "businessEvents/types";
2
+ import type { ChatButton, ClientResponse, CurrentIntro, Features } from "common/types/http";
3
+ import type { LanguageKey, LanguageMap } from "common/types/languages";
4
+ import type { MarketingCampaign } from "src/campaigns/types";
5
+ export declare class Client {
6
6
  tint: string;
7
7
  chat: boolean;
8
8
  intro?: CurrentIntro;
9
9
  handle: string;
10
10
  rollout: number;
11
- language: keyof LanguageMap;
11
+ language: LanguageKey;
12
12
  privacy: boolean;
13
13
  features: Features;
14
14
  persistence: string;
@@ -1,4 +1,5 @@
1
- import { BusinessEvent } from "businessEvents/types";
1
+ import type { BusinessEvent } from "businessEvents/types";
2
+ import type { LanguageKey } from "common/types/languages";
2
3
  export interface ChatButton {
3
4
  size: number;
4
5
  background_color: string;
@@ -43,20 +44,21 @@ export interface ClientObject {
43
44
  rollout: number;
44
45
  chat: boolean;
45
46
  persistence: string;
46
- language: string;
47
+ language: LanguageKey;
47
48
  privacy: boolean;
48
49
  tint: string;
49
50
  chat_button: ChatButton | null;
50
51
  intro?: CurrentIntro;
51
52
  features: Features;
52
53
  marketing_campaigns_order?: string[];
54
+ [key: string]: unknown;
53
55
  }
54
56
  export interface CachedClientObject {
55
57
  handle: string;
56
58
  rollout: number;
57
59
  chat: boolean;
58
60
  persistence: string;
59
- language: string;
61
+ language: LanguageKey;
60
62
  privacy: boolean;
61
63
  tint: string;
62
64
  chat_button: ChatButton | null;
@@ -64,6 +66,7 @@ export interface CachedClientObject {
64
66
  features: Features;
65
67
  business_events?: BusinessEvent[];
66
68
  marketing_campaigns_order?: string[];
69
+ [key: string]: unknown;
67
70
  }
68
71
  export interface ClientResponse {
69
72
  client: ClientObject;
@@ -1,5 +1,4 @@
1
- declare type LanguageKeys = "en" | "da" | "de" | "es" | "fi" | "fr" | "hi" | "ht" | "id" | "it" | "ja" | "km" | "ko" | "ms" | "my" | "no" | "nl" | "pa" | "pt" | "ru" | "sv" | "ta" | "th" | "tl" | "tr" | "vi" | "zh" | "zh-tw" | "bg" | "ro" | "el" | "hu" | "pl" | "cs" | "et" | "hr" | "lt" | "lv" | "sl" | "sk" | "is" | "ar" | "he";
1
+ export declare type LanguageKey = "en" | "da" | "de" | "es" | "fi" | "fr" | "hi" | "ht" | "id" | "it" | "ja" | "km" | "ko" | "ms" | "my" | "no" | "nl" | "pa" | "pt" | "ru" | "sv" | "ta" | "th" | "tl" | "tr" | "vi" | "zh" | "zh-tw" | "bg" | "ro" | "el" | "hu" | "pl" | "cs" | "et" | "hr" | "lt" | "lv" | "sl" | "sk" | "is" | "ar" | "he";
2
2
  export declare type LanguageMap = {
3
- [K in LanguageKeys]?: string;
3
+ [K in LanguageKey]?: string;
4
4
  };
5
- export {};
@@ -1,5 +1,5 @@
1
1
  import type { ConnectionState } from "common/constants/events";
2
- import type Client from "common/models/client";
2
+ import type { Client } from "common/models/client";
3
3
  import type { ChatterEventPayload } from "common/types/events";
4
4
  export interface StartOptions {
5
5
  handle?: string;
@@ -1,5 +1,5 @@
1
- import Client from "common/models/client";
2
- import { StorageKey, StorageValueByKey } from "frames/lib/safe-storage";
1
+ import type { Client } from "common/models/client";
2
+ import type { StorageKey, StorageValueByKey } from "frames/lib/safe-storage";
3
3
  export declare const PERSISTENCE_NORMAL = "normal";
4
4
  export declare const PERSISTENCE_SESSION = "session";
5
5
  /**
@@ -190,6 +190,13 @@ module.exports = __webpack_require__(3685);
190
190
 
191
191
  /***/ }),
192
192
 
193
+ /***/ 3263:
194
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
195
+
196
+ module.exports = __webpack_require__(4710);
197
+
198
+ /***/ }),
199
+
193
200
  /***/ 4889:
194
201
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
195
202
 
@@ -197,6 +204,13 @@ module.exports = __webpack_require__(4303);
197
204
 
198
205
  /***/ }),
199
206
 
207
+ /***/ 9356:
208
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
209
+
210
+ module.exports = __webpack_require__(3799);
211
+
212
+ /***/ }),
213
+
200
214
  /***/ 9542:
201
215
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
202
216
 
@@ -722,7 +736,7 @@ var browserPerformanceTimeOrigin = (function () {
722
736
 
723
737
  /***/ }),
724
738
 
725
- /***/ 7054:
739
+ /***/ 9136:
726
740
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
727
741
 
728
742
  "use strict";
@@ -8500,7 +8514,7 @@ var client = new error_tracker_BrowserClient({
8500
8514
  return event;
8501
8515
  },
8502
8516
  environment: "production",
8503
- release: "5094d37a41a17d892252465cfc3fc353b6f1da1d",
8517
+ release: "1.0.49-4562505",
8504
8518
  sampleRate: 0.25,
8505
8519
  autoSessionTracking: false,
8506
8520
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -8728,7 +8742,12 @@ var Channel = /*#__PURE__*/function () {
8728
8742
 
8729
8743
  _this.postMessage(requestEvent, payload, id);
8730
8744
  }).catch(function (e) {
8731
- // handling promise
8745
+ // We should NOT silently catch errors for "GET_STATE" request event - it is critical for application to work.
8746
+ if (requestEvent === "GET_STATE") {
8747
+ throw new errors/* AdaEmbedError */.S("Failed to respond to \"GET_STATE\" request. Reason: \"".concat(e.message, "\"."));
8748
+ } // handling promise
8749
+
8750
+
8732
8751
  if (e.message !== "Could not connect frame channel.") {
8733
8752
  error_tracker.trackException(e);
8734
8753
  }
@@ -8820,8 +8839,6 @@ var FrameChannel = /*#__PURE__*/function (_Channel) {
8820
8839
 
8821
8840
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "targetOrigin", void 0);
8822
8841
 
8823
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "eventTarget", void 0);
8824
-
8825
8842
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "isConnected", false);
8826
8843
 
8827
8844
  _this.name = name;
@@ -8893,11 +8910,20 @@ var FrameChannel = /*#__PURE__*/function (_Channel) {
8893
8910
  status: status
8894
8911
  });
8895
8912
  } catch (e) {
8896
- var _context2, _context3;
8913
+ var _context4, _context5;
8897
8914
 
8898
8915
  var reason = e instanceof Error ? e.message : "unknown";
8899
8916
  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(", "), "."));
8917
+
8918
+ if (eventName === "DISPATCH" && payload && (0,esm_typeof/* default */.Z)(payload) === "object") {
8919
+ var _context2, _context3;
8920
+
8921
+ var p = payload;
8922
+ var dispatchPayloadKeys = p.payload && (0,esm_typeof/* default */.Z)(p.payload) === "object" ? keys_default()(p.payload) : [];
8923
+ throw new errors/* AdaEmbedError */.S(concat_default()(_context2 = concat_default()(_context3 = "Failed to stringify payload for \"DISPATCH\" event. Reason: \"".concat(reason, "\". Action: \"")).call(_context3, p.actionKey, "\". Payload keys: ")).call(_context2, dispatchPayloadKeys.join(", "), "."));
8924
+ }
8925
+
8926
+ throw new errors/* AdaEmbedError */.S(concat_default()(_context4 = concat_default()(_context5 = "Failed to stringify object. Reason: \"".concat(reason, "\". Event: \"")).call(_context5, eventName, "\". Payload keys: ")).call(_context4, payloadRootKeys.join(", "), "."));
8901
8927
  }
8902
8928
  }
8903
8929
  }], [{
@@ -9187,7 +9213,7 @@ function getEmbedURL(_ref) {
9187
9213
  polyfillVersionString = "legacy";
9188
9214
  }
9189
9215
 
9190
- return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "5094d37", "/index.html");
9216
+ return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "4562505", "/index.html");
9191
9217
  }
9192
9218
  /**
9193
9219
  * Generate the Chat / API URL
@@ -10030,8 +10056,6 @@ var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
10030
10056
 
10031
10057
 
10032
10058
 
10033
- var INTRO_STYLE_EMOJI = "Emoji";
10034
- var INTRO_STYLE_TEXT = "Text";
10035
10059
  function getProcessedPath(path) {
10036
10060
  var regex = new RegExp("^http(s)?://(www.)?");
10037
10061
  return trim_default()(path).call(path).replace(regex, "");
@@ -10081,20 +10105,10 @@ function getIntroForCurrentUrl(intros, language) {
10081
10105
  var matchingIntro = findMatchingIntro(intros);
10082
10106
 
10083
10107
  if (!matchingIntro) {
10084
- return null;
10085
- }
10086
-
10087
- if (matchingIntro.style === INTRO_STYLE_TEXT) {
10088
- return {
10089
- response_id: matchingIntro.response_id,
10090
- body: matchingIntro.body.message_text[language],
10091
- style: matchingIntro.style,
10092
- delay: matchingIntro.delay,
10093
- duration: matchingIntro.duration
10094
- };
10108
+ return undefined;
10095
10109
  }
10096
10110
 
10097
- if (matchingIntro.style === INTRO_STYLE_EMOJI) {
10111
+ if (matchingIntro.style === "Emoji") {
10098
10112
  return {
10099
10113
  response_id: matchingIntro.response_id,
10100
10114
  body: matchingIntro.body.emoji_link,
@@ -10102,9 +10116,16 @@ function getIntroForCurrentUrl(intros, language) {
10102
10116
  delay: matchingIntro.delay,
10103
10117
  duration: matchingIntro.duration
10104
10118
  };
10105
- }
10119
+ } // Default - "Text" style
10106
10120
 
10107
- return null;
10121
+
10122
+ return {
10123
+ response_id: matchingIntro.response_id,
10124
+ body: matchingIntro.body.message_text[language],
10125
+ style: matchingIntro.style,
10126
+ delay: matchingIntro.delay,
10127
+ duration: matchingIntro.duration
10128
+ };
10108
10129
  }
10109
10130
  ;// CONCATENATED MODULE: ./src/campaigns/TriggerConditionEvaluator.ts
10110
10131
 
@@ -10674,7 +10695,7 @@ function fetch_client_objectSpread(target) { for (var i = 1; i < arguments.lengt
10674
10695
 
10675
10696
 
10676
10697
 
10677
- function clientMatchesExpectedFormat(client) {
10698
+ function isClientObject(client) {
10678
10699
  // We require the following properties defined
10679
10700
  return ["handle", "rollout", "chat", "features"].every(function (key) {
10680
10701
  return client[key] !== undefined;
@@ -10705,14 +10726,14 @@ function _fetchClient() {
10705
10726
  case 3:
10706
10727
  cachedClient = _context.sent;
10707
10728
 
10708
- if (!(cachedClient && clientMatchesExpectedFormat(cachedClient))) {
10729
+ if (!(cachedClient && isClientObject(cachedClient))) {
10709
10730
  _context.next = 6;
10710
10731
  break;
10711
10732
  }
10712
10733
 
10713
10734
  return _context.abrupt("return", {
10714
10735
  client: fetch_client_objectSpread({
10715
- intro: getIntroForCurrentUrl(cachedClient.intros, language || cachedClient.language)
10736
+ intro: getIntroForCurrentUrl(cachedClient.intros || [], language || cachedClient.language)
10716
10737
  }, cachedClient)
10717
10738
  });
10718
10739
 
@@ -10793,6 +10814,53 @@ function wait(ms) {
10793
10814
  return setTimeout(resolve, ms);
10794
10815
  });
10795
10816
  }
10817
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js/object/get-own-property-symbols.js
10818
+ var object_get_own_property_symbols = __webpack_require__(3263);
10819
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js/instance/index-of.js
10820
+ var index_of = __webpack_require__(5683);
10821
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js/object/keys.js
10822
+ var keys = __webpack_require__(9356);
10823
+ ;// CONCATENATED MODULE: ./node_modules/@babel/runtime-corejs3/helpers/esm/objectWithoutPropertiesLoose.js
10824
+
10825
+
10826
+ function _objectWithoutPropertiesLoose(source, excluded) {
10827
+ if (source == null) return {};
10828
+ var target = {};
10829
+
10830
+ var sourceKeys = keys(source);
10831
+
10832
+ var key, i;
10833
+
10834
+ for (i = 0; i < sourceKeys.length; i++) {
10835
+ key = sourceKeys[i];
10836
+ if (index_of(excluded).call(excluded, key) >= 0) continue;
10837
+ target[key] = source[key];
10838
+ }
10839
+
10840
+ return target;
10841
+ }
10842
+ ;// CONCATENATED MODULE: ./node_modules/@babel/runtime-corejs3/helpers/esm/objectWithoutProperties.js
10843
+
10844
+
10845
+
10846
+ function _objectWithoutProperties(source, excluded) {
10847
+ if (source == null) return {};
10848
+ var target = _objectWithoutPropertiesLoose(source, excluded);
10849
+ var key, i;
10850
+
10851
+ if (object_get_own_property_symbols) {
10852
+ var sourceSymbolKeys = object_get_own_property_symbols(source);
10853
+
10854
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
10855
+ key = sourceSymbolKeys[i];
10856
+ if (index_of(excluded).call(excluded, key) >= 0) continue;
10857
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
10858
+ target[key] = source[key];
10859
+ }
10860
+ }
10861
+
10862
+ return target;
10863
+ }
10796
10864
  // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/object/assign.js
10797
10865
  var core_js_stable_object_assign = __webpack_require__(1942);
10798
10866
  var object_assign_default = /*#__PURE__*/__webpack_require__.n(core_js_stable_object_assign);
@@ -10800,6 +10868,7 @@ var object_assign_default = /*#__PURE__*/__webpack_require__.n(core_js_stable_ob
10800
10868
 
10801
10869
 
10802
10870
 
10871
+ var _excluded = ["chat", "chat_button", "features", "handle", "language", "persistence", "privacy", "rollout", "tint"];
10803
10872
 
10804
10873
  var Client = function Client(clientResponse) {
10805
10874
  (0,classCallCheck/* default */.Z)(this, Client);
@@ -10832,15 +10901,34 @@ var Client = function Client(clientResponse) {
10832
10901
 
10833
10902
  (0,defineProperty/* default */.Z)(this, "ui_settings", void 0);
10834
10903
 
10904
+ var chat = clientResponse.chat,
10905
+ chatButton = clientResponse.chat_button,
10906
+ features = clientResponse.features,
10907
+ handle = clientResponse.handle,
10908
+ language = clientResponse.language,
10909
+ persistence = clientResponse.persistence,
10910
+ privacy = clientResponse.privacy,
10911
+ rollout = clientResponse.rollout,
10912
+ tint = clientResponse.tint,
10913
+ rest = _objectWithoutProperties(clientResponse, _excluded);
10914
+
10915
+ this.chat = chat;
10916
+ this.chat_button = chatButton;
10917
+ this.features = features;
10918
+ this.handle = handle;
10919
+ this.language = language;
10920
+ this.persistence = persistence;
10921
+ this.privacy = privacy;
10922
+ this.rollout = rollout;
10923
+ this.tint = tint;
10835
10924
  /**
10836
10925
  * Even if some properties are not used by Embed2, they may be used by Chat.
10837
10926
  * Chat can "pull" the client object from Embed2 in order to reduce an API
10838
10927
  * request. Embed2 should thus not modify keys.
10839
10928
  */
10840
- object_assign_default()(this, clientResponse);
10841
- };
10842
-
10843
10929
 
10930
+ object_assign_default()(this, rest);
10931
+ };
10844
10932
  function hasCampaignsEnabled(client) {
10845
10933
  return (client === null || client === void 0 ? void 0 : client.features.afm_proactive_messaging) || (client === null || client === void 0 ? void 0 : client.features.afm_proactive_messaging_free_tier);
10846
10934
  }
@@ -12658,7 +12746,7 @@ var Container = /*#__PURE__*/function (_Component) {
12658
12746
 
12659
12747
  case 6:
12660
12748
  _context3.t0 = type;
12661
- _context3.next = _context3.t0 === TRACK_EVENT ? 9 : _context3.t0 === TRIGGER_CAMPAIGN ? 14 : _context3.t0 === EVAL_CAMPAIGN_CONDITIONS ? 19 : _context3.t0 === TOGGLE ? 24 : _context3.t0 === GET_INFO ? 29 : _context3.t0 === SET_META_FIELDS ? 33 : _context3.t0 === "SET_SENSITIVE_META_FIELDS" ? 40 : _context3.t0 === STOP ? 45 : _context3.t0 === RESET ? 48 : _context3.t0 === DELETE_HISTORY ? 66 : _context3.t0 === CREATE_PROACTIVE ? 78 : 89;
12749
+ _context3.next = _context3.t0 === TRACK_EVENT ? 9 : _context3.t0 === TRIGGER_CAMPAIGN ? 14 : _context3.t0 === EVAL_CAMPAIGN_CONDITIONS ? 19 : _context3.t0 === TOGGLE ? 24 : _context3.t0 === GET_INFO ? 29 : _context3.t0 === SET_META_FIELDS ? 33 : _context3.t0 === "SET_SENSITIVE_META_FIELDS" ? 40 : _context3.t0 === STOP ? 45 : _context3.t0 === RESET ? 48 : _context3.t0 === DELETE_HISTORY ? 66 : _context3.t0 === CREATE_PROACTIVE ? 78 : 91;
12662
12750
  break;
12663
12751
 
12664
12752
  case 9:
@@ -12672,7 +12760,7 @@ var Container = /*#__PURE__*/function (_Component) {
12672
12760
 
12673
12761
  case 12:
12674
12762
  this.trackEvent(payload);
12675
- return _context3.abrupt("break", 89);
12763
+ return _context3.abrupt("break", 91);
12676
12764
 
12677
12765
  case 14:
12678
12766
  if (client.features.afm_proactive_messaging) {
@@ -12685,7 +12773,7 @@ var Container = /*#__PURE__*/function (_Component) {
12685
12773
 
12686
12774
  case 17:
12687
12775
  this.triggerCampaign(payload);
12688
- return _context3.abrupt("break", 89);
12776
+ return _context3.abrupt("break", 91);
12689
12777
 
12690
12778
  case 19:
12691
12779
  if (client.features.afm_proactive_messaging) {
@@ -12698,7 +12786,7 @@ var Container = /*#__PURE__*/function (_Component) {
12698
12786
 
12699
12787
  case 22:
12700
12788
  this.evaluateCampaignConditions(payload);
12701
- return _context3.abrupt("break", 89);
12789
+ return _context3.abrupt("break", 91);
12702
12790
 
12703
12791
  case 24:
12704
12792
  toggleChat = this.props.toggleChat;
@@ -12707,7 +12795,7 @@ var Container = /*#__PURE__*/function (_Component) {
12707
12795
 
12708
12796
  case 27:
12709
12797
  localChannel.postMessage(TOGGLE_RESPONSE, null, id);
12710
- return _context3.abrupt("break", 89);
12798
+ return _context3.abrupt("break", 91);
12711
12799
 
12712
12800
  case 29:
12713
12801
  _this$props10 = this.props, isDrawerOpen = _this$props10.isDrawerOpen, drawerHasBeenOpened = _this$props10.drawerHasBeenOpened, chatterToken = _this$props10.chatterToken;
@@ -12718,7 +12806,7 @@ var Container = /*#__PURE__*/function (_Component) {
12718
12806
  hasClosedChat: drawerHasBeenOpened && !isDrawerOpen
12719
12807
  };
12720
12808
  localChannel.postMessage(GET_INFO_RESPONSE, contentToReturn, id);
12721
- return _context3.abrupt("break", 89);
12809
+ return _context3.abrupt("break", 91);
12722
12810
 
12723
12811
  case 33:
12724
12812
  _this$props11 = this.props, metaFields = _this$props11.metaFields, setState = _this$props11.setState;
@@ -12731,7 +12819,7 @@ var Container = /*#__PURE__*/function (_Component) {
12731
12819
 
12732
12820
  case 38:
12733
12821
  localChannel.postMessage(SET_META_FIELDS_RESPONSE, null, id);
12734
- return _context3.abrupt("break", 89);
12822
+ return _context3.abrupt("break", 91);
12735
12823
 
12736
12824
  case 40:
12737
12825
  _this$props12 = this.props, sensitiveMetaFields = _this$props12.sensitiveMetaFields, _setState = _this$props12.setState;
@@ -12742,12 +12830,12 @@ var Container = /*#__PURE__*/function (_Component) {
12742
12830
 
12743
12831
  case 43:
12744
12832
  localChannel.postMessage("SET_SENSITIVE_META_FIELDS_RESPONSE", null, id);
12745
- return _context3.abrupt("break", 89);
12833
+ return _context3.abrupt("break", 91);
12746
12834
 
12747
12835
  case 45:
12748
12836
  localChannel.postMessage(STOP_RESPONSE, null, id);
12749
12837
  this.unmount();
12750
- return _context3.abrupt("break", 89);
12838
+ return _context3.abrupt("break", 91);
12751
12839
 
12752
12840
  case 48:
12753
12841
  _ref = payload, greeting = _ref.greeting, language = _ref.language, _newMetaFields = _ref.metaFields, _sensitiveMetaFields = _ref.sensitiveMetaFields, _ref$resetChatHistory = _ref.resetChatHistory, resetChatHistory = _ref$resetChatHistory === void 0 ? true : _ref$resetChatHistory;
@@ -12801,7 +12889,7 @@ var Container = /*#__PURE__*/function (_Component) {
12801
12889
  }
12802
12890
 
12803
12891
  localChannel.postMessage(RESET_RESPONSE, null, id);
12804
- return _context3.abrupt("break", 89);
12892
+ return _context3.abrupt("break", 91);
12805
12893
 
12806
12894
  case 66:
12807
12895
  _setState3 = this.props.setState;
@@ -12829,23 +12917,32 @@ var Container = /*#__PURE__*/function (_Component) {
12829
12917
  case 75:
12830
12918
  xStorageChannel.postMessage(DELETE_HISTORY_EVENT);
12831
12919
  localChannel.postMessage(DELETE_HISTORY_RESPONSE, null, id);
12832
- return _context3.abrupt("break", 89);
12920
+ return _context3.abrupt("break", 91);
12833
12921
 
12834
12922
  case 78:
12835
12923
  _ref2 = payload, body = _ref2.body, duration = _ref2.duration;
12836
- EXTRA_PROACTIVE_DELAY = 1000; // Free tier campaigns re-use the createProactive infrastructure
12924
+ EXTRA_PROACTIVE_DELAY = 1000;
12925
+
12926
+ if (client) {
12927
+ _context3.next = 82;
12928
+ break;
12929
+ }
12930
+
12931
+ throw new errors/* AdaEmbedError */.S("`client` is not defined");
12837
12932
 
12933
+ case 82:
12934
+ // Free tier campaigns re-use the createProactive infrastructure
12838
12935
  canCreateProactive = client.features.developer_proactive || client.features.afm_proactive_messaging_free_tier;
12839
12936
 
12840
12937
  if (canCreateProactive) {
12841
- _context3.next = 84;
12938
+ _context3.next = 86;
12842
12939
  break;
12843
12940
  }
12844
12941
 
12845
12942
  localChannel.postMessage(CREATE_PROACTIVE_RESPONSE, "Ada Embed - Proactive intros are not available in your feature set.", id, FetchEventStatus.Failure);
12846
12943
  return _context3.abrupt("return");
12847
12944
 
12848
- case 84:
12945
+ case 86:
12849
12946
  this.setState({
12850
12947
  hideIntroOverride: true
12851
12948
  }, /*#__PURE__*/(0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee() {
@@ -12883,14 +12980,14 @@ var Container = /*#__PURE__*/function (_Component) {
12883
12980
  }
12884
12981
  }, _callee);
12885
12982
  })));
12886
- _context3.next = 87;
12983
+ _context3.next = 89;
12887
12984
  return wait(duration * 1000 + EXTRA_PROACTIVE_DELAY);
12888
12985
 
12889
- case 87:
12986
+ case 89:
12890
12987
  localChannel.postMessage(CREATE_PROACTIVE_RESPONSE, null, id);
12891
- return _context3.abrupt("break", 89);
12988
+ return _context3.abrupt("break", 91);
12892
12989
 
12893
- case 89:
12990
+ case 91:
12894
12991
  case "end":
12895
12992
  return _context3.stop();
12896
12993
  }
@@ -12989,9 +13086,6 @@ var Container = /*#__PURE__*/function (_Component) {
12989
13086
  if (!newClient.features.chat_ui_v2) {
12990
13087
  (0,services_logger/* log */.c)("Clients on old UI", {
12991
13088
  clientHandle: newClient.handle
12992
- }, {
12993
- sampleRate: 0.01 // log 1 out of every 100
12994
-
12995
13089
  });
12996
13090
  }
12997
13091
 
@@ -13188,15 +13282,15 @@ var Container = /*#__PURE__*/function (_Component) {
13188
13282
  }, {
13189
13283
  key: "renderIntroFrame",
13190
13284
  value: function renderIntroFrame() {
13191
- var _intro$style;
13285
+ var _client$intro;
13192
13286
 
13193
13287
  var _this$props15 = this.props,
13194
13288
  adaSettings = _this$props15.adaSettings,
13195
- intro = _this$props15.intro;
13289
+ client = _this$props15.client;
13196
13290
  var parentElement = adaSettings.parentElement;
13197
13291
  var hideIntroOverride = this.state.hideIntroOverride;
13198
13292
 
13199
- if (parentElement || (intro === null || intro === void 0 ? void 0 : (_intro$style = intro.style) === null || _intro$style === void 0 ? void 0 : _intro$style.toLocaleLowerCase()) !== "text" || hideIntroOverride || // This avoids intros and campaigns being shown at the same time
13293
+ if (parentElement || (client === null || client === void 0 ? void 0 : (_client$intro = client.intro) === null || _client$intro === void 0 ? void 0 : _client$intro.style.toLocaleLowerCase()) !== "text" || hideIntroOverride || // This avoids intros and campaigns being shown at the same time
13200
13294
  this.shouldRenderChatFrame) {
13201
13295
  return null;
13202
13296
  }
@@ -13317,7 +13411,6 @@ function Container_mapStateToProps(storeState) {
13317
13411
  isChatWebsocketConnected: isChatWebsocketConnected,
13318
13412
  isDrawerOpen: isDrawerOpen,
13319
13413
  chatterToken: chatterToken,
13320
- intro: client === null || client === void 0 ? void 0 : client.intro,
13321
13414
  appConnectionState: appConnectionState,
13322
13415
  drawerHasBeenOpened: drawerHasBeenOpened,
13323
13416
  chatterInLiveChat: chatterInLiveChat,
@@ -13887,7 +13980,7 @@ window.__AdaEmbedConstructor = Embed;
13887
13980
  /* harmony export */ });
13888
13981
  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
13982
  var isProduction = "production" === "production";
13890
- var embed2Version = "5094d37";
13983
+ var embed2Version = "4562505";
13891
13984
 
13892
13985
  /***/ }),
13893
13986
 
@@ -14175,12 +14268,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
14175
14268
 
14176
14269
 
14177
14270
 
14178
- var DEFAULT_LOG_SAMPLE_RATE = 0.1;
14271
+ var DEFAULT_LOG_SAMPLE_RATE = 0.01; // 1% of logs will go through
14272
+
14179
14273
  var DD_BASE_URL = "https://browser-http-intake.logs.datadoghq.com/v1/input/";
14180
14274
  var DD_TOKEN = "pubfe23baedd2ea322bebb5ed2020fa2fa1";
14181
14275
 
14182
14276
  var shouldLog = function shouldLog(sampleRate) {
14183
- if (!DD_TOKEN || sampleRate === undefined || sampleRate <= 0) {
14277
+ if (!DD_TOKEN || sampleRate !== undefined && sampleRate <= 0) {
14184
14278
  return false;
14185
14279
  }
14186
14280
 
@@ -14216,7 +14310,12 @@ function _log() {
14216
14310
  body: _babel_runtime_corejs3_core_js_stable_json_stringify__WEBPACK_IMPORTED_MODULE_8___default()(_objectSpread(_objectSpread({
14217
14311
  message: message
14218
14312
  }, extra), {}, {
14219
- env: "production"
14313
+ service: "embed",
14314
+ env: "production",
14315
+ embedVersion: 2,
14316
+ version: "1.0.49",
14317
+ isNpm: true,
14318
+ commitHash: "4562505"
14220
14319
  }))
14221
14320
  });
14222
14321
 
@@ -14898,6 +14997,16 @@ var parent = __webpack_require__(1910);
14898
14997
  module.exports = parent;
14899
14998
 
14900
14999
 
15000
+ /***/ }),
15001
+
15002
+ /***/ 4710:
15003
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
15004
+
15005
+ var parent = __webpack_require__(9534);
15006
+
15007
+ module.exports = parent;
15008
+
15009
+
14901
15010
  /***/ }),
14902
15011
 
14903
15012
  /***/ 4303:
@@ -14908,6 +15017,16 @@ var parent = __webpack_require__(6507);
14908
15017
  module.exports = parent;
14909
15018
 
14910
15019
 
15020
+ /***/ }),
15021
+
15022
+ /***/ 3799:
15023
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
15024
+
15025
+ var parent = __webpack_require__(3059);
15026
+
15027
+ module.exports = parent;
15028
+
15029
+
14911
15030
  /***/ }),
14912
15031
 
14913
15032
  /***/ 5122:
@@ -23660,8 +23779,8 @@ function _loadEmbed() {
23660
23779
  while (1) {
23661
23780
  switch (_context18.prev = _context18.next) {
23662
23781
  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;
23782
+ if (adaSettings.customDomains) {
23783
+ embedScriptSource = config_info/* isModern */.pX ? adaSettings.customDomains.embedModern : adaSettings.customDomains.embedLegacy;
23665
23784
  } else {
23666
23785
  if (config_info/* isProduction */.yv) {
23667
23786
  host = "https://static.ada.support";
@@ -23671,7 +23790,7 @@ function _loadEmbed() {
23671
23790
  polyfillVersionString = "legacy";
23672
23791
  }
23673
23792
 
23674
- embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "5094d37", "/index.js");
23793
+ embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "4562505", "/index.js");
23675
23794
  }
23676
23795
 
23677
23796
  clientScriptExists = Boolean( true || // The client script is bundled with npm module
@@ -23776,7 +23895,7 @@ function createEmbedObject() {
23776
23895
  return loadEmbed(adaSettings);
23777
23896
 
23778
23897
  case 5:
23779
- if (!(adaSettings !== null && adaSettings !== void 0 && adaSettings.customDomains && window.__AdaEmbedConstructor && window.__AdaEmbedConstructor.embed2Version !== config_info/* embed2Version */.Mk)) {
23898
+ if (!(adaSettings.customDomains && window.__AdaEmbedConstructor && window.__AdaEmbedConstructor.embed2Version !== config_info/* embed2Version */.Mk)) {
23780
23899
  _context2.next = 7;
23781
23900
  break;
23782
23901
  }
@@ -23796,15 +23915,8 @@ function createEmbedObject() {
23796
23915
  startEmbedResolve();
23797
23916
  (0,logger/* log */.c)("Embed start", {
23798
23917
  handle: adaSettings.handle,
23799
- embedVersion: 2,
23800
23918
  embedSettings: adaSettings,
23801
- version: "1.0.43",
23802
- isNpm: true,
23803
- hostPage: window.location.href,
23804
- commitHash: "5094d37"
23805
- }, {
23806
- sampleRate: 0.01 // 1% of logs will go through
23807
-
23919
+ hostPage: window.location.href
23808
23920
  });
23809
23921
  return _context2.abrupt("return", embed.initialized);
23810
23922
 
@@ -24216,7 +24328,7 @@ function createEmbedObject() {
24216
24328
  }
24217
24329
  ;// CONCATENATED MODULE: ./src/index-npm.ts
24218
24330
 
24219
- Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 7054));
24331
+ Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 9136));
24220
24332
  /* harmony default export */ var index_npm = (createEmbedObject());
24221
24333
  }();
24222
24334
  module.exports = __webpack_exports__;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.0.43",
3
+ "version": "1.0.49",
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 86",
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",
@@ -68,7 +68,7 @@
68
68
  "@types/node": "^16.7.1",
69
69
  "@types/webpack": "^5.28.0",
70
70
  "@types/webpack-bundle-analyzer": "^4.4.1",
71
- "@types/webpack-dev-server": "^4.0.0",
71
+ "@types/webpack-dev-server": "^4.7.2",
72
72
  "babel-loader": "^8.0.6",
73
73
  "babel-preset-preact": "^2.0.0",
74
74
  "browserslist": "^4.17.4",
@@ -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",
@@ -1,12 +0,0 @@
1
- import "frames/lib/error-tracker";
2
- export declare const LIVE_CHAT_PENDING_STORAGE_KEY = "liveChatPending";
3
- export declare const IS_DRAWER_OPEN_STORAGE_KEY = "ada-embed_is-drawer-open";
4
- /**
5
- * NOTE: If you import this file into any other file
6
- * it will trigger the init() function below - may cause errors!
7
- */
8
- /**
9
- * Auto-opens the chat door if crossWindowPersistence is one, the chatter is in
10
- * a live chat, and if the drawer was previously opened.
11
- */
12
- export declare function setIsDrawerOpen(): Promise<void>;
@@ -1,3 +0,0 @@
1
- import { StoreState } from "common/types/store-state";
2
- export declare function initializeFrame(waitForOtherFrames?: boolean, initialState?: Partial<StoreState>): Promise<boolean>;
3
- export declare function addCustomStyles(styles: string, hasUICustomization: boolean): void;
@@ -1,6 +0,0 @@
1
- import * as Sentry from "@sentry/browser";
2
- declare const errorTracker: {
3
- trackException(error: Error): void;
4
- addBreadCrumb(category: string, message: string, data: object, level?: Sentry.Severity): void;
5
- };
6
- export default errorTracker;
@@ -1,3 +0,0 @@
1
- import FC from "common/lib/fc";
2
- declare const _default: FC;
3
- export default _default;
@@ -1,2 +0,0 @@
1
- import { StoreProxyInterface } from "common/types/store";
2
- export declare const store: StoreProxyInterface;