@ada-support/embed2 1.0.46 → 1.0.51

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;
@@ -11,7 +11,7 @@ export interface CSInterface {
11
11
  domain?: string;
12
12
  route?: string;
13
13
  qp?: {
14
- [key: string]: string | boolean | number;
14
+ [key: string]: string | boolean | number | null | undefined;
15
15
  };
16
16
  isEmbedFramed?: boolean;
17
17
  }
@@ -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;
@@ -22,7 +22,7 @@ export interface StartOptions {
22
22
  onAdaEmbedLoaded?(): void;
23
23
  toggleCallback?(isDrawerOpen: boolean): void;
24
24
  eventCallbacks?: {
25
- [eventName: string]: (customJavascriptEvent: object) => void;
25
+ [eventName: string]: ((customJavascriptEvent: object) => void) | undefined;
26
26
  };
27
27
  zdChatterAuthCallback?(callback: (token: string) => void): void;
28
28
  embedStyles?: 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: "1.0.46-1f14246",
8517
+ release: "1.0.51-8d041f3",
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
@@ -8730,7 +8744,7 @@ var Channel = /*#__PURE__*/function () {
8730
8744
  }).catch(function (e) {
8731
8745
  // We should NOT silently catch errors for "GET_STATE" request event - it is critical for application to work.
8732
8746
  if (requestEvent === "GET_STATE") {
8733
- throw new errors/* AdaEmbedError */.S("Failed to respond to \"GET_STATE\" request. Reason: ".concat(e.message, "."));
8747
+ throw new errors/* AdaEmbedError */.S("Failed to respond to \"GET_STATE\" request. Reason: \"".concat(e.message, "\"."));
8734
8748
  } // handling promise
8735
8749
 
8736
8750
 
@@ -8825,8 +8839,6 @@ var FrameChannel = /*#__PURE__*/function (_Channel) {
8825
8839
 
8826
8840
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "targetOrigin", void 0);
8827
8841
 
8828
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "eventTarget", void 0);
8829
-
8830
8842
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "isConnected", false);
8831
8843
 
8832
8844
  _this.name = name;
@@ -8898,20 +8910,20 @@ var FrameChannel = /*#__PURE__*/function (_Channel) {
8898
8910
  status: status
8899
8911
  });
8900
8912
  } catch (e) {
8901
- var _context3, _context4;
8913
+ var _context4, _context5;
8902
8914
 
8903
8915
  var reason = e instanceof Error ? e.message : "unknown";
8904
8916
  var payloadRootKeys = payload && (0,esm_typeof/* default */.Z)(payload) === "object" ? keys_default()(payload) : [];
8905
8917
 
8906
8918
  if (eventName === "DISPATCH" && payload && (0,esm_typeof/* default */.Z)(payload) === "object") {
8907
- var _context2;
8919
+ var _context2, _context3;
8908
8920
 
8909
8921
  var p = payload;
8910
8922
  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(", "), "."));
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(", "), "."));
8912
8924
  }
8913
8925
 
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(", "), "."));
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(", "), "."));
8915
8927
  }
8916
8928
  }
8917
8929
  }], [{
@@ -9201,7 +9213,7 @@ function getEmbedURL(_ref) {
9201
9213
  polyfillVersionString = "legacy";
9202
9214
  }
9203
9215
 
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");
9216
+ return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "8d041f3", "/index.html");
9205
9217
  }
9206
9218
  /**
9207
9219
  * Generate the Chat / API URL
@@ -9218,12 +9230,18 @@ function getURL(_ref2) {
9218
9230
  _ref2$qp = _ref2.qp,
9219
9231
  qp = _ref2$qp === void 0 ? {} : _ref2$qp;
9220
9232
 
9221
- var queryString = map_default()(_context8 = filter_default()(_context9 = keys_default()(qp)).call(_context9, function (key) {
9222
- return qp[key] !== undefined && qp[key] !== null;
9223
- })).call(_context8, function (key) {
9233
+ var queryString = filter_default()(_context8 = map_default()(_context9 = keys_default()(qp)).call(_context9, function (key) {
9224
9234
  var _context10;
9225
9235
 
9226
- return concat_default()(_context10 = "".concat(key, "=")).call(_context10, window.encodeURIComponent(qp[key]));
9236
+ var value = qp[key];
9237
+
9238
+ if (value === undefined || value === null) {
9239
+ return null;
9240
+ }
9241
+
9242
+ return concat_default()(_context10 = "".concat(key, "=")).call(_context10, window.encodeURIComponent(value));
9243
+ })).call(_context8, function (v) {
9244
+ return v !== null;
9227
9245
  }).join("&");
9228
9246
 
9229
9247
  var questionSym = queryString.length ? "?" : "";
@@ -10044,8 +10062,6 @@ var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
10044
10062
 
10045
10063
 
10046
10064
 
10047
- var INTRO_STYLE_EMOJI = "Emoji";
10048
- var INTRO_STYLE_TEXT = "Text";
10049
10065
  function getProcessedPath(path) {
10050
10066
  var regex = new RegExp("^http(s)?://(www.)?");
10051
10067
  return trim_default()(path).call(path).replace(regex, "");
@@ -10095,20 +10111,10 @@ function getIntroForCurrentUrl(intros, language) {
10095
10111
  var matchingIntro = findMatchingIntro(intros);
10096
10112
 
10097
10113
  if (!matchingIntro) {
10098
- return null;
10114
+ return undefined;
10099
10115
  }
10100
10116
 
10101
- if (matchingIntro.style === INTRO_STYLE_TEXT) {
10102
- return {
10103
- response_id: matchingIntro.response_id,
10104
- body: matchingIntro.body.message_text[language],
10105
- style: matchingIntro.style,
10106
- delay: matchingIntro.delay,
10107
- duration: matchingIntro.duration
10108
- };
10109
- }
10110
-
10111
- if (matchingIntro.style === INTRO_STYLE_EMOJI) {
10117
+ if (matchingIntro.style === "Emoji") {
10112
10118
  return {
10113
10119
  response_id: matchingIntro.response_id,
10114
10120
  body: matchingIntro.body.emoji_link,
@@ -10116,9 +10122,16 @@ function getIntroForCurrentUrl(intros, language) {
10116
10122
  delay: matchingIntro.delay,
10117
10123
  duration: matchingIntro.duration
10118
10124
  };
10119
- }
10125
+ } // Default - "Text" style
10120
10126
 
10121
- return null;
10127
+
10128
+ return {
10129
+ response_id: matchingIntro.response_id,
10130
+ body: matchingIntro.body.message_text[language],
10131
+ style: matchingIntro.style,
10132
+ delay: matchingIntro.delay,
10133
+ duration: matchingIntro.duration
10134
+ };
10122
10135
  }
10123
10136
  ;// CONCATENATED MODULE: ./src/campaigns/TriggerConditionEvaluator.ts
10124
10137
 
@@ -10688,7 +10701,7 @@ function fetch_client_objectSpread(target) { for (var i = 1; i < arguments.lengt
10688
10701
 
10689
10702
 
10690
10703
 
10691
- function clientMatchesExpectedFormat(client) {
10704
+ function isClientObject(client) {
10692
10705
  // We require the following properties defined
10693
10706
  return ["handle", "rollout", "chat", "features"].every(function (key) {
10694
10707
  return client[key] !== undefined;
@@ -10719,14 +10732,14 @@ function _fetchClient() {
10719
10732
  case 3:
10720
10733
  cachedClient = _context.sent;
10721
10734
 
10722
- if (!(cachedClient && clientMatchesExpectedFormat(cachedClient))) {
10735
+ if (!(cachedClient && isClientObject(cachedClient))) {
10723
10736
  _context.next = 6;
10724
10737
  break;
10725
10738
  }
10726
10739
 
10727
10740
  return _context.abrupt("return", {
10728
10741
  client: fetch_client_objectSpread({
10729
- intro: getIntroForCurrentUrl(cachedClient.intros, language || cachedClient.language)
10742
+ intro: getIntroForCurrentUrl(cachedClient.intros || [], language || cachedClient.language)
10730
10743
  }, cachedClient)
10731
10744
  });
10732
10745
 
@@ -10807,6 +10820,53 @@ function wait(ms) {
10807
10820
  return setTimeout(resolve, ms);
10808
10821
  });
10809
10822
  }
10823
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js/object/get-own-property-symbols.js
10824
+ var object_get_own_property_symbols = __webpack_require__(3263);
10825
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js/instance/index-of.js
10826
+ var index_of = __webpack_require__(5683);
10827
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js/object/keys.js
10828
+ var keys = __webpack_require__(9356);
10829
+ ;// CONCATENATED MODULE: ./node_modules/@babel/runtime-corejs3/helpers/esm/objectWithoutPropertiesLoose.js
10830
+
10831
+
10832
+ function _objectWithoutPropertiesLoose(source, excluded) {
10833
+ if (source == null) return {};
10834
+ var target = {};
10835
+
10836
+ var sourceKeys = keys(source);
10837
+
10838
+ var key, i;
10839
+
10840
+ for (i = 0; i < sourceKeys.length; i++) {
10841
+ key = sourceKeys[i];
10842
+ if (index_of(excluded).call(excluded, key) >= 0) continue;
10843
+ target[key] = source[key];
10844
+ }
10845
+
10846
+ return target;
10847
+ }
10848
+ ;// CONCATENATED MODULE: ./node_modules/@babel/runtime-corejs3/helpers/esm/objectWithoutProperties.js
10849
+
10850
+
10851
+
10852
+ function _objectWithoutProperties(source, excluded) {
10853
+ if (source == null) return {};
10854
+ var target = _objectWithoutPropertiesLoose(source, excluded);
10855
+ var key, i;
10856
+
10857
+ if (object_get_own_property_symbols) {
10858
+ var sourceSymbolKeys = object_get_own_property_symbols(source);
10859
+
10860
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
10861
+ key = sourceSymbolKeys[i];
10862
+ if (index_of(excluded).call(excluded, key) >= 0) continue;
10863
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
10864
+ target[key] = source[key];
10865
+ }
10866
+ }
10867
+
10868
+ return target;
10869
+ }
10810
10870
  // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/object/assign.js
10811
10871
  var core_js_stable_object_assign = __webpack_require__(1942);
10812
10872
  var object_assign_default = /*#__PURE__*/__webpack_require__.n(core_js_stable_object_assign);
@@ -10814,6 +10874,7 @@ var object_assign_default = /*#__PURE__*/__webpack_require__.n(core_js_stable_ob
10814
10874
 
10815
10875
 
10816
10876
 
10877
+ var _excluded = ["chat", "chat_button", "features", "handle", "language", "persistence", "privacy", "rollout", "tint"];
10817
10878
 
10818
10879
  var Client = function Client(clientResponse) {
10819
10880
  (0,classCallCheck/* default */.Z)(this, Client);
@@ -10846,15 +10907,34 @@ var Client = function Client(clientResponse) {
10846
10907
 
10847
10908
  (0,defineProperty/* default */.Z)(this, "ui_settings", void 0);
10848
10909
 
10910
+ var chat = clientResponse.chat,
10911
+ chatButton = clientResponse.chat_button,
10912
+ features = clientResponse.features,
10913
+ handle = clientResponse.handle,
10914
+ language = clientResponse.language,
10915
+ persistence = clientResponse.persistence,
10916
+ privacy = clientResponse.privacy,
10917
+ rollout = clientResponse.rollout,
10918
+ tint = clientResponse.tint,
10919
+ rest = _objectWithoutProperties(clientResponse, _excluded);
10920
+
10921
+ this.chat = chat;
10922
+ this.chat_button = chatButton;
10923
+ this.features = features;
10924
+ this.handle = handle;
10925
+ this.language = language;
10926
+ this.persistence = persistence;
10927
+ this.privacy = privacy;
10928
+ this.rollout = rollout;
10929
+ this.tint = tint;
10849
10930
  /**
10850
10931
  * Even if some properties are not used by Embed2, they may be used by Chat.
10851
10932
  * Chat can "pull" the client object from Embed2 in order to reduce an API
10852
10933
  * request. Embed2 should thus not modify keys.
10853
10934
  */
10854
- object_assign_default()(this, clientResponse);
10855
- };
10856
-
10857
10935
 
10936
+ object_assign_default()(this, rest);
10937
+ };
10858
10938
  function hasCampaignsEnabled(client) {
10859
10939
  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);
10860
10940
  }
@@ -11311,6 +11391,7 @@ function ChatFrame_isNativeReflectConstruct() { if (typeof Reflect === "undefine
11311
11391
 
11312
11392
 
11313
11393
 
11394
+
11314
11395
  var ChatFrame = /*#__PURE__*/function (_Component) {
11315
11396
  (0,inherits/* default */.Z)(ChatFrame, _Component);
11316
11397
 
@@ -11331,21 +11412,19 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11331
11412
 
11332
11413
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "iframeRef", y());
11333
11414
 
11334
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "pageYOffset", void 0);
11335
-
11336
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyOverflow", void 0);
11415
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "pageYOffset", 0);
11337
11416
 
11338
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyPosition", void 0);
11417
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyOverflow", "");
11339
11418
 
11340
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyTop", void 0);
11419
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyPosition", "");
11341
11420
 
11342
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyBottom", void 0);
11421
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyTop", "");
11343
11422
 
11344
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyLeft", void 0);
11423
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyBottom", "");
11345
11424
 
11346
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyRight", void 0);
11425
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyLeft", "");
11347
11426
 
11348
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "frameConnected", void 0);
11427
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyRight", "");
11349
11428
 
11350
11429
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "url", _this.getURL);
11351
11430
 
@@ -11365,6 +11444,8 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11365
11444
  var _this2 = this;
11366
11445
 
11367
11446
  var _this$props = this.props,
11447
+ adaSettings = _this$props.adaSettings,
11448
+ handle = _this$props.handle,
11368
11449
  name = _this$props.name,
11369
11450
  setChatHasBeenRendered = _this$props.setChatHasBeenRendered,
11370
11451
  messageService = _this$props.messageService,
@@ -11373,7 +11454,12 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11373
11454
  this.channel = messageService.registerFrameChannel(name, this.iframeRef.current.contentWindow, this.iframeRef.current.src);
11374
11455
  store.addChannelListener(name);
11375
11456
  this.bindChatEventHandlers();
11376
- this.handleScrollLock(); // Delay to allow inline css animation to work.
11457
+ this.handleScrollLock(); // We use this log to track number of chat impressions (times when users see chat iFrame render first time).
11458
+
11459
+ (0,services_logger/* log */.c)("Chat frame mount", {
11460
+ handle: handle,
11461
+ embedSettings: adaSettings
11462
+ }); // Delay to allow inline css animation to work.
11377
11463
 
11378
11464
  setTimeout(function () {
11379
11465
  _this2.setState({
@@ -11410,7 +11496,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11410
11496
  }
11411
11497
 
11412
11498
  var theme = client.ui_settings.chat.theme;
11413
- var systemDarkMode = Boolean(window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches);
11499
+ var systemDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches;
11414
11500
  return theme === "dark" || theme === "auto" && systemDarkMode;
11415
11501
  }
11416
11502
  /**
@@ -11432,6 +11518,11 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11432
11518
  privateMode = _this$props3.privateMode,
11433
11519
  testMode = _this$props3.testMode,
11434
11520
  adaSettings = _this$props3.adaSettings;
11521
+
11522
+ if (!handle) {
11523
+ throw new errors/* AdaEmbedError */.S("`handle` is not defined");
11524
+ }
11525
+
11435
11526
  return getURL({
11436
11527
  name: name,
11437
11528
  handle: handle,
@@ -11452,7 +11543,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11452
11543
  }, {
11453
11544
  key: "styles",
11454
11545
  get: function get() {
11455
- var _client$ui_settings2, _context10, _context11, _context12, _context13, _context14;
11546
+ var _client$ui_settings2, _client$ui_settings2$, _context10, _context11, _context12, _context13, _context14;
11456
11547
 
11457
11548
  var _this$props4 = this.props,
11458
11549
  isDrawerOpen = _this$props4.isDrawerOpen,
@@ -11469,7 +11560,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11469
11560
  closeTransitionTime = _this$state.closeTransitionTime;
11470
11561
  var isShown = isDrawerOpen && isMounted;
11471
11562
  var backgroundColor = this.darkMode ? "#121212" : "#fff";
11472
- var borderRadius = ((_client$ui_settings2 = client.ui_settings) === null || _client$ui_settings2 === void 0 ? void 0 : _client$ui_settings2.chat.style) === "rectangular" ? "8px" : "16px";
11563
+ var borderRadius = ((_client$ui_settings2 = client.ui_settings) === null || _client$ui_settings2 === void 0 ? void 0 : (_client$ui_settings2$ = _client$ui_settings2.chat) === null || _client$ui_settings2$ === void 0 ? void 0 : _client$ui_settings2$.style) === "rectangular" ? "8px" : "16px";
11473
11564
  var WINDOW_HEIGHT = 725;
11474
11565
  var TEST_BOT_NAV_HEIGHT = 48;
11475
11566
  var isTestBot = client.features.embed_test_bot && testMode;
@@ -11498,12 +11589,17 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11498
11589
  var _this$props5 = this.props,
11499
11590
  chatDimensions = _this$props5.chatDimensions,
11500
11591
  client = _this$props5.client,
11501
- adaSettings = _this$props5.adaSettings; // delta is used to determine how much of the button's height should be ignored
11592
+ adaSettings = _this$props5.adaSettings;
11593
+
11594
+ if (!(client !== null && client !== void 0 && client.chat_button)) {
11595
+ return "";
11596
+ } // delta is used to determine how much of the button's height should be ignored
11502
11597
  // when spacing the proactive message
11503
11598
 
11599
+
11504
11600
  var delta = 3;
11505
11601
  var TEXT_BUTTON_HEIGHT = 44;
11506
- var bottomOffset = (client === null || client === void 0 ? void 0 : (_client$ui_settings3 = client.ui_settings) === null || _client$ui_settings3 === void 0 ? void 0 : (_client$ui_settings3$ = _client$ui_settings3.embed) === null || _client$ui_settings3$ === void 0 ? void 0 : _client$ui_settings3$.style) === "text" ? TEXT_BUTTON_HEIGHT - delta : (client === null || client === void 0 ? void 0 : client.chat_button.size) - delta;
11602
+ var bottomOffset = ((_client$ui_settings3 = client.ui_settings) === null || _client$ui_settings3 === void 0 ? void 0 : (_client$ui_settings3$ = _client$ui_settings3.embed) === null || _client$ui_settings3$ === void 0 ? void 0 : _client$ui_settings3$.style) === "text" ? TEXT_BUTTON_HEIGHT - delta : client.chat_button.size - delta;
11507
11603
  return concat_default()(_context15 = concat_default()(_context16 = concat_default()(_context17 = "\n box-shadow: none;\n background: none;\n height: ".concat(chatDimensions === null || chatDimensions === void 0 ? void 0 : chatDimensions.height, "px !important;\n width: ")).call(_context17, chatDimensions === null || chatDimensions === void 0 ? void 0 : chatDimensions.width, "px !important;\n ")).call(_context16, getAlignment(adaSettings), ": 0;\n bottom: ")).call(_context15, bottomOffset, "px;\n z-index: 9999;\n ");
11508
11604
  }
11509
11605
  }, {
@@ -11519,6 +11615,10 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11519
11615
  return ChatFrame.parentElementStyles;
11520
11616
  }
11521
11617
 
11618
+ if (!client) {
11619
+ throw new errors/* AdaEmbedError */.S("`client` is not defined");
11620
+ }
11621
+
11522
11622
  if (client.features.afm_proactive_messaging && !isDrawerOpen) {
11523
11623
  var _context21;
11524
11624
 
@@ -11647,32 +11747,48 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11647
11747
  case 0:
11648
11748
  _this$props8 = this.props, adaSettings = _this$props8.adaSettings, setState = _this$props8.setState, setConnectionState = _this$props8.setConnectionState;
11649
11749
  _context22.t0 = type;
11650
- _context22.next = _context22.t0 === GET_WINDOW_ORIGIN ? 4 : _context22.t0 === CHAT_STARTED ? 6 : _context22.t0 === CHAT_WEBSOCKET_CONNECTED ? 9 : _context22.t0 === PUBLISH_EVENT ? 11 : _context22.t0 === ANALYTICS_EVENT ? 14 : _context22.t0 === CHATTER_EVENT ? 18 : _context22.t0 === "ZD_SESSION" ? 28 : _context22.t0 === CHATTER_LIVECHAT_EVENT ? 37 : _context22.t0 === CUSTOM_JAVASCRIPT_EVENT ? 43 : _context22.t0 === RESET_FROM_CHAT_EVENT ? 52 : _context22.t0 === ZD_JWT_AUTH_EVENT ? 55 : _context22.t0 === CREATE_NOTIFICATION_EVENT ? 58 : _context22.t0 === BROWSER_HAS_NOTIFICATIONS_EVENT ? 60 : _context22.t0 === REQUEST_NOTIFICATIONS_EVENT ? 62 : _context22.t0 === END_CONVERSATION_EVENT ? 64 : 67;
11750
+ _context22.next = _context22.t0 === GET_WINDOW_ORIGIN ? 4 : _context22.t0 === CHAT_STARTED ? 8 : _context22.t0 === CHAT_WEBSOCKET_CONNECTED ? 13 : _context22.t0 === PUBLISH_EVENT ? 15 : _context22.t0 === ANALYTICS_EVENT ? 18 : _context22.t0 === CHATTER_EVENT ? 22 : _context22.t0 === "ZD_SESSION" ? 32 : _context22.t0 === CHATTER_LIVECHAT_EVENT ? 41 : _context22.t0 === CUSTOM_JAVASCRIPT_EVENT ? 49 : _context22.t0 === RESET_FROM_CHAT_EVENT ? 58 : _context22.t0 === ZD_JWT_AUTH_EVENT ? 61 : _context22.t0 === CREATE_NOTIFICATION_EVENT ? 79 : _context22.t0 === BROWSER_HAS_NOTIFICATIONS_EVENT ? 81 : _context22.t0 === REQUEST_NOTIFICATIONS_EVENT ? 85 : _context22.t0 === END_CONVERSATION_EVENT ? 87 : 90;
11651
11751
  break;
11652
11752
 
11653
11753
  case 4:
11654
- this.channel.postMessage("SET_WINDOW_ORIGIN", window.location, id);
11655
- return _context22.abrupt("break", 68);
11754
+ if (this.channel) {
11755
+ _context22.next = 6;
11756
+ break;
11757
+ }
11758
+
11759
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11656
11760
 
11657
11761
  case 6:
11762
+ this.channel.postMessage("SET_WINDOW_ORIGIN", window.location, id);
11763
+ return _context22.abrupt("break", 91);
11764
+
11765
+ case 8:
11766
+ if (this.channel) {
11767
+ _context22.next = 10;
11768
+ break;
11769
+ }
11770
+
11771
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11772
+
11773
+ case 10:
11658
11774
  this.channel.isConnected = true;
11659
11775
  setConnectionState({
11660
11776
  "chat": ConnectionState.Done
11661
11777
  });
11662
- return _context22.abrupt("break", 68);
11778
+ return _context22.abrupt("break", 91);
11663
11779
 
11664
- case 9:
11780
+ case 13:
11665
11781
  setState({
11666
11782
  isChatWebsocketConnected: true
11667
11783
  });
11668
- return _context22.abrupt("break", 68);
11784
+ return _context22.abrupt("break", 91);
11669
11785
 
11670
- case 11:
11786
+ case 15:
11671
11787
  _ref = payload, eventKey = _ref.eventKey, data = _ref.data;
11672
11788
  publishEvent(eventKey, data);
11673
- return _context22.abrupt("break", 68);
11789
+ return _context22.abrupt("break", 91);
11674
11790
 
11675
- case 14:
11791
+ case 18:
11676
11792
  _ref2 = payload, analytics = _ref2.analytics;
11677
11793
  analyticsCallback = adaSettings.analyticsCallback;
11678
11794
 
@@ -11680,28 +11796,28 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11680
11796
  analyticsCallback(analytics);
11681
11797
  }
11682
11798
 
11683
- return _context22.abrupt("break", 68);
11799
+ return _context22.abrupt("break", 91);
11684
11800
 
11685
- case 18:
11801
+ case 22:
11686
11802
  client = this.props.client;
11687
11803
  _ref3 = payload, chatter = _ref3.chatter, created = _ref3.created;
11688
11804
  chatterTokenCallback = adaSettings.chatterTokenCallback;
11689
11805
 
11690
11806
  if (client) {
11691
- _context22.next = 23;
11807
+ _context22.next = 27;
11692
11808
  break;
11693
11809
  }
11694
11810
 
11695
11811
  throw new errors/* AdaEmbedError */.S("`client` is undefined");
11696
11812
 
11697
- case 23:
11698
- _context22.next = 25;
11813
+ case 27:
11814
+ _context22.next = 29;
11699
11815
  return setState({
11700
11816
  chatterToken: chatter,
11701
11817
  chatterCreated: created
11702
11818
  });
11703
11819
 
11704
- case 25:
11820
+ case 29:
11705
11821
  /**
11706
11822
  * Store the token so when embed loads in the future, it doesn't have to wait for it to
11707
11823
  * come from chat. This is important for campaign and business event triggers.
@@ -11718,26 +11834,26 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11718
11834
  chatterTokenCallback(chatter);
11719
11835
  }
11720
11836
 
11721
- return _context22.abrupt("break", 68);
11837
+ return _context22.abrupt("break", 91);
11722
11838
 
11723
- case 28:
11839
+ case 32:
11724
11840
  _client = this.props.client;
11725
11841
  _ref4 = payload, zdSessionId = _ref4.zdSessionId, zdPreviousTags = _ref4.zdPreviousTags;
11726
11842
 
11727
11843
  if (_client) {
11728
- _context22.next = 32;
11844
+ _context22.next = 36;
11729
11845
  break;
11730
11846
  }
11731
11847
 
11732
11848
  throw new errors/* AdaEmbedError */.S("`client` is undefined");
11733
11849
 
11734
- case 32:
11735
- _context22.next = 34;
11850
+ case 36:
11851
+ _context22.next = 38;
11736
11852
  return setState({
11737
11853
  zdSessionId: zdSessionId
11738
11854
  });
11739
11855
 
11740
- case 34:
11856
+ case 38:
11741
11857
  storage = function () {
11742
11858
  if (_client.persistence === PERSISTENCE_NORMAL) {
11743
11859
  return safeLocalStorage;
@@ -11764,17 +11880,25 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11764
11880
  }
11765
11881
  }
11766
11882
 
11767
- return _context22.abrupt("break", 68);
11883
+ return _context22.abrupt("break", 91);
11768
11884
 
11769
- case 37:
11885
+ case 41:
11770
11886
  _client2 = this.props.client;
11771
11887
  _ref5 = payload, inLiveChat = _ref5.inLiveChat;
11772
- _context22.next = 41;
11888
+ _context22.next = 45;
11773
11889
  return setState({
11774
11890
  chatterInLiveChat: inLiveChat
11775
11891
  });
11776
11892
 
11777
- case 41:
11893
+ case 45:
11894
+ if (_client2) {
11895
+ _context22.next = 47;
11896
+ break;
11897
+ }
11898
+
11899
+ throw new errors/* AdaEmbedError */.S("`client` is not defined");
11900
+
11901
+ case 47:
11778
11902
  /**
11779
11903
  * Store the token so when embed loads in the future, it doesn't have to wait for it to
11780
11904
  * come from chat. This is important for campaign and business event triggers.
@@ -11785,19 +11909,19 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11785
11909
  safeSessionStorage.setItem(IN_LIVE_CHAT_STORAGE_KEY, inLiveChat);
11786
11910
  }
11787
11911
 
11788
- return _context22.abrupt("break", 68);
11912
+ return _context22.abrupt("break", 91);
11789
11913
 
11790
- case 43:
11914
+ case 49:
11791
11915
  eventCallbacks = adaSettings.eventCallbacks;
11792
11916
 
11793
11917
  if (eventCallbacks) {
11794
- _context22.next = 46;
11918
+ _context22.next = 52;
11795
11919
  break;
11796
11920
  }
11797
11921
 
11798
- return _context22.abrupt("break", 68);
11922
+ return _context22.abrupt("break", 91);
11799
11923
 
11800
- case 46:
11924
+ case 52:
11801
11925
  customJavascriptEvent = payload.event_data;
11802
11926
  specificCallback = eventCallbacks[customJavascriptEvent.event_name];
11803
11927
  genericCallback = eventCallbacks["*"];
@@ -11810,65 +11934,107 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11810
11934
  genericCallback(customJavascriptEvent);
11811
11935
  }
11812
11936
 
11813
- return _context22.abrupt("break", 68);
11937
+ return _context22.abrupt("break", 91);
11814
11938
 
11815
- case 52:
11939
+ case 58:
11816
11940
  resetChat = this.props.resetChat;
11817
11941
  resetChat();
11818
- return _context22.abrupt("break", 68);
11942
+ return _context22.abrupt("break", 91);
11819
11943
 
11820
- case 55:
11944
+ case 61:
11821
11945
  zdChatterAuthCallback = adaSettings.zdChatterAuthCallback;
11822
11946
 
11823
- if (zdChatterAuthCallback) {
11824
- try {
11825
- zdChatterAuthCallback(function (token) {
11826
- _this4.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {
11827
- token: token
11828
- }, id);
11829
- });
11830
- } catch (e) {
11831
- console.warn("Function for zdChatterAuthCallback produced an error - please ensure the callback is functioning normally");
11832
- this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
11947
+ if (!zdChatterAuthCallback) {
11948
+ _context22.next = 75;
11949
+ break;
11950
+ }
11951
+
11952
+ _context22.prev = 63;
11953
+ zdChatterAuthCallback(function (token) {
11954
+ if (!_this4.channel) {
11955
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11833
11956
  }
11834
- } else {
11835
- this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
11957
+
11958
+ _this4.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {
11959
+ token: token
11960
+ }, id);
11961
+ });
11962
+ _context22.next = 73;
11963
+ break;
11964
+
11965
+ case 67:
11966
+ _context22.prev = 67;
11967
+ _context22.t1 = _context22["catch"](63);
11968
+ console.warn("Function for zdChatterAuthCallback produced an error - please ensure the callback is functioning normally");
11969
+
11970
+ if (this.channel) {
11971
+ _context22.next = 72;
11972
+ break;
11836
11973
  }
11837
11974
 
11838
- return _context22.abrupt("break", 68);
11975
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11839
11976
 
11840
- case 58:
11977
+ case 72:
11978
+ this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
11979
+
11980
+ case 73:
11981
+ _context22.next = 78;
11982
+ break;
11983
+
11984
+ case 75:
11985
+ if (this.channel) {
11986
+ _context22.next = 77;
11987
+ break;
11988
+ }
11989
+
11990
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11991
+
11992
+ case 77:
11993
+ this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
11994
+
11995
+ case 78:
11996
+ return _context22.abrupt("break", 91);
11997
+
11998
+ case 79:
11841
11999
  this.handleNotifications(payload);
11842
- return _context22.abrupt("break", 68);
12000
+ return _context22.abrupt("break", 91);
11843
12001
 
11844
- case 60:
12002
+ case 81:
12003
+ if (this.channel) {
12004
+ _context22.next = 83;
12005
+ break;
12006
+ }
12007
+
12008
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
12009
+
12010
+ case 83:
11845
12011
  this.channel.postMessage(BROWSER_HAS_NOTIFICATIONS_RESPONSE_EVENT, {
11846
12012
  browserHasNotificationSupport: browserHasNotificationSupport
11847
12013
  });
11848
- return _context22.abrupt("break", 68);
12014
+ return _context22.abrupt("break", 91);
11849
12015
 
11850
- case 62:
12016
+ case 85:
11851
12017
  requestNotificationPermission();
11852
- return _context22.abrupt("break", 68);
12018
+ return _context22.abrupt("break", 91);
11853
12019
 
11854
- case 64:
12020
+ case 87:
11855
12021
  conversationEndCallback = adaSettings.conversationEndCallback;
11856
12022
 
11857
12023
  if (conversationEndCallback) {
11858
12024
  conversationEndCallback(payload);
11859
12025
  }
11860
12026
 
11861
- return _context22.abrupt("break", 68);
12027
+ return _context22.abrupt("break", 91);
11862
12028
 
11863
- case 67:
11864
- return _context22.abrupt("break", 68);
12029
+ case 90:
12030
+ return _context22.abrupt("break", 91);
11865
12031
 
11866
- case 68:
12032
+ case 91:
11867
12033
  case "end":
11868
12034
  return _context22.stop();
11869
12035
  }
11870
12036
  }
11871
- }, _callee, this);
12037
+ }, _callee, this, [[63, 67]]);
11872
12038
  }));
11873
12039
 
11874
12040
  function handleChatEvent(_x, _x2, _x3) {
@@ -11885,7 +12051,13 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11885
12051
  var _this$props9 = this.props,
11886
12052
  name = _this$props9.name,
11887
12053
  messageService = _this$props9.messageService;
11888
- messageService.getChannel(name).addEventListener(function (type, payload, id) {
12054
+ var channel = messageService.getChannel(name);
12055
+
12056
+ if (!channel) {
12057
+ throw new errors/* AdaEmbedError */.S("`channel` is not defined");
12058
+ }
12059
+
12060
+ channel.addEventListener(function (type, payload, id) {
11889
12061
  _this5.handleChatEvent(type, payload, id);
11890
12062
  });
11891
12063
  }
@@ -12672,7 +12844,7 @@ var Container = /*#__PURE__*/function (_Component) {
12672
12844
 
12673
12845
  case 6:
12674
12846
  _context3.t0 = type;
12675
- _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;
12847
+ _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;
12676
12848
  break;
12677
12849
 
12678
12850
  case 9:
@@ -12686,7 +12858,7 @@ var Container = /*#__PURE__*/function (_Component) {
12686
12858
 
12687
12859
  case 12:
12688
12860
  this.trackEvent(payload);
12689
- return _context3.abrupt("break", 89);
12861
+ return _context3.abrupt("break", 91);
12690
12862
 
12691
12863
  case 14:
12692
12864
  if (client.features.afm_proactive_messaging) {
@@ -12699,7 +12871,7 @@ var Container = /*#__PURE__*/function (_Component) {
12699
12871
 
12700
12872
  case 17:
12701
12873
  this.triggerCampaign(payload);
12702
- return _context3.abrupt("break", 89);
12874
+ return _context3.abrupt("break", 91);
12703
12875
 
12704
12876
  case 19:
12705
12877
  if (client.features.afm_proactive_messaging) {
@@ -12712,7 +12884,7 @@ var Container = /*#__PURE__*/function (_Component) {
12712
12884
 
12713
12885
  case 22:
12714
12886
  this.evaluateCampaignConditions(payload);
12715
- return _context3.abrupt("break", 89);
12887
+ return _context3.abrupt("break", 91);
12716
12888
 
12717
12889
  case 24:
12718
12890
  toggleChat = this.props.toggleChat;
@@ -12721,7 +12893,7 @@ var Container = /*#__PURE__*/function (_Component) {
12721
12893
 
12722
12894
  case 27:
12723
12895
  localChannel.postMessage(TOGGLE_RESPONSE, null, id);
12724
- return _context3.abrupt("break", 89);
12896
+ return _context3.abrupt("break", 91);
12725
12897
 
12726
12898
  case 29:
12727
12899
  _this$props10 = this.props, isDrawerOpen = _this$props10.isDrawerOpen, drawerHasBeenOpened = _this$props10.drawerHasBeenOpened, chatterToken = _this$props10.chatterToken;
@@ -12732,7 +12904,7 @@ var Container = /*#__PURE__*/function (_Component) {
12732
12904
  hasClosedChat: drawerHasBeenOpened && !isDrawerOpen
12733
12905
  };
12734
12906
  localChannel.postMessage(GET_INFO_RESPONSE, contentToReturn, id);
12735
- return _context3.abrupt("break", 89);
12907
+ return _context3.abrupt("break", 91);
12736
12908
 
12737
12909
  case 33:
12738
12910
  _this$props11 = this.props, metaFields = _this$props11.metaFields, setState = _this$props11.setState;
@@ -12745,7 +12917,7 @@ var Container = /*#__PURE__*/function (_Component) {
12745
12917
 
12746
12918
  case 38:
12747
12919
  localChannel.postMessage(SET_META_FIELDS_RESPONSE, null, id);
12748
- return _context3.abrupt("break", 89);
12920
+ return _context3.abrupt("break", 91);
12749
12921
 
12750
12922
  case 40:
12751
12923
  _this$props12 = this.props, sensitiveMetaFields = _this$props12.sensitiveMetaFields, _setState = _this$props12.setState;
@@ -12756,12 +12928,12 @@ var Container = /*#__PURE__*/function (_Component) {
12756
12928
 
12757
12929
  case 43:
12758
12930
  localChannel.postMessage("SET_SENSITIVE_META_FIELDS_RESPONSE", null, id);
12759
- return _context3.abrupt("break", 89);
12931
+ return _context3.abrupt("break", 91);
12760
12932
 
12761
12933
  case 45:
12762
12934
  localChannel.postMessage(STOP_RESPONSE, null, id);
12763
12935
  this.unmount();
12764
- return _context3.abrupt("break", 89);
12936
+ return _context3.abrupt("break", 91);
12765
12937
 
12766
12938
  case 48:
12767
12939
  _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;
@@ -12815,7 +12987,7 @@ var Container = /*#__PURE__*/function (_Component) {
12815
12987
  }
12816
12988
 
12817
12989
  localChannel.postMessage(RESET_RESPONSE, null, id);
12818
- return _context3.abrupt("break", 89);
12990
+ return _context3.abrupt("break", 91);
12819
12991
 
12820
12992
  case 66:
12821
12993
  _setState3 = this.props.setState;
@@ -12843,23 +13015,32 @@ var Container = /*#__PURE__*/function (_Component) {
12843
13015
  case 75:
12844
13016
  xStorageChannel.postMessage(DELETE_HISTORY_EVENT);
12845
13017
  localChannel.postMessage(DELETE_HISTORY_RESPONSE, null, id);
12846
- return _context3.abrupt("break", 89);
13018
+ return _context3.abrupt("break", 91);
12847
13019
 
12848
13020
  case 78:
12849
13021
  _ref2 = payload, body = _ref2.body, duration = _ref2.duration;
12850
- EXTRA_PROACTIVE_DELAY = 1000; // Free tier campaigns re-use the createProactive infrastructure
13022
+ EXTRA_PROACTIVE_DELAY = 1000;
13023
+
13024
+ if (client) {
13025
+ _context3.next = 82;
13026
+ break;
13027
+ }
12851
13028
 
13029
+ throw new errors/* AdaEmbedError */.S("`client` is not defined");
13030
+
13031
+ case 82:
13032
+ // Free tier campaigns re-use the createProactive infrastructure
12852
13033
  canCreateProactive = client.features.developer_proactive || client.features.afm_proactive_messaging_free_tier;
12853
13034
 
12854
13035
  if (canCreateProactive) {
12855
- _context3.next = 84;
13036
+ _context3.next = 86;
12856
13037
  break;
12857
13038
  }
12858
13039
 
12859
13040
  localChannel.postMessage(CREATE_PROACTIVE_RESPONSE, "Ada Embed - Proactive intros are not available in your feature set.", id, FetchEventStatus.Failure);
12860
13041
  return _context3.abrupt("return");
12861
13042
 
12862
- case 84:
13043
+ case 86:
12863
13044
  this.setState({
12864
13045
  hideIntroOverride: true
12865
13046
  }, /*#__PURE__*/(0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee() {
@@ -12897,14 +13078,14 @@ var Container = /*#__PURE__*/function (_Component) {
12897
13078
  }
12898
13079
  }, _callee);
12899
13080
  })));
12900
- _context3.next = 87;
13081
+ _context3.next = 89;
12901
13082
  return wait(duration * 1000 + EXTRA_PROACTIVE_DELAY);
12902
13083
 
12903
- case 87:
13084
+ case 89:
12904
13085
  localChannel.postMessage(CREATE_PROACTIVE_RESPONSE, null, id);
12905
- return _context3.abrupt("break", 89);
13086
+ return _context3.abrupt("break", 91);
12906
13087
 
12907
- case 89:
13088
+ case 91:
12908
13089
  case "end":
12909
13090
  return _context3.stop();
12910
13091
  }
@@ -13199,15 +13380,15 @@ var Container = /*#__PURE__*/function (_Component) {
13199
13380
  }, {
13200
13381
  key: "renderIntroFrame",
13201
13382
  value: function renderIntroFrame() {
13202
- var _intro$style;
13383
+ var _client$intro;
13203
13384
 
13204
13385
  var _this$props15 = this.props,
13205
13386
  adaSettings = _this$props15.adaSettings,
13206
- intro = _this$props15.intro;
13387
+ client = _this$props15.client;
13207
13388
  var parentElement = adaSettings.parentElement;
13208
13389
  var hideIntroOverride = this.state.hideIntroOverride;
13209
13390
 
13210
- 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
13391
+ 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
13211
13392
  this.shouldRenderChatFrame) {
13212
13393
  return null;
13213
13394
  }
@@ -13328,7 +13509,6 @@ function Container_mapStateToProps(storeState) {
13328
13509
  isChatWebsocketConnected: isChatWebsocketConnected,
13329
13510
  isDrawerOpen: isDrawerOpen,
13330
13511
  chatterToken: chatterToken,
13331
- intro: client === null || client === void 0 ? void 0 : client.intro,
13332
13512
  appConnectionState: appConnectionState,
13333
13513
  drawerHasBeenOpened: drawerHasBeenOpened,
13334
13514
  chatterInLiveChat: chatterInLiveChat,
@@ -13898,7 +14078,7 @@ window.__AdaEmbedConstructor = Embed;
13898
14078
  /* harmony export */ });
13899
14079
  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);
13900
14080
  var isProduction = "production" === "production";
13901
- var embed2Version = "1f14246";
14081
+ var embed2Version = "8d041f3";
13902
14082
 
13903
14083
  /***/ }),
13904
14084
 
@@ -14231,9 +14411,9 @@ function _log() {
14231
14411
  service: "embed",
14232
14412
  env: "production",
14233
14413
  embedVersion: 2,
14234
- version: "1.0.46",
14414
+ version: "1.0.51",
14235
14415
  isNpm: true,
14236
- commitHash: "1f14246"
14416
+ commitHash: "8d041f3"
14237
14417
  }))
14238
14418
  });
14239
14419
 
@@ -14915,6 +15095,16 @@ var parent = __webpack_require__(1910);
14915
15095
  module.exports = parent;
14916
15096
 
14917
15097
 
15098
+ /***/ }),
15099
+
15100
+ /***/ 4710:
15101
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
15102
+
15103
+ var parent = __webpack_require__(9534);
15104
+
15105
+ module.exports = parent;
15106
+
15107
+
14918
15108
  /***/ }),
14919
15109
 
14920
15110
  /***/ 4303:
@@ -14925,6 +15115,16 @@ var parent = __webpack_require__(6507);
14925
15115
  module.exports = parent;
14926
15116
 
14927
15117
 
15118
+ /***/ }),
15119
+
15120
+ /***/ 3799:
15121
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
15122
+
15123
+ var parent = __webpack_require__(3059);
15124
+
15125
+ module.exports = parent;
15126
+
15127
+
14928
15128
  /***/ }),
14929
15129
 
14930
15130
  /***/ 5122:
@@ -23688,7 +23888,7 @@ function _loadEmbed() {
23688
23888
  polyfillVersionString = "legacy";
23689
23889
  }
23690
23890
 
23691
- embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "1f14246", "/index.js");
23891
+ embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "8d041f3", "/index.js");
23692
23892
  }
23693
23893
 
23694
23894
  clientScriptExists = Boolean( true || // The client script is bundled with npm module
@@ -24226,7 +24426,7 @@ function createEmbedObject() {
24226
24426
  }
24227
24427
  ;// CONCATENATED MODULE: ./src/index-npm.ts
24228
24428
 
24229
- Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 7054));
24429
+ Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 9136));
24230
24430
  /* harmony default export */ var index_npm = (createEmbedObject());
24231
24431
  }();
24232
24432
  module.exports = __webpack_exports__;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.0.46",
3
+ "version": "1.0.51",
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 109",
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",
@@ -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;