@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,219 @@
1
- import qt from"../models/backend-errors.js";import ue from"../models/braze-event.js";import{convertMsToSeconds as l,convertSecondsToMs as Dt}from"../util/date-utils.js";import s from"../common/event-logger.js";import{isArray as p,isEqual as ii}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"./storage-manager.js";export default class wt{constructor(t,e,s,i,r,o,n,a,h,u,c){this.Qi=t,this.h=e,this.Bo=s,this.v=i,this.j=r,this.gt=o,this.Ji=n,this.yo=a,this.Po=h,this.zo=u,this.Xo=c,this.$o=["npm"]}Ps(t,e){const s=this.Qi.te(),i=s.li(),r=this.h.I(o.q.Ho);ii(r,i)||(t.device=i),t.api_key=this.Ji,t.time=l((new Date).valueOf(),!0);const n=this.h.I(o.q.Yo)||[],a=this.h.I(o.q.Zo)||"";if(this.$o.length>0&&(!ii(n,this.$o)||a!==this.j.Vo())&&(t.sdk_metadata=this.$o),t.sdk_version=this.Po,this.zo&&(t.sdk_flavor=this.zo),t.app_version=this.Xo,t.device_id=s.id,e){const e=this.v.getUserId();null!=e&&(t.user_id=e)}return t}Os(t,e,i){const o=e.auth_error,n=e.error;if(!o&&!n)return!0;if(o){let e;this.Bo.Pn();const s={errorCode:o.error_code};for(const t of i)p(t)&&"X-Braze-Auth-Signature"===t[0]&&(s.signature=t[1]);t.respond_with&&t.respond_with.user_id?s.userId=t.respond_with.user_id:t.user_id&&(s.userId=t.user_id);const n=o.reason;return n?(s.reason=n,e=`due to ${n}`):e=`with error code ${o.error_code}.`,this.Bo.Gn()||(e+=' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),r.D.error(`SDK Authentication failed ${e}`),this.sa(t.events,t.attributes),this.Bo.Mn(s),!1}if(n){let i=n;switch(i){case qt.oa:const o="Received successful response with empty body.";return s.G(r.A.qs,{e:o}),r.D.info(o),!1;case qt.ha:const n="Received successful response with invalid JSON";return s.G(r.A.qs,{e:n+": "+e.response}),r.D.info(n),!1;case qt.ua:i=`The API key "${t.api_key}" is invalid for the baseUrl ${this.yo}`;break;case qt.ca:i="Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";break;case qt.la:i="No device identifier. Please contact support@braze.com"}r.D.error("Backend error: "+i)}return!1}fa(t,e,s,i){return!!(t&&0!==t.length||e&&0!==e.length||s||i)}ma(t,e,s,i){const r=[],o=t=>t||"",n=o(this.v.getUserId());let a,h,u,c,l=this.ni(t,e);if(s.length>0){const t=[];for(const e of s){if(a=e.li(),this.Bo.Gn()){if(n&&!a.user_id){c||(c={},c.events=[]),c.events.push(a);continue}if(o(a.user_id)!==n){h||(h=[]),h.push(a);continue}}t.push(a)}t.length>0&&(l.events=t)}if(i.length>0){const t=[];for(const e of i)this.Bo.Gn()&&o(e.user_id)!==n?(u||(u=[]),u.push(e)):t.push(e);t.length>0&&(l.attributes=t)}if(this.sa(h,u),l=this.Ps(l,!0),c){c=this.Ps(c,!1);const t={requestData:c,headers:this.Bs(c)};r.push(t)}if(l&&!this.fa(l.events,l.attributes,t,e))return c?r:null;const f={requestData:l,headers:this.Bs(l)};return r.push(f),r}sa(t,e){if(t){const e=[];for(const s of t){const t=ue.fromJson(s);t.time=Dt(t.time),e.push(t)}this.h.bo(e)}if(e)for(const t of e)this.h.pa(t)}Vs(t,e){let s="HTTP error ";null!=t&&(s+=t+" "),s+=e,r.D.error(s)}yr(t){return s.G(r.A.Ra,{n:t})}ni(t,e,s){const i={};t&&(i.feed=!0),e&&(i.triggers=!0);const r=null!=s?s:this.v.getUserId();return r&&(i.user_id=r),i.config={config_time:this.gt.Zs()},{respond_with:i}}Bs(t,e,s){const i=[["X-Braze-Api-Key",this.Ji]];let r=!1;if(null!=t.respond_with&&t.respond_with.triggers&&(i.push(["X-Braze-TriggersRequest","true"]),r=!0),null!=t.respond_with&&t.respond_with.feed&&(i.push(["X-Braze-FeedRequest","true"]),r=!0),e){i.push(["X-Braze-ContentCardsRequest","true"]);let t=this.h.I(o.q.As);t&&s||(t=0,this.h.B(o.q.As,t)),i.push(["BRAZE-SYNC-RETRY-COUNT",t.toString()]),r=!0}if(r&&i.push(["X-Braze-DataRequest","true"]),this.Bo.Gn()){const t=this.Bo.Hn();null!=t&&i.push(["X-Braze-Auth-Signature",t])}return i}Gs(t,e){const s=t.device;s&&s.os_version instanceof Promise?s.os_version.then((s=>{t.device.os_version=s,e()})):e()}Qs(){this.Bo.Qs()}Ks(){return this.yo}addSdkMetadata(t){for(const e of t)-1===this.$o.indexOf(e)&&this.$o.push(e)}}
1
+ import qt from "../models/backend-errors.js";
2
+ import ue from "../models/braze-event.js";
3
+ import {
4
+ convertMsToSeconds as l,
5
+ convertSecondsToMs as Bt
6
+ } from "../util/date-utils.js";
7
+ import s from "../common/event-logger.js";
8
+ import { isArray as p, isEqual as ii } from "../util/code-utils.js";
9
+ import r from "../../shared-lib/braze-shared-lib.js";
10
+ import { STORAGE_KEYS as o } from "./storage-manager.js";
11
+ export default class Ot {
12
+ constructor(t, e, s, i, r, o, n, a, u, h, c) {
13
+ (this.Ur = t),
14
+ (this.h = e),
15
+ (this.Ko = s),
16
+ (this.v = i),
17
+ (this.j = r),
18
+ (this.gt = o),
19
+ (this._r = n),
20
+ (this.Bo = a),
21
+ (this.Do = u),
22
+ (this.Go = h),
23
+ (this.sa = c),
24
+ (this.oa = ["npm"]);
25
+ }
26
+ Ps(t, e) {
27
+ const s = this.Ur.te(),
28
+ i = s.Mi(),
29
+ r = this.h.I(o.q.Yo);
30
+ ii(r, i) || (t.device = i),
31
+ (t.api_key = this._r),
32
+ (t.time = l(new Date().valueOf(), !0));
33
+ const n = this.h.I(o.q.ua) || [],
34
+ a = this.h.I(o.q.ha) || "";
35
+ if (
36
+ (this.oa.length > 0 &&
37
+ (!ii(n, this.oa) || a !== this.j.ca()) &&
38
+ (t.sdk_metadata = this.oa),
39
+ (t.sdk_version = this.Do),
40
+ this.Go && (t.sdk_flavor = this.Go),
41
+ (t.app_version = this.sa),
42
+ (t.device_id = s.id),
43
+ e)
44
+ ) {
45
+ const e = this.v.getUserId();
46
+ null != e && (t.user_id = e);
47
+ }
48
+ return t;
49
+ }
50
+ Os(t, e, i) {
51
+ const o = e.auth_error,
52
+ n = e.error;
53
+ if (!o && !n) return !0;
54
+ if (o) {
55
+ let e;
56
+ this.Ko.Xn();
57
+ const s = { errorCode: o.error_code };
58
+ for (const t of i)
59
+ p(t) && "X-Braze-Auth-Signature" === t[0] && (s.signature = t[1]);
60
+ t.respond_with && t.respond_with.user_id
61
+ ? (s.userId = t.respond_with.user_id)
62
+ : t.user_id && (s.userId = t.user_id);
63
+ const n = o.reason;
64
+ return (
65
+ n
66
+ ? ((s.reason = n), (e = `due to ${n}`))
67
+ : (e = `with error code ${o.error_code}.`),
68
+ this.Ko.Jn() ||
69
+ (e +=
70
+ ' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
71
+ r.D.error(`SDK Authentication failed ${e}`),
72
+ this.la(t.events, t.attributes),
73
+ this.Ko.Vn(s),
74
+ !1
75
+ );
76
+ }
77
+ if (n) {
78
+ let i = n;
79
+ switch (i) {
80
+ case qt.fa:
81
+ const o = "Received successful response with empty body.";
82
+ return s.G(r.A.qs, { e: o }), r.D.info(o), !1;
83
+ case qt.ma:
84
+ const n = "Received successful response with invalid JSON";
85
+ return s.G(r.A.qs, { e: n + ": " + e.response }), r.D.info(n), !1;
86
+ case qt.pa:
87
+ i = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Bo}`;
88
+ break;
89
+ case qt.Ra:
90
+ i =
91
+ "Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
92
+ break;
93
+ case qt.ba:
94
+ i = "No device identifier. Please contact support@braze.com";
95
+ }
96
+ r.D.error("Backend error: " + i);
97
+ }
98
+ return !1;
99
+ }
100
+ ga(t, e, s, i) {
101
+ return !!((t && 0 !== t.length) || (e && 0 !== e.length) || s || i);
102
+ }
103
+ qa(t, e, s, i) {
104
+ const r = [],
105
+ o = t => t || "",
106
+ n = o(this.v.getUserId());
107
+ let a,
108
+ u,
109
+ h,
110
+ c,
111
+ l = this.Ai(t, e);
112
+ if (s.length > 0) {
113
+ const t = [];
114
+ for (const e of s) {
115
+ if (((a = e.Mi()), this.Ko.Jn())) {
116
+ if (n && !a.user_id) {
117
+ c || ((c = {}), (c.events = [])), c.events.push(a);
118
+ continue;
119
+ }
120
+ if (o(a.user_id) !== n) {
121
+ u || (u = []), u.push(a);
122
+ continue;
123
+ }
124
+ }
125
+ t.push(a);
126
+ }
127
+ t.length > 0 && (l.events = t);
128
+ }
129
+ if (i.length > 0) {
130
+ const t = [];
131
+ for (const e of i)
132
+ this.Ko.Jn() && o(e.user_id) !== n
133
+ ? (h || (h = []), h.push(e))
134
+ : t.push(e);
135
+ t.length > 0 && (l.attributes = t);
136
+ }
137
+ if ((this.la(u, h), (l = this.Ps(l, !0)), c)) {
138
+ c = this.Ps(c, !1);
139
+ const t = { requestData: c, headers: this.Bs(c) };
140
+ r.push(t);
141
+ }
142
+ if (l && !this.ga(l.events, l.attributes, t, e)) return c ? r : null;
143
+ const f = { requestData: l, headers: this.Bs(l) };
144
+ return r.push(f), r;
145
+ }
146
+ la(t, e) {
147
+ if (t) {
148
+ const e = [];
149
+ for (const s of t) {
150
+ const t = ue.fromJson(s);
151
+ (t.time = Bt(t.time)), e.push(t);
152
+ }
153
+ this.h.bo(e);
154
+ }
155
+ if (e) for (const t of e) this.h.Aa(t);
156
+ }
157
+ Vs(t, e) {
158
+ let s = "HTTP error ";
159
+ null != t && (s += t + " "), (s += e), r.D.error(s);
160
+ }
161
+ yr(t) {
162
+ return s.G(r.A.za, { n: t });
163
+ }
164
+ Ai(t, e, s) {
165
+ const i = {};
166
+ t && (i.feed = !0), e && (i.triggers = !0);
167
+ const r = null != s ? s : this.v.getUserId();
168
+ return (
169
+ r && (i.user_id = r),
170
+ (i.config = { config_time: this.gt.Zs() }),
171
+ { respond_with: i }
172
+ );
173
+ }
174
+ Bs(t, e, s, i) {
175
+ const r = [["X-Braze-Api-Key", this._r]];
176
+ let n = !1;
177
+ if (
178
+ (null != t.respond_with &&
179
+ t.respond_with.triggers &&
180
+ (r.push(["X-Braze-TriggersRequest", "true"]), (n = !0)),
181
+ null != t.respond_with &&
182
+ t.respond_with.feed &&
183
+ (r.push(["X-Braze-FeedRequest", "true"]), (n = !0)),
184
+ e)
185
+ ) {
186
+ r.push(["X-Braze-ContentCardsRequest", "true"]);
187
+ let t = this.h.I(o.q.As);
188
+ (t && i) || ((t = 0), this.h.B(o.q.As, t)),
189
+ r.push(["BRAZE-SYNC-RETRY-COUNT", t.toString()]),
190
+ (n = !0);
191
+ }
192
+ if (
193
+ (s && (r.push(["X-Braze-FeatureFlagsRequest", "true"]), (n = !0)),
194
+ n && r.push(["X-Braze-DataRequest", "true"]),
195
+ this.Ko.Jn())
196
+ ) {
197
+ const t = this.Ko.Kn();
198
+ null != t && r.push(["X-Braze-Auth-Signature", t]);
199
+ }
200
+ return r;
201
+ }
202
+ Gs(t, e) {
203
+ const s = t.device;
204
+ s && s.os_version instanceof Promise
205
+ ? s.os_version.then(s => {
206
+ (t.device.os_version = s), e();
207
+ })
208
+ : e();
209
+ }
210
+ Qs() {
211
+ this.Ko.Qs();
212
+ }
213
+ Ks() {
214
+ return this.Bo;
215
+ }
216
+ addSdkMetadata(t) {
217
+ for (const e of t) -1 === this.oa.indexOf(e) && this.oa.push(e);
218
+ }
219
+ }
@@ -1 +1,88 @@
1
- import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import Ft from"../models/server-config.js";import s from"../common/event-logger.js";import r from"../../shared-lib/braze-shared-lib.js";export default class Ct{constructor(t){this.h=t,this.tl=new u,this.sl=new u,this.il=new u,this.rl=null}hl(){if(null==this.rl){const t=this.h.I(o.q.ol);this.rl=null!=t?Ft.yn(t):new Ft}return this.rl}Zs(){return this.hl().ul}al(t){if(null!=t&&null!=t.config){const e=t.config;if(e.time>this.hl().ul){const t=new Ft(e.time,e.events_blacklist,e.attributes_blacklist,e.purchases_blacklist,e.messaging_session_timeout,e.vapid_public_key,e.content_cards,e.feature_flags);let s=!1;null!=t.gl&&this.fn()!==t.gl&&(s=!0);let i=!1;null!=t.ml.enabled&&this.Ys()!==t.ml.enabled&&(i=!0);let r=!1;null!=t.cl.enabled&&this.fl()!==t.cl.enabled&&(r=!0),this.rl=t,this.h.B(o.q.ol,t.ss()),s&&this.tl.St(),i&&this.sl.St(),r&&this.il.St()}}}dn(t){let e=this.tl.ut(t);return this.bl&&this.tl.removeSubscription(this.bl),this.bl=e,e}Ms(t){return this.sl.ut(t)}dl(t){return this.il.ut(t)}ge(t){return-1!==this.hl().vl.indexOf(t)}hu(t){return-1!==this.hl().wl.indexOf(t)}Dr(t){return-1!==this.hl().Cl.indexOf(t)}Fl(){return this.hl().jl}fn(){return this.hl().gl}Ys(){return this.hl().ml.enabled||!1}fl(){return this.hl().cl.enabled&&null==this.Tl()?(s.G(r.A.qs,{e:"Missing feature flag refresh_rate_limit."}),!1):this.hl().cl.enabled||!1}Tl(){return this.hl().cl.El}}
1
+ import { STORAGE_KEYS as o } from "./storage-manager.js";
2
+ import u from "./subscription-manager.js";
3
+ import Ft from "../models/server-config.js";
4
+ import s from "../common/event-logger.js";
5
+ import r from "../../shared-lib/braze-shared-lib.js";
6
+ export default class Pt {
7
+ constructor(t) {
8
+ (this.h = t),
9
+ (this.tl = new u()),
10
+ (this.sl = new u()),
11
+ (this.il = new u()),
12
+ (this.rl = null);
13
+ }
14
+ hl() {
15
+ if (null == this.rl) {
16
+ const t = this.h.I(o.q.ol);
17
+ this.rl = null != t ? Ft.Sn(t) : new Ft();
18
+ }
19
+ return this.rl;
20
+ }
21
+ Zs() {
22
+ return this.hl().ul;
23
+ }
24
+ al(t) {
25
+ if (null != t && null != t.config) {
26
+ const e = t.config;
27
+ if (e.time > this.hl().ul) {
28
+ const t = new Ft(
29
+ e.time,
30
+ e.events_blacklist,
31
+ e.attributes_blacklist,
32
+ e.purchases_blacklist,
33
+ e.messaging_session_timeout,
34
+ e.vapid_public_key,
35
+ e.content_cards,
36
+ e.feature_flags
37
+ );
38
+ let s = !1;
39
+ null != t.gl && this.wn() !== t.gl && (s = !0);
40
+ let i = !1;
41
+ null != t.ml.enabled && this.Ys() !== t.ml.enabled && (i = !0);
42
+ let r = !1;
43
+ null != t.cl.enabled && this.ye() !== t.cl.enabled && (r = !0),
44
+ (this.rl = t),
45
+ this.h.B(o.q.ol, t.ss()),
46
+ s && this.tl.St(),
47
+ i && this.sl.St(),
48
+ r && this.il.St();
49
+ }
50
+ }
51
+ }
52
+ yn(t) {
53
+ let e = this.tl.ut(t);
54
+ return this.fl && this.tl.removeSubscription(this.fl), (this.fl = e), e;
55
+ }
56
+ Ms(t) {
57
+ return this.sl.ut(t);
58
+ }
59
+ Te(t) {
60
+ return this.il.ut(t);
61
+ }
62
+ ge(t) {
63
+ return -1 !== this.hl().bl.indexOf(t);
64
+ }
65
+ hu(t) {
66
+ return -1 !== this.hl().dl.indexOf(t);
67
+ }
68
+ Dr(t) {
69
+ return -1 !== this.hl().vl.indexOf(t);
70
+ }
71
+ wl() {
72
+ return this.hl().Cl;
73
+ }
74
+ wn() {
75
+ return this.hl().gl;
76
+ }
77
+ Ys() {
78
+ return this.hl().ml.enabled || !1;
79
+ }
80
+ ye() {
81
+ return this.hl().cl.enabled && null == this.$e()
82
+ ? (s.G(r.A.qs, { e: "Missing feature flag refresh_rate_limit." }), !1)
83
+ : this.hl().cl.enabled || !1;
84
+ }
85
+ $e() {
86
+ return this.hl().cl.refresh_rate_limit;
87
+ }
88
+ }
@@ -1 +1,68 @@
1
- import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{convertMsToSeconds as l}from"../util/date-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export default class Lt{constructor(s,t,e,i){this.h=s,this.v=t,this.gt=e,this.sh=1e3,i=parseFloat(i),isNaN(i)&&(i=1800),i<this.sh/1e3&&(r.D.info("Specified session timeout of "+i+"s is too small, using the minimum session timeout of "+this.sh/1e3+"s instead."),i=this.sh/1e3),this.eh=i}ih(s,t){return new ue(this.v.getUserId(),r.A.nh,s,t.eu,{d:l(s-t.rh)})}Vo(){const s=this.h.tu(o.iu.oh);return null==s?null:s.eu}hh(){const s=(new Date).valueOf(),t=this.gt.Fl(),e=this.h.I(o.q.lh);if(null!=e&&null==t)return!1;const i=null==e||s-e>1e3*t;return i&&this.h.B(o.q.lh,s),i}uh(s,t){return null==t||!(s-t.rh<this.sh)&&t.ah<s}mo(){const s=(new Date).valueOf(),t=s+1e3*this.eh,e=this.h.tu(o.iu.oh);if(this.uh(s,e)){let i="Generating session start event with time "+s;if(null!=e){let s=e.mh;s-e.rh<this.sh&&(s=e.rh+this.dh),this.h.fh(this.ih(s,e)),i+=" (old session ended "+s+")"}i+=". Will expire "+t.valueOf(),r.D.info(i);const n=new _t(r.it.nt(),t);this.h.fh(new ue(this.v.getUserId(),r.A.ph,s,n.eu)),this.h.ru(o.iu.oh,n);return null==this.h.I(o.q.lh)&&this.h.B(o.q.lh,s),n.eu}return e.mh=s,e.ah=t,this.h.ru(o.iu.oh,e),e.eu}gh(){const s=this.h.tu(o.iu.oh);null!=s&&(this.h.wh(o.iu.oh),this.h.fh(this.ih((new Date).valueOf(),s)))}}
1
+ import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
2
+ import ue from "../models/braze-event.js";
3
+ import _t from "../models/identifier.js";
4
+ import { convertMsToSeconds as l } from "../util/date-utils.js";
5
+ import r from "../../shared-lib/braze-shared-lib.js";
6
+ export default class Rt {
7
+ constructor(s, t, e, i) {
8
+ (this.h = s),
9
+ (this.v = t),
10
+ (this.gt = e),
11
+ (this.uh = 1e3),
12
+ (i = parseFloat(i)),
13
+ isNaN(i) && (i = 1800),
14
+ i < this.uh / 1e3 &&
15
+ (r.D.info(
16
+ "Specified session timeout of " +
17
+ i +
18
+ "s is too small, using the minimum session timeout of " +
19
+ this.uh / 1e3 +
20
+ "s instead."
21
+ ),
22
+ (i = this.uh / 1e3)),
23
+ (this.ah = i);
24
+ }
25
+ mh(s, t) {
26
+ return new ue(this.v.getUserId(), r.A.dh, s, t.iu, { d: l(s - t.fh) });
27
+ }
28
+ ca() {
29
+ const s = this.h.tu(o.eu.ph);
30
+ return null == s ? null : s.iu;
31
+ }
32
+ gh() {
33
+ const s = new Date().valueOf(),
34
+ t = this.gt.wl(),
35
+ e = this.h.I(o.q.wh);
36
+ if (null != e && null == t) return !1;
37
+ const i = null == e || s - e > 1e3 * t;
38
+ return i && this.h.B(o.q.wh, s), i;
39
+ }
40
+ Sh(s, t) {
41
+ return null == t || (!(s - t.fh < this.uh) && t.jh < s);
42
+ }
43
+ mo() {
44
+ const s = new Date().valueOf(),
45
+ t = s + 1e3 * this.ah,
46
+ e = this.h.tu(o.eu.ph);
47
+ if (this.Sh(s, e)) {
48
+ let i = "Generating session start event with time " + s;
49
+ if (null != e) {
50
+ let s = e.bh;
51
+ s - e.fh < this.uh && (s = e.fh + this.xh),
52
+ this.h.Dh(this.mh(s, e)),
53
+ (i += " (old session ended " + s + ")");
54
+ }
55
+ (i += ". Will expire " + t.valueOf()), r.D.info(i);
56
+ const n = new _t(r.it.nt(), t);
57
+ this.h.Dh(new ue(this.v.getUserId(), r.A.Ch, s, n.iu)),
58
+ this.h.ru(o.eu.ph, n);
59
+ return null == this.h.I(o.q.wh) && this.h.B(o.q.wh, s), n.iu;
60
+ }
61
+ return (e.bh = s), (e.jh = t), this.h.ru(o.eu.ph, e), e.iu;
62
+ }
63
+ Gh() {
64
+ const s = this.h.tu(o.eu.ph);
65
+ null != s &&
66
+ (this.h.Nh(o.eu.ph), this.h.Dh(this.mh(new Date().valueOf(), s)));
67
+ }
68
+ }
@@ -1 +1,35 @@
1
- import G,{STORAGE_KEYS as o}from"./storage-manager.js";import r from"../../shared-lib/braze-shared-lib.js";const Pt={jo:(e,t)=>{let a=!1;try{if(localStorage&&localStorage.getItem)try{localStorage.setItem(o.q.ga,!0),localStorage.getItem(o.q.ga)&&(localStorage.removeItem(o.q.ga),a=!0)}catch(e){if("QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||!(localStorage.length>0))throw e;a=!0}}catch(e){r.D.info("Local Storage not supported!")}const l=Pt.Sa(),c=new G.Ea(e,l&&!t,a);let n=null;return n=a?new G.wa(e):new G._a,new G(c,n)},Sa:()=>navigator.cookieEnabled||"cookie"in document&&(document.cookie.length>0||(document.cookie="test").indexOf.call(document.cookie,"test")>-1)};export default Pt;
1
+ import G, { STORAGE_KEYS as o } from "./storage-manager.js";
2
+ import r from "../../shared-lib/braze-shared-lib.js";
3
+ const Mt = {
4
+ Fo: (e, t) => {
5
+ let a = !1;
6
+ try {
7
+ if (localStorage && localStorage.getItem)
8
+ try {
9
+ localStorage.setItem(o.q.Sa, !0),
10
+ localStorage.getItem(o.q.Sa) &&
11
+ (localStorage.removeItem(o.q.Sa), (a = !0));
12
+ } catch (e) {
13
+ if (
14
+ ("QuotaExceededError" !== e.name &&
15
+ "NS_ERROR_DOM_QUOTA_REACHED" !== e.name) ||
16
+ !(localStorage.length > 0)
17
+ )
18
+ throw e;
19
+ a = !0;
20
+ }
21
+ } catch (e) {
22
+ r.D.info("Local Storage not supported!");
23
+ }
24
+ const l = Mt.Ea(),
25
+ c = new G.wa(e, l && !t, a);
26
+ let n = null;
27
+ return (n = a ? new G._a(e) : new G.Oa()), new G(c, n);
28
+ },
29
+ Ea: () =>
30
+ navigator.cookieEnabled ||
31
+ ("cookie" in document &&
32
+ (document.cookie.length > 0 ||
33
+ (document.cookie = "test").indexOf.call(document.cookie, "test") > -1))
34
+ };
35
+ export default Mt;