@ada-support/embed2 1.0.31 → 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,8 @@
1
- export declare const CHATTER_STORAGE_KEY = "chatter";
1
+ export declare const CHATTER_TOKEN_STORAGE_KEY = "chatter";
2
+ export declare const CHATTER_CREATED_STORAGE_KEY = "ada-embed_chatter-created";
2
3
  export declare const IN_LIVE_CHAT_STORAGE_KEY = "inLiveChat";
4
+ export declare const ZD_SESSION_STORAGE_KEY = "ada-embed_zd-session-id";
5
+ export declare const ZD_PREVIOUS_TAGS_STORAGE_KEY = "ada-embed_zd-previous-tags";
6
+ export declare const IS_DRAWER_OPEN_STORAGE_KEY = "ada-embed_is-drawer-open";
7
+ /** @deprecated - Use CHATTER_TOKEN_STORAGE_KEY */
8
+ export declare const CHATTER_STORAGE_KEY = "chatter";
@@ -20,5 +20,5 @@ export default class FC extends Channel {
20
20
  private static isMessageEvent;
21
21
  postMessage<T extends EmbedEvent>(eventName: T, data?: PayloadByEvent[T], id?: string, status?: FetchEventStatusType): void;
22
22
  addEventListener(handler: (type: string, payload?: object, id?: string, status?: FetchEventStatusType) => void): Refhandler;
23
- constructObjectToSend(type?: string, payload?: {}, id?: string, status?: FetchEventStatusType): string;
23
+ constructObjectToSend(type?: string, payload?: unknown, id?: string, status?: FetchEventStatusType): string;
24
24
  }
@@ -39,8 +39,12 @@ export interface StartOptions {
39
39
  align?: "right" | "left" | "auto";
40
40
  }
41
41
  export interface StoreState extends StartOptionsNoFunction {
42
+ chatterCreated?: string | null;
43
+ chatterToken?: string | null;
42
44
  client: Client;
43
45
  isDrawerOpen: boolean;
46
+ zdSessionId?: string | null;
47
+ zdPreviousTags?: string | null;
44
48
  drawerHasBeenOpened: boolean;
45
49
  isIntroShown: boolean;
46
50
  isButtonShown: boolean;
@@ -52,7 +56,6 @@ export interface StoreState extends StartOptionsNoFunction {
52
56
  wasIntroShown: boolean;
53
57
  unreadMessageCount: number;
54
58
  embedStyles?: string;
55
- chatterToken: string;
56
59
  connections: {
57
60
  [key: string]: ConnectionState;
58
61
  };
@@ -0,0 +1,12 @@
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>;
@@ -0,0 +1,3 @@
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;
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,3 @@
1
+ import FC from "common/lib/fc";
2
+ declare const _default: FC;
3
+ export default _default;
@@ -1,3 +1,4 @@
1
+ import { CHATTER_CREATED_STORAGE_KEY, CHATTER_TOKEN_STORAGE_KEY, IN_LIVE_CHAT_STORAGE_KEY, ZD_PREVIOUS_TAGS_STORAGE_KEY, ZD_SESSION_STORAGE_KEY } from "common/constants/storage-keys";
1
2
  export declare enum StorageTypes {
2
3
  Local = "local",
3
4
  Session = "session"
@@ -5,8 +6,11 @@ export declare enum StorageTypes {
5
6
  declare type StorageTypesType = StorageTypes.Local | StorageTypes.Session;
6
7
  export declare type StorageValueType = string | number | boolean | unknown[];
7
8
  export interface StorageValueByKey {
8
- "chatter": string;
9
- "inLiveChat": boolean;
9
+ [CHATTER_CREATED_STORAGE_KEY]: string;
10
+ [CHATTER_TOKEN_STORAGE_KEY]: string;
11
+ [IN_LIVE_CHAT_STORAGE_KEY]: boolean;
12
+ [ZD_SESSION_STORAGE_KEY]: string;
13
+ [ZD_PREVIOUS_TAGS_STORAGE_KEY]: string;
10
14
  "liveChatPending": boolean;
11
15
  "ada-embed_is-drawer-open": boolean;
12
16
  "[handle]_marketing_campaigns_shown": string;
@@ -25,8 +29,8 @@ export declare class SafeStorage {
25
29
  seralizeItem(value: StorageValueType): string | null;
26
30
  deserializeItem<T extends StorageValueType>(value: string | null): T | null;
27
31
  getItem<T extends StorageKey>(key: T): StorageValueByKey[T] | null;
28
- setItem(key: string, value: StorageValueType): void;
29
- removeItem(key: string): void;
32
+ setItem<T extends StorageKey>(key: T, value: StorageValueByKey[T]): void;
33
+ removeItem(key: StorageKey): void;
30
34
  }
31
35
  export declare const safeLocalStorage: SafeStorage;
32
36
  export declare const safeSessionStorage: SafeStorage;
@@ -0,0 +1,2 @@
1
+ import { StoreProxyInterface } from "common/types/store";
2
+ export declare const store: StoreProxyInterface;
@@ -8492,7 +8492,7 @@ var client = new error_tracker_BrowserClient({
8492
8492
  return event;
8493
8493
  },
8494
8494
  environment: "production",
8495
- release: "13bc8b2f33318b3a38d1db0307b7c55c69adae5e",
8495
+ release: "baf21d027df93293d6a0676107fbf0c3396f42e2",
8496
8496
  sampleRate: 0.25,
8497
8497
  autoSessionTracking: false,
8498
8498
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -8778,7 +8778,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !(c
8778
8778
 
8779
8779
 
8780
8780
 
8781
-
8782
8781
  /**
8783
8782
  * Frame Channel: Used for postMessage communication between iFrames.
8784
8783
  * NOTE: iFrames must have the same domain - when postMessages are sent between
@@ -8843,7 +8842,6 @@ var FC = /*#__PURE__*/function (_Channel) {
8843
8842
  parsedData = JSON.parse(event.data);
8844
8843
  }
8845
8844
  } catch (_unused) {
8846
- (0,errors/* warn */.Z)("postMessage not sent as JSON.");
8847
8845
  return;
8848
8846
  }
8849
8847
 
@@ -8868,7 +8866,7 @@ var FC = /*#__PURE__*/function (_Channel) {
8868
8866
  key: "constructObjectToSend",
8869
8867
  value: function constructObjectToSend() {
8870
8868
  var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
8871
- var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8869
+ var payload = arguments.length > 1 ? arguments[1] : undefined;
8872
8870
  var id = arguments.length > 2 ? arguments[2] : undefined;
8873
8871
  var status = arguments.length > 3 ? arguments[3] : undefined;
8874
8872
  // IE passes event message data as a string, so we normalize to string for all objects
@@ -9023,7 +9021,7 @@ var CE = /*#__PURE__*/function (_Channel) {
9023
9021
  // (for all browsers)
9024
9022
  return {
9025
9023
  type: type || "",
9026
- payload: payload || {},
9024
+ payload: payload,
9027
9025
  id: id,
9028
9026
  status: status
9029
9027
  };
@@ -9178,7 +9176,7 @@ function getEmbedURL(_ref) {
9178
9176
  polyfillVersionString = "legacy";
9179
9177
  }
9180
9178
 
9181
- return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "13bc8b2", "/index.html");
9179
+ return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "baf21d0", "/index.html");
9182
9180
  }
9183
9181
  /**
9184
9182
  * Generate the Chat / API URL
@@ -9215,18 +9213,26 @@ function getURL(_ref2) {
9215
9213
  }
9216
9214
 
9217
9215
  if (includes_default()(_context17 = window.location.hostname).call(_context17, "localhost") || handle === "e2ereference") {
9218
- var _context18, _context19, _context20, _context21;
9216
+ var _context18, _context23, _context24, _context25;
9219
9217
 
9220
9218
  var host = window.location.hostname;
9221
9219
  var domainName = includes_default()(_context18 = window.location.hostname).call(_context18, "localhost") ? "localhost" : "e2ereference";
9222
9220
 
9221
+ if (domainName === "localhost" && name === "chat") {
9222
+ var _context19, _context20, _context21, _context22;
9223
+
9224
+ // Chat should be on a different domain (even though the port is different).
9225
+ // We need this to test Embed+Chat behaviour when third-party cookies are disabled (incognito mode).
9226
+ return concat_default()(_context19 = concat_default()(_context20 = concat_default()(_context21 = concat_default()(_context22 = "".concat(window.location.protocol, "//")).call(_context22, handle, ".chat:8002/")).call(_context21, routeString)).call(_context20, questionSym)).call(_context19, queryString);
9227
+ }
9228
+
9223
9229
  if (name === "api" || name === "chat") {
9224
9230
  host += ":".concat(ports[domainName][name]);
9225
9231
  } else {
9226
9232
  host += ":".concat(ports[domainName].default);
9227
9233
  }
9228
9234
 
9229
- return concat_default()(_context19 = concat_default()(_context20 = concat_default()(_context21 = "http://".concat(host, "/")).call(_context21, routeString)).call(_context20, questionSym)).call(_context19, queryString);
9235
+ return concat_default()(_context23 = concat_default()(_context24 = concat_default()(_context25 = "http://".concat(host, "/")).call(_context25, routeString)).call(_context24, questionSym)).call(_context23, queryString);
9230
9236
  }
9231
9237
 
9232
9238
  return prodUrl;
@@ -9319,6 +9325,122 @@ var actions = {
9319
9325
  }
9320
9326
  };
9321
9327
  /* harmony default export */ var store_actions = (actions);
9328
+ ;// CONCATENATED MODULE: ./src/common/constants/storage-keys.ts
9329
+ var CHATTER_TOKEN_STORAGE_KEY = "chatter";
9330
+ var CHATTER_CREATED_STORAGE_KEY = "ada-embed_chatter-created";
9331
+ var IN_LIVE_CHAT_STORAGE_KEY = "inLiveChat";
9332
+ var ZD_SESSION_STORAGE_KEY = "ada-embed_zd-session-id";
9333
+ var ZD_PREVIOUS_TAGS_STORAGE_KEY = "ada-embed_zd-previous-tags";
9334
+ var IS_DRAWER_OPEN_STORAGE_KEY = "ada-embed_is-drawer-open";
9335
+ /** @deprecated - Use CHATTER_TOKEN_STORAGE_KEY */
9336
+
9337
+ var CHATTER_STORAGE_KEY = CHATTER_TOKEN_STORAGE_KEY;
9338
+ ;// CONCATENATED MODULE: ./src/frames/lib/safe-storage/index.ts
9339
+
9340
+
9341
+
9342
+
9343
+
9344
+
9345
+ var StorageTypes;
9346
+
9347
+ (function (StorageTypes) {
9348
+ StorageTypes["Local"] = "local";
9349
+ StorageTypes["Session"] = "session";
9350
+ })(StorageTypes || (StorageTypes = {}));
9351
+
9352
+ /**
9353
+ * local and session storage can throw exceptions when trying to access them
9354
+ * from the Window object and third-party cookies are disabled. SafeStorage
9355
+ * wraps common Storage methods in try catch blocks.
9356
+ */
9357
+ var SafeStorage = /*#__PURE__*/function () {
9358
+ function SafeStorage(storageType) {
9359
+ (0,classCallCheck/* default */.Z)(this, SafeStorage);
9360
+
9361
+ (0,defineProperty/* default */.Z)(this, "storageType", void 0);
9362
+
9363
+ (0,defineProperty/* default */.Z)(this, "storage", null);
9364
+
9365
+ this.storageType = storageType;
9366
+
9367
+ try {
9368
+ this.storage = storageType === "local" ? window.localStorage : window.sessionStorage;
9369
+ } catch (e) {
9370
+ (0,errors/* warn */.Z)("".concat(this.storageType, "Storage is disabled. This is likely because your browser is blocking third-party cookies."));
9371
+ }
9372
+ } // eslint-disable-next-line class-methods-use-this
9373
+
9374
+
9375
+ _createClass(SafeStorage, [{
9376
+ key: "seralizeItem",
9377
+ value: function seralizeItem(value) {
9378
+ try {
9379
+ return stringify_default()(value);
9380
+ } catch (error) {
9381
+ (0,errors/* warn */.Z)("Attempt to seralize failed: ".concat(error));
9382
+ }
9383
+
9384
+ return null;
9385
+ } // eslint-disable-next-line class-methods-use-this
9386
+
9387
+ }, {
9388
+ key: "deserializeItem",
9389
+ value: function deserializeItem(value) {
9390
+ try {
9391
+ return JSON.parse(value);
9392
+ } catch (error) {
9393
+ (0,errors/* warn */.Z)("Attempt to deserialize failed: ".concat(error));
9394
+ }
9395
+
9396
+ return null;
9397
+ }
9398
+ }, {
9399
+ key: "getItem",
9400
+ value: function getItem(key) {
9401
+ try {
9402
+ if (!this.storage) {
9403
+ throw new errors/* AdaEmbedError */.S("`storage` is null");
9404
+ }
9405
+
9406
+ return this.deserializeItem(this.storage.getItem(key));
9407
+ } catch (e) {
9408
+ (0,errors/* warn */.Z)("Cannot getItem from ".concat(this.storageType, "Storage."));
9409
+ return null;
9410
+ }
9411
+ }
9412
+ }, {
9413
+ key: "setItem",
9414
+ value: function setItem(key, value) {
9415
+ try {
9416
+ if (!this.storage) {
9417
+ throw new errors/* AdaEmbedError */.S("`storage` is null");
9418
+ }
9419
+
9420
+ this.storage.setItem(key, this.seralizeItem(value));
9421
+ } catch (e) {
9422
+ (0,errors/* warn */.Z)("Cannot setItem in ".concat(this.storageType, "Storage."));
9423
+ }
9424
+ }
9425
+ }, {
9426
+ key: "removeItem",
9427
+ value: function removeItem(key) {
9428
+ try {
9429
+ if (!this.storage) {
9430
+ throw new errors/* AdaEmbedError */.S("`storage` is null");
9431
+ }
9432
+
9433
+ this.storage.removeItem(key);
9434
+ } catch (e) {
9435
+ (0,errors/* warn */.Z)("Cannot removeItem from ".concat(this.storageType, "Storage."));
9436
+ }
9437
+ }
9438
+ }]);
9439
+
9440
+ return SafeStorage;
9441
+ }();
9442
+ var safeLocalStorage = new SafeStorage(StorageTypes.Local);
9443
+ var safeSessionStorage = new SafeStorage(StorageTypes.Session);
9322
9444
  ;// CONCATENATED MODULE: ./src/client/store/mutations/index.ts
9323
9445
 
9324
9446
 
@@ -9335,6 +9457,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
9335
9457
 
9336
9458
 
9337
9459
 
9460
+
9461
+
9338
9462
  var mutations = function mutations(state, action) {
9339
9463
  switch (action.type) {
9340
9464
  case ActionTypes.TOGGLE_CHAT_TYPE:
@@ -9345,6 +9469,7 @@ var mutations = function mutations(state, action) {
9345
9469
  hasChatOpenedAfterProactiveMessagesShown = true;
9346
9470
  }
9347
9471
 
9472
+ safeLocalStorage.setItem(IS_DRAWER_OPEN_STORAGE_KEY, !state.isDrawerOpen);
9348
9473
  return _objectSpread(_objectSpread({}, state), {}, {
9349
9474
  isDrawerOpen: !state.isDrawerOpen,
9350
9475
  isIntroShown: false,
@@ -9472,6 +9597,13 @@ function notificationPermListener(notificationPermChangeHandler) {
9472
9597
  ;// CONCATENATED MODULE: ./src/client/store/state.ts
9473
9598
 
9474
9599
 
9600
+
9601
+
9602
+
9603
+ function getValueFromStorage(key) {
9604
+ return safeLocalStorage.getItem(key) || safeSessionStorage.getItem(key);
9605
+ }
9606
+
9475
9607
  var state = {
9476
9608
  handle: undefined,
9477
9609
  styles: undefined,
@@ -9495,7 +9627,10 @@ var state = {
9495
9627
  initialURL: undefined,
9496
9628
  privateMode: false,
9497
9629
  rolloutOverride: undefined,
9498
- chatterToken: undefined,
9630
+ chatterToken: getValueFromStorage(CHATTER_TOKEN_STORAGE_KEY) || undefined,
9631
+ chatterCreated: getValueFromStorage(CHATTER_CREATED_STORAGE_KEY) || undefined,
9632
+ zdSessionId: getValueFromStorage(ZD_SESSION_STORAGE_KEY) || undefined,
9633
+ zdPreviousTags: getValueFromStorage(ZD_PREVIOUS_TAGS_STORAGE_KEY) || undefined,
9499
9634
  connections: {},
9500
9635
  appConnectionState: ConnectionState.Uninitiated,
9501
9636
  testMode: false,
@@ -9877,111 +10012,6 @@ var get_browser_language_getBrowserLanguage = function getBrowserLanguage() {
9877
10012
  };
9878
10013
 
9879
10014
  /* harmony default export */ var get_browser_language = (get_browser_language_getBrowserLanguage);
9880
- ;// CONCATENATED MODULE: ./src/frames/lib/safe-storage/index.ts
9881
-
9882
-
9883
-
9884
-
9885
-
9886
- var StorageTypes;
9887
-
9888
- (function (StorageTypes) {
9889
- StorageTypes["Local"] = "local";
9890
- StorageTypes["Session"] = "session";
9891
- })(StorageTypes || (StorageTypes = {}));
9892
-
9893
- /**
9894
- * local and session storage can throw exceptions when trying to access them
9895
- * from the Window object and third-party cookies are disabled. SafeStorage
9896
- * wraps common Storage methods in try catch blocks.
9897
- */
9898
- var SafeStorage = /*#__PURE__*/function () {
9899
- function SafeStorage(storageType) {
9900
- (0,classCallCheck/* default */.Z)(this, SafeStorage);
9901
-
9902
- (0,defineProperty/* default */.Z)(this, "storageType", void 0);
9903
-
9904
- (0,defineProperty/* default */.Z)(this, "storage", null);
9905
-
9906
- this.storageType = storageType;
9907
-
9908
- try {
9909
- this.storage = storageType === "local" ? window.localStorage : window.sessionStorage;
9910
- } catch (e) {
9911
- (0,errors/* warn */.Z)("".concat(this.storageType, "Storage is disabled. This is likely because your browser is blocking third-party cookies."));
9912
- }
9913
- } // eslint-disable-next-line class-methods-use-this
9914
-
9915
-
9916
- _createClass(SafeStorage, [{
9917
- key: "seralizeItem",
9918
- value: function seralizeItem(value) {
9919
- try {
9920
- return stringify_default()(value);
9921
- } catch (error) {
9922
- (0,errors/* warn */.Z)("Attempt to seralize failed: ".concat(error));
9923
- }
9924
-
9925
- return null;
9926
- } // eslint-disable-next-line class-methods-use-this
9927
-
9928
- }, {
9929
- key: "deserializeItem",
9930
- value: function deserializeItem(value) {
9931
- try {
9932
- return JSON.parse(value);
9933
- } catch (error) {
9934
- (0,errors/* warn */.Z)("Attempt to deserialize failed: ".concat(error));
9935
- }
9936
-
9937
- return null;
9938
- }
9939
- }, {
9940
- key: "getItem",
9941
- value: function getItem(key) {
9942
- try {
9943
- if (!this.storage) {
9944
- throw new errors/* AdaEmbedError */.S("`storage` is null");
9945
- }
9946
-
9947
- return this.deserializeItem(this.storage.getItem(key));
9948
- } catch (e) {
9949
- (0,errors/* warn */.Z)("Cannot getItem from ".concat(this.storageType, "Storage."));
9950
- return null;
9951
- }
9952
- }
9953
- }, {
9954
- key: "setItem",
9955
- value: function setItem(key, value) {
9956
- try {
9957
- if (!this.storage) {
9958
- throw new errors/* AdaEmbedError */.S("`storage` is null");
9959
- }
9960
-
9961
- this.storage.setItem(key, this.seralizeItem(value));
9962
- } catch (e) {
9963
- (0,errors/* warn */.Z)("Cannot setItem in ".concat(this.storageType, "Storage."));
9964
- }
9965
- }
9966
- }, {
9967
- key: "removeItem",
9968
- value: function removeItem(key) {
9969
- try {
9970
- if (!this.storage) {
9971
- throw new errors/* AdaEmbedError */.S("`storage` is null");
9972
- }
9973
-
9974
- this.storage.removeItem(key);
9975
- } catch (e) {
9976
- (0,errors/* warn */.Z)("Cannot removeItem from ".concat(this.storageType, "Storage."));
9977
- }
9978
- }
9979
- }]);
9980
-
9981
- return SafeStorage;
9982
- }();
9983
- var safeLocalStorage = new SafeStorage(StorageTypes.Local);
9984
- var safeSessionStorage = new SafeStorage(StorageTypes.Session);
9985
10015
  // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/instance/trim.js
9986
10016
  var trim = __webpack_require__(5843);
9987
10017
  var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
@@ -10610,9 +10640,6 @@ function bindActionCreators(action, dispatch) {
10610
10640
  return dispatch(action, payload);
10611
10641
  };
10612
10642
  }
10613
- ;// CONCATENATED MODULE: ./src/common/constants/storage-keys.ts
10614
- var CHATTER_STORAGE_KEY = "chatter";
10615
- var IN_LIVE_CHAT_STORAGE_KEY = "inLiveChat";
10616
10643
  ;// CONCATENATED MODULE: ./src/common/helpers/fetch-client.ts
10617
10644
 
10618
10645
 
@@ -11138,13 +11165,15 @@ var ButtonFrame = /*#__PURE__*/function (_Component) {
11138
11165
  return "";
11139
11166
  }
11140
11167
 
11141
- var delayedIsShown = this.state.delayedIsShown; // 56 = (SHADOW BLUR=48) + (2 * SPREAD=8)
11168
+ var delayedIsShown = this.state.delayedIsShown; // 48 = (SHADOW BLUR=40) + (2 * SPREAD=8)
11142
11169
 
11143
- var BOX_SHADOW_BUFFER = client.features.chat_ui_v2 ? 56 : 8;
11170
+ var BOX_SHADOW_BUFFER = client.features.chat_ui_v2 ? 48 : 8;
11144
11171
  var POSITION_FROM_SCREEN_EDGE = 24;
11145
11172
  var buttonSizeWithBuffer = buttonSize + BOX_SHADOW_BUFFER;
11146
11173
  var buttonPosition = POSITION_FROM_SCREEN_EDGE - BOX_SHADOW_BUFFER / 2;
11147
- var frameHeight = buttonSize + BOX_SHADOW_BUFFER;
11174
+ var roundFrameHeight = buttonSize + BOX_SHADOW_BUFFER; // text button has a fixed height of 44px
11175
+
11176
+ var textFrameHeight = 44 + BOX_SHADOW_BUFFER;
11148
11177
  var stylesForHiding = "\n top: -9999px !important;\n left: -9999px !important;\n ";
11149
11178
 
11150
11179
  var styles = concat_default()(_context2 = concat_default()(_context3 = concat_default()(_context4 = concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "\n position: fixed;\n bottom: ".concat(buttonPosition, "px;\n ")).call(_context7, getAlignment(adaSettings), ": ")).call(_context6, buttonPosition, "px;\n z-index: 10000;\n height: ")).call(_context5, buttonSizeWithBuffer, "px;\n width: ")).call(_context4, buttonSizeWithBuffer, "px;\n overflow: hidden;\n visibility: ")).call(_context3, this.isShown ? "visible" : "hidden", ";\n opacity: ")).call(_context2, this.isShown ? "1" : "0", ";\n transition: visibility 200ms ease, opacity 200ms ease;\n ");
@@ -11157,11 +11186,11 @@ var ButtonFrame = /*#__PURE__*/function (_Component) {
11157
11186
  if (buttonStyle === "text") {
11158
11187
  var _context9;
11159
11188
 
11160
- styles += concat_default()(_context9 = "\n width: ".concat(frameWidth, "px;\n height: ")).call(_context9, frameHeight, "px;\n ");
11189
+ styles += concat_default()(_context9 = "\n width: ".concat(frameWidth, "px;\n height: ")).call(_context9, textFrameHeight, "px;\n ");
11161
11190
  } else {
11162
11191
  var _context10;
11163
11192
 
11164
- styles += concat_default()(_context10 = "\n width: ".concat(frameHeight, "px;\n height: ")).call(_context10, frameHeight, "px;\n ");
11193
+ styles += concat_default()(_context10 = "\n width: ".concat(roundFrameHeight, "px;\n height: ")).call(_context10, roundFrameHeight, "px;\n ");
11165
11194
  }
11166
11195
  }
11167
11196
 
@@ -11252,6 +11281,7 @@ function ChatFrame_isNativeReflectConstruct() { if (typeof Reflect === "undefine
11252
11281
 
11253
11282
 
11254
11283
 
11284
+
11255
11285
  var ChatFrame = /*#__PURE__*/function (_Component) {
11256
11286
  (0,inherits/* default */.Z)(ChatFrame, _Component);
11257
11287
 
@@ -11442,7 +11472,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11442
11472
  adaSettings = _this$props5.adaSettings; // delta is used to determine how much of the button's height should be ignored
11443
11473
  // when spacing the proactive message
11444
11474
 
11445
- var delta = 14;
11475
+ var delta = 3;
11446
11476
  var TEXT_BUTTON_HEIGHT = 44;
11447
11477
  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 = client.chat_button) === null || _client$chat_button === void 0 ? void 0 : _client$chat_button.size) - delta;
11448
11478
  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 ");
@@ -11580,7 +11610,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11580
11610
  var _handleChatEvent = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee(type, payload, id) {
11581
11611
  var _this4 = this;
11582
11612
 
11583
- var _this$props8, adaSettings, setState, setConnectionState, _ref, eventKey, data, _ref2, analytics, analyticsCallback, client, _ref3, chatter, chatterTokenCallback, _client, _ref4, inLiveChat, eventCallbacks, customJavascriptEvent, specificCallback, genericCallback, resetChat, zdChatterAuthCallback, conversationEndCallback;
11613
+ var _this$props8, adaSettings, setState, setConnectionState, _ref, eventKey, data, _ref2, analytics, analyticsCallback, client, _ref3, chatter, created, chatterTokenCallback, _client, _ref4, zdSessionId, zdPreviousTags, storage, _client2, _ref5, inLiveChat, eventCallbacks, customJavascriptEvent, specificCallback, genericCallback, resetChat, zdChatterAuthCallback, conversationEndCallback;
11584
11614
 
11585
11615
  return regenerator_default().wrap(function _callee$(_context22) {
11586
11616
  while (1) {
@@ -11588,30 +11618,30 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11588
11618
  case 0:
11589
11619
  _this$props8 = this.props, adaSettings = _this$props8.adaSettings, setState = _this$props8.setState, setConnectionState = _this$props8.setConnectionState;
11590
11620
  _context22.t0 = type;
11591
- _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 === CHATTER_LIVECHAT_EVENT ? 26 : _context22.t0 === CUSTOM_JAVASCRIPT_EVENT ? 32 : _context22.t0 === RESET_FROM_CHAT_EVENT ? 41 : _context22.t0 === ZD_JWT_AUTH_EVENT ? 44 : _context22.t0 === CREATE_NOTIFICATION_EVENT ? 47 : _context22.t0 === BROWSER_HAS_NOTIFICATIONS_EVENT ? 49 : _context22.t0 === REQUEST_NOTIFICATIONS_EVENT ? 51 : _context22.t0 === END_CONVERSATION_EVENT ? 53 : 56;
11621
+ _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;
11592
11622
  break;
11593
11623
 
11594
11624
  case 4:
11595
11625
  this.channel.postMessage("SET_WINDOW_ORIGIN", window.location, id);
11596
- return _context22.abrupt("break", 57);
11626
+ return _context22.abrupt("break", 68);
11597
11627
 
11598
11628
  case 6:
11599
11629
  this.channel.isConnected = true;
11600
11630
  setConnectionState({
11601
11631
  "chat": ConnectionState.Done
11602
11632
  });
11603
- return _context22.abrupt("break", 57);
11633
+ return _context22.abrupt("break", 68);
11604
11634
 
11605
11635
  case 9:
11606
11636
  setState({
11607
11637
  isChatWebsocketConnected: true
11608
11638
  });
11609
- return _context22.abrupt("break", 57);
11639
+ return _context22.abrupt("break", 68);
11610
11640
 
11611
11641
  case 11:
11612
11642
  _ref = payload, eventKey = _ref.eventKey, data = _ref.data;
11613
11643
  publishEvent(eventKey, data);
11614
- return _context22.abrupt("break", 57);
11644
+ return _context22.abrupt("break", 68);
11615
11645
 
11616
11646
  case 14:
11617
11647
  _ref2 = payload, analytics = _ref2.analytics;
@@ -11621,66 +11651,124 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11621
11651
  analyticsCallback(analytics);
11622
11652
  }
11623
11653
 
11624
- return _context22.abrupt("break", 57);
11654
+ return _context22.abrupt("break", 68);
11625
11655
 
11626
11656
  case 18:
11627
11657
  client = this.props.client;
11628
- _ref3 = payload, chatter = _ref3.chatter;
11658
+ _ref3 = payload, chatter = _ref3.chatter, created = _ref3.created;
11629
11659
  chatterTokenCallback = adaSettings.chatterTokenCallback;
11630
- _context22.next = 23;
11660
+
11661
+ if (client) {
11662
+ _context22.next = 23;
11663
+ break;
11664
+ }
11665
+
11666
+ throw new errors/* AdaEmbedError */.S("`client` is undefined");
11667
+
11668
+ case 23:
11669
+ _context22.next = 25;
11631
11670
  return setState({
11632
- chatterToken: chatter
11671
+ chatterToken: chatter,
11672
+ chatterCreated: created
11633
11673
  });
11634
11674
 
11635
- case 23:
11675
+ case 25:
11636
11676
  /**
11637
11677
  * Store the token so when embed loads in the future, it doesn't have to wait for it to
11638
11678
  * come from chat. This is important for campaign and business event triggers.
11639
11679
  */
11640
11680
  if (client.persistence === PERSISTENCE_NORMAL) {
11641
11681
  safeLocalStorage.setItem(CHATTER_STORAGE_KEY, chatter);
11682
+ safeLocalStorage.setItem(CHATTER_CREATED_STORAGE_KEY, created);
11642
11683
  } else if (client.persistence === PERSISTENCE_SESSION) {
11643
11684
  safeSessionStorage.setItem(CHATTER_STORAGE_KEY, chatter);
11685
+ safeSessionStorage.setItem(CHATTER_CREATED_STORAGE_KEY, created);
11644
11686
  }
11645
11687
 
11646
11688
  if (chatterTokenCallback) {
11647
11689
  chatterTokenCallback(chatter);
11648
11690
  }
11649
11691
 
11650
- return _context22.abrupt("break", 57);
11692
+ return _context22.abrupt("break", 68);
11651
11693
 
11652
- case 26:
11694
+ case 28:
11653
11695
  _client = this.props.client;
11654
- _ref4 = payload, inLiveChat = _ref4.inLiveChat;
11655
- _context22.next = 30;
11696
+ _ref4 = payload, zdSessionId = _ref4.zdSessionId, zdPreviousTags = _ref4.zdPreviousTags;
11697
+
11698
+ if (_client) {
11699
+ _context22.next = 32;
11700
+ break;
11701
+ }
11702
+
11703
+ throw new errors/* AdaEmbedError */.S("`client` is undefined");
11704
+
11705
+ case 32:
11706
+ _context22.next = 34;
11707
+ return setState({
11708
+ zdSessionId: zdSessionId
11709
+ });
11710
+
11711
+ case 34:
11712
+ storage = function () {
11713
+ if (_client.persistence === PERSISTENCE_NORMAL) {
11714
+ return safeLocalStorage;
11715
+ }
11716
+
11717
+ if (_client.persistence === PERSISTENCE_SESSION) {
11718
+ return safeSessionStorage;
11719
+ }
11720
+
11721
+ return null;
11722
+ }();
11723
+
11724
+ if (storage) {
11725
+ if (zdSessionId === null) {
11726
+ storage.removeItem(ZD_SESSION_STORAGE_KEY);
11727
+ } else {
11728
+ storage.setItem(ZD_SESSION_STORAGE_KEY, zdSessionId);
11729
+ }
11730
+
11731
+ if (zdPreviousTags === null) {
11732
+ storage.removeItem(ZD_PREVIOUS_TAGS_STORAGE_KEY);
11733
+ } else {
11734
+ storage.setItem(ZD_PREVIOUS_TAGS_STORAGE_KEY, zdPreviousTags);
11735
+ }
11736
+ }
11737
+
11738
+ return _context22.abrupt("break", 68);
11739
+
11740
+ case 37:
11741
+ _client2 = this.props.client;
11742
+ _ref5 = payload, inLiveChat = _ref5.inLiveChat;
11743
+ _context22.next = 41;
11656
11744
  return setState({
11657
11745
  chatterInLiveChat: inLiveChat
11658
11746
  });
11659
11747
 
11660
- case 30:
11748
+ case 41:
11661
11749
  /**
11662
11750
  * Store the token so when embed loads in the future, it doesn't have to wait for it to
11663
11751
  * come from chat. This is important for campaign and business event triggers.
11664
11752
  */
11665
- if (_client.persistence === PERSISTENCE_NORMAL) {
11753
+ if (_client2.persistence === PERSISTENCE_NORMAL) {
11666
11754
  safeLocalStorage.setItem(IN_LIVE_CHAT_STORAGE_KEY, inLiveChat);
11667
- } else if (_client.persistence === PERSISTENCE_SESSION) {
11755
+ } else if (_client2.persistence === PERSISTENCE_SESSION) {
11668
11756
  safeSessionStorage.setItem(IN_LIVE_CHAT_STORAGE_KEY, inLiveChat);
11669
11757
  }
11670
11758
 
11671
- return _context22.abrupt("break", 57);
11759
+ return _context22.abrupt("break", 68);
11672
11760
 
11673
- case 32:
11761
+ case 43:
11674
11762
  eventCallbacks = adaSettings.eventCallbacks;
11675
11763
 
11676
11764
  if (eventCallbacks) {
11677
- _context22.next = 35;
11765
+ _context22.next = 46;
11678
11766
  break;
11679
11767
  }
11680
11768
 
11681
- return _context22.abrupt("break", 57);
11769
+ return _context22.abrupt("break", 68);
11682
11770
 
11683
- case 35:
11771
+ case 46:
11684
11772
  customJavascriptEvent = payload.event_data;
11685
11773
  specificCallback = eventCallbacks[customJavascriptEvent.event_name];
11686
11774
  genericCallback = eventCallbacks["*"];
@@ -11693,14 +11781,14 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11693
11781
  genericCallback(customJavascriptEvent);
11694
11782
  }
11695
11783
 
11696
- return _context22.abrupt("break", 57);
11784
+ return _context22.abrupt("break", 68);
11697
11785
 
11698
- case 41:
11786
+ case 52:
11699
11787
  resetChat = this.props.resetChat;
11700
11788
  resetChat();
11701
- return _context22.abrupt("break", 57);
11789
+ return _context22.abrupt("break", 68);
11702
11790
 
11703
- case 44:
11791
+ case 55:
11704
11792
  zdChatterAuthCallback = adaSettings.zdChatterAuthCallback;
11705
11793
 
11706
11794
  if (zdChatterAuthCallback) {
@@ -11718,35 +11806,35 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11718
11806
  this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
11719
11807
  }
11720
11808
 
11721
- return _context22.abrupt("break", 57);
11809
+ return _context22.abrupt("break", 68);
11722
11810
 
11723
- case 47:
11811
+ case 58:
11724
11812
  this.handleNotifications(payload);
11725
- return _context22.abrupt("break", 57);
11813
+ return _context22.abrupt("break", 68);
11726
11814
 
11727
- case 49:
11815
+ case 60:
11728
11816
  this.channel.postMessage(BROWSER_HAS_NOTIFICATIONS_RESPONSE_EVENT, {
11729
11817
  browserHasNotificationSupport: browserHasNotificationSupport
11730
11818
  });
11731
- return _context22.abrupt("break", 57);
11819
+ return _context22.abrupt("break", 68);
11732
11820
 
11733
- case 51:
11821
+ case 62:
11734
11822
  requestNotificationPermission();
11735
- return _context22.abrupt("break", 57);
11823
+ return _context22.abrupt("break", 68);
11736
11824
 
11737
- case 53:
11825
+ case 64:
11738
11826
  conversationEndCallback = adaSettings.conversationEndCallback;
11739
11827
 
11740
11828
  if (conversationEndCallback) {
11741
11829
  conversationEndCallback(payload);
11742
11830
  }
11743
11831
 
11744
- return _context22.abrupt("break", 57);
11832
+ return _context22.abrupt("break", 68);
11745
11833
 
11746
- case 56:
11747
- return _context22.abrupt("break", 57);
11834
+ case 67:
11835
+ return _context22.abrupt("break", 68);
11748
11836
 
11749
- case 57:
11837
+ case 68:
11750
11838
  case "end":
11751
11839
  return _context22.stop();
11752
11840
  }
@@ -12166,6 +12254,7 @@ function Container_isNativeReflectConstruct() { if (typeof Reflect === "undefine
12166
12254
 
12167
12255
 
12168
12256
 
12257
+
12169
12258
 
12170
12259
 
12171
12260
  var Container = /*#__PURE__*/function (_Component) {
@@ -12294,7 +12383,6 @@ var Container = /*#__PURE__*/function (_Component) {
12294
12383
  campaignToTrigger = _this$state.campaignToTrigger,
12295
12384
  campaignTriggerOptions = _this$state.campaignTriggerOptions,
12296
12385
  followUpResponseId = _this$state.followUpResponseId;
12297
- var chatChannel = messageService.getChannel(CHAT_IFRAME);
12298
12386
  /* We wait for all necessary preconditions (e.g. necessary connections established) to be true,
12299
12387
  * then trigger the campaign. campaignToTrigger is cleared after triggering, so we do not need
12300
12388
  * to worry about duplicate triggers.
@@ -12317,13 +12405,17 @@ var Container = /*#__PURE__*/function (_Component) {
12317
12405
  } // If a follow-up response has been queued by a triggered Campaign, tell chat to show it
12318
12406
 
12319
12407
 
12320
- if (chatChannel && isChatWebsocketConnected && isDrawerOpen && followUpResponseId) {
12321
- chatChannel.postMessage(SEND_GREETING, {
12322
- responseId: followUpResponseId
12323
- });
12324
- this.setState({
12325
- followUpResponseId: null
12326
- });
12408
+ if (isChatWebsocketConnected && isDrawerOpen && followUpResponseId) {
12409
+ var chatChannel = messageService.getChannel(CHAT_IFRAME);
12410
+
12411
+ if (chatChannel) {
12412
+ chatChannel.postMessage(SEND_GREETING, {
12413
+ responseId: followUpResponseId
12414
+ });
12415
+ this.setState({
12416
+ followUpResponseId: null
12417
+ });
12418
+ }
12327
12419
  }
12328
12420
 
12329
12421
  if (prevProps.isDrawerOpen !== isDrawerOpen && toggleCallback) {
@@ -12532,7 +12624,7 @@ var Container = /*#__PURE__*/function (_Component) {
12532
12624
  var _handleEmbedAction = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee2(type, payload, id) {
12533
12625
  var _this5 = this;
12534
12626
 
12535
- var _this$props9, client, messageService, adaSettings, parentElement, localChannel, xStorageChannel, toggleChat, _this$props10, isDrawerOpen, drawerHasBeenOpened, chatterToken, contentToReturn, _this$props11, metaFields, setState, metaData, newMetaFields, _this$props12, sensitiveMetaFields, _setState, _ref, greeting, language, _newMetaFields, _sensitiveMetaFields, _ref$resetChatHistory, resetChatHistory, _setState2, chatHasBeenRendered, _ref2, body, duration, EXTRA_PROACTIVE_DELAY, canCreateProactive;
12627
+ var _this$props9, client, messageService, adaSettings, parentElement, localChannel, xStorageChannel, toggleChat, _this$props10, isDrawerOpen, drawerHasBeenOpened, chatterToken, contentToReturn, _this$props11, metaFields, setState, metaData, newMetaFields, _this$props12, sensitiveMetaFields, _setState, _ref, greeting, language, _newMetaFields, _sensitiveMetaFields, _ref$resetChatHistory, resetChatHistory, _setState2, chatHasBeenRendered, newState, _setState3, _ref2, body, duration, EXTRA_PROACTIVE_DELAY, canCreateProactive;
12536
12628
 
12537
12629
  return regenerator_default().wrap(function _callee2$(_context3) {
12538
12630
  while (1) {
@@ -12552,7 +12644,7 @@ var Container = /*#__PURE__*/function (_Component) {
12552
12644
 
12553
12645
  case 6:
12554
12646
  _context3.t0 = type;
12555
- _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 ? 60 : _context3.t0 === CREATE_PROACTIVE ? 65 : 76;
12647
+ _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;
12556
12648
  break;
12557
12649
 
12558
12650
  case 9:
@@ -12566,7 +12658,7 @@ var Container = /*#__PURE__*/function (_Component) {
12566
12658
 
12567
12659
  case 12:
12568
12660
  this.trackEvent(payload);
12569
- return _context3.abrupt("break", 76);
12661
+ return _context3.abrupt("break", 89);
12570
12662
 
12571
12663
  case 14:
12572
12664
  if (client.features.afm_proactive_messaging) {
@@ -12579,7 +12671,7 @@ var Container = /*#__PURE__*/function (_Component) {
12579
12671
 
12580
12672
  case 17:
12581
12673
  this.triggerCampaign(payload);
12582
- return _context3.abrupt("break", 76);
12674
+ return _context3.abrupt("break", 89);
12583
12675
 
12584
12676
  case 19:
12585
12677
  if (client.features.afm_proactive_messaging) {
@@ -12592,7 +12684,7 @@ var Container = /*#__PURE__*/function (_Component) {
12592
12684
 
12593
12685
  case 22:
12594
12686
  this.evaluateCampaignConditions(payload);
12595
- return _context3.abrupt("break", 76);
12687
+ return _context3.abrupt("break", 89);
12596
12688
 
12597
12689
  case 24:
12598
12690
  toggleChat = this.props.toggleChat;
@@ -12601,7 +12693,7 @@ var Container = /*#__PURE__*/function (_Component) {
12601
12693
 
12602
12694
  case 27:
12603
12695
  localChannel.postMessage(TOGGLE_RESPONSE, null, id);
12604
- return _context3.abrupt("break", 76);
12696
+ return _context3.abrupt("break", 89);
12605
12697
 
12606
12698
  case 29:
12607
12699
  _this$props10 = this.props, isDrawerOpen = _this$props10.isDrawerOpen, drawerHasBeenOpened = _this$props10.drawerHasBeenOpened, chatterToken = _this$props10.chatterToken;
@@ -12612,7 +12704,7 @@ var Container = /*#__PURE__*/function (_Component) {
12612
12704
  hasClosedChat: drawerHasBeenOpened && !isDrawerOpen
12613
12705
  };
12614
12706
  localChannel.postMessage(GET_INFO_RESPONSE, contentToReturn, id);
12615
- return _context3.abrupt("break", 76);
12707
+ return _context3.abrupt("break", 89);
12616
12708
 
12617
12709
  case 33:
12618
12710
  _this$props11 = this.props, metaFields = _this$props11.metaFields, setState = _this$props11.setState;
@@ -12625,7 +12717,7 @@ var Container = /*#__PURE__*/function (_Component) {
12625
12717
 
12626
12718
  case 38:
12627
12719
  localChannel.postMessage(SET_META_FIELDS_RESPONSE, null, id);
12628
- return _context3.abrupt("break", 76);
12720
+ return _context3.abrupt("break", 89);
12629
12721
 
12630
12722
  case 40:
12631
12723
  _this$props12 = this.props, sensitiveMetaFields = _this$props12.sensitiveMetaFields, _setState = _this$props12.setState;
@@ -12636,42 +12728,54 @@ var Container = /*#__PURE__*/function (_Component) {
12636
12728
 
12637
12729
  case 43:
12638
12730
  localChannel.postMessage("SET_SENSITIVE_META_FIELDS_RESPONSE", null, id);
12639
- return _context3.abrupt("break", 76);
12731
+ return _context3.abrupt("break", 89);
12640
12732
 
12641
12733
  case 45:
12642
12734
  localChannel.postMessage(STOP_RESPONSE, null, id);
12643
12735
  this.unmount();
12644
- return _context3.abrupt("break", 76);
12736
+ return _context3.abrupt("break", 89);
12645
12737
 
12646
12738
  case 48:
12647
12739
  _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;
12648
12740
  _setState2 = this.props.setState;
12649
12741
  chatHasBeenRendered = this.state.chatHasBeenRendered;
12650
- _context3.next = 53;
12651
- return _setState2({
12742
+ newState = {
12652
12743
  greeting: greeting,
12653
12744
  language: language,
12654
12745
  metaFields: _newMetaFields,
12655
12746
  sensitiveMetaFields: _sensitiveMetaFields
12656
- });
12747
+ };
12657
12748
 
12658
- case 53:
12659
12749
  if (!resetChatHistory) {
12660
- _context3.next = 57;
12750
+ _context3.next = 61;
12661
12751
  break;
12662
12752
  }
12663
12753
 
12664
12754
  if (xStorageChannel) {
12665
- _context3.next = 56;
12755
+ _context3.next = 55;
12666
12756
  break;
12667
12757
  }
12668
12758
 
12669
12759
  throw new errors/* AdaEmbedError */.S("`xStorageChannel` is null");
12670
12760
 
12671
- case 56:
12672
- xStorageChannel.postMessage(DELETE_HISTORY_EVENT);
12761
+ case 55:
12762
+ xStorageChannel.postMessage(DELETE_HISTORY_EVENT); // Clear chatter data from local storage
12673
12763
 
12674
- case 57:
12764
+ safeLocalStorage.removeItem(CHATTER_TOKEN_STORAGE_KEY);
12765
+ safeSessionStorage.removeItem(CHATTER_TOKEN_STORAGE_KEY);
12766
+ safeLocalStorage.removeItem(CHATTER_CREATED_STORAGE_KEY);
12767
+ safeSessionStorage.removeItem(CHATTER_CREATED_STORAGE_KEY); // And from state
12768
+
12769
+ newState = Container_objectSpread(Container_objectSpread({}, newState), {}, {
12770
+ chatterToken: null,
12771
+ chatterCreated: null
12772
+ });
12773
+
12774
+ case 61:
12775
+ _context3.next = 63;
12776
+ return _setState2(newState);
12777
+
12778
+ case 63:
12675
12779
  if (chatHasBeenRendered) {
12676
12780
  this.setState({
12677
12781
  hideChatOverride: true
@@ -12683,36 +12787,51 @@ var Container = /*#__PURE__*/function (_Component) {
12683
12787
  }
12684
12788
 
12685
12789
  localChannel.postMessage(RESET_RESPONSE, null, id);
12686
- return _context3.abrupt("break", 76);
12790
+ return _context3.abrupt("break", 89);
12791
+
12792
+ case 66:
12793
+ _setState3 = this.props.setState;
12687
12794
 
12688
- case 60:
12689
12795
  if (xStorageChannel) {
12690
- _context3.next = 62;
12796
+ _context3.next = 69;
12691
12797
  break;
12692
12798
  }
12693
12799
 
12694
12800
  throw new errors/* AdaEmbedError */.S("`xStorageChannel` is null");
12695
12801
 
12696
- case 62:
12802
+ case 69:
12803
+ // Clear chatter data from local storage
12804
+ safeLocalStorage.removeItem(CHATTER_TOKEN_STORAGE_KEY);
12805
+ safeSessionStorage.removeItem(CHATTER_TOKEN_STORAGE_KEY);
12806
+ safeLocalStorage.removeItem(CHATTER_CREATED_STORAGE_KEY);
12807
+ safeSessionStorage.removeItem(CHATTER_CREATED_STORAGE_KEY); // And from state
12808
+
12809
+ _context3.next = 75;
12810
+ return _setState3({
12811
+ chatterToken: null,
12812
+ chatterCreated: null
12813
+ });
12814
+
12815
+ case 75:
12697
12816
  xStorageChannel.postMessage(DELETE_HISTORY_EVENT);
12698
12817
  localChannel.postMessage(DELETE_HISTORY_RESPONSE, null, id);
12699
- return _context3.abrupt("break", 76);
12818
+ return _context3.abrupt("break", 89);
12700
12819
 
12701
- case 65:
12820
+ case 78:
12702
12821
  _ref2 = payload, body = _ref2.body, duration = _ref2.duration;
12703
12822
  EXTRA_PROACTIVE_DELAY = 1000; // Free tier campaigns re-use the createProactive infrastructure
12704
12823
 
12705
12824
  canCreateProactive = client.features.developer_proactive || client.features.afm_proactive_messaging_free_tier;
12706
12825
 
12707
12826
  if (canCreateProactive) {
12708
- _context3.next = 71;
12827
+ _context3.next = 84;
12709
12828
  break;
12710
12829
  }
12711
12830
 
12712
12831
  localChannel.postMessage(CREATE_PROACTIVE_RESPONSE, "Ada Embed - Proactive intros are not available in your feature set.", id, FetchEventStatus.Failure);
12713
12832
  return _context3.abrupt("return");
12714
12833
 
12715
- case 71:
12834
+ case 84:
12716
12835
  this.setState({
12717
12836
  hideIntroOverride: true
12718
12837
  }, /*#__PURE__*/(0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee() {
@@ -12750,14 +12869,14 @@ var Container = /*#__PURE__*/function (_Component) {
12750
12869
  }
12751
12870
  }, _callee);
12752
12871
  })));
12753
- _context3.next = 74;
12872
+ _context3.next = 87;
12754
12873
  return wait(duration * 1000 + EXTRA_PROACTIVE_DELAY);
12755
12874
 
12756
- case 74:
12875
+ case 87:
12757
12876
  localChannel.postMessage(CREATE_PROACTIVE_RESPONSE, null, id);
12758
- return _context3.abrupt("break", 76);
12877
+ return _context3.abrupt("break", 89);
12759
12878
 
12760
- case 76:
12879
+ case 89:
12761
12880
  case "end":
12762
12881
  return _context3.stop();
12763
12882
  }
@@ -13726,7 +13845,7 @@ window.__AdaEmbedConstructor = Embed;
13726
13845
  /* harmony export */ });
13727
13846
  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);
13728
13847
  var isProduction = "production" === "production";
13729
- var embed2Version = "13bc8b2";
13848
+ var embed2Version = "baf21d0";
13730
13849
 
13731
13850
  /***/ }),
13732
13851
 
@@ -23123,7 +23242,7 @@ function _loadEmbed() {
23123
23242
  polyfillVersionString = "legacy";
23124
23243
  }
23125
23244
 
23126
- embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "13bc8b2", "/index.js");
23245
+ embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "baf21d0", "/index.js");
23127
23246
  }
23128
23247
 
23129
23248
  clientScriptExists = Boolean( true || // The client script is bundled with npm module
@@ -23250,10 +23369,10 @@ function createEmbedObject() {
23250
23369
  handle: adaSettings.handle,
23251
23370
  embedVersion: 2,
23252
23371
  embedSettings: adaSettings,
23253
- version: "1.0.31",
23372
+ version: "1.0.35",
23254
23373
  isNpm: true,
23255
23374
  hostPage: window.location.href,
23256
- commitHash: "13bc8b2"
23375
+ commitHash: "baf21d0"
23257
23376
  }, {
23258
23377
  sampleRate: 0.01 // 1% of logs will go through
23259
23378
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.0.31",
3
+ "version": "1.0.35",
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 30",
13
+ "lint": "tsc --noEmit --strict false && ./node_modules/.bin/eslint --report-unused-disable-directives --ext .js,.jsx,.ts,.tsx . --max-warnings 26",
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",
@@ -72,7 +72,7 @@
72
72
  "babel-preset-preact": "^2.0.0",
73
73
  "browserslist": "^4.17.4",
74
74
  "browserslist-useragent-regexp": "^3.0.2",
75
- "cypress": "^8.6.0",
75
+ "cypress": "^9.1.0",
76
76
  "enzyme": "^3.11.0",
77
77
  "enzyme-adapter-preact-pure": "^2.2.0",
78
78
  "eslint-plugin-chai-friendly": "^0.7.2",
@@ -86,8 +86,8 @@
86
86
  "npm-run-all": "^4.1.5",
87
87
  "start-server-and-test": "^1.14.0",
88
88
  "svg-inline-loader": "^0.8.0",
89
- "testcafe": "^1.15.3",
90
- "testcafe-browser-provider-lambdatest": "^2.0.5",
89
+ "testcafe": "^1.17.1",
90
+ "testcafe-browser-provider-lambdatest": "2.0.5",
91
91
  "ts-loader": "^6.2.1",
92
92
  "ts-node": "^10.2.1",
93
93
  "tsconfig-paths": "^3.11.0",
@@ -116,6 +116,7 @@
116
116
  "webpack-s3-plugin": "^1.2.0-rc.0"
117
117
  },
118
118
  "resolutions": {
119
+ "json-schema": ">=0.4.0",
119
120
  "minimist": ">=0.2.1",
120
121
  "nth-check": ">=2.0.1"
121
122
  },