@braze/web-sdk 4.7.1 → 4.8.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 +27 -24
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +5 -5
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +24 -24
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +17 -17
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +18 -18
- package/src/Card/card-manager-factory.js +2 -2
- package/src/Card/card-manager.js +47 -41
- package/src/Card/display/card-display.js +70 -67
- package/src/Card/log-card-click.js +1 -1
- package/src/Card/log-card-dismissal.js +1 -1
- package/src/Card/log-card-impressions.js +3 -3
- package/src/Card/models/banner.js +3 -2
- package/src/Card/models/captioned-image.js +6 -5
- package/src/Card/models/card.js +107 -87
- package/src/Card/models/classic-card.js +5 -5
- package/src/Card/models/control-card.js +5 -21
- package/src/Card/types.js +1 -0
- package/src/Card/util/card-factory.js +32 -32
- package/src/ContentCards/content-cards-provider-factory.js +3 -3
- package/src/ContentCards/content-cards-provider.js +283 -175
- package/src/ContentCards/content-cards.js +2 -2
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/log-content-cards-displayed.js +2 -2
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +9 -6
- package/src/ContentCards/types.js +1 -0
- package/src/ContentCards/ui/hide-content-cards.js +2 -2
- package/src/ContentCards/ui/show-content-cards.js +35 -33
- package/src/Core/add-sdk-metadata.js +17 -18
- package/src/Core/change-user.js +12 -14
- package/src/Core/destroy.js +1 -1
- package/src/Core/disable-sdk.js +7 -6
- package/src/Core/enable-sdk.js +4 -4
- package/src/Core/get-device-id.js +7 -6
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +57 -40
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/log-custom-event.js +22 -15
- package/src/Core/log-purchase.js +33 -33
- package/src/Core/open-session.js +17 -15
- package/src/Core/request-immediate-data-flush.js +4 -2
- package/src/Core/set-logger.js +1 -1
- package/src/Core/set-sdk-authentication-signature.js +5 -6
- package/src/Core/subscribe-to-sdk-authentication-failures.js +3 -1
- package/src/Core/toggle-logging.js +1 -1
- package/src/Core/types.js +1 -0
- package/src/Core/wipe-data.js +11 -10
- package/src/FeatureFlags/feature-flag-factory.js +6 -6
- package/src/FeatureFlags/feature-flag.js +17 -17
- package/src/FeatureFlags/feature-flags-provider-factory.js +2 -2
- package/src/FeatureFlags/feature-flags-provider.js +67 -65
- package/src/FeatureFlags/get-all-feature-flags.js +3 -3
- package/src/FeatureFlags/get-feature-flag.js +4 -4
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -1
- package/src/Feed/feed-provider-factory.js +8 -8
- package/src/Feed/feed-provider.js +57 -46
- package/src/Feed/feed.js +1 -1
- package/src/Feed/get-cached-feed.js +2 -2
- package/src/Feed/log-feed-displayed.js +3 -1
- package/src/Feed/request-feed-refresh.js +2 -2
- package/src/Feed/subscribe-to-feed-updates.js +2 -2
- package/src/Feed/types.js +1 -0
- package/src/Feed/ui/hide-feed.js +2 -2
- package/src/Feed/ui/show-feed.js +40 -36
- package/src/InAppMessage/display/html-message-to-html.js +125 -119
- package/src/InAppMessage/display/in-app-message-to-html.js +72 -69
- package/src/InAppMessage/display/modal-utils.js +18 -13
- package/src/InAppMessage/in-app-message-factory.js +9 -8
- package/src/InAppMessage/in-app-message-manager-factory.js +7 -7
- package/src/InAppMessage/in-app-message-manager.js +122 -108
- package/src/InAppMessage/log-in-app-message-button-click.js +10 -10
- package/src/InAppMessage/log-in-app-message-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-html-click.js +10 -10
- package/src/InAppMessage/log-in-app-message-impression.js +5 -5
- package/src/InAppMessage/models/control-message.js +4 -1
- package/src/InAppMessage/models/full-screen-message.js +35 -37
- package/src/InAppMessage/models/html-message.js +34 -33
- package/src/InAppMessage/models/in-app-message-button.js +23 -16
- package/src/InAppMessage/models/in-app-message.js +147 -105
- package/src/InAppMessage/models/modal-message.js +34 -36
- package/src/InAppMessage/models/slide-up-message.js +25 -27
- package/src/InAppMessage/models/templated-in-app-message.js +12 -7
- package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
- package/src/InAppMessage/types.js +1 -0
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
- package/src/InAppMessage/ui/show-in-app-message.js +95 -89
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -0
- package/src/Push/is-push-blocked.js +2 -2
- package/src/Push/is-push-permission-granted.js +2 -2
- package/src/Push/is-push-supported.js +2 -2
- package/src/Push/push-manager-factory.js +20 -20
- package/src/Push/push-manager.js +192 -174
- package/src/Push/request-push-permission.js +4 -3
- package/src/Push/types.js +1 -0
- package/src/Push/unregister-push.js +2 -2
- package/src/Push/utils/push-utils.js +10 -10
- package/src/User/types.js +1 -0
- package/src/User/user-manager.js +24 -24
- package/src/User/user.js +117 -105
- package/src/common/base-feed.js +7 -7
- package/src/common/base-provider.js +2 -2
- package/src/common/constants.js +6 -0
- package/src/common/event-logger.js +6 -6
- package/src/common/feed-display.js +18 -18
- package/src/common/types.js +1 -0
- package/src/l10n/l10n-manager-factory.js +5 -5
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +204 -202
- package/src/managers/device-manager.js +23 -23
- package/src/managers/network-manager.js +96 -82
- package/src/managers/server-config-manager.js +60 -42
- package/src/managers/session-manager.js +41 -41
- package/src/managers/storage-manager-factory.js +15 -15
- package/src/managers/storage-manager.js +165 -155
- package/src/managers/subscription-manager.js +11 -11
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +7 -7
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +7 -7
- package/src/models/push-token.js +7 -7
- package/src/models/request-result.js +3 -3
- package/src/models/server-config.js +20 -20
- package/src/request-controller.js +176 -174
- package/src/triggers/models/custom-event-data.js +6 -6
- package/src/triggers/models/custom-event-property-data.js +9 -9
- package/src/triggers/models/filter-set.js +9 -9
- package/src/triggers/models/filter.js +64 -64
- package/src/triggers/models/in-app-message-click-data.js +12 -12
- package/src/triggers/models/purchase-data.js +3 -3
- package/src/triggers/models/purchase-property-data.js +9 -9
- package/src/triggers/models/push-click-data.js +5 -5
- package/src/triggers/models/trigger-condition.js +52 -52
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +42 -42
- package/src/triggers/triggers-provider-factory.js +8 -8
- package/src/triggers/triggers-provider.js +171 -168
- package/src/types.js +1 -0
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +20 -20
- package/src/util/browser-detector.js +22 -22
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/code-utils.js +1 -1
- package/src/util/color-utils.js +2 -2
- package/src/util/component-utils.js +2 -2
- package/src/util/deprecation-utils.js +1 -1
- package/src/util/device-constants.js +5 -5
- package/src/util/dom-utils.js +2 -2
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +11 -11
- package/src/util/request-header-utils.js +23 -0
- package/src/util/string-utils.js +1 -1
- package/src/util/user-agent-parser.js +20 -20
- package/src/util/validation-utils.js +44 -44
- package/src/util/window-utils.js +3 -3
|
@@ -1,59 +1,61 @@
|
|
|
1
1
|
import qt from "../models/backend-errors.js";
|
|
2
2
|
import ue from "../models/braze-event.js";
|
|
3
3
|
import {
|
|
4
|
-
convertMsToSeconds as
|
|
4
|
+
convertMsToSeconds as h,
|
|
5
5
|
convertSecondsToMs as Xt
|
|
6
6
|
} from "../util/date-utils.js";
|
|
7
7
|
import s from "../common/event-logger.js";
|
|
8
8
|
import { isArray as p, isEqual as ii } from "../util/code-utils.js";
|
|
9
9
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
10
|
-
import { STORAGE_KEYS as
|
|
10
|
+
import { STORAGE_KEYS as i } from "./storage-manager.js";
|
|
11
|
+
import T from "../util/request-header-utils.js";
|
|
12
|
+
import { LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as Ht } from "../common/constants.js";
|
|
11
13
|
export default class Pt {
|
|
12
14
|
constructor(t, e, s, i, r, o, n, a, u, h, c) {
|
|
13
|
-
(this.
|
|
14
|
-
(this.
|
|
15
|
-
(this.
|
|
16
|
-
(this.
|
|
17
|
-
(this.
|
|
18
|
-
(this.
|
|
19
|
-
(this.
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
23
|
-
(this
|
|
24
|
-
(this.
|
|
15
|
+
(this.Xo = t),
|
|
16
|
+
(this.Jn = e),
|
|
17
|
+
(this.gh = s),
|
|
18
|
+
(this.Qo = i),
|
|
19
|
+
(this.fh = r),
|
|
20
|
+
(this.Zo = o),
|
|
21
|
+
(this.Ko = n),
|
|
22
|
+
(this.Ho = a),
|
|
23
|
+
(this.Vo = u),
|
|
24
|
+
(this.Yo = h),
|
|
25
|
+
(this.pa = c),
|
|
26
|
+
(this.Ra = ["npm"]);
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
const s = this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
ii(
|
|
31
|
-
(t.api_key = this.
|
|
32
|
-
(t.time =
|
|
33
|
-
const n = this.
|
|
34
|
-
a = this.
|
|
28
|
+
Gs(t, e) {
|
|
29
|
+
const s = this.Xo.te(),
|
|
30
|
+
r = s.Wi(),
|
|
31
|
+
o = this.Jn.v(i.k.ma);
|
|
32
|
+
ii(o, r) || (t.device = r),
|
|
33
|
+
(t.api_key = this.Ko),
|
|
34
|
+
(t.time = h(new Date().valueOf(), !0));
|
|
35
|
+
const n = this.Jn.v(i.k.ga) || [],
|
|
36
|
+
a = this.Jn.v(i.k.qa) || "";
|
|
35
37
|
if (
|
|
36
|
-
(this.
|
|
37
|
-
(!ii(n, this.
|
|
38
|
-
(t.sdk_metadata = this.
|
|
39
|
-
(t.sdk_version = this.
|
|
40
|
-
this.
|
|
41
|
-
(t.app_version = this
|
|
38
|
+
(this.Ra.length > 0 &&
|
|
39
|
+
(!ii(n, this.Ra) || a !== this.fh.ba()) &&
|
|
40
|
+
(t.sdk_metadata = this.Ra),
|
|
41
|
+
(t.sdk_version = this.Vo),
|
|
42
|
+
this.Yo && (t.sdk_flavor = this.Yo),
|
|
43
|
+
(t.app_version = this.pa),
|
|
42
44
|
(t.device_id = s.id),
|
|
43
45
|
e)
|
|
44
46
|
) {
|
|
45
|
-
const e = this.
|
|
47
|
+
const e = this.Qo.getUserId();
|
|
46
48
|
null != e && (t.user_id = e);
|
|
47
49
|
}
|
|
48
50
|
return t;
|
|
49
51
|
}
|
|
50
|
-
|
|
52
|
+
ti(t, e, i) {
|
|
51
53
|
const o = e.auth_error,
|
|
52
54
|
n = e.error;
|
|
53
55
|
if (!o && !n) return !0;
|
|
54
56
|
if (o) {
|
|
55
57
|
let e;
|
|
56
|
-
this.
|
|
58
|
+
this.gh.pu();
|
|
57
59
|
const s = { errorCode: o.error_code };
|
|
58
60
|
for (const t of i)
|
|
59
61
|
p(t) && "X-Braze-Auth-Signature" === t[0] && (s.signature = t[1]);
|
|
@@ -65,12 +67,12 @@ export default class Pt {
|
|
|
65
67
|
n
|
|
66
68
|
? ((s.reason = n), (e = `due to ${n}`))
|
|
67
69
|
: (e = `with error code ${o.error_code}.`),
|
|
68
|
-
this.
|
|
70
|
+
this.gh.Zn() ||
|
|
69
71
|
(e +=
|
|
70
72
|
' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
|
|
71
|
-
r.
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
73
|
+
r.j.error(`SDK Authentication failed ${e}`),
|
|
74
|
+
this.Aa(t.events, t.attributes),
|
|
75
|
+
this.gh.Su(s),
|
|
74
76
|
!1
|
|
75
77
|
);
|
|
76
78
|
}
|
|
@@ -78,50 +80,50 @@ export default class Pt {
|
|
|
78
80
|
let i,
|
|
79
81
|
o = n;
|
|
80
82
|
switch (o) {
|
|
81
|
-
case qt.
|
|
83
|
+
case qt.za:
|
|
82
84
|
return (
|
|
83
85
|
(i = "Received successful response with empty body."),
|
|
84
|
-
s.
|
|
85
|
-
r.
|
|
86
|
+
s.N(r.q.Is, { e: i }),
|
|
87
|
+
r.j.info(i),
|
|
86
88
|
!1
|
|
87
89
|
);
|
|
88
|
-
case qt.
|
|
90
|
+
case qt.Ba:
|
|
89
91
|
return (
|
|
90
92
|
(i = "Received successful response with invalid JSON"),
|
|
91
|
-
s.
|
|
92
|
-
r.
|
|
93
|
+
s.N(r.q.Is, { e: i + ": " + e.response }),
|
|
94
|
+
r.j.info(i),
|
|
93
95
|
!1
|
|
94
96
|
);
|
|
95
|
-
case qt.
|
|
96
|
-
o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.
|
|
97
|
+
case qt.Da:
|
|
98
|
+
o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Ho}`;
|
|
97
99
|
break;
|
|
98
|
-
case qt.
|
|
100
|
+
case qt.Sa:
|
|
99
101
|
o =
|
|
100
102
|
"Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
|
|
101
103
|
break;
|
|
102
|
-
case qt.
|
|
104
|
+
case qt.va:
|
|
103
105
|
o = "No device identifier. Please contact support@braze.com";
|
|
104
106
|
}
|
|
105
|
-
r.
|
|
107
|
+
r.j.error("Backend error: " + o);
|
|
106
108
|
}
|
|
107
109
|
return !1;
|
|
108
110
|
}
|
|
109
|
-
|
|
111
|
+
ka(t, e, s, i) {
|
|
110
112
|
return !!((t && 0 !== t.length) || (e && 0 !== e.length) || s || i);
|
|
111
113
|
}
|
|
112
|
-
|
|
114
|
+
Ta(t, e, s, i) {
|
|
113
115
|
const r = [],
|
|
114
116
|
o = t => t || "",
|
|
115
|
-
n = o(this.
|
|
117
|
+
n = o(this.Qo.getUserId());
|
|
116
118
|
let a,
|
|
117
119
|
u,
|
|
118
120
|
h,
|
|
119
121
|
c,
|
|
120
|
-
l = this.
|
|
122
|
+
l = this.Vi(t, e);
|
|
121
123
|
if (s.length > 0) {
|
|
122
124
|
const t = [];
|
|
123
125
|
for (const e of s) {
|
|
124
|
-
if (((a = e.
|
|
126
|
+
if (((a = e.Wi()), this.gh.Zn())) {
|
|
125
127
|
if (n && !a.user_id) {
|
|
126
128
|
c || ((c = {}), (c.events = [])), c.events.push(a);
|
|
127
129
|
continue;
|
|
@@ -138,50 +140,61 @@ export default class Pt {
|
|
|
138
140
|
if (i.length > 0) {
|
|
139
141
|
const t = [];
|
|
140
142
|
for (const e of i)
|
|
141
|
-
this.
|
|
143
|
+
this.gh.Zn() && o(e.user_id) !== n
|
|
142
144
|
? (h || (h = []), h.push(e))
|
|
143
145
|
: t.push(e);
|
|
144
146
|
t.length > 0 && (l.attributes = t);
|
|
145
147
|
}
|
|
146
|
-
if ((this.
|
|
147
|
-
c = this.
|
|
148
|
-
const t = { requestData: c, headers: this.
|
|
148
|
+
if ((this.Aa(u, h), (l = this.Gs(l, !0)), c)) {
|
|
149
|
+
c = this.Gs(c, !1);
|
|
150
|
+
const t = { requestData: c, headers: this.Ks(c, T.Qs.Xa) };
|
|
149
151
|
r.push(t);
|
|
150
152
|
}
|
|
151
|
-
if (l && !this.
|
|
152
|
-
const f = { requestData: l, headers: this.
|
|
153
|
+
if (l && !this.ka(l.events, l.attributes, t, e)) return c ? r : null;
|
|
154
|
+
const f = { requestData: l, headers: this.Ks(l, T.Qs.Xa) };
|
|
153
155
|
return r.push(f), r;
|
|
154
156
|
}
|
|
155
|
-
|
|
157
|
+
Aa(t, e) {
|
|
156
158
|
if (t) {
|
|
157
159
|
const e = [];
|
|
158
160
|
for (const s of t) {
|
|
159
161
|
const t = ue.fromJson(s);
|
|
160
162
|
(t.time = Xt(t.time)), e.push(t);
|
|
161
163
|
}
|
|
162
|
-
this.
|
|
164
|
+
this.Jn.co(e);
|
|
163
165
|
}
|
|
164
|
-
if (e) for (const t of e) this.
|
|
166
|
+
if (e) for (const t of e) this.Jn.wa(t);
|
|
165
167
|
}
|
|
166
|
-
|
|
168
|
+
ii(t, e) {
|
|
167
169
|
let s = "HTTP error ";
|
|
168
|
-
null != t && (s += t + " "), (s += e), r.
|
|
170
|
+
null != t && (s += t + " "), (s += e), r.j.error(s);
|
|
169
171
|
}
|
|
170
|
-
|
|
171
|
-
return s.
|
|
172
|
+
qr(t) {
|
|
173
|
+
return s.N(r.q.ya, { n: t });
|
|
172
174
|
}
|
|
173
|
-
|
|
175
|
+
Vi(t, e, s) {
|
|
174
176
|
const i = {};
|
|
175
177
|
t && (i.feed = !0), e && (i.triggers = !0);
|
|
176
|
-
const r = null != s ? s : this.
|
|
178
|
+
const r = null != s ? s : this.Qo.getUserId();
|
|
177
179
|
return (
|
|
178
180
|
r && (i.user_id = r),
|
|
179
|
-
(i.config = { config_time: this.
|
|
181
|
+
(i.config = { config_time: this.Zo.oi() }),
|
|
180
182
|
{ respond_with: i }
|
|
181
183
|
);
|
|
182
184
|
}
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
+
Ca(t) {
|
|
186
|
+
const e = new Date().valueOf();
|
|
187
|
+
let s = Ht.toString(),
|
|
188
|
+
i = T.Ea(this.Jn, t);
|
|
189
|
+
if (-1 !== i) {
|
|
190
|
+
s = (e - i).toString();
|
|
191
|
+
}
|
|
192
|
+
return s;
|
|
193
|
+
}
|
|
194
|
+
Ks(t, e, s) {
|
|
195
|
+
const r = [["X-Braze-Api-Key", this.Ko]];
|
|
196
|
+
let o = this.Ca(e);
|
|
197
|
+
r.push(["X-Braze-Last-Req-Ms-Ago", o]);
|
|
185
198
|
let n = !1;
|
|
186
199
|
if (
|
|
187
200
|
(null != t.respond_with &&
|
|
@@ -190,25 +203,26 @@ export default class Pt {
|
|
|
190
203
|
null != t.respond_with &&
|
|
191
204
|
t.respond_with.feed &&
|
|
192
205
|
(r.push(["X-Braze-FeedRequest", "true"]), (n = !0)),
|
|
193
|
-
e)
|
|
206
|
+
e === T.Qs.Os)
|
|
194
207
|
) {
|
|
195
208
|
r.push(["X-Braze-ContentCardsRequest", "true"]);
|
|
196
|
-
let t = this.
|
|
197
|
-
(t &&
|
|
209
|
+
let t = this.Jn.v(i.k.Fs);
|
|
210
|
+
(t && s) || ((t = 0), this.Jn.D(i.k.Fs, t)),
|
|
198
211
|
r.push(["BRAZE-SYNC-RETRY-COUNT", t.toString()]),
|
|
199
212
|
(n = !0);
|
|
200
213
|
}
|
|
201
214
|
if (
|
|
202
|
-
(
|
|
215
|
+
(e === T.Qs.xi &&
|
|
216
|
+
(r.push(["X-Braze-FeatureFlagsRequest", "true"]), (n = !0)),
|
|
203
217
|
n && r.push(["X-Braze-DataRequest", "true"]),
|
|
204
|
-
this.
|
|
218
|
+
this.gh.Zn())
|
|
205
219
|
) {
|
|
206
|
-
const t = this.
|
|
220
|
+
const t = this.gh.au();
|
|
207
221
|
null != t && r.push(["X-Braze-Auth-Signature", t]);
|
|
208
222
|
}
|
|
209
223
|
return r;
|
|
210
224
|
}
|
|
211
|
-
|
|
225
|
+
Vs(t, e) {
|
|
212
226
|
const s = t.device;
|
|
213
227
|
s && s.os_version instanceof Promise
|
|
214
228
|
? s.os_version.then(s => {
|
|
@@ -216,13 +230,13 @@ export default class Pt {
|
|
|
216
230
|
})
|
|
217
231
|
: e();
|
|
218
232
|
}
|
|
219
|
-
|
|
220
|
-
this.
|
|
233
|
+
si() {
|
|
234
|
+
this.gh.si();
|
|
221
235
|
}
|
|
222
|
-
|
|
223
|
-
return this.
|
|
236
|
+
Zs() {
|
|
237
|
+
return this.Ho;
|
|
224
238
|
}
|
|
225
239
|
addSdkMetadata(t) {
|
|
226
|
-
for (const e of t) -1 === this.
|
|
240
|
+
for (const e of t) -1 === this.Ra.indexOf(e) && this.Ra.push(e);
|
|
227
241
|
}
|
|
228
242
|
}
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import { STORAGE_KEYS as
|
|
2
|
-
import
|
|
1
|
+
import { STORAGE_KEYS as i } from "./storage-manager.js";
|
|
2
|
+
import E from "./subscription-manager.js";
|
|
3
3
|
import Kt from "../models/server-config.js";
|
|
4
4
|
import s from "../common/event-logger.js";
|
|
5
5
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
6
|
+
import {
|
|
7
|
+
CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT as xt,
|
|
8
|
+
CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT as Vt
|
|
9
|
+
} from "../common/constants.js";
|
|
6
10
|
export default class Mt {
|
|
7
11
|
constructor(t) {
|
|
8
|
-
(this.
|
|
9
|
-
(this.tl = new
|
|
10
|
-
(this.el = new
|
|
11
|
-
(this.sl = new
|
|
12
|
+
(this.Jn = t),
|
|
13
|
+
(this.tl = new E()),
|
|
14
|
+
(this.el = new E()),
|
|
15
|
+
(this.sl = new E()),
|
|
12
16
|
(this.il = null);
|
|
13
17
|
}
|
|
14
18
|
rl() {
|
|
15
19
|
if (null == this.il) {
|
|
16
|
-
const t = this.
|
|
17
|
-
this.il = null != t ? Kt.
|
|
20
|
+
const t = this.Jn.v(i.k.ll);
|
|
21
|
+
this.il = null != t ? Kt.Tn(t) : new Kt();
|
|
18
22
|
}
|
|
19
23
|
return this.il;
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
return this.rl().
|
|
25
|
+
oi() {
|
|
26
|
+
return this.rl().hl;
|
|
23
27
|
}
|
|
24
|
-
|
|
28
|
+
ol(t) {
|
|
25
29
|
if (null != t && null != t.config) {
|
|
26
30
|
const e = t.config;
|
|
27
|
-
if (e.time > this.rl().
|
|
31
|
+
if (e.time > this.rl().hl) {
|
|
28
32
|
const t = new Kt(
|
|
29
33
|
e.time,
|
|
30
34
|
e.events_blacklist,
|
|
@@ -36,53 +40,67 @@ export default class Mt {
|
|
|
36
40
|
e.feature_flags
|
|
37
41
|
);
|
|
38
42
|
let s = !1;
|
|
39
|
-
null != t.
|
|
40
|
-
let i = !1;
|
|
41
|
-
null != t.ml.enabled && this.Ys() !== t.ml.enabled && (i = !0);
|
|
43
|
+
null != t.al && this.jn() !== t.al && (s = !0);
|
|
42
44
|
let r = !1;
|
|
43
|
-
null != t.
|
|
45
|
+
null != t.ul.enabled && this.ni() !== t.ul.enabled && (r = !0);
|
|
46
|
+
let n = !1;
|
|
47
|
+
null != t.mi.enabled && this.bi() !== t.mi.enabled && (n = !0),
|
|
44
48
|
(this.il = t),
|
|
45
|
-
this.
|
|
46
|
-
s && this.tl.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
this.Jn.D(i.k.ll, t.ss()),
|
|
50
|
+
s && this.tl.Et(),
|
|
51
|
+
r && this.el.Et(),
|
|
52
|
+
n && this.sl.Et();
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
|
-
|
|
53
|
-
let e = this.tl.
|
|
54
|
-
return this.
|
|
56
|
+
Un(t) {
|
|
57
|
+
let e = this.tl.lt(t);
|
|
58
|
+
return this.ml && this.tl.removeSubscription(this.ml), (this.ml = e), e;
|
|
55
59
|
}
|
|
56
|
-
|
|
57
|
-
return this.el.
|
|
60
|
+
$s(t) {
|
|
61
|
+
return this.el.lt(t);
|
|
58
62
|
}
|
|
59
|
-
|
|
60
|
-
return this.sl.
|
|
63
|
+
Ni(t) {
|
|
64
|
+
return this.sl.lt(t);
|
|
61
65
|
}
|
|
62
66
|
ge(t) {
|
|
63
|
-
return -1 !== this.rl().
|
|
67
|
+
return -1 !== this.rl().cl.indexOf(t);
|
|
64
68
|
}
|
|
65
69
|
hu(t) {
|
|
66
|
-
return -1 !== this.rl().
|
|
70
|
+
return -1 !== this.rl().gl.indexOf(t);
|
|
67
71
|
}
|
|
68
72
|
Dr(t) {
|
|
69
|
-
return -1 !== this.rl().
|
|
73
|
+
return -1 !== this.rl().fl.indexOf(t);
|
|
74
|
+
}
|
|
75
|
+
dl() {
|
|
76
|
+
return this.rl().bl;
|
|
77
|
+
}
|
|
78
|
+
jn() {
|
|
79
|
+
return this.rl().al;
|
|
80
|
+
}
|
|
81
|
+
ni() {
|
|
82
|
+
return this.rl().ul.enabled || !1;
|
|
70
83
|
}
|
|
71
|
-
|
|
72
|
-
|
|
84
|
+
_s() {
|
|
85
|
+
const t = this.rl().ul.rate_limit;
|
|
86
|
+
return !(!t || null == t.enabled) && t.enabled;
|
|
73
87
|
}
|
|
74
|
-
|
|
75
|
-
|
|
88
|
+
fi() {
|
|
89
|
+
if (!this._s()) return -1;
|
|
90
|
+
const t = this.rl().ul.rate_limit;
|
|
91
|
+
return null == t.capacity ? xt : t.capacity <= 0 ? -1 : t.capacity;
|
|
76
92
|
}
|
|
77
|
-
|
|
78
|
-
|
|
93
|
+
di() {
|
|
94
|
+
if (!this._s()) return -1;
|
|
95
|
+
const t = this.rl().ul.rate_limit;
|
|
96
|
+
return null == t.refill_rate ? Vt : t.refill_rate <= 0 ? -1 : t.refill_rate;
|
|
79
97
|
}
|
|
80
|
-
|
|
81
|
-
return this.rl().
|
|
82
|
-
? (s.
|
|
83
|
-
: this.rl().
|
|
98
|
+
bi() {
|
|
99
|
+
return this.rl().mi.enabled && null == this.Si()
|
|
100
|
+
? (s.N(r.q.Is, { e: "Missing feature flag refresh_rate_limit." }), !1)
|
|
101
|
+
: this.rl().mi.enabled || !1;
|
|
84
102
|
}
|
|
85
|
-
|
|
86
|
-
return this.rl().
|
|
103
|
+
Si() {
|
|
104
|
+
return this.rl().mi.refresh_rate_limit;
|
|
87
105
|
}
|
|
88
106
|
}
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import { STORAGE_KEYS as
|
|
1
|
+
import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
|
|
2
2
|
import ue from "../models/braze-event.js";
|
|
3
3
|
import _t from "../models/identifier.js";
|
|
4
|
-
import { convertMsToSeconds as
|
|
4
|
+
import { convertMsToSeconds as h } from "../util/date-utils.js";
|
|
5
5
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
6
|
-
export default class
|
|
6
|
+
export default class Dt {
|
|
7
7
|
constructor(s, t, e, i) {
|
|
8
|
-
(this.
|
|
9
|
-
(this.
|
|
10
|
-
(this.
|
|
11
|
-
(this.
|
|
8
|
+
(this.Jn = s),
|
|
9
|
+
(this.Qo = t),
|
|
10
|
+
(this.Zo = e),
|
|
11
|
+
(this.jh = 1e3),
|
|
12
12
|
(i = parseFloat(i)),
|
|
13
13
|
isNaN(i) && (i = 1800),
|
|
14
|
-
i < this.
|
|
15
|
-
(r.
|
|
14
|
+
i < this.jh / 1e3 &&
|
|
15
|
+
(r.j.info(
|
|
16
16
|
"Specified session timeout of " +
|
|
17
17
|
i +
|
|
18
18
|
"s is too small, using the minimum session timeout of " +
|
|
19
|
-
this.
|
|
19
|
+
this.jh / 1e3 +
|
|
20
20
|
"s instead."
|
|
21
21
|
),
|
|
22
|
-
(i = this.
|
|
23
|
-
(this.
|
|
22
|
+
(i = this.jh / 1e3)),
|
|
23
|
+
(this.xh = i);
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
return new ue(this.
|
|
25
|
+
Gh(s, t) {
|
|
26
|
+
return new ue(this.Qo.getUserId(), r.q.Fh, s, t.iu, { d: h(s - t.Hh) });
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
const s = this.
|
|
28
|
+
ba() {
|
|
29
|
+
const s = this.Jn.tu(i.eu.Wh);
|
|
30
30
|
return null == s ? null : s.iu;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
kh() {
|
|
33
33
|
const s = new Date().valueOf(),
|
|
34
|
-
t = this.
|
|
35
|
-
e = this.
|
|
34
|
+
t = this.Zo.dl(),
|
|
35
|
+
e = this.Jn.v(i.k.qh);
|
|
36
36
|
if (null != e && null == t) return !1;
|
|
37
|
-
const
|
|
38
|
-
return
|
|
37
|
+
const n = null == e || s - e > 1e3 * t;
|
|
38
|
+
return n && this.Jn.D(i.k.qh, s), n;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
return null == t || (!(s - t.
|
|
40
|
+
yh(s, t) {
|
|
41
|
+
return null == t || (!(s - t.Hh < this.jh) && t.Bh < s);
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
bo() {
|
|
44
44
|
const s = new Date().valueOf(),
|
|
45
|
-
t = s + 1e3 * this.
|
|
46
|
-
e = this.
|
|
47
|
-
if (this.
|
|
48
|
-
let
|
|
45
|
+
t = s + 1e3 * this.xh,
|
|
46
|
+
e = this.Jn.tu(i.eu.Wh);
|
|
47
|
+
if (this.yh(s, e)) {
|
|
48
|
+
let n = "Generating session start event with time " + s;
|
|
49
49
|
if (null != e) {
|
|
50
|
-
let s = e.
|
|
51
|
-
s - e.
|
|
52
|
-
this.
|
|
53
|
-
(
|
|
50
|
+
let s = e.Jh;
|
|
51
|
+
s - e.Hh < this.jh && (s = e.Hh + this.Kh),
|
|
52
|
+
this.Jn.Qh(this.Gh(s, e)),
|
|
53
|
+
(n += " (old session ended " + s + ")");
|
|
54
54
|
}
|
|
55
|
-
(
|
|
56
|
-
const
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
59
|
-
return null == this.
|
|
55
|
+
(n += ". Will expire " + t.valueOf()), r.j.info(n);
|
|
56
|
+
const o = new _t(r.Z.Y(), t);
|
|
57
|
+
this.Jn.Qh(new ue(this.Qo.getUserId(), r.q.Vh, s, o.iu)),
|
|
58
|
+
this.Jn.uu(i.eu.Wh, o);
|
|
59
|
+
return null == this.Jn.v(i.k.qh) && this.Jn.D(i.k.qh, s), o.iu;
|
|
60
60
|
}
|
|
61
|
-
return (e.
|
|
61
|
+
return (e.Jh = s), (e.Bh = t), this.Jn.uu(i.eu.Wh, e), e.iu;
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
const s = this.
|
|
63
|
+
Xh() {
|
|
64
|
+
const s = this.Jn.tu(i.eu.Wh);
|
|
65
65
|
null != s &&
|
|
66
|
-
(this.
|
|
66
|
+
(this.Jn.Yh(i.eu.Wh), this.Jn.Qh(this.Gh(new Date().valueOf(), s)));
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import O, { STORAGE_KEYS as i } from "./storage-manager.js";
|
|
2
2
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
let
|
|
3
|
+
const Bt = {
|
|
4
|
+
qo: (e, o) => {
|
|
5
|
+
let t = !1;
|
|
6
6
|
try {
|
|
7
7
|
if (localStorage && localStorage.getItem)
|
|
8
8
|
try {
|
|
9
|
-
localStorage.setItem(
|
|
10
|
-
localStorage.getItem(
|
|
11
|
-
(localStorage.removeItem(
|
|
9
|
+
localStorage.setItem(i.k._a, !0),
|
|
10
|
+
localStorage.getItem(i.k._a) &&
|
|
11
|
+
(localStorage.removeItem(i.k._a), (t = !0));
|
|
12
12
|
} catch (e) {
|
|
13
13
|
if (
|
|
14
14
|
("QuotaExceededError" !== e.name &&
|
|
@@ -16,20 +16,20 @@ const Dt = {
|
|
|
16
16
|
!(localStorage.length > 0)
|
|
17
17
|
)
|
|
18
18
|
throw e;
|
|
19
|
-
|
|
19
|
+
t = !0;
|
|
20
20
|
}
|
|
21
21
|
} catch (e) {
|
|
22
|
-
r.
|
|
22
|
+
r.j.info("Local Storage not supported!");
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
let
|
|
27
|
-
return (
|
|
24
|
+
const a = Bt.Oa(),
|
|
25
|
+
l = new O.xa(e, a && !o, t);
|
|
26
|
+
let c = null;
|
|
27
|
+
return (c = t ? new O.Ma(e) : new O.Qa()), new O(l, c);
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
Oa: () =>
|
|
30
30
|
navigator.cookieEnabled ||
|
|
31
31
|
("cookie" in document &&
|
|
32
32
|
(document.cookie.length > 0 ||
|
|
33
33
|
(document.cookie = "test").indexOf.call(document.cookie, "test") > -1))
|
|
34
34
|
};
|
|
35
|
-
export default
|
|
35
|
+
export default Bt;
|