@braze/web-sdk 4.10.1 → 5.0.1
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 +26 -111
- 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 +34 -1
- package/shared-lib/guid.js +10 -1
- package/shared-lib/indexed-db-adapter.js +352 -1
- package/shared-lib/logger.js +38 -1
- package/shared-lib/supported-options.js +26 -1
- package/shared-lib/types.js +1 -1
- package/src/Card/card-manager-factory.js +14 -1
- package/src/Card/card-manager.js +78 -1
- package/src/Card/display/card-display.js +138 -1
- package/src/Card/index.js +6 -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-click.js +4 -1
- package/src/Card/log-content-card-impressions.js +4 -1
- package/src/Card/models/captioned-image.js +33 -1
- package/src/Card/models/card.js +197 -1
- package/src/Card/models/classic-card.js +32 -1
- package/src/Card/models/control-card.js +23 -1
- package/src/Card/models/image-only.js +31 -1
- package/src/Card/models/index.js +5 -1
- package/src/Card/types.js +1 -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 +391 -1
- package/src/ContentCards/content-cards.js +24 -1
- package/src/ContentCards/get-cached-content-cards.js +5 -1
- package/src/ContentCards/index.js +7 -1
- package/src/ContentCards/request-content-cards-refresh.js +5 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +17 -1
- package/src/ContentCards/types.js +1 -1
- package/src/ContentCards/ui/hide-content-cards.js +8 -1
- package/src/ContentCards/ui/show-content-cards.js +77 -1
- package/src/ContentCards/ui/toggle-content-cards.js +8 -1
- package/src/Core/add-sdk-metadata.js +26 -1
- package/src/Core/braze-sdk-metadata.js +10 -1
- package/src/Core/change-user.js +17 -1
- package/src/Core/destroy.js +5 -1
- package/src/Core/device-properties.js +9 -1
- package/src/Core/disable-sdk.js +15 -1
- package/src/Core/enable-sdk.js +11 -1
- package/src/Core/get-device-id.js +13 -1
- package/src/Core/get-user.js +4 -1
- package/src/Core/handle-braze-action.js +87 -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 +38 -1
- package/src/Core/log-purchase.js +245 -1
- package/src/Core/open-session.js +25 -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 +6 -1
- package/src/Core/set-logger.js +4 -1
- package/src/Core/set-sdk-authentication-signature.js +8 -1
- package/src/Core/subscribe-to-sdk-authentication-failures.js +6 -1
- package/src/Core/toggle-logging.js +4 -1
- package/src/Core/types.js +1 -1
- package/src/Core/wipe-data.js +16 -1
- package/src/FeatureFlags/feature-flag-factory.js +24 -1
- package/src/FeatureFlags/feature-flag.js +64 -1
- package/src/FeatureFlags/feature-flags-provider-factory.js +19 -1
- package/src/FeatureFlags/feature-flags-provider.js +145 -1
- package/src/FeatureFlags/get-all-feature-flags.js +12 -1
- package/src/FeatureFlags/get-feature-flag.js +10 -1
- package/src/FeatureFlags/index.js +6 -1
- package/src/FeatureFlags/log-feature-flag-impression.js +23 -1
- package/src/FeatureFlags/refresh-feature-flags.js +9 -1
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +9 -1
- package/src/FeatureFlags/types.js +1 -1
- package/src/Feed/feed-provider-factory.js +18 -1
- package/src/Feed/feed-provider.js +90 -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 +7 -1
- package/src/Feed/request-feed-refresh.js +5 -1
- package/src/Feed/subscribe-to-feed-updates.js +5 -1
- package/src/Feed/types.js +1 -1
- package/src/Feed/ui/hide-feed.js +7 -1
- package/src/Feed/ui/show-feed.js +96 -1
- package/src/Feed/ui/toggle-feed.js +8 -1
- package/src/InAppMessage/defer-in-app-message.js +13 -1
- package/src/InAppMessage/display/get-animation-effect.js +19 -1
- package/src/InAppMessage/display/html-message-to-html.js +243 -1
- package/src/InAppMessage/display/in-app-message-to-html.js +188 -1
- package/src/InAppMessage/display/modal-utils.js +73 -1
- package/src/InAppMessage/get-deferred-in-app-message.js +5 -1
- package/src/InAppMessage/in-app-message-factory.js +166 -1
- package/src/InAppMessage/in-app-message-manager-factory.js +16 -1
- package/src/InAppMessage/in-app-message-manager.js +248 -1
- package/src/InAppMessage/index.js +16 -1
- package/src/InAppMessage/log-in-app-message-button-click.js +27 -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 +11 -1
- package/src/InAppMessage/models/full-screen-message.js +105 -1
- package/src/InAppMessage/models/html-message.js +68 -1
- package/src/InAppMessage/models/in-app-message-button.js +47 -1
- package/src/InAppMessage/models/in-app-message.js +382 -1
- package/src/InAppMessage/models/modal-message.js +101 -1
- package/src/InAppMessage/models/slide-up-message.js +84 -1
- package/src/InAppMessage/models/templated-in-app-message.js +19 -1
- package/src/InAppMessage/subscribe-to-in-app-message.js +10 -1
- package/src/InAppMessage/types.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +15 -1
- package/src/InAppMessage/ui/show-in-app-message.js +181 -1
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -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 +387 -1
- package/src/Push/request-push-permission.js +9 -1
- package/src/Push/types.js +1 -1
- package/src/Push/unregister-push.js +5 -1
- package/src/Push/utils/push-utils.js +36 -1
- package/src/User/index.js +1 -1
- package/src/User/types.js +1 -1
- package/src/User/user-manager.js +73 -1
- package/src/User/user.js +302 -1
- package/src/common/base-feed.js +29 -1
- package/src/common/base-provider.js +6 -1
- package/src/common/constants.js +14 -1
- package/src/common/event-logger.js +31 -1
- package/src/common/feed-display.js +210 -1
- package/src/common/translations.js +148 -1
- package/src/common/types.js +1 -1
- package/src/index.js +9 -1
- package/src/l10n/l10n-manager-factory.js +22 -1
- package/src/l10n/l10n-manager.js +25 -1
- package/src/l10n/types.js +1 -1
- package/src/managers/auth-manager.js +51 -1
- package/src/managers/braze-instance.js +322 -1
- package/src/managers/device-manager.js +85 -1
- package/src/managers/network-manager.js +256 -1
- package/src/managers/server-config-manager.js +108 -1
- package/src/managers/session-manager.js +75 -1
- package/src/managers/storage-manager-factory.js +42 -1
- package/src/managers/storage-manager.js +426 -1
- package/src/managers/subscription-manager.js +28 -1
- package/src/managers/types.js +1 -1
- package/src/models/backend-errors.js +8 -1
- package/src/models/braze-event.js +47 -1
- package/src/models/braze-sdk-metadata.js +10 -1
- package/src/models/device.js +18 -1
- package/src/models/identifier.js +19 -1
- package/src/models/push-token.js +27 -1
- package/src/models/request-result.js +8 -1
- package/src/models/server-config.js +48 -1
- package/src/models/types.js +1 -1
- package/src/request-controller.js +311 -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 +102 -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 +105 -1
- package/src/triggers/models/trigger-events.js +8 -1
- package/src/triggers/models/trigger.js +122 -1
- package/src/triggers/triggers-provider-factory.js +34 -1
- package/src/triggers/triggers-provider.js +326 -1
- package/src/triggers/types.js +1 -1
- package/src/types.js +1 -1
- package/src/ui/js/attach-css.js +13 -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 +84 -1
- package/src/util/browser-detector.js +84 -1
- package/src/util/client-hints-parser.js +66 -1
- package/src/util/code-utils.js +100 -1
- package/src/util/color-utils.js +29 -1
- package/src/util/component-utils.js +26 -1
- package/src/util/date-utils.js +28 -1
- package/src/util/deprecation-utils.js +5 -1
- package/src/util/device-constants.js +13 -1
- package/src/util/dom-utils.js +91 -1
- package/src/util/error-utils.js +2 -1
- package/src/util/key-codes.js +1 -1
- package/src/util/math.js +5 -1
- package/src/util/net.js +71 -1
- package/src/util/request-header-utils.js +46 -1
- package/src/util/string-utils.js +22 -1
- package/src/util/types.js +1 -1
- package/src/util/url-utils.js +20 -1
- package/src/util/user-agent-parser.js +80 -1
- package/src/util/validation-utils.js +217 -1
- package/src/util/window-utils.js +34 -1
- package/src/Card/models/banner.js +0 -1
- package/src/ContentCards/log-content-cards-displayed.js +0 -1
|
@@ -1 +1,391 @@
|
|
|
1
|
-
import C,{readResponseHeaders as b
|
|
1
|
+
import C, { readResponseHeaders as b } from "../util/net.js";
|
|
2
|
+
import y from "../common/base-provider.js";
|
|
3
|
+
import e from "../managers/braze-instance.js";
|
|
4
|
+
import ContentCards from "./content-cards.js";
|
|
5
|
+
import { dateFromUnixTimestamp as l } from "../util/date-utils.js";
|
|
6
|
+
import { isURIJavascriptOrData as N } from "../util/url-utils.js";
|
|
7
|
+
import {
|
|
8
|
+
newCardFromContentCardsJson as j,
|
|
9
|
+
newCardFromSerializedValue as R,
|
|
10
|
+
} from "../Card/util/card-factory.js";
|
|
11
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
12
|
+
import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
|
|
13
|
+
import E from "../managers/subscription-manager.js";
|
|
14
|
+
import s from "../common/event-logger.js";
|
|
15
|
+
import T from "../util/request-header-utils.js";
|
|
16
|
+
import { randomInclusive as D } from "../util/math.js";
|
|
17
|
+
import { MAX_ERROR_RETRIES_CONTENT_CARDS as S } from "../common/constants.js";
|
|
18
|
+
export default class v extends y {
|
|
19
|
+
constructor(t, s, i, h, n) {
|
|
20
|
+
super(),
|
|
21
|
+
(this.wt = t),
|
|
22
|
+
(this.u = s),
|
|
23
|
+
(this.yt = i),
|
|
24
|
+
(this.Jt = h),
|
|
25
|
+
(this.$t = n),
|
|
26
|
+
(this.wt = t),
|
|
27
|
+
(this.u = s),
|
|
28
|
+
(this.yt = i),
|
|
29
|
+
(this.Jt = h),
|
|
30
|
+
(this.$t = n),
|
|
31
|
+
(this.Bt = new E()),
|
|
32
|
+
e.Ht(this.Bt),
|
|
33
|
+
(this.Kt = 0),
|
|
34
|
+
(this.Qt = 0),
|
|
35
|
+
(this.cards = []),
|
|
36
|
+
this.Yt();
|
|
37
|
+
const o = r.ts.Zt;
|
|
38
|
+
new r.es(o, r.j).ss(o.rs.hs, (t) => {
|
|
39
|
+
this.ns(t);
|
|
40
|
+
}),
|
|
41
|
+
(this.os = null),
|
|
42
|
+
(this.ls = null),
|
|
43
|
+
(this.us = null),
|
|
44
|
+
(this.cs = null),
|
|
45
|
+
(this.fs = null),
|
|
46
|
+
(this.ds = 10),
|
|
47
|
+
(this.ps = 0);
|
|
48
|
+
}
|
|
49
|
+
Cs() {
|
|
50
|
+
return this.os;
|
|
51
|
+
}
|
|
52
|
+
ws(t) {
|
|
53
|
+
this.os = t;
|
|
54
|
+
}
|
|
55
|
+
bs() {
|
|
56
|
+
return this.ls;
|
|
57
|
+
}
|
|
58
|
+
vs(t) {
|
|
59
|
+
this.ls = t;
|
|
60
|
+
}
|
|
61
|
+
Yt() {
|
|
62
|
+
if (!this.u) return;
|
|
63
|
+
const t = this.u.v(i.k.gs) || [],
|
|
64
|
+
s = [];
|
|
65
|
+
for (let i = 0; i < t.length; i++) {
|
|
66
|
+
const e = R(t[i]);
|
|
67
|
+
null != e && s.push(e);
|
|
68
|
+
}
|
|
69
|
+
(this.cards = this.ys(this.Ns(s, !1))),
|
|
70
|
+
(this.Kt = this.u.v(i.k.js) || this.Kt),
|
|
71
|
+
(this.Qt = this.u.v(i.k.Rs) || this.Qt);
|
|
72
|
+
}
|
|
73
|
+
Ts(t, s = !1, e = 0, h = 0) {
|
|
74
|
+
let r;
|
|
75
|
+
if (s) {
|
|
76
|
+
r = [];
|
|
77
|
+
for (const t of this.cards) t.test && r.push(t);
|
|
78
|
+
} else r = this.cards.slice();
|
|
79
|
+
for (let i = 0; i < t.length; i++) {
|
|
80
|
+
const e = t[i];
|
|
81
|
+
let h = null;
|
|
82
|
+
for (let t = 0; t < this.cards.length; t++)
|
|
83
|
+
if (e.id === this.cards[t].id) {
|
|
84
|
+
h = this.cards[t];
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
if (s) {
|
|
88
|
+
const t = j(e);
|
|
89
|
+
null != h && h.viewed && t && (t.viewed = !0), null != t && r.push(t);
|
|
90
|
+
} else if (null == h) {
|
|
91
|
+
const t = j(e);
|
|
92
|
+
null != t && r.push(t);
|
|
93
|
+
} else {
|
|
94
|
+
if (!h.Ct(e))
|
|
95
|
+
for (let t = 0; t < r.length; t++)
|
|
96
|
+
if (e.id === r[t].id) {
|
|
97
|
+
r.splice(t, 1);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
(this.cards = this.ys(this.Ns(r, s))),
|
|
103
|
+
this.Ds(),
|
|
104
|
+
(this.Kt = e),
|
|
105
|
+
(this.Qt = h),
|
|
106
|
+
this.u && (this.u.D(i.k.js, this.Kt), this.u.D(i.k.Rs, this.Qt));
|
|
107
|
+
}
|
|
108
|
+
Ss(t) {
|
|
109
|
+
if (this.ks() && null != t && t.cards) {
|
|
110
|
+
this.u && this.u.D(i.k.Us, e.As());
|
|
111
|
+
const s = t.full_sync;
|
|
112
|
+
s || this.Yt(),
|
|
113
|
+
this.Ts(t.cards, s, t.last_full_sync_at, t.last_card_updated_at),
|
|
114
|
+
this.Bt.Dt(this.Ls(!0));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
Fs(t) {
|
|
118
|
+
this.u && this.u.D(i.k.zs, t);
|
|
119
|
+
}
|
|
120
|
+
Ms(t, e, h) {
|
|
121
|
+
const n = () => {
|
|
122
|
+
this.xs(e, h, !0);
|
|
123
|
+
},
|
|
124
|
+
o = t ? b(t) : null;
|
|
125
|
+
let l;
|
|
126
|
+
if ((this.Es(), !o || !o["retry-after"])) return void this.Fs(0);
|
|
127
|
+
const a = o["retry-after"];
|
|
128
|
+
if (isNaN(a) && !isNaN(Date.parse(a)))
|
|
129
|
+
(l = Date.parse(a) - new Date().getTime()), l < 0 && n();
|
|
130
|
+
else {
|
|
131
|
+
if (isNaN(parseFloat(a.toString()))) {
|
|
132
|
+
const t =
|
|
133
|
+
"Received unexpected value for retry-after header in /sync response";
|
|
134
|
+
return s.N(r.q.qs, { e: t + ": " + a }), void this.Fs(0);
|
|
135
|
+
}
|
|
136
|
+
l = 1e3 * parseFloat(a.toString());
|
|
137
|
+
}
|
|
138
|
+
this.us = window.setTimeout(() => {
|
|
139
|
+
n();
|
|
140
|
+
}, l);
|
|
141
|
+
let u = 0;
|
|
142
|
+
this.u && (u = this.u.v(i.k.zs)),
|
|
143
|
+
(null == u || isNaN(parseInt(u.toString()))) && (u = 0),
|
|
144
|
+
this.Fs(parseInt(u.toString()) + 1);
|
|
145
|
+
}
|
|
146
|
+
ns(t) {
|
|
147
|
+
if (!this.ks()) return;
|
|
148
|
+
this.Yt();
|
|
149
|
+
const s = this.cards.slice();
|
|
150
|
+
let i = null;
|
|
151
|
+
this.wt && (i = this.wt.getUserId());
|
|
152
|
+
for (let e = 0; e < t.length; e++)
|
|
153
|
+
if (i === t[e].userId || (null == i && null == t[e].userId)) {
|
|
154
|
+
const i = t[e].card;
|
|
155
|
+
let h = null;
|
|
156
|
+
for (let t = 0; t < this.cards.length; t++)
|
|
157
|
+
if (i.id === this.cards[t].id) {
|
|
158
|
+
h = this.cards[t];
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
if (null == h) {
|
|
162
|
+
const t = j(i);
|
|
163
|
+
null != t && s.push(t);
|
|
164
|
+
} else {
|
|
165
|
+
if (!h.Ct(i))
|
|
166
|
+
for (let t = 0; t < s.length; t++)
|
|
167
|
+
if (i.id === s[t].id) {
|
|
168
|
+
s.splice(t, 1);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
(this.cards = this.ys(this.Ns(s, !1))), this.Ds(), this.Bt.Dt(this.Ls(!0));
|
|
174
|
+
}
|
|
175
|
+
Ns(t, s) {
|
|
176
|
+
let e = {},
|
|
177
|
+
h = {},
|
|
178
|
+
r = {};
|
|
179
|
+
this.u &&
|
|
180
|
+
((e = this.u.v(i.k.C) || {}),
|
|
181
|
+
(h = this.u.v(i.k.K) || {}),
|
|
182
|
+
(r = this.u.v(i.k.G) || {}));
|
|
183
|
+
const n = {},
|
|
184
|
+
o = {},
|
|
185
|
+
l = {};
|
|
186
|
+
for (let s = 0; s < t.length; s++) {
|
|
187
|
+
const i = t[s].id;
|
|
188
|
+
i &&
|
|
189
|
+
(e[i] && ((t[s].clicked = !0), (n[i] = !0)),
|
|
190
|
+
h[i] && ((t[s].viewed = !0), (o[i] = !0)),
|
|
191
|
+
r[i] && ((t[s].dismissed = !0), (l[i] = !0)));
|
|
192
|
+
}
|
|
193
|
+
return (
|
|
194
|
+
s &&
|
|
195
|
+
this.u &&
|
|
196
|
+
(this.u.D(i.k.C, n), this.u.D(i.k.K, o), this.u.D(i.k.G, l)),
|
|
197
|
+
t
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
ys(t) {
|
|
201
|
+
const s = [],
|
|
202
|
+
e = new Date();
|
|
203
|
+
let h = {};
|
|
204
|
+
this.u && (h = this.u.v(i.k.G) || {});
|
|
205
|
+
let n = !1;
|
|
206
|
+
for (let i = 0; i < t.length; i++) {
|
|
207
|
+
const o = t[i].url;
|
|
208
|
+
if (!this.Jt && o && N(o)) {
|
|
209
|
+
r.j.error(
|
|
210
|
+
`Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`,
|
|
211
|
+
);
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
const l = t[i].expiresAt;
|
|
215
|
+
let a = !0;
|
|
216
|
+
if ((null != l && (a = l >= e), (a = a && !t[i].dismissed), a))
|
|
217
|
+
s.push(t[i]);
|
|
218
|
+
else {
|
|
219
|
+
const s = t[i].id;
|
|
220
|
+
s && (h[s] = !0), (n = !0);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return n && this.u && this.u.D(i.k.G, h), s;
|
|
224
|
+
}
|
|
225
|
+
Ds() {
|
|
226
|
+
if (!this.u) return;
|
|
227
|
+
const t = [];
|
|
228
|
+
for (let s = 0; s < this.cards.length; s++) t.push(this.cards[s].tt());
|
|
229
|
+
this.u.D(i.k.gs, t);
|
|
230
|
+
}
|
|
231
|
+
Es() {
|
|
232
|
+
this.us && (clearTimeout(this.us), (this.us = null));
|
|
233
|
+
}
|
|
234
|
+
Is() {
|
|
235
|
+
null != this.cs && (clearTimeout(this.cs), (this.cs = null));
|
|
236
|
+
}
|
|
237
|
+
Js(t = 1e3 * this.ds, s, i) {
|
|
238
|
+
this.Is(),
|
|
239
|
+
(this.cs = window.setTimeout(() => {
|
|
240
|
+
this.xs(s, i, !0);
|
|
241
|
+
}, t)),
|
|
242
|
+
(this.fs = t);
|
|
243
|
+
}
|
|
244
|
+
xs(t, s, h = !1, n = !0) {
|
|
245
|
+
var o;
|
|
246
|
+
const l = this.$t,
|
|
247
|
+
a = this.u;
|
|
248
|
+
if (!l || !a) return void ("function" == typeof s && s());
|
|
249
|
+
const u = !h;
|
|
250
|
+
if ((u && (this.Es(), this.Fs(0)), !this.ks()))
|
|
251
|
+
return void (
|
|
252
|
+
this.yt &&
|
|
253
|
+
this.yt.Ps(() => {
|
|
254
|
+
this.xs(t, s);
|
|
255
|
+
})
|
|
256
|
+
);
|
|
257
|
+
let c = !0;
|
|
258
|
+
if (
|
|
259
|
+
(u &&
|
|
260
|
+
(null === (o = this.yt) || void 0 === o ? void 0 : o.$s()) &&
|
|
261
|
+
(c = this._s()),
|
|
262
|
+
!c)
|
|
263
|
+
)
|
|
264
|
+
return void r.j.info("Content card sync being throttled.");
|
|
265
|
+
n && this.Is();
|
|
266
|
+
const f = l.Bs({}, !0);
|
|
267
|
+
a.v(i.k.Us) !== e.As() && this.Gs(),
|
|
268
|
+
(f.last_full_sync_at = this.Kt),
|
|
269
|
+
(f.last_card_updated_at = this.Qt);
|
|
270
|
+
const d = l.Hs(f, T.Os.Ks, h);
|
|
271
|
+
let m = !1;
|
|
272
|
+
l.Qs(f, () => {
|
|
273
|
+
if (this.u) {
|
|
274
|
+
const t = new Date().valueOf();
|
|
275
|
+
u && this.u.D(i.k.Vs, t), T.Ws(this.u, T.Os.Ks, t);
|
|
276
|
+
}
|
|
277
|
+
C.Xs({
|
|
278
|
+
url: l.Ys() + "/content_cards/sync",
|
|
279
|
+
data: f,
|
|
280
|
+
headers: d,
|
|
281
|
+
O: (i, e) => {
|
|
282
|
+
if (!l.Zs(f, i, d))
|
|
283
|
+
return (m = !0), void ("function" == typeof s && s());
|
|
284
|
+
l.ti(),
|
|
285
|
+
this.Ms(e, t, s),
|
|
286
|
+
this.Ss(i),
|
|
287
|
+
(m = !1),
|
|
288
|
+
T.si(this.u, T.Os.Ks, 1),
|
|
289
|
+
"function" == typeof t && t();
|
|
290
|
+
},
|
|
291
|
+
error: (t) => {
|
|
292
|
+
l.ii(t, "retrieving content cards"),
|
|
293
|
+
(m = !0),
|
|
294
|
+
"function" == typeof s && s();
|
|
295
|
+
},
|
|
296
|
+
ei: () => {
|
|
297
|
+
if (m && n && !this.cs && this.ps + 1 < S) {
|
|
298
|
+
T.hi(this.u, T.Os.Ks);
|
|
299
|
+
let i = this.fs;
|
|
300
|
+
(null == i || i < 1e3 * this.ds) && (i = 1e3 * this.ds),
|
|
301
|
+
this.Js(Math.min(3e5, D(1e3 * this.ds, 3 * i)), t, s),
|
|
302
|
+
(this.ps = this.ps + 1);
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
Ls(t) {
|
|
309
|
+
t || this.Yt();
|
|
310
|
+
const s = this.ys(this.cards);
|
|
311
|
+
s.sort((t, s) =>
|
|
312
|
+
t.pinned && !s.pinned
|
|
313
|
+
? -1
|
|
314
|
+
: s.pinned && !t.pinned
|
|
315
|
+
? 1
|
|
316
|
+
: t.updated && s.updated && t.updated > s.updated
|
|
317
|
+
? -1
|
|
318
|
+
: t.updated && s.updated && s.updated > t.updated
|
|
319
|
+
? 1
|
|
320
|
+
: 0,
|
|
321
|
+
);
|
|
322
|
+
let e = Math.max(this.Qt || 0, this.Kt || 0);
|
|
323
|
+
return (
|
|
324
|
+
0 === e && (e = void 0),
|
|
325
|
+
this.u && this.u.v(i.k.Rs) === this.Qt && void 0 === e && (e = this.Qt),
|
|
326
|
+
new ContentCards(s, l(e))
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
ri(t) {
|
|
330
|
+
return this.Bt.It(t);
|
|
331
|
+
}
|
|
332
|
+
Gs() {
|
|
333
|
+
(this.Kt = 0),
|
|
334
|
+
(this.Qt = 0),
|
|
335
|
+
this.u && (this.u.ni(i.k.js), this.u.ni(i.k.Rs));
|
|
336
|
+
}
|
|
337
|
+
changeUser(t) {
|
|
338
|
+
t ||
|
|
339
|
+
((this.cards = []),
|
|
340
|
+
this.Bt.Dt(new ContentCards(this.cards.slice(), null)),
|
|
341
|
+
this.u &&
|
|
342
|
+
(this.u.ni(i.k.gs),
|
|
343
|
+
this.u.ni(i.k.C),
|
|
344
|
+
this.u.ni(i.k.K),
|
|
345
|
+
this.u.ni(i.k.G))),
|
|
346
|
+
this.Gs();
|
|
347
|
+
}
|
|
348
|
+
clearData(t) {
|
|
349
|
+
(this.Kt = 0),
|
|
350
|
+
(this.Qt = 0),
|
|
351
|
+
(this.cards = []),
|
|
352
|
+
this.Bt.Dt(new ContentCards(this.cards.slice(), null)),
|
|
353
|
+
t &&
|
|
354
|
+
this.u &&
|
|
355
|
+
(this.u.ni(i.k.gs),
|
|
356
|
+
this.u.ni(i.k.C),
|
|
357
|
+
this.u.ni(i.k.K),
|
|
358
|
+
this.u.ni(i.k.G),
|
|
359
|
+
this.u.ni(i.k.js),
|
|
360
|
+
this.u.ni(i.k.Rs));
|
|
361
|
+
}
|
|
362
|
+
ks() {
|
|
363
|
+
return !(this.yt && !this.yt.oi()) || (0 !== this.yt.li() && this.ai(), !1);
|
|
364
|
+
}
|
|
365
|
+
ui(t) {
|
|
366
|
+
this.u && this.u.D(i.k.ci, t);
|
|
367
|
+
}
|
|
368
|
+
fi() {
|
|
369
|
+
return this.u ? this.u.v(i.k.ci) : null;
|
|
370
|
+
}
|
|
371
|
+
_s() {
|
|
372
|
+
const t = this.u,
|
|
373
|
+
s = this.yt;
|
|
374
|
+
if (!t || !s) return !0;
|
|
375
|
+
const e = t.v(i.k.Vs);
|
|
376
|
+
if (null == e || isNaN(e)) return !0;
|
|
377
|
+
const h = s.di(),
|
|
378
|
+
r = s.mi();
|
|
379
|
+
if (-1 === h || -1 === r) return !0;
|
|
380
|
+
let n = this.fi();
|
|
381
|
+
(null == n || isNaN(n)) && (n = h);
|
|
382
|
+
const o = (new Date().valueOf() - e) / 1e3;
|
|
383
|
+
return (
|
|
384
|
+
(n = Math.min(n + o / r, h)),
|
|
385
|
+
!(n < 1) && ((n = Math.trunc(n) - 1), this.ui(n), !0)
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
ai() {
|
|
389
|
+
this.Bt.Dt(new ContentCards([], new Date())), this.u && this.u.ni(i.k.gs);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
import x from"../common/base-feed.js";
|
|
1
|
+
import x from "../common/base-feed.js";
|
|
2
|
+
import { logCardClick, logCardImpressions } from "../Card/index.js";
|
|
3
|
+
import { requestContentCardsRefresh } from "./request-content-cards-refresh.js";
|
|
4
|
+
export default class ContentCards extends x {
|
|
5
|
+
constructor(r, e) {
|
|
6
|
+
super(r, e);
|
|
7
|
+
}
|
|
8
|
+
getUnviewedCardCount() {
|
|
9
|
+
return super.getUnreadCardCount();
|
|
10
|
+
}
|
|
11
|
+
logCardImpressions(r) {
|
|
12
|
+
logCardImpressions(r, !0);
|
|
13
|
+
}
|
|
14
|
+
logCardClick(r) {
|
|
15
|
+
return logCardClick(r, !0);
|
|
16
|
+
}
|
|
17
|
+
sr() {
|
|
18
|
+
requestContentCardsRefresh();
|
|
19
|
+
}
|
|
20
|
+
ur() {
|
|
21
|
+
return !0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
ContentCards.mr = 6e4;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
import g from"./content-cards-provider-factory.js";
|
|
1
|
+
import g from "./content-cards-provider-factory.js";
|
|
2
|
+
import e from "../managers/braze-instance.js";
|
|
3
|
+
export function getCachedContentCards() {
|
|
4
|
+
if (e.rr()) return g.er().Ls(!1);
|
|
5
|
+
}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
export{default as ContentCards}from"./content-cards.js";
|
|
1
|
+
export { default as ContentCards } from "./content-cards.js";
|
|
2
|
+
export { getCachedContentCards } from "./get-cached-content-cards.js";
|
|
3
|
+
export { hideContentCards } from "./ui/hide-content-cards.js";
|
|
4
|
+
export { requestContentCardsRefresh } from "./request-content-cards-refresh.js";
|
|
5
|
+
export { showContentCards } from "./ui/show-content-cards.js";
|
|
6
|
+
export { subscribeToContentCardsUpdates } from "./subscribe-to-content-cards-updates.js";
|
|
7
|
+
export { toggleContentCards } from "./ui/toggle-content-cards.js";
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
import e from"../managers/braze-instance.js";
|
|
1
|
+
import e from "../managers/braze-instance.js";
|
|
2
|
+
import g from "./content-cards-provider-factory.js";
|
|
3
|
+
export function requestContentCardsRefresh(r, t) {
|
|
4
|
+
if (e.rr()) return g.er().xs(r, t);
|
|
5
|
+
}
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import e from"../managers/braze-instance.js";
|
|
1
|
+
import e from "../managers/braze-instance.js";
|
|
2
|
+
import g from "./content-cards-provider-factory.js";
|
|
3
|
+
export function subscribeToContentCardsUpdates(r) {
|
|
4
|
+
if (!e.rr()) return;
|
|
5
|
+
const t = g.er(),
|
|
6
|
+
n = t.ri(r);
|
|
7
|
+
if (!t.bs()) {
|
|
8
|
+
const r = e.cr();
|
|
9
|
+
if (r) {
|
|
10
|
+
const n = r.pr(() => {
|
|
11
|
+
t.xs();
|
|
12
|
+
});
|
|
13
|
+
n && t.vs(n);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return n;
|
|
17
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export {};
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
import e from"../../managers/braze-instance.js";
|
|
1
|
+
import e from "../../managers/braze-instance.js";
|
|
2
|
+
import { destroyFeedHtml as z } from "../../common/feed-display.js";
|
|
3
|
+
export function hideContentCards(n) {
|
|
4
|
+
if (!e.rr()) return;
|
|
5
|
+
const o = document.querySelectorAll(".ab-feed");
|
|
6
|
+
for (let e = 0; e < o.length; e++)
|
|
7
|
+
(null == n || (null != n && o[e].parentNode === n)) && z(o[e]);
|
|
8
|
+
}
|
|
@@ -1 +1,77 @@
|
|
|
1
|
-
import e,{OPTIONS as L
|
|
1
|
+
import e, { OPTIONS as L } from "../../managers/braze-instance.js";
|
|
2
|
+
import { ContentCards, subscribeToContentCardsUpdates } from "../index.js";
|
|
3
|
+
import g from "../content-cards-provider-factory.js";
|
|
4
|
+
import {
|
|
5
|
+
destroyFeedHtml as z,
|
|
6
|
+
detectFeedImpressions as q,
|
|
7
|
+
feedToHtml as I,
|
|
8
|
+
LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as M,
|
|
9
|
+
refreshFeed as $,
|
|
10
|
+
registerFeedSubscriptionId as k,
|
|
11
|
+
updateFeedCards as A,
|
|
12
|
+
} from "../../common/feed-display.js";
|
|
13
|
+
import { setCardHeight as B } from "../../Card/display/card-display.js";
|
|
14
|
+
import { setupFeedUI as F } from "../../ui/js/index.js";
|
|
15
|
+
import r from "../../../shared-lib/braze-shared-lib.js";
|
|
16
|
+
export function showContentCards(n, t) {
|
|
17
|
+
if (!e.rr()) return;
|
|
18
|
+
F();
|
|
19
|
+
let o = !1;
|
|
20
|
+
null == n && ((n = document.body), (o = !0));
|
|
21
|
+
const a = e.nn(L.tn) || e.nn(L.en) || !1,
|
|
22
|
+
i = g.er().Ls(!1);
|
|
23
|
+
"function" == typeof t && A(i, t(i.cards.slice()), i.lastUpdated, null, a);
|
|
24
|
+
const s = I(i, a, o),
|
|
25
|
+
l = g.er(),
|
|
26
|
+
f = l.Cs();
|
|
27
|
+
(null == i.lastUpdated ||
|
|
28
|
+
new Date().valueOf() - i.lastUpdated.valueOf() > ContentCards.mr) &&
|
|
29
|
+
(null == f || new Date().valueOf() - f > ContentCards.mr) &&
|
|
30
|
+
(r.j.info(
|
|
31
|
+
`Cached content cards were older than max TTL of ${ContentCards.mr} ms, requesting an update from the server.`,
|
|
32
|
+
),
|
|
33
|
+
$(i, s),
|
|
34
|
+
l.ws(new Date().valueOf()));
|
|
35
|
+
const c = new Date().valueOf(),
|
|
36
|
+
u = subscribeToContentCardsUpdates(function (n) {
|
|
37
|
+
const e = s.querySelectorAll(".ab-refresh-button")[0];
|
|
38
|
+
if (null != e) {
|
|
39
|
+
let n = 500,
|
|
40
|
+
t = (n -= new Date().valueOf() - c);
|
|
41
|
+
const o = s.getAttribute(M);
|
|
42
|
+
o && ((t = parseInt(o)), isNaN(t) || (n -= new Date().valueOf() - t)),
|
|
43
|
+
setTimeout(
|
|
44
|
+
function () {
|
|
45
|
+
e.className = e.className.replace(/fa-spin/g, "");
|
|
46
|
+
},
|
|
47
|
+
Math.max(n, 0),
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
let o = n.cards;
|
|
51
|
+
"function" == typeof t && (o = t(o.slice())),
|
|
52
|
+
A(i, o, n.lastUpdated, s, a);
|
|
53
|
+
});
|
|
54
|
+
k(u, s);
|
|
55
|
+
const d = function (n) {
|
|
56
|
+
const t = n.querySelectorAll(".ab-feed");
|
|
57
|
+
let e = null;
|
|
58
|
+
for (let o = 0; o < t.length; o++) t[o].parentNode === n && (e = t[o]);
|
|
59
|
+
null != e
|
|
60
|
+
? (z(e), null != e.parentNode && e.parentNode.replaceChild(s, e))
|
|
61
|
+
: n.appendChild(s),
|
|
62
|
+
setTimeout(function () {
|
|
63
|
+
s.className = s.className.replace("ab-hide", "ab-show");
|
|
64
|
+
}, 0),
|
|
65
|
+
o && s.focus(),
|
|
66
|
+
q(i, s),
|
|
67
|
+
B(i.cards, n);
|
|
68
|
+
};
|
|
69
|
+
var m;
|
|
70
|
+
null != n
|
|
71
|
+
? d(n)
|
|
72
|
+
: (window.onload =
|
|
73
|
+
((m = window.onload),
|
|
74
|
+
function () {
|
|
75
|
+
"function" == typeof m && m(new Event("oldLoad")), d(document.body);
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
import e from"../../managers/braze-instance.js";
|
|
1
|
+
import e from "../../managers/braze-instance.js";
|
|
2
|
+
import { hideContentCards, showContentCards } from "../index.js";
|
|
3
|
+
export function toggleContentCards(n, o) {
|
|
4
|
+
e.rr() &&
|
|
5
|
+
(document.querySelectorAll(".ab-feed").length > 0
|
|
6
|
+
? hideContentCards()
|
|
7
|
+
: showContentCards(n, o));
|
|
8
|
+
}
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
import K from"../managers/braze-instance.js";
|
|
1
|
+
import K from "../managers/braze-instance.js";
|
|
2
|
+
import BrazeSdkMetadata from "./braze-sdk-metadata.js";
|
|
3
|
+
import {
|
|
4
|
+
isArray as p,
|
|
5
|
+
validateValueIsFromEnum as G,
|
|
6
|
+
} from "../util/code-utils.js";
|
|
7
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
8
|
+
export function addSdkMetadata(a) {
|
|
9
|
+
if (!K.rr()) return;
|
|
10
|
+
if (!p(a))
|
|
11
|
+
return (
|
|
12
|
+
r.j.error("Cannot set SDK metadata because metadata is not an array."), !1
|
|
13
|
+
);
|
|
14
|
+
for (const t of a)
|
|
15
|
+
if (
|
|
16
|
+
!G(
|
|
17
|
+
BrazeSdkMetadata,
|
|
18
|
+
t,
|
|
19
|
+
"sdkMetadata contained an invalid value.",
|
|
20
|
+
"BrazeSdkMetadata",
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
return !1;
|
|
24
|
+
const t = K.ar();
|
|
25
|
+
return t && t.addSdkMetadata(a), !0;
|
|
26
|
+
}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
export default{
|
|
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
|
+
};
|
package/src/Core/change-user.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import e from"../managers/braze-instance.js";
|
|
1
|
+
import e from "../managers/braze-instance.js";
|
|
2
|
+
import { getByteLength as U } from "../util/string-utils.js";
|
|
3
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
4
|
+
import { User } from "../User/index.js";
|
|
5
|
+
import { validateStandardString as H } from "../util/validation-utils.js";
|
|
6
|
+
export function changeUser(i, t) {
|
|
7
|
+
if (!e.rr()) return;
|
|
8
|
+
if (null == i || 0 === i.length || i != i)
|
|
9
|
+
return void r.j.error("changeUser requires a non-empty userId.");
|
|
10
|
+
if (U(i) > User.lr)
|
|
11
|
+
return void r.j.error(
|
|
12
|
+
`Rejected user id "${i}" because it is longer than ${User.lr} bytes.`,
|
|
13
|
+
);
|
|
14
|
+
if (null != t && !H(t, "set signature for new user", "signature")) return;
|
|
15
|
+
const s = e.cr();
|
|
16
|
+
s && s.changeUser(i.toString(), e.gr(), t);
|
|
17
|
+
}
|
package/src/Core/destroy.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
import e from"../managers/braze-instance.js";
|
|
1
|
+
import e from "../managers/braze-instance.js";
|
|
2
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
3
|
+
export function destroy() {
|
|
4
|
+
r.j.info("Destroying Braze instance"), e.destroy(!0);
|
|
5
|
+
}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export default{
|
|
1
|
+
export default {
|
|
2
|
+
BROWSER: "browser",
|
|
3
|
+
BROWSER_VERSION: "browserVersion",
|
|
4
|
+
OS: "os",
|
|
5
|
+
RESOLUTION: "resolution",
|
|
6
|
+
LANGUAGE: "language",
|
|
7
|
+
TIME_ZONE: "timeZone",
|
|
8
|
+
USER_AGENT: "userAgent",
|
|
9
|
+
};
|