@ada-support/embed2 1.6.14 → 1.6.17

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,10 +1,10 @@
1
+ import type { AdaStorageKey, AdaStorageValueByKey } from "@ada-support/web-storage";
1
2
  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
  /**
6
6
  * Retrieves items from local or session storage, depending on the client's
7
7
  * persistence setting. If privateMode is set, it returns null.
8
8
  */
9
- export declare function retrieveStorage<T extends StorageKey>(key: T, client: Client, privateMode?: boolean): StorageValueByKey[T] | null;
10
- export declare function setBrowserStorageItem<T extends StorageKey>(key: T, value: StorageValueByKey[T], persistenceSetting: Client["persistence"]): void;
9
+ export declare function retrieveStorage<T extends AdaStorageKey>(key: T, client: Client, privateMode?: boolean): AdaStorageValueByKey[T] | null;
10
+ export declare function setBrowserStorageItem<T extends AdaStorageKey>(key: T, value: AdaStorageValueByKey[T], persistenceSetting: Client["persistence"]): void;
@@ -1,6 +1,117 @@
1
1
  /******/ (function() { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
+ /***/ 2740:
5
+ /***/ (function(__unused_webpack_module, exports) {
6
+
7
+ "use strict";
8
+
9
+ var __assign = (this && this.__assign) || function () {
10
+ __assign = Object.assign || function(t) {
11
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
12
+ s = arguments[i];
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
14
+ t[p] = s[p];
15
+ }
16
+ return t;
17
+ };
18
+ return __assign.apply(this, arguments);
19
+ };
20
+ exports.__esModule = true;
21
+ exports.createStorage = void 0;
22
+ var WEB_STORAGE_ACCESS_ERROR_MESSAGE = "Cannot access Web Storage API";
23
+ var createStorage = function (storageType) {
24
+ var storageProvider;
25
+ // To handle incognito mode. Calling localStorage throws an error when in incognito
26
+ try {
27
+ storageProvider = storageType === "local" ? localStorage : sessionStorage;
28
+ }
29
+ catch (e) {
30
+ console.warn(WEB_STORAGE_ACCESS_ERROR_MESSAGE);
31
+ }
32
+ var storage = {
33
+ setItem: function (key, value) {
34
+ try {
35
+ storageProvider === null || storageProvider === void 0 ? void 0 : storageProvider.setItem(key, JSON.stringify(value));
36
+ }
37
+ catch (e) {
38
+ console.warn(WEB_STORAGE_ACCESS_ERROR_MESSAGE);
39
+ }
40
+ },
41
+ getItem: function (key) {
42
+ try {
43
+ var rawStorageValue = storageProvider === null || storageProvider === void 0 ? void 0 : storageProvider.getItem(key);
44
+ return rawStorageValue && JSON.parse(rawStorageValue);
45
+ }
46
+ catch (e) {
47
+ console.warn(WEB_STORAGE_ACCESS_ERROR_MESSAGE);
48
+ return null;
49
+ }
50
+ },
51
+ removeItem: function (key) {
52
+ try {
53
+ storageProvider === null || storageProvider === void 0 ? void 0 : storageProvider.removeItem(key);
54
+ }
55
+ catch (e) {
56
+ console.warn(WEB_STORAGE_ACCESS_ERROR_MESSAGE);
57
+ }
58
+ },
59
+ clear: function () {
60
+ try {
61
+ storageProvider === null || storageProvider === void 0 ? void 0 : storageProvider.clear();
62
+ }
63
+ catch (e) {
64
+ console.warn(WEB_STORAGE_ACCESS_ERROR_MESSAGE);
65
+ }
66
+ },
67
+ /** Stores a key/value pair within `ada-functional-storage` Storage key */
68
+ setFnItem: function (key, value) {
69
+ var _a;
70
+ var currentValue = storage.getItem("ada-functional-storage") || {};
71
+ var newValue = __assign(__assign({}, currentValue), (_a = {}, _a[key] = value, _a));
72
+ storage.setItem("ada-functional-storage", newValue);
73
+ },
74
+ /** Gets a value under `ada-functional-storage` Storage key */
75
+ getFnItem: function (key) {
76
+ var value = storage.getItem("ada-functional-storage");
77
+ return (value && value[key]) || null;
78
+ }
79
+ };
80
+ return storage;
81
+ };
82
+ exports.createStorage = createStorage;
83
+
84
+
85
+ /***/ }),
86
+
87
+ /***/ 1110:
88
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
89
+
90
+ "use strict";
91
+ var __webpack_unused_export__;
92
+
93
+ __webpack_unused_export__ = true;
94
+ __webpack_unused_export__ = exports.Dp = exports.wG = void 0;
95
+ var create_storage_1 = __webpack_require__(2740);
96
+ exports.wG = (0, create_storage_1.createStorage)("local");
97
+ exports.Dp = (0, create_storage_1.createStorage)("session");
98
+ /** Checks if Web Storage API is supported */
99
+ var isWebStorageSupported = function () {
100
+ try {
101
+ var key = "key_to_test_local_storage";
102
+ localStorage.setItem(key, key);
103
+ localStorage.removeItem(key);
104
+ return true;
105
+ }
106
+ catch (e) {
107
+ return false;
108
+ }
109
+ };
110
+ __webpack_unused_export__ = isWebStorageSupported;
111
+
112
+
113
+ /***/ }),
114
+
4
115
  /***/ 8580:
5
116
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
6
117
 
@@ -7210,7 +7321,7 @@ function now(){
7210
7321
  /******/ };
7211
7322
  /******/
7212
7323
  /******/ // Execute the module function
7213
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
7324
+ /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
7214
7325
  /******/
7215
7326
  /******/ // Flag the module as loaded
7216
7327
  /******/ module.loaded = true;
@@ -15806,7 +15917,7 @@ const client = new error_tracker_BrowserClient({
15806
15917
  },
15807
15918
 
15808
15919
  environment: "production",
15809
- release: "1.6.14-2ab56a6",
15920
+ release: "1.6.17-976287f",
15810
15921
  sampleRate: 0.25,
15811
15922
  autoSessionTracking: false,
15812
15923
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -16436,7 +16547,7 @@ function getEmbedURL(_ref) {
16436
16547
  host = "http://".concat(window.location.hostname, ":9001");
16437
16548
  }
16438
16549
 
16439
- return "".concat(host, "/embed/").concat(frameName, "/").concat("2ab56a6", "/index.html");
16550
+ return "".concat(host, "/embed/").concat(frameName, "/").concat("976287f", "/index.html");
16440
16551
  }
16441
16552
 
16442
16553
  function constructQueryString(query) {
@@ -16632,111 +16743,8 @@ const actions = {
16632
16743
  };
16633
16744
  }
16634
16745
  };
16635
- ;// CONCATENATED MODULE: ./src/common/constants/storage-keys.ts
16636
- const CHATTER_TOKEN_STORAGE_KEY = "chatter";
16637
- const CHATTER_CREATED_STORAGE_KEY = "ada-embed_chatter-created";
16638
- const SESSION_AUTH_TOKEN_STORAGE_KEY = "ada-embed_session-token";
16639
- const IN_LIVE_CHAT_STORAGE_KEY = "inLiveChat";
16640
- const ZD_SESSION_STORAGE_KEY = "ada-embed_zd-session-id";
16641
- const ZD_PREVIOUS_TAGS_STORAGE_KEY = "ada-embed_zd-previous-tags";
16642
- const IS_DRAWER_OPEN_STORAGE_KEY = "ada-embed_is-drawer-open";
16643
- const ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY = "ada-embed_zd-messaging-external-user-id";
16644
- const ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY = "ada-embed_zd-messaging-chatter-created";
16645
- /** @deprecated - Use CHATTER_TOKEN_STORAGE_KEY */
16646
-
16647
- const CHATTER_STORAGE_KEY = (/* unused pure expression or super */ null && (CHATTER_TOKEN_STORAGE_KEY));
16648
- ;// CONCATENATED MODULE: ./src/frames/lib/safe-storage/index.ts
16649
-
16650
-
16651
- let StorageTypes;
16652
-
16653
- (function (StorageTypes) {
16654
- StorageTypes["Local"] = "local";
16655
- StorageTypes["Session"] = "session";
16656
- })(StorageTypes || (StorageTypes = {}));
16657
-
16658
- /**
16659
- * local and session storage can throw exceptions when trying to access them
16660
- * from the Window object and third-party cookies are disabled. SafeStorage
16661
- * wraps common Storage methods in try catch blocks.
16662
- */
16663
- class SafeStorage {
16664
- constructor(storageType) {
16665
- _defineProperty(this, "storageType", void 0);
16666
-
16667
- _defineProperty(this, "storage", null);
16668
-
16669
- this.storageType = storageType;
16670
-
16671
- try {
16672
- this.storage = storageType === "local" ? window.localStorage : window.sessionStorage;
16673
- } catch (e) {
16674
- warn("".concat(this.storageType, "Storage is disabled. This is likely because your browser is blocking third-party cookies."));
16675
- }
16676
- } // eslint-disable-next-line class-methods-use-this
16677
-
16678
-
16679
- seralizeItem(value) {
16680
- try {
16681
- return JSON.stringify(value);
16682
- } catch (error) {
16683
- warn("Attempt to seralize failed: ".concat(error));
16684
- }
16685
-
16686
- return null;
16687
- } // eslint-disable-next-line class-methods-use-this
16688
-
16689
-
16690
- deserializeItem(value) {
16691
- try {
16692
- return JSON.parse(value);
16693
- } catch (error) {
16694
- warn("Attempt to deserialize failed: ".concat(error));
16695
- }
16696
-
16697
- return null;
16698
- }
16699
-
16700
- getItem(key) {
16701
- try {
16702
- if (!this.storage) {
16703
- throw new AdaEmbedError("`storage` is null");
16704
- }
16705
-
16706
- return this.deserializeItem(this.storage.getItem(key));
16707
- } catch (e) {
16708
- warn("Cannot getItem from ".concat(this.storageType, "Storage."));
16709
- return null;
16710
- }
16711
- }
16712
-
16713
- setItem(key, value) {
16714
- try {
16715
- if (!this.storage) {
16716
- throw new AdaEmbedError("`storage` is null");
16717
- }
16718
-
16719
- this.storage.setItem(key, this.seralizeItem(value));
16720
- } catch (e) {
16721
- warn("Cannot setItem in ".concat(this.storageType, "Storage."));
16722
- }
16723
- }
16724
-
16725
- removeItem(key) {
16726
- try {
16727
- if (!this.storage) {
16728
- throw new AdaEmbedError("`storage` is null");
16729
- }
16730
-
16731
- this.storage.removeItem(key);
16732
- } catch (e) {
16733
- warn("Cannot removeItem from ".concat(this.storageType, "Storage."));
16734
- }
16735
- }
16736
-
16737
- }
16738
- const safeLocalStorage = new SafeStorage(StorageTypes.Local);
16739
- const safeSessionStorage = new SafeStorage(StorageTypes.Session);
16746
+ // EXTERNAL MODULE: ./node_modules/@ada-support/web-storage/dist/index.js
16747
+ var dist = __webpack_require__(1110);
16740
16748
  ;// CONCATENATED MODULE: ./src/client/store/mutations/index.ts
16741
16749
 
16742
16750
 
@@ -16748,7 +16756,6 @@ function mutations_objectSpread(target) { for (var i = 1; i < arguments.length;
16748
16756
 
16749
16757
 
16750
16758
 
16751
-
16752
16759
  const mutations = (state, action) => {
16753
16760
  switch (action.type) {
16754
16761
  case ActionTypes.TOGGLE_CHAT_TYPE:
@@ -16764,7 +16771,7 @@ const mutations = (state, action) => {
16764
16771
  hasChatOpenedAfterProactiveMessagesShown = true;
16765
16772
  }
16766
16773
 
16767
- safeLocalStorage.setItem(IS_DRAWER_OPEN_STORAGE_KEY, !state.isDrawerOpen);
16774
+ dist/* adaLocalStorage.setItem */.wG.setItem("ada-embed_is-drawer-open", !state.isDrawerOpen);
16768
16775
  return mutations_objectSpread(mutations_objectSpread({}, state), {}, {
16769
16776
  isDrawerOpen: !state.isDrawerOpen,
16770
16777
  isIntroShown: false,
@@ -17063,6 +17070,19 @@ function notificationPermListener(notificationPermChangeHandler) {
17063
17070
  };
17064
17071
  });
17065
17072
  }
17073
+ ;// CONCATENATED MODULE: ./src/common/constants/storage-keys.ts
17074
+ const CHATTER_TOKEN_STORAGE_KEY = "chatter";
17075
+ const CHATTER_CREATED_STORAGE_KEY = "ada-embed_chatter-created";
17076
+ const SESSION_AUTH_TOKEN_STORAGE_KEY = "ada-embed_session-token";
17077
+ const IN_LIVE_CHAT_STORAGE_KEY = "inLiveChat";
17078
+ const ZD_SESSION_STORAGE_KEY = "ada-embed_zd-session-id";
17079
+ const ZD_PREVIOUS_TAGS_STORAGE_KEY = "ada-embed_zd-previous-tags";
17080
+ const IS_DRAWER_OPEN_STORAGE_KEY = "ada-embed_is-drawer-open";
17081
+ const ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY = "ada-embed_zd-messaging-external-user-id";
17082
+ const ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY = "ada-embed_zd-messaging-chatter-created";
17083
+ /** @deprecated - Use CHATTER_TOKEN_STORAGE_KEY */
17084
+
17085
+ const CHATTER_STORAGE_KEY = (/* unused pure expression or super */ null && (CHATTER_TOKEN_STORAGE_KEY));
17066
17086
  ;// CONCATENATED MODULE: ./src/client/store/state.ts
17067
17087
 
17068
17088
 
@@ -17070,7 +17090,7 @@ function notificationPermListener(notificationPermChangeHandler) {
17070
17090
 
17071
17091
 
17072
17092
  function getValueFromStorage(key) {
17073
- return safeLocalStorage.getItem(key) || safeSessionStorage.getItem(key);
17093
+ return dist/* adaLocalStorage.getItem */.wG.getItem(key) || dist/* adaSessionStorage.getItem */.Dp.getItem(key);
17074
17094
  }
17075
17095
 
17076
17096
  const getInitialState = adaSettings => ({
@@ -17423,6 +17443,12 @@ function isStartOptions(input) {
17423
17443
  ;// CONCATENATED MODULE: ./src/campaigns/campaign.ts
17424
17444
 
17425
17445
 
17446
+ function campaign_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17447
+
17448
+ function campaign_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? campaign_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : campaign_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17449
+
17450
+
17451
+
17426
17452
 
17427
17453
 
17428
17454
 
@@ -17449,17 +17475,15 @@ function campaignShownWithinFrequency(campaign, handle) {
17449
17475
 
17450
17476
  case "once-per-session":
17451
17477
  {
17452
- var _safeSessionStorage$g;
17453
-
17454
- const perSessionCampaigns = ((_safeSessionStorage$g = safeSessionStorage.getItem("".concat(handle, "_marketing_campaigns_shown"))) === null || _safeSessionStorage$g === void 0 ? void 0 : _safeSessionStorage$g.split(",")) || [];
17478
+ const storageValue = dist/* adaSessionStorage.getFnItem */.Dp.getFnItem("marketing_campaigns_shown");
17479
+ const perSessionCampaigns = storageValue ? (storageValue[handle] || "").split(",") : [];
17455
17480
  return includes_default()(perSessionCampaigns).call(perSessionCampaigns, campaign.campaign_key);
17456
17481
  }
17457
17482
 
17458
17483
  case "once-per-user":
17459
17484
  {
17460
- var _safeLocalStorage$get;
17461
-
17462
- const perSessionCampaigns = ((_safeLocalStorage$get = safeLocalStorage.getItem("".concat(handle, "_marketing_campaigns_shown"))) === null || _safeLocalStorage$get === void 0 ? void 0 : _safeLocalStorage$get.split(",")) || [];
17485
+ const storageValue = dist/* adaLocalStorage.getFnItem */.wG.getFnItem("marketing_campaigns_shown");
17486
+ const perSessionCampaigns = storageValue ? (storageValue[handle] || "").split(",") : [];
17463
17487
  return includes_default()(perSessionCampaigns).call(perSessionCampaigns, campaign.campaign_key);
17464
17488
  }
17465
17489
 
@@ -17474,25 +17498,27 @@ function addCampaignToStorageString(oldStorageValue, campaignId) {
17474
17498
 
17475
17499
 
17476
17500
  function recordCampaignTrigger(campaignKey, frequency, handle) {
17477
- const storageKey = "".concat(handle, "_marketing_campaigns_shown");
17478
-
17479
17501
  switch (frequency) {
17480
17502
  case "every-time":
17481
17503
  break;
17482
17504
 
17483
17505
  case "once-per-session":
17484
17506
  {
17485
- const oldStorageValue = safeSessionStorage.getItem(storageKey);
17486
- const newStorageValue = addCampaignToStorageString(oldStorageValue, campaignKey);
17487
- safeSessionStorage.setItem(storageKey, newStorageValue);
17507
+ const currentStorageValue = dist/* adaSessionStorage.getFnItem */.Dp.getFnItem("marketing_campaigns_shown");
17508
+ const newStorageValue = addCampaignToStorageString(currentStorageValue ? currentStorageValue[handle] || "" : "", campaignKey);
17509
+ dist/* adaSessionStorage.setFnItem */.Dp.setFnItem("marketing_campaigns_shown", campaign_objectSpread(campaign_objectSpread({}, currentStorageValue), {}, {
17510
+ [handle]: newStorageValue
17511
+ }));
17488
17512
  break;
17489
17513
  }
17490
17514
 
17491
17515
  case "once-per-user":
17492
17516
  {
17493
- const oldStorageValue = safeLocalStorage.getItem(storageKey);
17494
- const newStorageValue = addCampaignToStorageString(oldStorageValue, campaignKey);
17495
- safeLocalStorage.setItem(storageKey, newStorageValue);
17517
+ const currentStorageValue = dist/* adaSessionStorage.getFnItem */.Dp.getFnItem("marketing_campaigns_shown");
17518
+ const newStorageValue = addCampaignToStorageString(currentStorageValue ? currentStorageValue[handle] || "" : "", campaignKey);
17519
+ dist/* adaLocalStorage.setFnItem */.wG.setFnItem("marketing_campaigns_shown", campaign_objectSpread(campaign_objectSpread({}, currentStorageValue), {}, {
17520
+ [handle]: newStorageValue
17521
+ }));
17496
17522
  break;
17497
17523
  }
17498
17524
  // If an unknown frequency type is found, do nothing
@@ -17644,12 +17670,21 @@ function unbindLocationChangeOverrides() {
17644
17670
  window.removeEventListener("popstate", popStateListener);
17645
17671
  }
17646
17672
  ;// CONCATENATED MODULE: ./src/client/helpers/rollout.ts
17673
+
17674
+
17675
+ function rollout_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17676
+
17677
+ function rollout_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? rollout_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : rollout_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17678
+
17679
+
17680
+
17647
17681
  function storeRollout(handle, group, lastProb) {
17648
- try {
17649
- window.localStorage.setItem("".concat(handle, "_ada_chap_rollout_group"), group);
17650
- window.localStorage.setItem("".concat(handle, "_ada_chap_rollout_last_prob"), lastProb.toString());
17651
- } catch (e) {// Failed to set to localStorage
17652
- }
17682
+ dist/* adaLocalStorage.setFnItem */.wG.setFnItem("rolloutGroup", rollout_objectSpread(rollout_objectSpread({}, dist/* adaLocalStorage.getFnItem */.wG.getFnItem("rolloutGroup")), {}, {
17683
+ [handle]: group
17684
+ }));
17685
+ dist/* adaLocalStorage.setFnItem */.wG.setFnItem("rolloutLastValue", rollout_objectSpread(rollout_objectSpread({}, dist/* adaLocalStorage.getFnItem */.wG.getFnItem("rolloutLastValue")), {}, {
17686
+ [handle]: lastProb
17687
+ }));
17653
17688
  }
17654
17689
  /**
17655
17690
  * Reads the stored rollout group and probability
@@ -17661,15 +17696,10 @@ function readRollout(handle) {
17661
17696
  group: null,
17662
17697
  lastProb: null
17663
17698
  };
17664
-
17665
- try {
17666
- rollout.group = window.localStorage.getItem("".concat(handle, "_ada_chap_rollout_group"));
17667
- rollout.lastProb = JSON.parse(window.localStorage.getItem("".concat(handle, "_ada_chap_rollout_last_prob")) || "null");
17668
- return rollout;
17669
- } catch (e) {
17670
- // Failed to read localStorage
17671
- return rollout;
17672
- }
17699
+ rollout.group = // I don't know what ESLint is complaining about here
17700
+ (dist/* adaLocalStorage.getFnItem */.wG.getFnItem("rolloutGroup") || {})[handle] || null;
17701
+ rollout.lastProb = (dist/* adaLocalStorage.getFnItem */.wG.getFnItem("rolloutLastValue") || {})[handle] || null;
17702
+ return rollout;
17673
17703
  }
17674
17704
 
17675
17705
  function checkRollout(rollout, handle) {
@@ -18114,41 +18144,24 @@ function retrieveStorage(key, client, privateMode) {
18114
18144
  }
18115
18145
 
18116
18146
  if (persistence === PERSISTENCE_NORMAL) {
18117
- return safeLocalStorage.getItem(key);
18147
+ return dist/* adaLocalStorage.getItem */.wG.getItem(key);
18118
18148
  }
18119
18149
 
18120
18150
  if (persistence === PERSISTENCE_SESSION) {
18121
- return safeSessionStorage.getItem(key);
18151
+ return dist/* adaSessionStorage.getItem */.Dp.getItem(key);
18122
18152
  }
18123
18153
 
18124
18154
  return null;
18125
18155
  }
18126
18156
  function setBrowserStorageItem(key, value, persistenceSetting) {
18127
18157
  if (persistenceSetting === PERSISTENCE_NORMAL) {
18128
- safeLocalStorage.setItem(key, value);
18158
+ dist/* adaLocalStorage.setItem */.wG.setItem(key, value);
18129
18159
  }
18130
18160
 
18131
18161
  if (persistenceSetting === PERSISTENCE_SESSION) {
18132
- safeSessionStorage.setItem(key, value);
18162
+ dist/* adaSessionStorage.setItem */.Dp.setItem(key, value);
18133
18163
  }
18134
18164
  }
18135
- ;// CONCATENATED MODULE: ./src/services/persistence/index.ts
18136
- const persistence = {
18137
- get: item => {
18138
- try {
18139
- return localStorage.getItem(item);
18140
- } catch (e) {
18141
- /* istanbul ignore next */
18142
- return null;
18143
- }
18144
- },
18145
- set: (item, value) => {
18146
- try {
18147
- localStorage.setItem(item, value);
18148
- } catch (e) {// Do nothing
18149
- }
18150
- }
18151
- };
18152
18165
  // EXTERNAL MODULE: ./node_modules/lodash.memoize/index.js
18153
18166
  var lodash_memoize = __webpack_require__(773);
18154
18167
  var lodash_memoize_default = /*#__PURE__*/__webpack_require__.n(lodash_memoize);
@@ -18192,9 +18205,9 @@ async function log(message, extra, options) {
18192
18205
  service: "embed",
18193
18206
  env: "production",
18194
18207
  embedVersion: 2,
18195
- version: "1.6.14",
18208
+ version: "1.6.17",
18196
18209
  isNpm: true,
18197
- commitHash: "2ab56a6"
18210
+ commitHash: "976287f"
18198
18211
  }))
18199
18212
  });
18200
18213
  }
@@ -18277,10 +18290,10 @@ const getChatVersionFromManifest = manifest => {
18277
18290
  }
18278
18291
 
18279
18292
  const manifestString = JSON.stringify(manifest);
18280
- const manifestCache = persistence.get("ada-embed_chat-manifest-cache");
18293
+ const manifestCache = dist/* adaLocalStorage.getItem */.wG.getItem("ada-embed_chat-manifest-cache");
18281
18294
 
18282
18295
  if (manifestString === manifestCache) {
18283
- const assignedVersion = persistence.get("ada-embed_chat-assigned-version");
18296
+ const assignedVersion = dist/* adaLocalStorage.getItem */.wG.getItem("ada-embed_chat-assigned-version");
18284
18297
  /* istanbul ignore else */
18285
18298
 
18286
18299
  if (assignedVersion) {
@@ -18307,8 +18320,8 @@ const getChatVersionFromManifest = manifest => {
18307
18320
  }
18308
18321
  }
18309
18322
 
18310
- persistence.set("ada-embed_chat-assigned-version", hash);
18311
- persistence.set("ada-embed_chat-manifest-cache", manifestString);
18323
+ dist/* adaLocalStorage.setItem */.wG.setItem("ada-embed_chat-assigned-version", hash);
18324
+ dist/* adaLocalStorage.setItem */.wG.setItem("ada-embed_chat-manifest-cache", manifestString);
18312
18325
  return hash;
18313
18326
  };
18314
18327
  const getChatVersion = async adaSettings => {
@@ -18764,7 +18777,7 @@ class ChatFrame extends d {
18764
18777
  const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
18765
18778
  const smsToken = hostPageUrlParams.get("adaSMSToken");
18766
18779
  const queryParams = {
18767
- embedVersion: "2ab56a6".slice(0, 7),
18780
+ embedVersion: "976287f".slice(0, 7),
18768
18781
  greeting,
18769
18782
  language,
18770
18783
  skipGreeting,
@@ -19113,11 +19126,11 @@ class ChatFrame extends d {
19113
19126
 
19114
19127
  const storage = (() => {
19115
19128
  if (client.persistence === PERSISTENCE_NORMAL) {
19116
- return safeLocalStorage;
19129
+ return dist/* adaLocalStorage */.wG;
19117
19130
  }
19118
19131
 
19119
19132
  if (client.persistence === PERSISTENCE_SESSION) {
19120
- return safeSessionStorage;
19133
+ return dist/* adaSessionStorage */.Dp;
19121
19134
  }
19122
19135
 
19123
19136
  return null;
@@ -19160,15 +19173,15 @@ class ChatFrame extends d {
19160
19173
  });
19161
19174
 
19162
19175
  if (zdMessagingExternalUserId === null) {
19163
- safeLocalStorage.removeItem(ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY);
19176
+ dist/* adaLocalStorage.removeItem */.wG.removeItem(ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY);
19164
19177
  } else {
19165
- safeLocalStorage.setItem(ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY, zdMessagingExternalUserId);
19178
+ dist/* adaLocalStorage.setItem */.wG.setItem(ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY, zdMessagingExternalUserId);
19166
19179
  }
19167
19180
 
19168
19181
  if (zdMessagingChatterCreated === null) {
19169
- safeLocalStorage.removeItem(ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY);
19182
+ dist/* adaLocalStorage.removeItem */.wG.removeItem(ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY);
19170
19183
  } else {
19171
- safeLocalStorage.setItem(ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY, zdMessagingChatterCreated);
19184
+ dist/* adaLocalStorage.setItem */.wG.setItem(ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY, zdMessagingChatterCreated);
19172
19185
  }
19173
19186
 
19174
19187
  break;
@@ -19196,9 +19209,9 @@ class ChatFrame extends d {
19196
19209
 
19197
19210
 
19198
19211
  if (client.persistence === PERSISTENCE_NORMAL) {
19199
- safeLocalStorage.setItem(IN_LIVE_CHAT_STORAGE_KEY, inLiveChat);
19212
+ dist/* adaLocalStorage.setItem */.wG.setItem(IN_LIVE_CHAT_STORAGE_KEY, inLiveChat);
19200
19213
  } else if (client.persistence === PERSISTENCE_SESSION) {
19201
- safeSessionStorage.setItem(IN_LIVE_CHAT_STORAGE_KEY, inLiveChat);
19214
+ dist/* adaSessionStorage.setItem */.Dp.setItem(IN_LIVE_CHAT_STORAGE_KEY, inLiveChat);
19202
19215
  }
19203
19216
 
19204
19217
  break;
@@ -20240,10 +20253,10 @@ class Container extends d {
20240
20253
 
20241
20254
  xStorageChannel.postMessage(DELETE_HISTORY_EVENT, undefined); // Clear chatter data from local storage
20242
20255
 
20243
- safeLocalStorage.removeItem(CHATTER_TOKEN_STORAGE_KEY);
20244
- safeSessionStorage.removeItem(CHATTER_TOKEN_STORAGE_KEY);
20245
- safeLocalStorage.removeItem(CHATTER_CREATED_STORAGE_KEY);
20246
- safeSessionStorage.removeItem(CHATTER_CREATED_STORAGE_KEY); // And from state
20256
+ dist/* adaLocalStorage.removeItem */.wG.removeItem(CHATTER_TOKEN_STORAGE_KEY);
20257
+ dist/* adaSessionStorage.removeItem */.Dp.removeItem(CHATTER_TOKEN_STORAGE_KEY);
20258
+ dist/* adaLocalStorage.removeItem */.wG.removeItem(CHATTER_CREATED_STORAGE_KEY);
20259
+ dist/* adaSessionStorage.removeItem */.Dp.removeItem(CHATTER_CREATED_STORAGE_KEY); // And from state
20247
20260
 
20248
20261
  newState = Container_objectSpread(Container_objectSpread({}, newState), {}, {
20249
20262
  chatterToken: null,
@@ -20278,10 +20291,10 @@ class Container extends d {
20278
20291
  } // Clear chatter data from local storage
20279
20292
 
20280
20293
 
20281
- safeLocalStorage.removeItem(CHATTER_TOKEN_STORAGE_KEY);
20282
- safeSessionStorage.removeItem(CHATTER_TOKEN_STORAGE_KEY);
20283
- safeLocalStorage.removeItem(CHATTER_CREATED_STORAGE_KEY);
20284
- safeSessionStorage.removeItem(CHATTER_CREATED_STORAGE_KEY); // And from state
20294
+ dist/* adaLocalStorage.removeItem */.wG.removeItem(CHATTER_TOKEN_STORAGE_KEY);
20295
+ dist/* adaSessionStorage.removeItem */.Dp.removeItem(CHATTER_TOKEN_STORAGE_KEY);
20296
+ dist/* adaLocalStorage.removeItem */.wG.removeItem(CHATTER_CREATED_STORAGE_KEY);
20297
+ dist/* adaSessionStorage.removeItem */.Dp.removeItem(CHATTER_CREATED_STORAGE_KEY); // And from state
20285
20298
 
20286
20299
  await setState({
20287
20300
  chatterToken: null,
@@ -20980,7 +20993,7 @@ class Embed {
20980
20993
 
20981
20994
  }
20982
20995
 
20983
- _defineProperty(Embed, "embed2Version", "2ab56a6");
20996
+ _defineProperty(Embed, "embed2Version", "976287f");
20984
20997
  ;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
20985
20998
 
20986
20999
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.6.14",
3
+ "version": "1.6.17",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",
@@ -83,7 +83,8 @@
83
83
  "webpack-dev-server": "^4.3.1"
84
84
  },
85
85
  "dependencies": {
86
- "@ada-support/embed-types": "^1.6.3",
86
+ "@ada-support/embed-types": "^1.6.4",
87
+ "@ada-support/web-storage": "^0.14.0",
87
88
  "@babel/core": "^7.16.12",
88
89
  "@babel/plugin-proposal-class-properties": "^7.16.7",
89
90
  "@babel/plugin-proposal-numeric-separator": "^7.16.7",
@@ -1,40 +0,0 @@
1
- import type { CHATTER_CREATED_STORAGE_KEY, CHATTER_TOKEN_STORAGE_KEY, IN_LIVE_CHAT_STORAGE_KEY, SESSION_AUTH_TOKEN_STORAGE_KEY, ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY, ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY, ZD_PREVIOUS_TAGS_STORAGE_KEY, ZD_SESSION_STORAGE_KEY } from "common/constants/storage-keys";
2
- export declare enum StorageTypes {
3
- Local = "local",
4
- Session = "session"
5
- }
6
- declare type StorageTypesType = StorageTypes.Local | StorageTypes.Session;
7
- export declare type StorageValueType = string | number | boolean | unknown[];
8
- export interface StorageValueByKey {
9
- [CHATTER_CREATED_STORAGE_KEY]: string;
10
- [CHATTER_TOKEN_STORAGE_KEY]: string;
11
- [SESSION_AUTH_TOKEN_STORAGE_KEY]: string;
12
- [IN_LIVE_CHAT_STORAGE_KEY]: boolean;
13
- [ZD_SESSION_STORAGE_KEY]: string;
14
- [ZD_PREVIOUS_TAGS_STORAGE_KEY]: string;
15
- [ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY]: string;
16
- [ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY]: string;
17
- liveChatPending: boolean;
18
- "ada-embed_is-drawer-open": boolean;
19
- "[handle]_marketing_campaigns_shown": string;
20
- test: string;
21
- }
22
- export declare type StorageKey = keyof StorageValueByKey;
23
- /**
24
- * local and session storage can throw exceptions when trying to access them
25
- * from the Window object and third-party cookies are disabled. SafeStorage
26
- * wraps common Storage methods in try catch blocks.
27
- */
28
- export declare class SafeStorage {
29
- storageType: StorageTypesType;
30
- storage: Storage | null;
31
- constructor(storageType: StorageTypesType);
32
- seralizeItem(value: StorageValueType): string | null;
33
- deserializeItem<T extends StorageValueType>(value: string | null): T | null;
34
- getItem<T extends StorageKey>(key: T): StorageValueByKey[T] | null;
35
- setItem<T extends StorageKey>(key: T, value: StorageValueByKey[T]): void;
36
- removeItem(key: StorageKey): void;
37
- }
38
- export declare const safeLocalStorage: SafeStorage;
39
- export declare const safeSessionStorage: SafeStorage;
40
- export {};
@@ -1,6 +0,0 @@
1
- declare type PersistenceKey = "ada-embed_chat-manifest-cache" | "ada-embed_chat-assigned-version";
2
- export declare const persistence: {
3
- get: (item: PersistenceKey) => string;
4
- set: (item: PersistenceKey, value: string) => void;
5
- };
6
- export {};