@braze/web-sdk 4.2.1 → 4.4.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 +57 -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 +174 -1
- package/src/Card/models/classic-card.js +32 -1
- package/src/Card/models/control-card.js +38 -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 +16 -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 +267 -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,283 @@
|
|
|
1
|
-
import b,{readResponseHeaders as C
|
|
1
|
+
import b, { readResponseHeaders as C } 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 h } from "../util/date-utils.js";
|
|
6
|
+
import { isURIJavascriptOrData as j } from "../util/url-utils.js";
|
|
7
|
+
import {
|
|
8
|
+
newCardFromContentCardsJson as N,
|
|
9
|
+
newCardFromSerializedValue as S
|
|
10
|
+
} from "../Card/util/card-factory.js";
|
|
11
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
12
|
+
import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
13
|
+
import u from "../managers/subscription-manager.js";
|
|
14
|
+
import s from "../common/event-logger.js";
|
|
15
|
+
export default class v extends y {
|
|
16
|
+
constructor(t, s, i, h, n) {
|
|
17
|
+
super(),
|
|
18
|
+
(this.v = t),
|
|
19
|
+
(this.h = s),
|
|
20
|
+
(this.gt = i),
|
|
21
|
+
(this.wt = h),
|
|
22
|
+
(this.vt = n),
|
|
23
|
+
(this.yt = new u()),
|
|
24
|
+
e.jt(this.yt),
|
|
25
|
+
(this.Ut = 0),
|
|
26
|
+
(this.kt = 0),
|
|
27
|
+
this.zt();
|
|
28
|
+
const o = r.xt.Ft;
|
|
29
|
+
new r.qt(o, r.D).Jt(o.$t.Mt, t => {
|
|
30
|
+
this.Bt(t);
|
|
31
|
+
}),
|
|
32
|
+
(this.Gt = null);
|
|
33
|
+
}
|
|
34
|
+
Ht() {
|
|
35
|
+
return this.Kt;
|
|
36
|
+
}
|
|
37
|
+
Qt(t) {
|
|
38
|
+
this.Kt = t;
|
|
39
|
+
}
|
|
40
|
+
Vt() {
|
|
41
|
+
return this.Wt;
|
|
42
|
+
}
|
|
43
|
+
Xt(t) {
|
|
44
|
+
this.Wt = t;
|
|
45
|
+
}
|
|
46
|
+
zt() {
|
|
47
|
+
const t = this.h.I(o.q.Yt) || [],
|
|
48
|
+
s = [];
|
|
49
|
+
for (let i = 0; i < t.length; i++) {
|
|
50
|
+
const e = S(t[i]);
|
|
51
|
+
null != e && s.push(e);
|
|
52
|
+
}
|
|
53
|
+
(this.Zt = this.Cs(this.ws(s, !1))),
|
|
54
|
+
(this.Ut = this.h.I(o.q.vs) || this.Ut),
|
|
55
|
+
(this.kt = this.h.I(o.q.ys) || this.kt);
|
|
56
|
+
}
|
|
57
|
+
Ns(t, s, i, e) {
|
|
58
|
+
let h;
|
|
59
|
+
if (s) {
|
|
60
|
+
h = [];
|
|
61
|
+
for (const t of this.Zt) t.test && h.push(t);
|
|
62
|
+
} else h = this.Zt.slice();
|
|
63
|
+
for (let i = 0; i < t.length; i++) {
|
|
64
|
+
const e = t[i];
|
|
65
|
+
let r = null;
|
|
66
|
+
for (let t = 0; t < this.Zt.length; t++)
|
|
67
|
+
if (e.id === this.Zt[t].id) {
|
|
68
|
+
r = this.Zt[t];
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
if (s) {
|
|
72
|
+
const t = N(e);
|
|
73
|
+
null != r && r.viewed && (t.viewed = !0), null != t && h.push(t);
|
|
74
|
+
} else if (null == r) {
|
|
75
|
+
const t = N(e);
|
|
76
|
+
null != t && h.push(t);
|
|
77
|
+
} else {
|
|
78
|
+
if (!r.ct(e))
|
|
79
|
+
for (let t = 0; t < h.length; t++)
|
|
80
|
+
if (e.id === h[t].id) {
|
|
81
|
+
h.splice(t, 1);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
(this.Zt = this.Cs(this.ws(h, s))),
|
|
87
|
+
this.Ss(),
|
|
88
|
+
(this.Ut = i || 0),
|
|
89
|
+
this.h.B(o.q.vs, this.Ut),
|
|
90
|
+
(this.kt = e || 0),
|
|
91
|
+
this.h.B(o.q.ys, this.kt);
|
|
92
|
+
}
|
|
93
|
+
Rs(t) {
|
|
94
|
+
if (this.Ts() && null != t && t.cards) {
|
|
95
|
+
this.h.B(o.q._s, e.Ds());
|
|
96
|
+
const s = t.full_sync;
|
|
97
|
+
s || this.zt(),
|
|
98
|
+
this.Ns(t.cards, s, t.last_full_sync_at, t.last_card_updated_at),
|
|
99
|
+
this.yt.St(this.Us(!0));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
Fs(t) {
|
|
103
|
+
this.h.B(o.q.As, t);
|
|
104
|
+
}
|
|
105
|
+
Ls(t, i, e) {
|
|
106
|
+
const h = () => {
|
|
107
|
+
this.Is(i, e, !0);
|
|
108
|
+
},
|
|
109
|
+
n = C(t);
|
|
110
|
+
let a, l;
|
|
111
|
+
if ((this.Js(), !n["retry-after"])) return void this.Fs(0);
|
|
112
|
+
if (((a = n["retry-after"]), isNaN(a) && !isNaN(Date.parse(a))))
|
|
113
|
+
(l = Date.parse(a) - new Date().getTime()), l < 0 && h();
|
|
114
|
+
else {
|
|
115
|
+
if (isNaN(parseFloat(a))) {
|
|
116
|
+
const t =
|
|
117
|
+
"Received unexpected value for retry-after header in /sync response";
|
|
118
|
+
return s.G(r.A.qs, { e: t + ": " + a }), void this.Fs(0);
|
|
119
|
+
}
|
|
120
|
+
l = 1e3 * a;
|
|
121
|
+
}
|
|
122
|
+
this.Gt = setTimeout(() => {
|
|
123
|
+
h();
|
|
124
|
+
}, l);
|
|
125
|
+
let c = this.h.I(o.q.As);
|
|
126
|
+
(c && !isNaN(parseInt(c))) || (c = 0), this.Fs(parseInt(c) + 1);
|
|
127
|
+
}
|
|
128
|
+
Bt(t) {
|
|
129
|
+
if (!this.Ts()) return;
|
|
130
|
+
this.zt();
|
|
131
|
+
const s = this.Zt.slice(),
|
|
132
|
+
i = this.v.getUserId();
|
|
133
|
+
for (let e = 0; e < t.length; e++)
|
|
134
|
+
if (i === t[e].userId || (null == i && null == t[e].userId)) {
|
|
135
|
+
const i = t[e].card;
|
|
136
|
+
let h = null;
|
|
137
|
+
for (let t = 0; t < this.Zt.length; t++)
|
|
138
|
+
if (i.id === this.Zt[t].id) {
|
|
139
|
+
h = this.Zt[t];
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
if (null == h) {
|
|
143
|
+
const t = N(i);
|
|
144
|
+
null != t && s.push(t);
|
|
145
|
+
} else {
|
|
146
|
+
if (!h.ct(i))
|
|
147
|
+
for (let t = 0; t < s.length; t++)
|
|
148
|
+
if (i.id === s[t].id) {
|
|
149
|
+
s.splice(t, 1);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
(this.Zt = this.Cs(this.ws(s, !1))), this.Ss(), this.yt.St(this.Us(!0));
|
|
155
|
+
}
|
|
156
|
+
ws(t, s) {
|
|
157
|
+
const i = this.h.I(o.q.$) || {},
|
|
158
|
+
e = this.h.I(o.q.O) || {},
|
|
159
|
+
h = this.h.I(o.q.K) || {},
|
|
160
|
+
r = {},
|
|
161
|
+
n = {},
|
|
162
|
+
a = {};
|
|
163
|
+
for (let s = 0; s < t.length; s++)
|
|
164
|
+
i[t[s].id] && ((t[s].clicked = !0), (r[t[s].id] = !0)),
|
|
165
|
+
e[t[s].id] && ((t[s].viewed = !0), (n[t[s].id] = !0)),
|
|
166
|
+
h[t[s].id] && ((t[s].dismissed = !0), (a[t[s].id] = !0));
|
|
167
|
+
return s && (this.h.B(o.q.$, r), this.h.B(o.q.O, n), this.h.B(o.q.K, a)), t;
|
|
168
|
+
}
|
|
169
|
+
Cs(t) {
|
|
170
|
+
const s = [],
|
|
171
|
+
i = new Date(),
|
|
172
|
+
e = this.h.I(o.q.K) || {};
|
|
173
|
+
let h = !1;
|
|
174
|
+
for (let n = 0; n < t.length; n++) {
|
|
175
|
+
const o = t[n].url;
|
|
176
|
+
!this.wt && o && j(o)
|
|
177
|
+
? r.D.error(
|
|
178
|
+
`Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`
|
|
179
|
+
)
|
|
180
|
+
: (null == t[n].expiresAt || t[n].expiresAt >= i) && !t[n].dismissed
|
|
181
|
+
? s.push(t[n])
|
|
182
|
+
: ((e[t[n].id] = !0), (h = !0));
|
|
183
|
+
}
|
|
184
|
+
return h && this.h.B(o.q.K, e), s;
|
|
185
|
+
}
|
|
186
|
+
Ss() {
|
|
187
|
+
const t = [];
|
|
188
|
+
for (let s = 0; s < this.Zt.length; s++) t.push(this.Zt[s].ss());
|
|
189
|
+
this.h.B(o.q.Yt, t);
|
|
190
|
+
}
|
|
191
|
+
Js() {
|
|
192
|
+
this.Gt && (clearTimeout(this.Gt), (this.Gt = null));
|
|
193
|
+
}
|
|
194
|
+
Is(t, s, i) {
|
|
195
|
+
if ((i || (this.Js(), this.Fs(0)), !this.Ts()))
|
|
196
|
+
return void (
|
|
197
|
+
this.Es ||
|
|
198
|
+
(this.Es = this.gt.Ms(() => {
|
|
199
|
+
this.Is(t, s);
|
|
200
|
+
}))
|
|
201
|
+
);
|
|
202
|
+
const h = this.vt.Ps({}, !0);
|
|
203
|
+
this.h.I(o.q._s) !== e.Ds() && this.$s(),
|
|
204
|
+
(h.last_full_sync_at = this.Ut),
|
|
205
|
+
(h.last_card_updated_at = this.kt);
|
|
206
|
+
const r = this.vt.Bs(h, !0, !1, i);
|
|
207
|
+
this.vt.Gs(h, () => {
|
|
208
|
+
b.Hs({
|
|
209
|
+
url: this.vt.Ks() + "/content_cards/sync",
|
|
210
|
+
data: h,
|
|
211
|
+
headers: r,
|
|
212
|
+
S: (i, e) => {
|
|
213
|
+
this.vt.Os(h, i, r)
|
|
214
|
+
? (this.vt.Qs(),
|
|
215
|
+
this.Ls(e, t, s),
|
|
216
|
+
this.Rs(i),
|
|
217
|
+
"function" == typeof t && t())
|
|
218
|
+
: "function" == typeof s && s();
|
|
219
|
+
},
|
|
220
|
+
error: t => {
|
|
221
|
+
this.vt.Vs(t, "retrieving content cards"),
|
|
222
|
+
"function" == typeof s && s();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
Us(t) {
|
|
228
|
+
t || this.zt();
|
|
229
|
+
const s = this.Cs(this.Zt);
|
|
230
|
+
s.sort((t, s) =>
|
|
231
|
+
t.pinned && !s.pinned
|
|
232
|
+
? -1
|
|
233
|
+
: s.pinned && !t.pinned
|
|
234
|
+
? 1
|
|
235
|
+
: t.updated > s.updated
|
|
236
|
+
? -1
|
|
237
|
+
: s.updated > t.updated
|
|
238
|
+
? 1
|
|
239
|
+
: 0
|
|
240
|
+
);
|
|
241
|
+
let i = Math.max(this.kt || 0, this.Ut || 0);
|
|
242
|
+
return (
|
|
243
|
+
0 === i && (i = void 0),
|
|
244
|
+
this.h.I(o.q.ys) === this.kt && void 0 === i && (i = this.kt),
|
|
245
|
+
new ContentCards(s, h(i))
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
Ws(t) {
|
|
249
|
+
return this.yt.ut(t);
|
|
250
|
+
}
|
|
251
|
+
$s() {
|
|
252
|
+
(this.Ut = 0), (this.kt = 0), this.h.Xs(o.q.vs), this.h.Xs(o.q.ys);
|
|
253
|
+
}
|
|
254
|
+
changeUser(t) {
|
|
255
|
+
t ||
|
|
256
|
+
((this.Zt = []),
|
|
257
|
+
this.yt.St(new ContentCards(this.Zt.slice(), null)),
|
|
258
|
+
this.h.Xs(o.q.Yt),
|
|
259
|
+
this.h.Xs(o.q.$),
|
|
260
|
+
this.h.Xs(o.q.O),
|
|
261
|
+
this.h.Xs(o.q.K)),
|
|
262
|
+
this.$s();
|
|
263
|
+
}
|
|
264
|
+
clearData(t) {
|
|
265
|
+
(this.Ut = 0),
|
|
266
|
+
(this.kt = 0),
|
|
267
|
+
(this.Zt = []),
|
|
268
|
+
this.yt.St(new ContentCards(this.Zt.slice(), null)),
|
|
269
|
+
t &&
|
|
270
|
+
(this.h.Xs(o.q.Yt),
|
|
271
|
+
this.h.Xs(o.q.$),
|
|
272
|
+
this.h.Xs(o.q.O),
|
|
273
|
+
this.h.Xs(o.q.K),
|
|
274
|
+
this.h.Xs(o.q.vs),
|
|
275
|
+
this.h.Xs(o.q.ys));
|
|
276
|
+
}
|
|
277
|
+
Ts() {
|
|
278
|
+
return !!this.gt.Ys() || (0 !== this.gt.Zs() && this.ti(), !1);
|
|
279
|
+
}
|
|
280
|
+
ti() {
|
|
281
|
+
this.yt.St(new ContentCards([], new Date().valueOf())), this.h.Xs(o.q.Yt);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
@@ -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
|
+
logCardClick(r, !0);
|
|
16
|
+
}
|
|
17
|
+
sr() {
|
|
18
|
+
requestContentCardsRefresh();
|
|
19
|
+
}
|
|
20
|
+
dr() {
|
|
21
|
+
return !0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
ContentCards.ur = 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().Us(!1);
|
|
5
|
+
}
|
|
@@ -1 +1,8 @@
|
|
|
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 { logContentCardsDisplayed } from "./log-content-cards-displayed.js";
|
|
5
|
+
export { requestContentCardsRefresh } from "./request-content-cards-refresh.js";
|
|
6
|
+
export { showContentCards } from "./ui/show-content-cards.js";
|
|
7
|
+
export { subscribeToContentCardsUpdates } from "./subscribe-to-content-cards-updates.js";
|
|
8
|
+
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 { logDeprecationWarning as D } from "../util/deprecation-utils.js";
|
|
3
|
+
export function logContentCardsDisplayed() {
|
|
4
|
+
if (e.rr()) return D("logContentCardsDisplayed", "method"), !0;
|
|
5
|
+
}
|
|
@@ -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().Is(r, t);
|
|
5
|
+
}
|
|
@@ -1 +1,14 @@
|
|
|
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.Ws(r);
|
|
7
|
+
if (!t.Vt()) {
|
|
8
|
+
const r = e.mr().cr(() => {
|
|
9
|
+
t.Is();
|
|
10
|
+
});
|
|
11
|
+
t.Xt(r);
|
|
12
|
+
}
|
|
13
|
+
return n;
|
|
14
|
+
}
|
|
@@ -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,72 @@
|
|
|
1
|
-
import e,{OPTIONS as T
|
|
1
|
+
import e, { OPTIONS as T } 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 L,
|
|
9
|
+
refreshFeed as M,
|
|
10
|
+
registerFeedSubscriptionId as $,
|
|
11
|
+
updateFeedCards as k
|
|
12
|
+
} from "../../common/feed-display.js";
|
|
13
|
+
import { setCardHeight as A } from "../../Card/display/card-display.js";
|
|
14
|
+
import { setupFeedUI as B } 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
|
+
B();
|
|
19
|
+
let o = !1;
|
|
20
|
+
null == n && ((n = document.body), (o = !0));
|
|
21
|
+
const a = e.nn(T.tn) || e.nn(T.en) || !1;
|
|
22
|
+
let i = g.er().Us(!1);
|
|
23
|
+
"function" == typeof t && k(i, t(i.cards.slice()), i.lastUpdated, null, a);
|
|
24
|
+
const s = I(i, a),
|
|
25
|
+
f = g.er();
|
|
26
|
+
(null == i.lastUpdated ||
|
|
27
|
+
new Date().valueOf() - i.lastUpdated.valueOf() > ContentCards.ur) &&
|
|
28
|
+
(null == f.Ht() || new Date().valueOf() - f.Ht() > ContentCards.ur) &&
|
|
29
|
+
(r.D.info(
|
|
30
|
+
`Cached content cards were older than max TTL of ${ContentCards.ur} ms, requesting an update from the server.`
|
|
31
|
+
),
|
|
32
|
+
M(i, s),
|
|
33
|
+
f.Qt(new Date().valueOf()));
|
|
34
|
+
const l = new Date().valueOf(),
|
|
35
|
+
c = subscribeToContentCardsUpdates(function(n) {
|
|
36
|
+
const e = s.querySelectorAll(".ab-refresh-button")[0];
|
|
37
|
+
if (null != e) {
|
|
38
|
+
let n = 500;
|
|
39
|
+
const t = parseInt(s.getAttribute(L));
|
|
40
|
+
isNaN(t)
|
|
41
|
+
? (n -= new Date().valueOf() - l)
|
|
42
|
+
: (n -= new Date().valueOf() - t),
|
|
43
|
+
setTimeout(function() {
|
|
44
|
+
e.className = e.className.replace(/fa-spin/g, "");
|
|
45
|
+
}, Math.max(n, 0));
|
|
46
|
+
}
|
|
47
|
+
let o = n.cards;
|
|
48
|
+
"function" == typeof t && (o = t(o.slice())),
|
|
49
|
+
k(i, o, n.lastUpdated, s, a);
|
|
50
|
+
});
|
|
51
|
+
$(c, s);
|
|
52
|
+
const u = function(n) {
|
|
53
|
+
const t = n.querySelectorAll(".ab-feed");
|
|
54
|
+
let e = null;
|
|
55
|
+
for (let o = 0; o < t.length; o++) t[o].parentNode === n && (e = t[o]);
|
|
56
|
+
null != e ? (z(e), e.parentNode.replaceChild(s, e)) : n.appendChild(s),
|
|
57
|
+
setTimeout(function() {
|
|
58
|
+
s.className = s.className.replace("ab-hide", "ab-show");
|
|
59
|
+
}, 0),
|
|
60
|
+
o && s.focus(),
|
|
61
|
+
q(i, s),
|
|
62
|
+
A(i.cards, n);
|
|
63
|
+
};
|
|
64
|
+
var m;
|
|
65
|
+
null != n
|
|
66
|
+
? u(n)
|
|
67
|
+
: (window.onload =
|
|
68
|
+
((m = window.onload),
|
|
69
|
+
function() {
|
|
70
|
+
"function" == typeof m && m(), u(document.body);
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
@@ -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,27 @@
|
|
|
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 F
|
|
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()) {
|
|
10
|
+
if (!p(a))
|
|
11
|
+
return (
|
|
12
|
+
r.D.error("Cannot set SDK metadata because metadata is not an array."),
|
|
13
|
+
!1
|
|
14
|
+
);
|
|
15
|
+
for (const t of a)
|
|
16
|
+
if (
|
|
17
|
+
!F(
|
|
18
|
+
BrazeSdkMetadata,
|
|
19
|
+
t,
|
|
20
|
+
"sdkMetadata contained an invalid value.",
|
|
21
|
+
"BrazeSdkMetadata"
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
return !1;
|
|
25
|
+
return K.nr().addSdkMetadata(a), !0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -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,19 @@
|
|
|
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 R } from "../util/validation-utils.js";
|
|
6
|
+
export function changeUser(s, i) {
|
|
7
|
+
return (
|
|
8
|
+
!!e.rr() &&
|
|
9
|
+
(null == s || 0 === s.length || s != s
|
|
10
|
+
? (r.D.error("changeUser requires a non-empty userId."), !1)
|
|
11
|
+
: U(s) > User.ee
|
|
12
|
+
? (r.D.error(
|
|
13
|
+
`Rejected user id "${s}" because it is longer than ${User.ee} bytes.`
|
|
14
|
+
),
|
|
15
|
+
!1)
|
|
16
|
+
: !(null != i && !R(i, "set signature for new user", "signature")) &&
|
|
17
|
+
void e.mr().changeUser(s.toString(), e.re(), i))
|
|
18
|
+
);
|
|
19
|
+
}
|
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.D.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
|
+
};
|
package/src/Core/disable-sdk.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
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
|
+
import G, { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
4
|
+
export function disableSDK() {
|
|
5
|
+
null != e.mr() && e.mr().requestImmediateDataFlush();
|
|
6
|
+
const n = new G.ne(null, !0);
|
|
7
|
+
n.store(o.ae, "This-cookie-will-expire-in-" + n.ie());
|
|
8
|
+
const a = r.xt.Ft;
|
|
9
|
+
new r.qt(a, r.D).setItem(a.$t.oe, a.se, !0), e.destroy(!1), e.le(!0);
|
|
10
|
+
}
|
package/src/Core/enable-sdk.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
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
|
+
import G, { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
4
|
+
export function enableSDK() {
|
|
5
|
+
new G.ne(null, !0).remove(o.ae);
|
|
6
|
+
const a = r.xt.Ft;
|
|
7
|
+
new r.qt(a, r.D).br(a.$t.oe, a.se), e.destroy(!1), e.le(!1);
|
|
8
|
+
}
|
|
@@ -1 +1,10 @@
|
|
|
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 getDeviceId(i) {
|
|
4
|
+
e.rr() &&
|
|
5
|
+
(null == i &&
|
|
6
|
+
r.D.error(
|
|
7
|
+
"getDeviceId must be supplied with a callback. e.g., braze.getDeviceId(function(deviceId) {console.log('the device id is ' + deviceId)})"
|
|
8
|
+
),
|
|
9
|
+
"function" == typeof i && i(e.ce().te().id));
|
|
10
|
+
}
|
package/src/Core/get-user.js
CHANGED