@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.
- package/index.d.ts +68 -6
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +8 -1
- package/shared-lib/encoding-utils.js +12 -1
- package/shared-lib/event-types.js +32 -1
- package/shared-lib/guid.js +10 -1
- package/shared-lib/indexed-db-adapter.js +315 -1
- package/shared-lib/logger.js +38 -1
- package/shared-lib/supported-options.js +26 -1
- package/src/Card/card-manager-factory.js +14 -1
- package/src/Card/card-manager.js +72 -1
- package/src/Card/display/card-display.js +134 -1
- package/src/Card/index.js +5 -1
- package/src/Card/log-card-click.js +11 -1
- package/src/Card/log-card-dismissal.js +11 -1
- package/src/Card/log-card-impressions.js +13 -1
- package/src/Card/log-content-card-impressions.js +4 -1
- package/src/Card/models/banner.js +30 -1
- package/src/Card/models/captioned-image.js +32 -1
- package/src/Card/models/card.js +175 -1
- package/src/Card/models/classic-card.js +32 -1
- package/src/Card/models/control-card.js +39 -1
- package/src/Card/models/index.js +5 -1
- package/src/Card/util/card-factory.js +104 -1
- package/src/ContentCards/content-cards-provider-factory.js +20 -1
- package/src/ContentCards/content-cards-provider.js +283 -1
- package/src/ContentCards/content-cards.js +24 -1
- package/src/ContentCards/get-cached-content-cards.js +5 -1
- package/src/ContentCards/index.js +8 -1
- package/src/ContentCards/log-content-cards-displayed.js +5 -1
- package/src/ContentCards/request-content-cards-refresh.js +5 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +14 -1
- package/src/ContentCards/ui/hide-content-cards.js +8 -1
- package/src/ContentCards/ui/show-content-cards.js +72 -1
- package/src/ContentCards/ui/toggle-content-cards.js +8 -1
- package/src/Core/add-sdk-metadata.js +27 -1
- package/src/Core/braze-sdk-metadata.js +10 -1
- package/src/Core/change-user.js +19 -1
- package/src/Core/destroy.js +5 -1
- package/src/Core/device-properties.js +9 -1
- package/src/Core/disable-sdk.js +10 -1
- package/src/Core/enable-sdk.js +8 -1
- package/src/Core/get-device-id.js +10 -1
- package/src/Core/get-user.js +4 -1
- package/src/Core/handle-braze-action.js +64 -1
- package/src/Core/index.js +23 -1
- package/src/Core/initialize.js +4 -1
- package/src/Core/is-disabled.js +4 -1
- package/src/Core/log-custom-event.js +36 -1
- package/src/Core/log-purchase.js +245 -1
- package/src/Core/open-session.js +23 -1
- package/src/Core/remove-all-subscriptions.js +4 -1
- package/src/Core/remove-subscription.js +4 -1
- package/src/Core/request-immediate-data-flush.js +4 -1
- package/src/Core/set-logger.js +4 -1
- package/src/Core/set-sdk-authentication-signature.js +9 -1
- package/src/Core/subscribe-to-sdk-authentication-failures.js +4 -1
- package/src/Core/toggle-logging.js +4 -1
- package/src/Core/wipe-data.js +15 -1
- package/src/FeatureFlags/feature-flag-factory.js +14 -0
- package/src/FeatureFlags/feature-flag.js +16 -0
- package/src/FeatureFlags/feature-flags-provider-factory.js +19 -0
- package/src/FeatureFlags/feature-flags-provider.js +94 -0
- package/src/FeatureFlags/get-all-feature-flags.js +12 -0
- package/src/FeatureFlags/get-feature-flag.js +12 -0
- package/src/FeatureFlags/index.js +4 -0
- package/src/FeatureFlags/refresh-feature-flags.js +9 -0
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +6 -0
- package/src/Feed/feed-provider-factory.js +18 -1
- package/src/Feed/feed-provider.js +79 -1
- package/src/Feed/feed.js +20 -1
- package/src/Feed/get-cached-feed.js +5 -1
- package/src/Feed/index.js +8 -1
- package/src/Feed/log-feed-displayed.js +5 -1
- package/src/Feed/request-feed-refresh.js +5 -1
- package/src/Feed/subscribe-to-feed-updates.js +5 -1
- package/src/Feed/ui/hide-feed.js +7 -1
- package/src/Feed/ui/show-feed.js +89 -1
- package/src/Feed/ui/toggle-feed.js +8 -1
- package/src/InAppMessage/display/get-animation-effect.js +19 -1
- package/src/InAppMessage/display/html-message-to-html.js +223 -1
- package/src/InAppMessage/display/in-app-message-to-html.js +152 -1
- package/src/InAppMessage/display/modal-utils.js +68 -1
- package/src/InAppMessage/in-app-message-factory.js +145 -1
- package/src/InAppMessage/in-app-message-manager-factory.js +16 -1
- package/src/InAppMessage/in-app-message-manager.js +189 -1
- package/src/InAppMessage/index.js +14 -1
- package/src/InAppMessage/log-in-app-message-button-click.js +19 -1
- package/src/InAppMessage/log-in-app-message-click.js +19 -1
- package/src/InAppMessage/log-in-app-message-html-click.js +23 -1
- package/src/InAppMessage/log-in-app-message-impression.js +13 -1
- package/src/InAppMessage/models/control-message.js +8 -1
- package/src/InAppMessage/models/full-screen-message.js +71 -1
- package/src/InAppMessage/models/html-message.js +54 -1
- package/src/InAppMessage/models/in-app-message-button.js +40 -1
- package/src/InAppMessage/models/in-app-message.js +271 -1
- package/src/InAppMessage/models/modal-message.js +68 -1
- package/src/InAppMessage/models/slide-up-message.js +58 -1
- package/src/InAppMessage/models/templated-in-app-message.js +14 -1
- package/src/InAppMessage/subscribe-to-in-app-message.js +10 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +15 -1
- package/src/InAppMessage/ui/show-in-app-message.js +170 -1
- package/src/Push/index.js +5 -1
- package/src/Push/is-push-blocked.js +5 -1
- package/src/Push/is-push-permission-granted.js +5 -1
- package/src/Push/is-push-supported.js +5 -1
- package/src/Push/push-manager-factory.js +30 -1
- package/src/Push/push-manager.js +360 -1
- package/src/Push/request-push-permission.js +8 -1
- package/src/Push/unregister-push.js +5 -1
- package/src/Push/utils/push-utils.js +34 -1
- package/src/User/index.js +1 -1
- package/src/User/user-manager.js +70 -1
- package/src/User/user.js +278 -1
- package/src/common/base-feed.js +25 -1
- package/src/common/base-provider.js +6 -1
- package/src/common/constants.js +5 -1
- package/src/common/event-logger.js +24 -1
- package/src/common/feed-display.js +200 -1
- package/src/common/translations.js +148 -1
- package/src/index.js +9 -1
- package/src/l10n/l10n-manager-factory.js +22 -1
- package/src/l10n/l10n-manager.js +21 -1
- package/src/managers/auth-manager.js +48 -1
- package/src/managers/braze-instance.js +307 -1
- package/src/managers/device-manager.js +80 -1
- package/src/managers/network-manager.js +219 -1
- package/src/managers/server-config-manager.js +88 -1
- package/src/managers/session-manager.js +68 -1
- package/src/managers/storage-manager-factory.js +35 -1
- package/src/managers/storage-manager.js +394 -1
- package/src/managers/subscription-manager.js +25 -1
- package/src/models/backend-errors.js +8 -1
- package/src/models/braze-event.js +41 -1
- package/src/models/braze-sdk-metadata.js +10 -1
- package/src/models/device.js +26 -1
- package/src/models/identifier.js +20 -1
- package/src/models/push-token.js +22 -1
- package/src/models/request-result.js +8 -1
- package/src/models/server-config.js +32 -1
- package/src/request-controller.js +288 -1
- package/src/triggers/models/custom-event-data.js +14 -1
- package/src/triggers/models/custom-event-property-data.js +21 -1
- package/src/triggers/models/filter-set.js +55 -1
- package/src/triggers/models/filter.js +98 -1
- package/src/triggers/models/in-app-message-click-data.js +25 -1
- package/src/triggers/models/purchase-data.js +14 -1
- package/src/triggers/models/purchase-property-data.js +21 -1
- package/src/triggers/models/push-click-data.js +15 -1
- package/src/triggers/models/trigger-condition.js +109 -1
- package/src/triggers/models/trigger-events.js +8 -1
- package/src/triggers/models/trigger.js +110 -1
- package/src/triggers/triggers-provider-factory.js +30 -1
- package/src/triggers/triggers-provider.js +307 -1
- package/src/ui/js/attach-css.js +12 -1
- package/src/ui/js/feed-css.js +12 -1
- package/src/ui/js/iam-css.js +12 -1
- package/src/ui/js/index.js +3 -1
- package/src/ui/js/load-font-awesome.js +13 -1
- package/src/util/base-device-parser.js +14 -1
- package/src/util/braze-actions.js +79 -1
- package/src/util/browser-detector.js +85 -1
- package/src/util/client-hints-parser.js +60 -1
- package/src/util/code-utils.js +92 -1
- package/src/util/color-utils.js +23 -1
- package/src/util/component-utils.js +26 -1
- package/src/util/date-utils.js +27 -1
- package/src/util/deprecation-utils.js +5 -1
- package/src/util/device-constants.js +14 -1
- package/src/util/dom-utils.js +87 -1
- package/src/util/key-codes.js +1 -1
- package/src/util/math.js +5 -1
- package/src/util/net.js +75 -1
- package/src/util/string-utils.js +22 -1
- package/src/util/url-utils.js +23 -1
- package/src/util/user-agent-parser.js +85 -1
- package/src/util/validation-utils.js +136 -1
- package/src/util/window-utils.js +35 -1
|
@@ -1 +1,219 @@
|
|
|
1
|
-
import qt from"../models/backend-errors.js";
|
|
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";
|
|
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";
|
|
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";
|
|
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;
|