@braze/web-sdk 4.3.0 → 4.5.0

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.
Files changed (178) hide show
  1. package/index.d.ts +68 -6
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +8 -1
  4. package/shared-lib/encoding-utils.js +12 -1
  5. package/shared-lib/event-types.js +32 -1
  6. package/shared-lib/guid.js +10 -1
  7. package/shared-lib/indexed-db-adapter.js +315 -1
  8. package/shared-lib/logger.js +38 -1
  9. package/shared-lib/supported-options.js +26 -1
  10. package/src/Card/card-manager-factory.js +14 -1
  11. package/src/Card/card-manager.js +72 -1
  12. package/src/Card/display/card-display.js +134 -1
  13. package/src/Card/index.js +5 -1
  14. package/src/Card/log-card-click.js +11 -1
  15. package/src/Card/log-card-dismissal.js +11 -1
  16. package/src/Card/log-card-impressions.js +13 -1
  17. package/src/Card/log-content-card-impressions.js +4 -1
  18. package/src/Card/models/banner.js +30 -1
  19. package/src/Card/models/captioned-image.js +32 -1
  20. package/src/Card/models/card.js +175 -1
  21. package/src/Card/models/classic-card.js +32 -1
  22. package/src/Card/models/control-card.js +39 -1
  23. package/src/Card/models/index.js +5 -1
  24. package/src/Card/util/card-factory.js +104 -1
  25. package/src/ContentCards/content-cards-provider-factory.js +20 -1
  26. package/src/ContentCards/content-cards-provider.js +283 -1
  27. package/src/ContentCards/content-cards.js +24 -1
  28. package/src/ContentCards/get-cached-content-cards.js +5 -1
  29. package/src/ContentCards/index.js +8 -1
  30. package/src/ContentCards/log-content-cards-displayed.js +5 -1
  31. package/src/ContentCards/request-content-cards-refresh.js +5 -1
  32. package/src/ContentCards/subscribe-to-content-cards-updates.js +14 -1
  33. package/src/ContentCards/ui/hide-content-cards.js +8 -1
  34. package/src/ContentCards/ui/show-content-cards.js +72 -1
  35. package/src/ContentCards/ui/toggle-content-cards.js +8 -1
  36. package/src/Core/add-sdk-metadata.js +27 -1
  37. package/src/Core/braze-sdk-metadata.js +10 -1
  38. package/src/Core/change-user.js +19 -1
  39. package/src/Core/destroy.js +5 -1
  40. package/src/Core/device-properties.js +9 -1
  41. package/src/Core/disable-sdk.js +10 -1
  42. package/src/Core/enable-sdk.js +8 -1
  43. package/src/Core/get-device-id.js +10 -1
  44. package/src/Core/get-user.js +4 -1
  45. package/src/Core/handle-braze-action.js +64 -1
  46. package/src/Core/index.js +23 -1
  47. package/src/Core/initialize.js +4 -1
  48. package/src/Core/is-disabled.js +4 -1
  49. package/src/Core/log-custom-event.js +36 -1
  50. package/src/Core/log-purchase.js +245 -1
  51. package/src/Core/open-session.js +23 -1
  52. package/src/Core/remove-all-subscriptions.js +4 -1
  53. package/src/Core/remove-subscription.js +4 -1
  54. package/src/Core/request-immediate-data-flush.js +4 -1
  55. package/src/Core/set-logger.js +4 -1
  56. package/src/Core/set-sdk-authentication-signature.js +9 -1
  57. package/src/Core/subscribe-to-sdk-authentication-failures.js +4 -1
  58. package/src/Core/toggle-logging.js +4 -1
  59. package/src/Core/wipe-data.js +15 -1
  60. package/src/FeatureFlags/feature-flag-factory.js +14 -0
  61. package/src/FeatureFlags/feature-flag.js +16 -0
  62. package/src/FeatureFlags/feature-flags-provider-factory.js +19 -0
  63. package/src/FeatureFlags/feature-flags-provider.js +94 -0
  64. package/src/FeatureFlags/get-all-feature-flags.js +12 -0
  65. package/src/FeatureFlags/get-feature-flag.js +12 -0
  66. package/src/FeatureFlags/index.js +4 -0
  67. package/src/FeatureFlags/refresh-feature-flags.js +9 -0
  68. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +6 -0
  69. package/src/Feed/feed-provider-factory.js +18 -1
  70. package/src/Feed/feed-provider.js +79 -1
  71. package/src/Feed/feed.js +20 -1
  72. package/src/Feed/get-cached-feed.js +5 -1
  73. package/src/Feed/index.js +8 -1
  74. package/src/Feed/log-feed-displayed.js +5 -1
  75. package/src/Feed/request-feed-refresh.js +5 -1
  76. package/src/Feed/subscribe-to-feed-updates.js +5 -1
  77. package/src/Feed/ui/hide-feed.js +7 -1
  78. package/src/Feed/ui/show-feed.js +89 -1
  79. package/src/Feed/ui/toggle-feed.js +8 -1
  80. package/src/InAppMessage/display/get-animation-effect.js +19 -1
  81. package/src/InAppMessage/display/html-message-to-html.js +223 -1
  82. package/src/InAppMessage/display/in-app-message-to-html.js +152 -1
  83. package/src/InAppMessage/display/modal-utils.js +68 -1
  84. package/src/InAppMessage/in-app-message-factory.js +145 -1
  85. package/src/InAppMessage/in-app-message-manager-factory.js +16 -1
  86. package/src/InAppMessage/in-app-message-manager.js +189 -1
  87. package/src/InAppMessage/index.js +14 -1
  88. package/src/InAppMessage/log-in-app-message-button-click.js +19 -1
  89. package/src/InAppMessage/log-in-app-message-click.js +19 -1
  90. package/src/InAppMessage/log-in-app-message-html-click.js +23 -1
  91. package/src/InAppMessage/log-in-app-message-impression.js +13 -1
  92. package/src/InAppMessage/models/control-message.js +8 -1
  93. package/src/InAppMessage/models/full-screen-message.js +71 -1
  94. package/src/InAppMessage/models/html-message.js +54 -1
  95. package/src/InAppMessage/models/in-app-message-button.js +40 -1
  96. package/src/InAppMessage/models/in-app-message.js +271 -1
  97. package/src/InAppMessage/models/modal-message.js +68 -1
  98. package/src/InAppMessage/models/slide-up-message.js +58 -1
  99. package/src/InAppMessage/models/templated-in-app-message.js +14 -1
  100. package/src/InAppMessage/subscribe-to-in-app-message.js +10 -1
  101. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +15 -1
  102. package/src/InAppMessage/ui/show-in-app-message.js +170 -1
  103. package/src/Push/index.js +5 -1
  104. package/src/Push/is-push-blocked.js +5 -1
  105. package/src/Push/is-push-permission-granted.js +5 -1
  106. package/src/Push/is-push-supported.js +5 -1
  107. package/src/Push/push-manager-factory.js +30 -1
  108. package/src/Push/push-manager.js +360 -1
  109. package/src/Push/request-push-permission.js +8 -1
  110. package/src/Push/unregister-push.js +5 -1
  111. package/src/Push/utils/push-utils.js +34 -1
  112. package/src/User/index.js +1 -1
  113. package/src/User/user-manager.js +70 -1
  114. package/src/User/user.js +278 -1
  115. package/src/common/base-feed.js +25 -1
  116. package/src/common/base-provider.js +6 -1
  117. package/src/common/constants.js +5 -1
  118. package/src/common/event-logger.js +24 -1
  119. package/src/common/feed-display.js +200 -1
  120. package/src/common/translations.js +148 -1
  121. package/src/index.js +9 -1
  122. package/src/l10n/l10n-manager-factory.js +22 -1
  123. package/src/l10n/l10n-manager.js +21 -1
  124. package/src/managers/auth-manager.js +48 -1
  125. package/src/managers/braze-instance.js +307 -1
  126. package/src/managers/device-manager.js +80 -1
  127. package/src/managers/network-manager.js +219 -1
  128. package/src/managers/server-config-manager.js +88 -1
  129. package/src/managers/session-manager.js +68 -1
  130. package/src/managers/storage-manager-factory.js +35 -1
  131. package/src/managers/storage-manager.js +394 -1
  132. package/src/managers/subscription-manager.js +25 -1
  133. package/src/models/backend-errors.js +8 -1
  134. package/src/models/braze-event.js +41 -1
  135. package/src/models/braze-sdk-metadata.js +10 -1
  136. package/src/models/device.js +26 -1
  137. package/src/models/identifier.js +20 -1
  138. package/src/models/push-token.js +22 -1
  139. package/src/models/request-result.js +8 -1
  140. package/src/models/server-config.js +32 -1
  141. package/src/request-controller.js +288 -1
  142. package/src/triggers/models/custom-event-data.js +14 -1
  143. package/src/triggers/models/custom-event-property-data.js +21 -1
  144. package/src/triggers/models/filter-set.js +55 -1
  145. package/src/triggers/models/filter.js +98 -1
  146. package/src/triggers/models/in-app-message-click-data.js +25 -1
  147. package/src/triggers/models/purchase-data.js +14 -1
  148. package/src/triggers/models/purchase-property-data.js +21 -1
  149. package/src/triggers/models/push-click-data.js +15 -1
  150. package/src/triggers/models/trigger-condition.js +109 -1
  151. package/src/triggers/models/trigger-events.js +8 -1
  152. package/src/triggers/models/trigger.js +110 -1
  153. package/src/triggers/triggers-provider-factory.js +30 -1
  154. package/src/triggers/triggers-provider.js +307 -1
  155. package/src/ui/js/attach-css.js +12 -1
  156. package/src/ui/js/feed-css.js +12 -1
  157. package/src/ui/js/iam-css.js +12 -1
  158. package/src/ui/js/index.js +3 -1
  159. package/src/ui/js/load-font-awesome.js +13 -1
  160. package/src/util/base-device-parser.js +14 -1
  161. package/src/util/braze-actions.js +79 -1
  162. package/src/util/browser-detector.js +85 -1
  163. package/src/util/client-hints-parser.js +60 -1
  164. package/src/util/code-utils.js +92 -1
  165. package/src/util/color-utils.js +23 -1
  166. package/src/util/component-utils.js +26 -1
  167. package/src/util/date-utils.js +27 -1
  168. package/src/util/deprecation-utils.js +5 -1
  169. package/src/util/device-constants.js +14 -1
  170. package/src/util/dom-utils.js +87 -1
  171. package/src/util/key-codes.js +1 -1
  172. package/src/util/math.js +5 -1
  173. package/src/util/net.js +75 -1
  174. package/src/util/string-utils.js +22 -1
  175. package/src/util/url-utils.js +23 -1
  176. package/src/util/user-agent-parser.js +85 -1
  177. package/src/util/validation-utils.js +136 -1
  178. package/src/util/window-utils.js +35 -1
@@ -1 +1,394 @@
1
- import et from"../util/browser-detector.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{isArray as p,keys as rr,validateValueIsFromEnum as F,values as At}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{User}from"../User/index.js";export const STORAGE_KEYS={iu:{su:"ab.storage.userId",Go:"ab.storage.deviceId",oh:"ab.storage.sessionId"},q:{ga:"ab.test",Ta:"ab.storage.events",Aa:"ab.storage.attributes",Oa:"ab.storage.attributes.anonymous_user",Ho:"ab.storage.device",Yo:"ab.storage.sdk_metadata",Zo:"ab.storage.session_id_for_cached_metadata",gn:"ab.storage.pushToken",ei:"ab.storage.newsFeed",hi:"ab.storage.lastNewsFeedRefresh",P:"ab.storage.cardImpressions",ol:"ab.storage.serverConfig",ba:"ab.storage.triggers",Ia:"ab.storage.triggers.ts",lh:"ab.storage.messagingSessionStart",Yt:"ab.storage.cc",vs:"ab.storage.ccLastFullSync",ys:"ab.storage.ccLastCardUpdated",$:"ab.storage.ccClicks",O:"ab.storage.ccImpressions",K:"ab.storage.ccDismissals",Ka:"ab.storage.lastDisplayedTriggerTimesById",Ya:"ab.storage.lastDisplayedTriggerTime",Da:"ab.storage.triggerFireInstancesById",Jn:"ab.storage.signature",As:"ab.storage.brazeSyncRetryCount",_s:"ab.storage.sdkVersion"},ae:"ab.optOut"};export default class G{constructor(t,e){this.Ga=t,this.Na=e}ru(t,e){let s=e;null!=e&&e instanceof _t&&(s=e.ss()),this.Ga.store(t,s)}va(t){const e=this.tu(t);null!=e&&(e.mh=(new Date).valueOf(),this.ru(t,e))}tu(t){return _t.yn(this.Ga.lr(t))}wh(t){this.Ga.remove(t)}bo(t){if(null==t||0===t.length)return!1;p(t)||(t=[t]);let e=this.Na.lr(STORAGE_KEYS.q.Ta);null!=e&&p(e)||(e=[]);for(let s=0;s<t.length;s++)e.push(t[s].ss());return this.Na.store(STORAGE_KEYS.q.Ta,e)}fh(t){return null!=t&&this.bo([t])}Ca(){let t=this.Na.lr(STORAGE_KEYS.q.Ta);this.Na.remove(STORAGE_KEYS.q.Ta),null==t&&(t=[]);const e=[];let s=!1,o=null;if(p(t))for(let s=0;s<t.length;s++)ue.Ma(t[s])?e.push(ue.yn(t[s])):o=s;else s=!0;if(s||null!=o){let n="Stored events could not be deserialized as Events";s&&(n+=", was "+Object.prototype.toString.call(t)+" not an array"),null!=o&&(n+=", value at index "+o+" does not look like an event"),n+=", serialized values were of type "+typeof t+": "+JSON.stringify(t),e.push(new ue(null,r.A.qs,(new Date).valueOf(),null,{e:n}))}return e}B(t,e){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot store object.","STORAGE_KEYS.OBJECTS")&&this.Na.store(t,e)}I(t){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot retrieve object.","STORAGE_KEYS.OBJECTS")&&this.Na.lr(t)}Xs(t){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot remove object.","STORAGE_KEYS.OBJECTS")&&(this.Na.remove(t),!0)}clearData(){const t=rr(STORAGE_KEYS.iu),e=rr(STORAGE_KEYS.q);for(let e=0;e<t.length;e++){const s=t[e];this.Ga.remove(STORAGE_KEYS.iu[s])}for(let t=0;t<e.length;t++){const s=e[t];this.Na.remove(STORAGE_KEYS.q[s])}}ya(t){return t||STORAGE_KEYS.q.Oa}pa(t){let e=this.Na.lr(STORAGE_KEYS.q.Aa);null==e&&(e={});const s=this.ya(t[User._n]);for(let r in t)r===User._n||null!=e[s]&&null!=e[s][r]||this.mu(t[User._n],r,t[r])}mu(t,e,s){let r=this.Na.lr(STORAGE_KEYS.q.Aa);null==r&&(r={});const o=this.ya(t);let n=r[o];if(null==n&&(n={},null!=t&&(n[User._n]=t)),e===User.lu){null==n[e]&&(n[e]={});for(let t in s)n[e][t]=s[t]}else n[e]=s;return r[o]=n,this.Na.store(STORAGE_KEYS.q.Aa,r)}Ua(){const t=this.Na.lr(STORAGE_KEYS.q.Aa);this.Na.remove(STORAGE_KEYS.q.Aa);const e=[];for(let s in t)null!=t[s]&&e.push(t[s]);return e}ou(t){const e=this.Na.lr(STORAGE_KEYS.q.Aa);if(null!=e){const s=this.ya(null),r=e[s];null!=r&&(e[s]=void 0,this.Na.store(STORAGE_KEYS.q.Aa,e),r[User._n]=t,this.pa(r))}const s=this.tu(STORAGE_KEYS.iu.oh);let r=null;null!=s&&(r=s.eu);const o=this.Ca();if(null!=o)for(let e=0;e<o.length;e++){const s=o[e];null==s.userId&&s.sessionId==r&&(s.userId=t),this.fh(s)}}Ba(){return this.Na.Fa}}G.wa=class{constructor(t){this.Ji=t,this.Fa=et.La()?3:10}Pa(t){return t+"."+this.Ji}store(t,e){const s={v:e};try{return localStorage.setItem(this.Pa(t),JSON.stringify(s)),!0}catch(t){return r.D.info("Storage failure: "+t.message),!1}}lr(t){try{const e=JSON.parse(localStorage.getItem(this.Pa(t)));return null==e?null:e.v}catch(t){return r.D.info("Storage retrieval failure: "+t.message),null}}remove(t){try{localStorage.removeItem(this.Pa(t))}catch(t){return r.D.info("Storage removal failure: "+t.message),!1}}};G.ne=class{constructor(t,e){this.Ji=t,this.xa=this.Ja(),this.ka=576e3,this.Va=!!e}Pa(t){return null!=this.Ji?t+"."+this.Ji:t}Ja(){let t=0,e=document.location.hostname;const s=e.split("."),r="ab._gd";for(;t<s.length-1&&-1===document.cookie.indexOf(r+"="+r);)t++,e="."+s.slice(-1-t).join("."),document.cookie=r+"="+r+";domain="+e+";";return document.cookie=r+"=;expires="+new Date(0).toGMTString()+";domain="+e+";",e}ie(){const t=new Date;return t.setTime(t.getTime()+60*this.ka*1e3),t.getFullYear()}za(){const t=At(STORAGE_KEYS.iu),e=document.cookie.split(";");for(let s=0;s<e.length;s++){let r=e[s];for(;" "===r.charAt(0);)r=r.substring(1);let o=!1;for(let e=0;e<t.length;e++)if(0===r.indexOf(t[e])){o=!0;break}if(o){const t=r.split("=")[0];-1===t.indexOf("."+this.Ji)&&this.Qa(t)}}}store(t,e){this.za();const s=new Date;s.setTime(s.getTime()+60*this.ka*1e3);const o="expires="+s.toUTCString(),n="domain="+this.xa;let i;i=this.Va?e:encodeURIComponent(JSON.stringify(e));const a=this.Pa(t)+"="+i+";"+o+";"+n+";path=/";return a.length>=4093?(r.D.info("Storage failure: string is "+a.length+" chars which is too large to store as a cookie."),!1):(document.cookie=a,!0)}lr(t){const e=[],s=this.Pa(t)+"=",o=document.cookie.split(";");for(let n=0;n<o.length;n++){let i=o[n];for(;" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(s))try{let t;t=this.Va?i.substring(s.length,i.length):JSON.parse(decodeURIComponent(i.substring(s.length,i.length))),e.push(t)}catch(e){return r.D.info("Storage retrieval failure: "+e.message),this.remove(t),null}}return e.length>0?e[e.length-1]:null}remove(t){this.Qa(this.Pa(t))}Qa(t){const e=t+"=;expires="+new Date(0).toGMTString();document.cookie=e,document.cookie=e+";path=/";const s=e+";domain="+this.xa;document.cookie=s,document.cookie=s+";path=/"}};G._a=class{constructor(){this.Ha={},this.Wa=5242880,this.Fa=3}store(t,e){const s={value:e},o=this.Xa(e);return o>this.Wa?(r.D.info("Storage failure: object is ≈"+o+" bytes which is greater than the max of "+this.Wa),!1):(this.Ha[t]=s,!0)}Xa(t){const e=[],s=[t];let r=0;for(;s.length;){const t=s.pop();if("boolean"==typeof t)r+=4;else if("string"==typeof t)r+=2*t.length;else if("number"==typeof t)r+=8;else if("object"==typeof t&&-1===e.indexOf(t)){e.push(t);for(let e in t)s.push(t[e])}}return r}lr(t){const e=this.Ha[t];return null==e?null:e.value}remove(t){this.Ha[t]=null}};G.Ea=class{constructor(t,e,s){this.Za=[],e&&this.Za.push(new G.ne(t)),s&&this.Za.push(new G.wa(t)),this.Za.push(new G._a(t))}store(t,e){let s=!0;for(let r=0;r<this.Za.length;r++)s=this.Za[r].store(t,e)&&s;return s}lr(t){for(let e=0;e<this.Za.length;e++){const s=this.Za[e].lr(t);if(null!=s)return s}return null}remove(t){for(let e=0;e<this.Za.length;e++)this.Za[e].remove(t)}};
1
+ import ot from "../util/browser-detector.js";
2
+ import ue from "../models/braze-event.js";
3
+ import _t from "../models/identifier.js";
4
+ import {
5
+ isArray as p,
6
+ keys as rr,
7
+ validateValueIsFromEnum as F,
8
+ values as At
9
+ } from "../util/code-utils.js";
10
+ import r from "../../shared-lib/braze-shared-lib.js";
11
+ import { User } from "../User/index.js";
12
+ export const STORAGE_KEYS = {
13
+ eu: {
14
+ su: "ab.storage.userId",
15
+ Jo: "ab.storage.deviceId",
16
+ ph: "ab.storage.sessionId"
17
+ },
18
+ q: {
19
+ Sa: "ab.test",
20
+ Ta: "ab.storage.events",
21
+ Ia: "ab.storage.attributes",
22
+ Ka: "ab.storage.attributes.anonymous_user",
23
+ Yo: "ab.storage.device",
24
+ ua: "ab.storage.sdk_metadata",
25
+ ha: "ab.storage.session_id_for_cached_metadata",
26
+ Pn: "ab.storage.pushToken",
27
+ ei: "ab.storage.newsFeed",
28
+ hi: "ab.storage.lastNewsFeedRefresh",
29
+ P: "ab.storage.cardImpressions",
30
+ ol: "ab.storage.serverConfig",
31
+ Ya: "ab.storage.triggers",
32
+ Da: "ab.storage.triggers.ts",
33
+ wh: "ab.storage.messagingSessionStart",
34
+ Yt: "ab.storage.cc",
35
+ vs: "ab.storage.ccLastFullSync",
36
+ ys: "ab.storage.ccLastCardUpdated",
37
+ $: "ab.storage.ccClicks",
38
+ O: "ab.storage.ccImpressions",
39
+ K: "ab.storage.ccDismissals",
40
+ Ga: "ab.storage.lastDisplayedTriggerTimesById",
41
+ Na: "ab.storage.lastDisplayedTriggerTime",
42
+ va: "ab.storage.triggerFireInstancesById",
43
+ Mn: "ab.storage.signature",
44
+ As: "ab.storage.brazeSyncRetryCount",
45
+ _s: "ab.storage.sdkVersion",
46
+ ze: "ab.storage.ff",
47
+ qe: "ab.storage.ffLastRefreshAt"
48
+ },
49
+ ae: "ab.optOut"
50
+ };
51
+ export default class G {
52
+ constructor(t, e) {
53
+ (this.Ma = t), (this.Ca = e);
54
+ }
55
+ ru(t, e) {
56
+ let s = e;
57
+ null != e && e instanceof _t && (s = e.ss()), this.Ma.store(t, s);
58
+ }
59
+ ya(t) {
60
+ const e = this.tu(t);
61
+ null != e && ((e.bh = new Date().valueOf()), this.ru(t, e));
62
+ }
63
+ tu(t) {
64
+ return _t.Sn(this.Ma.lr(t));
65
+ }
66
+ Nh(t) {
67
+ this.Ma.remove(t);
68
+ }
69
+ bo(t) {
70
+ if (null == t || 0 === t.length) return !1;
71
+ p(t) || (t = [t]);
72
+ let e = this.Ca.lr(STORAGE_KEYS.q.Ta);
73
+ (null != e && p(e)) || (e = []);
74
+ for (let s = 0; s < t.length; s++) e.push(t[s].ss());
75
+ return this.Ca.store(STORAGE_KEYS.q.Ta, e);
76
+ }
77
+ Dh(t) {
78
+ return null != t && this.bo([t]);
79
+ }
80
+ Ua() {
81
+ let t = this.Ca.lr(STORAGE_KEYS.q.Ta);
82
+ this.Ca.remove(STORAGE_KEYS.q.Ta), null == t && (t = []);
83
+ const e = [];
84
+ let s = !1,
85
+ o = null;
86
+ if (p(t))
87
+ for (let s = 0; s < t.length; s++)
88
+ ue.Fa(t[s]) ? e.push(ue.Sn(t[s])) : (o = s);
89
+ else s = !0;
90
+ if (s || null != o) {
91
+ let n = "Stored events could not be deserialized as Events";
92
+ s &&
93
+ (n += ", was " + Object.prototype.toString.call(t) + " not an array"),
94
+ null != o &&
95
+ (n += ", value at index " + o + " does not look like an event"),
96
+ (n +=
97
+ ", serialized values were of type " +
98
+ typeof t +
99
+ ": " +
100
+ JSON.stringify(t)),
101
+ e.push(new ue(null, r.A.qs, new Date().valueOf(), null, { e: n }));
102
+ }
103
+ return e;
104
+ }
105
+ B(t, e) {
106
+ return (
107
+ !!F(
108
+ STORAGE_KEYS.q,
109
+ t,
110
+ "StorageManager cannot store object.",
111
+ "STORAGE_KEYS.OBJECTS"
112
+ ) && this.Ca.store(t, e)
113
+ );
114
+ }
115
+ I(t) {
116
+ return (
117
+ !!F(
118
+ STORAGE_KEYS.q,
119
+ t,
120
+ "StorageManager cannot retrieve object.",
121
+ "STORAGE_KEYS.OBJECTS"
122
+ ) && this.Ca.lr(t)
123
+ );
124
+ }
125
+ Xs(t) {
126
+ return (
127
+ !!F(
128
+ STORAGE_KEYS.q,
129
+ t,
130
+ "StorageManager cannot remove object.",
131
+ "STORAGE_KEYS.OBJECTS"
132
+ ) && (this.Ca.remove(t), !0)
133
+ );
134
+ }
135
+ clearData() {
136
+ const t = rr(STORAGE_KEYS.eu),
137
+ e = rr(STORAGE_KEYS.q);
138
+ for (let e = 0; e < t.length; e++) {
139
+ const s = t[e];
140
+ this.Ma.remove(STORAGE_KEYS.eu[s]);
141
+ }
142
+ for (let t = 0; t < e.length; t++) {
143
+ const s = e[t];
144
+ this.Ca.remove(STORAGE_KEYS.q[s]);
145
+ }
146
+ }
147
+ La(t) {
148
+ return t || STORAGE_KEYS.q.Ka;
149
+ }
150
+ Aa(t) {
151
+ let e = this.Ca.lr(STORAGE_KEYS.q.Ia);
152
+ null == e && (e = {});
153
+ const s = this.La(t[User.Rn]);
154
+ for (let r in t)
155
+ r === User.Rn ||
156
+ (null != e[s] && null != e[s][r]) ||
157
+ this.mu(t[User.Rn], r, t[r]);
158
+ }
159
+ mu(t, e, s) {
160
+ let r = this.Ca.lr(STORAGE_KEYS.q.Ia);
161
+ null == r && (r = {});
162
+ const o = this.La(t);
163
+ let n = r[o];
164
+ if (
165
+ (null == n && ((n = {}), null != t && (n[User.Rn] = t)), e === User.lu)
166
+ ) {
167
+ null == n[e] && (n[e] = {});
168
+ for (let t in s) n[e][t] = s[t];
169
+ } else n[e] = s;
170
+ return (r[o] = n), this.Ca.store(STORAGE_KEYS.q.Ia, r);
171
+ }
172
+ Ba() {
173
+ const t = this.Ca.lr(STORAGE_KEYS.q.Ia);
174
+ this.Ca.remove(STORAGE_KEYS.q.Ia);
175
+ const e = [];
176
+ for (let s in t) null != t[s] && e.push(t[s]);
177
+ return e;
178
+ }
179
+ ou(t) {
180
+ const e = this.Ca.lr(STORAGE_KEYS.q.Ia);
181
+ if (null != e) {
182
+ const s = this.La(null),
183
+ r = e[s];
184
+ null != r &&
185
+ ((e[s] = void 0),
186
+ this.Ca.store(STORAGE_KEYS.q.Ia, e),
187
+ (r[User.Rn] = t),
188
+ this.Aa(r));
189
+ }
190
+ const s = this.tu(STORAGE_KEYS.eu.ph);
191
+ let r = null;
192
+ null != s && (r = s.iu);
193
+ const o = this.Ua();
194
+ if (null != o)
195
+ for (let e = 0; e < o.length; e++) {
196
+ const s = o[e];
197
+ null == s.userId && s.sessionId == r && (s.userId = t), this.Dh(s);
198
+ }
199
+ }
200
+ Pa() {
201
+ return this.Ca.xa;
202
+ }
203
+ }
204
+ G._a = class {
205
+ constructor(t) {
206
+ (this._r = t), (this.xa = ot.Ja() ? 3 : 10);
207
+ }
208
+ ka(t) {
209
+ return t + "." + this._r;
210
+ }
211
+ store(t, e) {
212
+ const s = { v: e };
213
+ try {
214
+ return localStorage.setItem(this.ka(t), JSON.stringify(s)), !0;
215
+ } catch (t) {
216
+ return r.D.info("Storage failure: " + t.message), !1;
217
+ }
218
+ }
219
+ lr(t) {
220
+ try {
221
+ const e = JSON.parse(localStorage.getItem(this.ka(t)));
222
+ return null == e ? null : e.v;
223
+ } catch (t) {
224
+ return r.D.info("Storage retrieval failure: " + t.message), null;
225
+ }
226
+ }
227
+ remove(t) {
228
+ try {
229
+ localStorage.removeItem(this.ka(t));
230
+ } catch (t) {
231
+ return r.D.info("Storage removal failure: " + t.message), !1;
232
+ }
233
+ }
234
+ };
235
+ G.ne = class {
236
+ constructor(t, e) {
237
+ (this._r = t), (this.Va = this.Qa()), (this.Ha = 576e3), (this.Wa = !!e);
238
+ }
239
+ ka(t) {
240
+ return null != this._r ? t + "." + this._r : t;
241
+ }
242
+ Qa() {
243
+ let t = 0,
244
+ e = document.location.hostname;
245
+ const s = e.split("."),
246
+ r = "ab._gd";
247
+ for (; t < s.length - 1 && -1 === document.cookie.indexOf(r + "=" + r); )
248
+ t++,
249
+ (e = "." + s.slice(-1 - t).join(".")),
250
+ (document.cookie = r + "=" + r + ";domain=" + e + ";");
251
+ return (
252
+ (document.cookie =
253
+ r + "=;expires=" + new Date(0).toGMTString() + ";domain=" + e + ";"),
254
+ e
255
+ );
256
+ }
257
+ ie() {
258
+ const t = new Date();
259
+ return t.setTime(t.getTime() + 60 * this.Ha * 1e3), t.getFullYear();
260
+ }
261
+ Xa() {
262
+ const t = At(STORAGE_KEYS.eu),
263
+ e = document.cookie.split(";");
264
+ for (let s = 0; s < e.length; s++) {
265
+ let r = e[s];
266
+ for (; " " === r.charAt(0); ) r = r.substring(1);
267
+ let o = !1;
268
+ for (let e = 0; e < t.length; e++)
269
+ if (0 === r.indexOf(t[e])) {
270
+ o = !0;
271
+ break;
272
+ }
273
+ if (o) {
274
+ const t = r.split("=")[0];
275
+ -1 === t.indexOf("." + this._r) && this.Za(t);
276
+ }
277
+ }
278
+ }
279
+ store(t, e) {
280
+ this.Xa();
281
+ const s = new Date();
282
+ s.setTime(s.getTime() + 60 * this.Ha * 1e3);
283
+ const o = "expires=" + s.toUTCString(),
284
+ n = "domain=" + this.Va;
285
+ let i;
286
+ i = this.Wa ? e : encodeURIComponent(JSON.stringify(e));
287
+ const a = this.ka(t) + "=" + i + ";" + o + ";" + n + ";path=/";
288
+ return a.length >= 4093
289
+ ? (r.D.info(
290
+ "Storage failure: string is " +
291
+ a.length +
292
+ " chars which is too large to store as a cookie."
293
+ ),
294
+ !1)
295
+ : ((document.cookie = a), !0);
296
+ }
297
+ lr(t) {
298
+ const e = [],
299
+ s = this.ka(t) + "=",
300
+ o = document.cookie.split(";");
301
+ for (let n = 0; n < o.length; n++) {
302
+ let i = o[n];
303
+ for (; " " === i.charAt(0); ) i = i.substring(1);
304
+ if (0 === i.indexOf(s))
305
+ try {
306
+ let t;
307
+ (t = this.Wa
308
+ ? i.substring(s.length, i.length)
309
+ : JSON.parse(decodeURIComponent(i.substring(s.length, i.length)))),
310
+ e.push(t);
311
+ } catch (e) {
312
+ return (
313
+ r.D.info("Storage retrieval failure: " + e.message),
314
+ this.remove(t),
315
+ null
316
+ );
317
+ }
318
+ }
319
+ return e.length > 0 ? e[e.length - 1] : null;
320
+ }
321
+ remove(t) {
322
+ this.Za(this.ka(t));
323
+ }
324
+ Za(t) {
325
+ const e = t + "=;expires=" + new Date(0).toGMTString();
326
+ (document.cookie = e), (document.cookie = e + ";path=/");
327
+ const s = e + ";domain=" + this.Va;
328
+ (document.cookie = s), (document.cookie = s + ";path=/");
329
+ }
330
+ };
331
+ G.Oa = class {
332
+ constructor() {
333
+ (this.$a = {}), (this.El = 5242880), (this.xa = 3);
334
+ }
335
+ store(t, e) {
336
+ const s = { value: e },
337
+ o = this.Sl(e);
338
+ return o > this.El
339
+ ? (r.D.info(
340
+ "Storage failure: object is ≈" +
341
+ o +
342
+ " bytes which is greater than the max of " +
343
+ this.El
344
+ ),
345
+ !1)
346
+ : ((this.$a[t] = s), !0);
347
+ }
348
+ Sl(t) {
349
+ const e = [],
350
+ s = [t];
351
+ let r = 0;
352
+ for (; s.length; ) {
353
+ const t = s.pop();
354
+ if ("boolean" == typeof t) r += 4;
355
+ else if ("string" == typeof t) r += 2 * t.length;
356
+ else if ("number" == typeof t) r += 8;
357
+ else if ("object" == typeof t && -1 === e.indexOf(t)) {
358
+ e.push(t);
359
+ for (let e in t) s.push(t[e]);
360
+ }
361
+ }
362
+ return r;
363
+ }
364
+ lr(t) {
365
+ const e = this.$a[t];
366
+ return null == e ? null : e.value;
367
+ }
368
+ remove(t) {
369
+ this.$a[t] = null;
370
+ }
371
+ };
372
+ G.wa = class {
373
+ constructor(t, e, s) {
374
+ (this._l = []),
375
+ e && this._l.push(new G.ne(t)),
376
+ s && this._l.push(new G._a(t)),
377
+ this._l.push(new G.Oa(t));
378
+ }
379
+ store(t, e) {
380
+ let s = !0;
381
+ for (let r = 0; r < this._l.length; r++) s = this._l[r].store(t, e) && s;
382
+ return s;
383
+ }
384
+ lr(t) {
385
+ for (let e = 0; e < this._l.length; e++) {
386
+ const s = this._l[e].lr(t);
387
+ if (null != s) return s;
388
+ }
389
+ return null;
390
+ }
391
+ remove(t) {
392
+ for (let e = 0; e < this._l.length; e++) this._l[e].remove(t);
393
+ }
394
+ };
@@ -1 +1,25 @@
1
- import r from"../../shared-lib/braze-shared-lib.js";export default class u{constructor(){this.De={}}ut(t){if("function"!=typeof t)return null;const i=r.it.nt();return this.De[i]=t,i}removeSubscription(t){delete this.De[t]}removeAllSubscriptions(){this.De={}}St(t){const i=[];for(let r in this.De)i.push(this.De[r](t));return i}}
1
+ import r from "../../shared-lib/braze-shared-lib.js";
2
+ export default class u {
3
+ constructor() {
4
+ this.Pe = {};
5
+ }
6
+ ut(t) {
7
+ if ("function" != typeof t) return null;
8
+ const i = r.it.nt();
9
+ return (this.Pe[i] = t), i;
10
+ }
11
+ removeSubscription(t) {
12
+ delete this.Pe[t];
13
+ }
14
+ removeAllSubscriptions() {
15
+ this.Pe = {};
16
+ }
17
+ bu() {
18
+ return Object.keys(this.Pe).length;
19
+ }
20
+ St(t) {
21
+ const i = [];
22
+ for (let r in this.Pe) i.push(this.Pe[r](t));
23
+ return i;
24
+ }
25
+ }
@@ -1 +1,8 @@
1
- export default{ua:"invalid_api_key",ca:"blacklisted",la:"no_device_identifier",ha:"invalid_json_response",oa:"empty_response",__:"sdk_auth_error"};
1
+ export default {
2
+ pa: "invalid_api_key",
3
+ Ra: "blacklisted",
4
+ ba: "no_device_identifier",
5
+ ma: "invalid_json_response",
6
+ fa: "empty_response",
7
+ __: "sdk_auth_error"
8
+ };
@@ -1 +1,41 @@
1
- import{isObject as jt}from"../util/code-utils.js";import{convertMsToSeconds as l,timestampOrNow as Jt}from"../util/date-utils.js";export default class ue{constructor(t,i,s,r,e){this.userId=t,this.type=i,this.time=Jt(s),this.sessionId=r,this.data=e}li(){const t={name:this.type,time:l(this.time),data:this.data||{},session_id:this.sessionId};return null!=this.userId&&(t.user_id=this.userId),t}ss(){return{u:this.userId,t:this.type,ts:this.time,s:this.sessionId,d:this.data}}static fromJson(t){return new ue(t.user_id,t.name,t.time,t.session_id,t.data)}static Ma(t){return null!=t&&jt(t)&&null!=t.t&&""!==t.t}static yn(t){return new ue(t.u,t.t,t.ts,t.s,t.d)}}
1
+ import { isObject as Jt } from "../util/code-utils.js";
2
+ import {
3
+ convertMsToSeconds as l,
4
+ timestampOrNow as Vt
5
+ } from "../util/date-utils.js";
6
+ export default class ue {
7
+ constructor(t, i, s, r, e) {
8
+ (this.userId = t),
9
+ (this.type = i),
10
+ (this.time = Vt(s)),
11
+ (this.sessionId = r),
12
+ (this.data = e);
13
+ }
14
+ Mi() {
15
+ const t = {
16
+ name: this.type,
17
+ time: l(this.time),
18
+ data: this.data || {},
19
+ session_id: this.sessionId
20
+ };
21
+ return null != this.userId && (t.user_id = this.userId), t;
22
+ }
23
+ ss() {
24
+ return {
25
+ u: this.userId,
26
+ t: this.type,
27
+ ts: this.time,
28
+ s: this.sessionId,
29
+ d: this.data
30
+ };
31
+ }
32
+ static fromJson(t) {
33
+ return new ue(t.user_id, t.name, t.time, t.session_id, t.data);
34
+ }
35
+ static Fa(t) {
36
+ return null != t && Jt(t) && null != t.t && "" !== t.t;
37
+ }
38
+ static Sn(t) {
39
+ return new ue(t.u, t.t, t.ts, t.s, t.d);
40
+ }
41
+ }
@@ -1 +1,10 @@
1
- export default{GOOGLE_TAG_MANAGER:"gg",MPARTICLE:"mp",SEGMENT:"sg",TEALIUM:"tl",MANUAL:"manu",NPM:"npm",CDN:"wcd",SHOPIFY:"shp"};
1
+ export default {
2
+ GOOGLE_TAG_MANAGER: "gg",
3
+ MPARTICLE: "mp",
4
+ SEGMENT: "sg",
5
+ TEALIUM: "tl",
6
+ MANUAL: "manu",
7
+ NPM: "npm",
8
+ CDN: "wcd",
9
+ SHOPIFY: "shp"
10
+ };
@@ -1 +1,26 @@
1
- import DeviceProperties from"../Core/device-properties.js";export default class Ie{constructor(s){this.id=s}li(){const s={};return null!=this[DeviceProperties.BROWSER]&&(s.browser=this[DeviceProperties.BROWSER]),null!=this[DeviceProperties.BROWSER_VERSION]&&(s.browser_version=this[DeviceProperties.BROWSER_VERSION]),null!=this[DeviceProperties.OS]&&(s.os_version=this[DeviceProperties.OS]),null!=this[DeviceProperties.RESOLUTION]&&(s.resolution=this[DeviceProperties.RESOLUTION]),null!=this[DeviceProperties.LANGUAGE]&&(s.locale=this[DeviceProperties.LANGUAGE]),null!=this[DeviceProperties.TIME_ZONE]&&(s.time_zone=this[DeviceProperties.TIME_ZONE]),null!=this[DeviceProperties.USER_AGENT]&&(s.user_agent=this[DeviceProperties.USER_AGENT]),s}}
1
+ import DeviceProperties from "../Core/device-properties.js";
2
+ export default class Ie {
3
+ constructor(s) {
4
+ this.id = s;
5
+ }
6
+ Mi() {
7
+ const s = {};
8
+ return (
9
+ null != this[DeviceProperties.BROWSER] &&
10
+ (s.browser = this[DeviceProperties.BROWSER]),
11
+ null != this[DeviceProperties.BROWSER_VERSION] &&
12
+ (s.browser_version = this[DeviceProperties.BROWSER_VERSION]),
13
+ null != this[DeviceProperties.OS] &&
14
+ (s.os_version = this[DeviceProperties.OS]),
15
+ null != this[DeviceProperties.RESOLUTION] &&
16
+ (s.resolution = this[DeviceProperties.RESOLUTION]),
17
+ null != this[DeviceProperties.LANGUAGE] &&
18
+ (s.locale = this[DeviceProperties.LANGUAGE]),
19
+ null != this[DeviceProperties.TIME_ZONE] &&
20
+ (s.time_zone = this[DeviceProperties.TIME_ZONE]),
21
+ null != this[DeviceProperties.USER_AGENT] &&
22
+ (s.user_agent = this[DeviceProperties.USER_AGENT]),
23
+ s
24
+ );
25
+ }
26
+ }
@@ -1 +1,20 @@
1
- import r from"../../shared-lib/braze-shared-lib.js";export default class _t{constructor(t,e,s){null==t&&(t=r.it.nt()),s=parseInt(s),(isNaN(s)||0===s)&&(s=(new Date).valueOf()),this.eu=t,this.rh=s,this.mh=(new Date).valueOf(),this.ah=e}ss(){return{g:this.eu,e:this.ah,c:this.rh,l:this.mh}}static yn(t){if(null==t||null==t.g)return null;const e=new _t(t.g,t.e,t.c);return e.mh=t.l,e}}
1
+ import r from "../../shared-lib/braze-shared-lib.js";
2
+ export default class _t {
3
+ constructor(t, e, s) {
4
+ null == t && (t = r.it.nt()),
5
+ (s = parseInt(s)),
6
+ (isNaN(s) || 0 === s) && (s = new Date().valueOf()),
7
+ (this.iu = t),
8
+ (this.fh = s),
9
+ (this.bh = new Date().valueOf()),
10
+ (this.jh = e);
11
+ }
12
+ ss() {
13
+ return { g: this.iu, e: this.jh, c: this.fh, l: this.bh };
14
+ }
15
+ static Sn(t) {
16
+ if (null == t || null == t.g) return null;
17
+ const e = new _t(t.g, t.e, t.c);
18
+ return (e.bh = t.l), e;
19
+ }
20
+ }
@@ -1 +1,22 @@
1
- import{rehydrateDateAfterJsonization as w}from"../util/date-utils.js";export default class ei{constructor(t,i,l,s,u){this.endpoint=t||null,this.wn=i||null,this.publicKey=l||null,this.zl=s||null,this.gl=u||null}ss(){return{e:this.endpoint,c:this.wn,p:this.publicKey,u:this.zl,v:this.gl}}static yn(t){return new ei(t.e,w(t.c),t.p,t.u,t.v)}}
1
+ import { rehydrateDateAfterJsonization as w } from "../util/date-utils.js";
2
+ export default class ei {
3
+ constructor(t, i, l, s, u) {
4
+ (this.endpoint = t || null),
5
+ (this.Dn = i || null),
6
+ (this.publicKey = l || null),
7
+ (this.zl = s || null),
8
+ (this.gl = u || null);
9
+ }
10
+ ss() {
11
+ return {
12
+ e: this.endpoint,
13
+ c: this.Dn,
14
+ p: this.publicKey,
15
+ u: this.zl,
16
+ v: this.gl
17
+ };
18
+ }
19
+ static Sn(t) {
20
+ return new ei(t.e, w(t.c), t.p, t.u, t.v);
21
+ }
22
+ }
@@ -1 +1,8 @@
1
- export default class t{constructor(t,s){this.S=!!t,this.ve=s||[]}V(t){this.S=this.S&&t.S,this.ve.push(...t.ve)}}
1
+ export default class t {
2
+ constructor(t, s) {
3
+ (this.S = !!t), (this.ve = s || []);
4
+ }
5
+ V(t) {
6
+ (this.S = this.S && t.S), this.ve.push(...t.ve);
7
+ }
8
+ }
@@ -1 +1,32 @@
1
- export default class Ft{constructor(t,s,i,h,l,e,r,u){this.ul=t||0,this.vl=s||[],this.wl=i||[],this.Cl=h||[],this.jl=l,null!=l&&""!==l||(this.jl=null),this.gl=e||null,this.ml=r||{},this.cl=u||{}}ss(){return{s:"4.3.0",l:this.ul,e:this.vl,a:this.wl,p:this.Cl,m:this.jl,v:this.gl,c:this.ml,f:this.cl}}static yn(t){let s=t.l;return"4.3.0"!==t.s&&(s=0),new Ft(s,t.e,t.a,t.p,t.m,t.v,t.c,t.f)}}
1
+ export default class Ft {
2
+ constructor(t, s, i, h, l, e, r, u) {
3
+ (this.ul = t || 0),
4
+ (this.bl = s || []),
5
+ (this.dl = i || []),
6
+ (this.vl = h || []),
7
+ (this.Cl = l),
8
+ (null != l && "" !== l) || (this.Cl = null),
9
+ (this.gl = e || null),
10
+ (this.ml = r || {}),
11
+ (this.cl = u || {});
12
+ }
13
+ ss() {
14
+ return {
15
+ s: "4.5.0",
16
+ l: this.ul,
17
+ e: this.bl,
18
+ a: this.dl,
19
+ p: this.vl,
20
+ m: this.Cl,
21
+ v: this.gl,
22
+ c: this.ml,
23
+ f: this.cl
24
+ };
25
+ }
26
+ static Sn(t) {
27
+ let s = t.l;
28
+ return (
29
+ "4.5.0" !== t.s && (s = 0), new Ft(s, t.e, t.a, t.p, t.m, t.v, t.c, t.f)
30
+ );
31
+ }
32
+ }