@braze/web-sdk 5.9.0 → 6.0.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 +109 -253
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +24 -26
- package/shared-lib/guid.js +2 -2
- package/shared-lib/indexed-db-adapter.js +19 -19
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +21 -22
- package/src/Banner/display/banner-to-html.js +13 -25
- package/src/Banner/display/destroy-banner-html.js +2 -2
- package/src/Banner/display/detect-banner-impressions.js +11 -11
- package/src/Banner/index.js +0 -1
- package/src/Banner/request-banners-refresh.js +8 -8
- package/src/Banner/subscribe-to-banners-updates.js +2 -2
- package/src/Banner/ui/insert-banner.js +7 -7
- package/src/Card/card-manager.js +35 -37
- package/src/Card/display/card-display.js +76 -74
- package/src/Card/index.js +0 -2
- package/src/Card/log-card-dismissal.js +2 -2
- package/src/Card/log-content-card-click.js +9 -2
- package/src/Card/log-content-card-impressions.js +11 -2
- package/src/Card/models/captioned-image.js +20 -20
- package/src/Card/models/card.js +110 -104
- package/src/Card/models/classic-card.js +20 -20
- package/src/Card/models/control-card.js +14 -14
- package/src/Card/models/image-only.js +19 -20
- package/src/Card/util/card-factory.js +57 -78
- package/src/ContentCards/content-cards-provider-factory.js +10 -10
- package/src/ContentCards/content-cards-provider.js +109 -109
- package/src/ContentCards/content-cards.js +21 -13
- package/src/ContentCards/get-cached-content-cards.js +2 -2
- package/src/ContentCards/request-content-cards-refresh.js +2 -2
- package/src/ContentCards/subscribe-to-content-cards-updates.js +5 -5
- package/src/ContentCards/ui/hide-content-cards.js +5 -5
- package/src/ContentCards/ui/show-content-cards.js +34 -34
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +7 -7
- package/src/Core/disable-sdk.js +6 -6
- package/src/Core/enable-sdk.js +5 -5
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +7 -7
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/is-initialized.js +1 -1
- package/src/Core/log-custom-event.js +9 -9
- package/src/Core/log-purchase.js +7 -7
- package/src/Core/open-session.js +12 -12
- package/src/Core/request-immediate-data-flush.js +1 -1
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/wipe-data.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +7 -7
- package/src/FeatureFlags/feature-flag.js +6 -6
- package/src/FeatureFlags/feature-flags-provider-factory.js +9 -9
- package/src/FeatureFlags/feature-flags-provider.js +1 -1
- package/src/FeatureFlags/get-all-feature-flags.js +2 -2
- package/src/FeatureFlags/get-feature-flag.js +2 -2
- package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
- package/src/FeatureFlags/refresh-feature-flags.js +2 -2
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +37 -37
- package/src/InAppMessage/display/in-app-message-to-html.js +139 -133
- package/src/InAppMessage/display/modal-utils.js +39 -41
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +22 -14
- package/src/InAppMessage/in-app-message-manager.js +90 -88
- package/src/InAppMessage/log-in-app-message-button-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-html-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/control-message.js +2 -2
- package/src/InAppMessage/models/full-screen-message.js +40 -34
- package/src/InAppMessage/models/html-message.js +23 -21
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +137 -133
- package/src/InAppMessage/models/modal-message.js +39 -33
- package/src/InAppMessage/models/slide-up-message.js +36 -30
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +56 -62
- 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 +8 -8
- package/src/Push/push-manager.js +90 -90
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/utils/push-utils.js +25 -15
- package/src/User/user-manager.js +14 -14
- package/src/User/user.js +55 -55
- package/src/common/content-cards-display.js +211 -0
- package/src/common/event-logger.js +6 -6
- package/src/index.js +0 -1
- package/src/l10n/l10n-manager-factory.js +9 -9
- package/src/l10n/l10n-manager.js +6 -6
- package/src/managers/auth-manager.js +27 -27
- package/src/managers/braze-instance.js +136 -137
- package/src/managers/device-manager.js +22 -22
- package/src/managers/network-manager.js +180 -183
- package/src/managers/server-config-manager.js +63 -63
- package/src/managers/session-manager.js +34 -34
- package/src/managers/storage-manager-factory.js +11 -11
- package/src/managers/storage-manager.js +139 -141
- package/src/managers/subscription-manager.js +3 -3
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +15 -15
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +13 -13
- package/src/models/push-token.js +12 -12
- package/src/models/request-result.js +2 -2
- package/src/models/server-config.js +29 -29
- package/src/request-controller.js +181 -169
- package/src/triggers/models/custom-event-data.js +6 -6
- package/src/triggers/models/custom-event-property-data.js +7 -7
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +45 -45
- package/src/triggers/models/in-app-message-click-data.js +3 -3
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +47 -47
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +15 -15
- package/src/triggers/triggers-provider-factory.js +4 -4
- package/src/triggers/triggers-provider.js +44 -44
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/banner-css.js +1 -1
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +4 -4
- package/src/util/braze-actions.js +8 -14
- package/src/util/browser-detector.js +12 -12
- package/src/util/client-hints-parser.js +3 -3
- package/src/util/component-utils.js +14 -14
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +6 -6
- package/src/util/html-display-utils.js +37 -37
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +17 -17
- package/src/util/user-agent-parser.js +4 -4
- package/src/util/validation-utils.js +20 -20
- package/src/util/window-utils.js +1 -1
- package/src/Card/log-card-click.js +0 -11
- package/src/Card/log-card-impressions.js +0 -13
- package/src/Feed/feed-provider-factory.js +0 -18
- package/src/Feed/feed-provider.js +0 -90
- package/src/Feed/feed.js +0 -20
- package/src/Feed/get-cached-feed.js +0 -5
- package/src/Feed/index.js +0 -8
- package/src/Feed/log-feed-displayed.js +0 -7
- package/src/Feed/request-feed-refresh.js +0 -5
- package/src/Feed/subscribe-to-feed-updates.js +0 -5
- package/src/Feed/types.js +0 -1
- package/src/Feed/ui/hide-feed.js +0 -7
- package/src/Feed/ui/show-feed.js +0 -96
- package/src/Feed/ui/toggle-feed.js +0 -8
- package/src/common/base-feed.js +0 -29
- package/src/common/feed-display.js +0 -211
|
@@ -2,51 +2,51 @@ import l from "../util/net.js";
|
|
|
2
2
|
import t from "../common/base-provider.js";
|
|
3
3
|
import r from "../managers/braze-instance.js";
|
|
4
4
|
import ContentCards from "./content-cards.js";
|
|
5
|
-
import { dateFromUnixTimestamp as
|
|
6
|
-
import { isURIJavascriptOrData as
|
|
5
|
+
import { dateFromUnixTimestamp as V } from "../util/date-utils.js";
|
|
6
|
+
import { isURIJavascriptOrData as tt } from "../util/url-utils.js";
|
|
7
7
|
import {
|
|
8
|
-
newCardFromContentCardsJson as
|
|
9
|
-
newCardFromSerializedValue as
|
|
8
|
+
newCardFromContentCardsJson as st,
|
|
9
|
+
newCardFromSerializedValue as it,
|
|
10
10
|
} from "../Card/util/card-factory.js";
|
|
11
11
|
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
12
12
|
import u from "../managers/subscription-manager.js";
|
|
13
13
|
import h from "../util/request-header-utils.js";
|
|
14
14
|
import { randomInclusive as a } from "../util/math.js";
|
|
15
|
-
import { logger as N, IndexedDBAdapter as
|
|
16
|
-
export default class
|
|
15
|
+
import { logger as N, IndexedDBAdapter as et } from "../../shared-lib/index.js";
|
|
16
|
+
export default class Y extends t {
|
|
17
17
|
constructor(t, s, i, e, h) {
|
|
18
18
|
super(),
|
|
19
19
|
(this.Cs = t),
|
|
20
20
|
(this.C = s),
|
|
21
21
|
(this.B = i),
|
|
22
|
-
(this.
|
|
22
|
+
(this.ws = e),
|
|
23
23
|
(this.S = h),
|
|
24
24
|
(this.Cs = t),
|
|
25
25
|
(this.C = s),
|
|
26
26
|
(this.B = i),
|
|
27
|
-
(this.
|
|
27
|
+
(this.ws = e),
|
|
28
28
|
(this.S = h),
|
|
29
|
-
(this.
|
|
30
|
-
r.F(this.
|
|
31
|
-
(this.
|
|
32
|
-
(this.
|
|
29
|
+
(this.ys = new u()),
|
|
30
|
+
r.F(this.ys),
|
|
31
|
+
(this.Ss = 0),
|
|
32
|
+
(this.Ts = 0),
|
|
33
33
|
(this.cards = []),
|
|
34
|
-
this.
|
|
35
|
-
const n =
|
|
36
|
-
new
|
|
37
|
-
this
|
|
34
|
+
this.Rs();
|
|
35
|
+
const n = et.Ds.Us;
|
|
36
|
+
new et(n, N).As(n.Ls.Fs, (t) => {
|
|
37
|
+
this.Ns(t);
|
|
38
38
|
}),
|
|
39
|
-
(this.
|
|
39
|
+
(this.Js = null),
|
|
40
40
|
(this.N = null),
|
|
41
|
-
(this.
|
|
42
|
-
(this
|
|
43
|
-
(this.
|
|
41
|
+
(this.Ms = null),
|
|
42
|
+
(this.$s = null),
|
|
43
|
+
(this.Bs = 10);
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
return this.
|
|
45
|
+
Es() {
|
|
46
|
+
return this.Js;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
this.
|
|
48
|
+
Ps(t) {
|
|
49
|
+
this.Js = t;
|
|
50
50
|
}
|
|
51
51
|
Ct() {
|
|
52
52
|
return this.N;
|
|
@@ -54,19 +54,19 @@ export default class Q extends t {
|
|
|
54
54
|
Tt(t) {
|
|
55
55
|
this.N = t;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
Rs() {
|
|
58
58
|
if (!this.C) return;
|
|
59
|
-
const t = this.C.ft(s.gt.
|
|
59
|
+
const t = this.C.ft(s.gt.Xs) || [],
|
|
60
60
|
i = [];
|
|
61
61
|
for (let s = 0; s < t.length; s++) {
|
|
62
|
-
const e =
|
|
62
|
+
const e = it(t[s]);
|
|
63
63
|
null != e && i.push(e);
|
|
64
64
|
}
|
|
65
|
-
(this.cards = this.
|
|
66
|
-
(this.
|
|
67
|
-
(this.
|
|
65
|
+
(this.cards = this._s(this.Gs(i, !1))),
|
|
66
|
+
(this.Ss = this.C.ft(s.gt.Hs) || this.Ss),
|
|
67
|
+
(this.Ts = this.C.ft(s.gt.Is) || this.Ts);
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
Ks(t, i = !1, e = 0, h = 0) {
|
|
70
70
|
let r;
|
|
71
71
|
if (i) {
|
|
72
72
|
r = [];
|
|
@@ -81,10 +81,10 @@ export default class Q extends t {
|
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
if (i) {
|
|
84
|
-
const t =
|
|
84
|
+
const t = st(e);
|
|
85
85
|
null != h && h.viewed && t && (t.viewed = !0), null != t && r.push(t);
|
|
86
86
|
} else if (null == h) {
|
|
87
|
-
const t =
|
|
87
|
+
const t = st(e);
|
|
88
88
|
null != t && r.push(t);
|
|
89
89
|
} else {
|
|
90
90
|
if (!h.ri(e))
|
|
@@ -95,28 +95,28 @@ export default class Q extends t {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
(this.cards = this.
|
|
99
|
-
this.
|
|
100
|
-
(this.
|
|
101
|
-
(this.
|
|
102
|
-
this.C && (this.C.Bt(s.gt.
|
|
98
|
+
(this.cards = this._s(this.Gs(r, i))),
|
|
99
|
+
this.Os(),
|
|
100
|
+
(this.Ss = e),
|
|
101
|
+
(this.Ts = h),
|
|
102
|
+
this.C && (this.C.Bt(s.gt.Hs, this.Ss), this.C.Bt(s.gt.Is, this.Ts));
|
|
103
103
|
}
|
|
104
104
|
U(t) {
|
|
105
|
-
if (this.
|
|
106
|
-
this.C && this.C.Bt(s.gt.
|
|
105
|
+
if (this.Qs() && null != t && t.cards) {
|
|
106
|
+
this.C && this.C.Bt(s.gt.Vs, r.Ws());
|
|
107
107
|
const i = t.full_sync;
|
|
108
|
-
i || this.
|
|
109
|
-
this.
|
|
110
|
-
this.
|
|
108
|
+
i || this.Rs(),
|
|
109
|
+
this.Ks(t.cards, i, t.last_full_sync_at, t.last_card_updated_at),
|
|
110
|
+
this.ys.X(this.Ys(!0));
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
this.
|
|
113
|
+
Zs(t) {
|
|
114
|
+
this.fi(), (this.Ms = t);
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
Ns(t) {
|
|
117
117
|
var s;
|
|
118
|
-
if (!this.
|
|
119
|
-
this.
|
|
118
|
+
if (!this.Qs()) return;
|
|
119
|
+
this.Rs();
|
|
120
120
|
const i = this.cards.slice();
|
|
121
121
|
let e = null;
|
|
122
122
|
e = null === (s = this.Cs) || void 0 === s ? void 0 : s.getUserId();
|
|
@@ -130,7 +130,7 @@ export default class Q extends t {
|
|
|
130
130
|
break;
|
|
131
131
|
}
|
|
132
132
|
if (null == h) {
|
|
133
|
-
const t =
|
|
133
|
+
const t = st(e);
|
|
134
134
|
null != t && i.push(t);
|
|
135
135
|
} else {
|
|
136
136
|
if (!h.ri(e))
|
|
@@ -141,16 +141,16 @@ export default class Q extends t {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
(this.cards = this.
|
|
144
|
+
(this.cards = this._s(this.Gs(i, !1))), this.Os(), this.ys.X(this.Ys(!0));
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
Gs(t, i) {
|
|
147
147
|
let e = {},
|
|
148
148
|
h = {},
|
|
149
149
|
r = {};
|
|
150
150
|
this.C &&
|
|
151
151
|
((e = this.C.ft(s.gt.Kt) || {}),
|
|
152
|
-
(h = this.C.ft(s.gt.
|
|
153
|
-
(r = this.C.ft(s.gt.
|
|
152
|
+
(h = this.C.ft(s.gt.Xt) || {}),
|
|
153
|
+
(r = this.C.ft(s.gt.Qt) || {}));
|
|
154
154
|
const n = {},
|
|
155
155
|
o = {},
|
|
156
156
|
l = {};
|
|
@@ -164,19 +164,19 @@ export default class Q extends t {
|
|
|
164
164
|
return (
|
|
165
165
|
i &&
|
|
166
166
|
this.C &&
|
|
167
|
-
(this.C.Bt(s.gt.Kt, n), this.C.Bt(s.gt.
|
|
167
|
+
(this.C.Bt(s.gt.Kt, n), this.C.Bt(s.gt.Xt, o), this.C.Bt(s.gt.Qt, l)),
|
|
168
168
|
t
|
|
169
169
|
);
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
_s(t) {
|
|
172
172
|
const i = [],
|
|
173
173
|
e = new Date();
|
|
174
174
|
let h = {};
|
|
175
|
-
this.C && (h = this.C.ft(s.gt.
|
|
175
|
+
this.C && (h = this.C.ft(s.gt.Qt) || {});
|
|
176
176
|
let r = !1;
|
|
177
177
|
for (let s = 0; s < t.length; s++) {
|
|
178
178
|
const n = t[s].url;
|
|
179
|
-
if (!this.
|
|
179
|
+
if (!this.ws && n && tt(n)) {
|
|
180
180
|
N.error(
|
|
181
181
|
`Card with url ${n} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`,
|
|
182
182
|
);
|
|
@@ -191,42 +191,42 @@ export default class Q extends t {
|
|
|
191
191
|
i && (h[i] = !0), (r = !0);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
return r && this.C && this.C.Bt(s.gt.
|
|
194
|
+
return r && this.C && this.C.Bt(s.gt.Qt, h), i;
|
|
195
195
|
}
|
|
196
|
-
|
|
196
|
+
Os() {
|
|
197
197
|
var t;
|
|
198
198
|
const i = [];
|
|
199
199
|
for (let t = 0; t < this.cards.length; t++) i.push(this.cards[t].bt());
|
|
200
|
-
null === (t = this.C) || void 0 === t || t.Bt(s.gt.
|
|
200
|
+
null === (t = this.C) || void 0 === t || t.Bt(s.gt.Xs, i);
|
|
201
201
|
}
|
|
202
|
-
|
|
203
|
-
this.
|
|
202
|
+
fi() {
|
|
203
|
+
this.Ms && (clearTimeout(this.Ms), (this.Ms = null));
|
|
204
204
|
}
|
|
205
|
-
|
|
205
|
+
Ci(t, i, e = !1) {
|
|
206
206
|
var n;
|
|
207
207
|
const o = this.S,
|
|
208
208
|
u = this.C;
|
|
209
209
|
if (!o || !u) return void ("function" == typeof i && i());
|
|
210
|
-
if ((e && (h.
|
|
210
|
+
if ((e && (h.bi(u, h.O.vi), this.fi()), !this.Qs()))
|
|
211
211
|
return void (
|
|
212
212
|
null === (n = this.B) ||
|
|
213
213
|
void 0 === n ||
|
|
214
|
-
n.
|
|
215
|
-
this.
|
|
214
|
+
n.wi(() => {
|
|
215
|
+
this.Ci(t, i, !0);
|
|
216
216
|
})
|
|
217
217
|
);
|
|
218
218
|
const c = o.H({}, !0);
|
|
219
|
-
u.ft(s.gt.
|
|
220
|
-
(c.last_full_sync_at = this.
|
|
221
|
-
(c.last_card_updated_at = this.
|
|
222
|
-
const f = o.J(c, h.O.
|
|
219
|
+
u.ft(s.gt.Vs) !== r.Ws() && this.gi(),
|
|
220
|
+
(c.last_full_sync_at = this.Ss),
|
|
221
|
+
(c.last_card_updated_at = this.Ts);
|
|
222
|
+
const f = o.J(c, h.O.vi, e);
|
|
223
223
|
let d = !1;
|
|
224
224
|
o.V(
|
|
225
225
|
c,
|
|
226
226
|
(s = -1) => {
|
|
227
227
|
if (this.C) {
|
|
228
228
|
const t = new Date().valueOf();
|
|
229
|
-
h.W(this.C, h.O.
|
|
229
|
+
h.W(this.C, h.O.vi, t);
|
|
230
230
|
}
|
|
231
231
|
-1 !== s && f.push(["X-Braze-Req-Tokens-Remaining", s.toString()]),
|
|
232
232
|
l.Y({
|
|
@@ -246,30 +246,30 @@ export default class Q extends t {
|
|
|
246
246
|
nt: (s, e) => {
|
|
247
247
|
let r;
|
|
248
248
|
if (d) {
|
|
249
|
-
let t = this
|
|
250
|
-
(null == t || t < 1e3 * this.
|
|
251
|
-
(r = Math.min(3e5, a(1e3 * this.
|
|
249
|
+
let t = this.$s;
|
|
250
|
+
(null == t || t < 1e3 * this.Bs) && (t = 1e3 * this.Bs),
|
|
251
|
+
(r = Math.min(3e5, a(1e3 * this.Bs, 3 * t)));
|
|
252
252
|
}
|
|
253
253
|
o.rt(
|
|
254
254
|
e,
|
|
255
255
|
() => {
|
|
256
|
-
this.
|
|
256
|
+
this.Ci(t, i, !1);
|
|
257
257
|
},
|
|
258
|
-
h.O.
|
|
259
|
-
(t) => this.
|
|
260
|
-
() => this.
|
|
258
|
+
h.O.vi,
|
|
259
|
+
(t) => this.Zs(t),
|
|
260
|
+
() => this.fi(),
|
|
261
261
|
r,
|
|
262
262
|
);
|
|
263
263
|
},
|
|
264
264
|
});
|
|
265
265
|
},
|
|
266
|
-
h.O.
|
|
266
|
+
h.O.vi,
|
|
267
267
|
i,
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
|
-
|
|
271
|
-
t || this.
|
|
272
|
-
const i = this.
|
|
270
|
+
Ys(t) {
|
|
271
|
+
t || this.Rs();
|
|
272
|
+
const i = this._s(this.cards);
|
|
273
273
|
i.sort((t, s) =>
|
|
274
274
|
t.pinned && !s.pinned
|
|
275
275
|
? -1
|
|
@@ -281,52 +281,52 @@ export default class Q extends t {
|
|
|
281
281
|
? 1
|
|
282
282
|
: 0,
|
|
283
283
|
);
|
|
284
|
-
let e = Math.max(this.
|
|
284
|
+
let e = Math.max(this.Ts || 0, this.Ss || 0);
|
|
285
285
|
return (
|
|
286
286
|
0 === e && (e = void 0),
|
|
287
|
-
this.C && this.C.ft(s.gt.
|
|
288
|
-
new ContentCards(i,
|
|
287
|
+
this.C && this.C.ft(s.gt.Is) === this.Ts && void 0 === e && (e = this.Ts),
|
|
288
|
+
new ContentCards(i, V(e))
|
|
289
289
|
);
|
|
290
290
|
}
|
|
291
291
|
qt(t) {
|
|
292
|
-
return this.
|
|
292
|
+
return this.ys.Dt(t);
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
(this.
|
|
296
|
-
(this.
|
|
297
|
-
this.C && (this.C.Ut(s.gt.
|
|
294
|
+
gi() {
|
|
295
|
+
(this.Ss = 0),
|
|
296
|
+
(this.Ts = 0),
|
|
297
|
+
this.C && (this.C.Ut(s.gt.Hs), this.C.Ut(s.gt.Is));
|
|
298
298
|
}
|
|
299
299
|
changeUser(t) {
|
|
300
300
|
t ||
|
|
301
301
|
((this.cards = []),
|
|
302
|
-
this.
|
|
302
|
+
this.ys.X(new ContentCards(this.cards.slice(), null)),
|
|
303
303
|
this.C &&
|
|
304
|
-
(this.C.Ut(s.gt.
|
|
304
|
+
(this.C.Ut(s.gt.Xs),
|
|
305
305
|
this.C.Ut(s.gt.Kt),
|
|
306
|
-
this.C.Ut(s.gt.
|
|
307
|
-
this.C.Ut(s.gt.
|
|
308
|
-
this.
|
|
309
|
-
this.
|
|
306
|
+
this.C.Ut(s.gt.Xt),
|
|
307
|
+
this.C.Ut(s.gt.Qt))),
|
|
308
|
+
this.fi(),
|
|
309
|
+
this.gi();
|
|
310
310
|
}
|
|
311
311
|
clearData(t) {
|
|
312
|
-
(this.
|
|
313
|
-
(this.
|
|
312
|
+
(this.Ss = 0),
|
|
313
|
+
(this.Ts = 0),
|
|
314
314
|
(this.cards = []),
|
|
315
|
-
this.
|
|
315
|
+
this.ys.X(new ContentCards(this.cards.slice(), null)),
|
|
316
316
|
t &&
|
|
317
317
|
this.C &&
|
|
318
|
-
(this.C.Ut(s.gt.
|
|
318
|
+
(this.C.Ut(s.gt.Xs),
|
|
319
319
|
this.C.Ut(s.gt.Kt),
|
|
320
|
-
this.C.Ut(s.gt.
|
|
321
|
-
this.C.Ut(s.gt.
|
|
322
|
-
this.C.Ut(s.gt.
|
|
323
|
-
this.C.Ut(s.gt.
|
|
324
|
-
this.
|
|
320
|
+
this.C.Ut(s.gt.Xt),
|
|
321
|
+
this.C.Ut(s.gt.Qt),
|
|
322
|
+
this.C.Ut(s.gt.Hs),
|
|
323
|
+
this.C.Ut(s.gt.Is)),
|
|
324
|
+
this.fi();
|
|
325
325
|
}
|
|
326
|
-
|
|
327
|
-
return !!this.B && (!!this.B.
|
|
326
|
+
Qs() {
|
|
327
|
+
return !!this.B && (!!this.B.ji() || (0 !== this.B.Et() && this.yi(), !1));
|
|
328
328
|
}
|
|
329
|
-
|
|
330
|
-
this.
|
|
329
|
+
yi() {
|
|
330
|
+
this.ys.X(new ContentCards([], new Date())), this.C && this.C.Ut(s.gt.Xs);
|
|
331
331
|
}
|
|
332
332
|
}
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ControlCard,
|
|
3
|
+
logContentCardClick,
|
|
4
|
+
logContentCardImpressions,
|
|
5
|
+
} from "../Card/index.js";
|
|
3
6
|
import { requestContentCardsRefresh } from "./request-content-cards-refresh.js";
|
|
4
|
-
export default class ContentCards
|
|
5
|
-
constructor(r,
|
|
6
|
-
|
|
7
|
+
export default class ContentCards {
|
|
8
|
+
constructor(r, t) {
|
|
9
|
+
(this.cards = r),
|
|
10
|
+
(this.lastUpdated = t),
|
|
11
|
+
(this.cards = r),
|
|
12
|
+
(this.lastUpdated = t);
|
|
7
13
|
}
|
|
8
14
|
getUnviewedCardCount() {
|
|
9
|
-
|
|
15
|
+
let r = 0;
|
|
16
|
+
for (const t of this.cards) t.viewed || t instanceof ControlCard || r++;
|
|
17
|
+
return r;
|
|
10
18
|
}
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
sr(r) {
|
|
20
|
+
logContentCardImpressions(r);
|
|
13
21
|
}
|
|
14
|
-
|
|
15
|
-
return
|
|
22
|
+
nr(r) {
|
|
23
|
+
return logContentCardClick(r);
|
|
16
24
|
}
|
|
17
|
-
|
|
25
|
+
dr() {
|
|
18
26
|
requestContentCardsRefresh();
|
|
19
27
|
}
|
|
20
|
-
|
|
28
|
+
ar() {
|
|
21
29
|
return !0;
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
|
-
ContentCards.
|
|
32
|
+
(ContentCards.ur = 6e4), (ContentCards.cr = 500), (ContentCards.Cr = 1e4);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Z from "./content-cards-provider-factory.js";
|
|
2
2
|
import r from "../managers/braze-instance.js";
|
|
3
3
|
export function getCachedContentCards() {
|
|
4
|
-
if (r.rr()) return
|
|
4
|
+
if (r.rr()) return Z.m().Ys(!1);
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import Z from "./content-cards-provider-factory.js";
|
|
3
3
|
export function requestContentCardsRefresh(e, t) {
|
|
4
|
-
if (r.rr()) return
|
|
4
|
+
if (r.rr()) return Z.m().Ci(e, t, !0);
|
|
5
5
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import Z from "./content-cards-provider-factory.js";
|
|
3
3
|
export function subscribeToContentCardsUpdates(o) {
|
|
4
4
|
if (!r.rr()) return;
|
|
5
|
-
const t =
|
|
5
|
+
const t = Z.m(),
|
|
6
6
|
n = t.qt(o);
|
|
7
7
|
if (!t.Ct()) {
|
|
8
|
-
const o = r.
|
|
8
|
+
const o = r.nn();
|
|
9
9
|
if (o) {
|
|
10
|
-
const r = o.
|
|
11
|
-
t.
|
|
10
|
+
const r = o.rn(() => {
|
|
11
|
+
t.Ci(void 0, void 0, !0);
|
|
12
12
|
});
|
|
13
13
|
r && t.Tt(r);
|
|
14
14
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import r from "../../managers/braze-instance.js";
|
|
2
|
-
import {
|
|
3
|
-
export function hideContentCards(
|
|
2
|
+
import { destroyContentCardsHtml as nn } from "../../common/content-cards-display.js";
|
|
3
|
+
export function hideContentCards(n) {
|
|
4
4
|
if (!r.rr()) return;
|
|
5
|
-
const
|
|
6
|
-
for (let
|
|
7
|
-
(null ==
|
|
5
|
+
const o = document.querySelectorAll(".ab-feed");
|
|
6
|
+
for (let t = 0; t < o.length; t++)
|
|
7
|
+
(null == n || (null != n && o[t].parentNode === n)) && nn(o[t]);
|
|
8
8
|
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import r, { OPTIONS as
|
|
1
|
+
import r, { OPTIONS as z } from "../../managers/braze-instance.js";
|
|
2
2
|
import { ContentCards, subscribeToContentCardsUpdates } from "../index.js";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
destroyFeedHtml as ee,
|
|
6
|
-
detectFeedImpressions as nn,
|
|
7
|
-
feedToHtml as tn,
|
|
8
|
-
LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as en,
|
|
9
|
-
refreshFeed as on,
|
|
10
|
-
registerFeedSubscriptionId as rn,
|
|
11
|
-
updateFeedCards as an,
|
|
12
|
-
} from "../../common/feed-display.js";
|
|
13
|
-
import { setCardHeight as sn } from "../../Card/display/card-display.js";
|
|
14
|
-
import { setupFeedUI as fn } from "../../ui/js/index.js";
|
|
3
|
+
import Z from "../content-cards-provider-factory.js";
|
|
4
|
+
import { setCardHeight as tn } from "../../Card/display/card-display.js";
|
|
15
5
|
import { logger as N } from "../../../shared-lib/index.js";
|
|
6
|
+
import {
|
|
7
|
+
destroyContentCardsHtml as nn,
|
|
8
|
+
detectContentCardsImpressions as en,
|
|
9
|
+
contentCardsToHtml as on,
|
|
10
|
+
LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as rn,
|
|
11
|
+
refreshContentCardsUI as sn,
|
|
12
|
+
registerContentCardsSubscriptionId as an,
|
|
13
|
+
updateContentCards as cn,
|
|
14
|
+
} from "../../common/content-cards-display.js";
|
|
15
|
+
import { setupFeedUI as fn } from "../../ui/js/feed-css.js";
|
|
16
16
|
export function showContentCards(n, t) {
|
|
17
17
|
if (!r.rr()) return;
|
|
18
18
|
fn();
|
|
19
19
|
let e = !1;
|
|
20
20
|
null == n && ((n = document.body), (e = !0));
|
|
21
|
-
const o = r.ee(
|
|
22
|
-
|
|
23
|
-
"function" == typeof t &&
|
|
24
|
-
const a =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(null ==
|
|
28
|
-
new Date().valueOf() -
|
|
29
|
-
(null ==
|
|
21
|
+
const o = r.ee(z.tn) || !1,
|
|
22
|
+
s = Z.m().Ys(!1);
|
|
23
|
+
"function" == typeof t && cn(s, t(s.cards.slice()), s.lastUpdated, null, o);
|
|
24
|
+
const a = on(s, o, e),
|
|
25
|
+
i = Z.m(),
|
|
26
|
+
c = i.Es();
|
|
27
|
+
(null == s.lastUpdated ||
|
|
28
|
+
new Date().valueOf() - s.lastUpdated.valueOf() > ContentCards.ur) &&
|
|
29
|
+
(null == c || new Date().valueOf() - c > ContentCards.ur) &&
|
|
30
30
|
(N.info(
|
|
31
|
-
`Cached content cards were older than max TTL of ${ContentCards.
|
|
31
|
+
`Cached content cards were older than max TTL of ${ContentCards.ur} ms, requesting an update from the server.`,
|
|
32
32
|
),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
33
|
+
sn(s, a),
|
|
34
|
+
i.Ps(new Date().valueOf()));
|
|
35
|
+
const f = new Date().valueOf(),
|
|
36
|
+
l = subscribeToContentCardsUpdates(function (n) {
|
|
37
37
|
const e = a.querySelectorAll(".ab-refresh-button")[0];
|
|
38
38
|
if (null != e) {
|
|
39
39
|
let n = 500,
|
|
40
|
-
t = (n -= new Date().valueOf() -
|
|
41
|
-
const o = a.getAttribute(
|
|
40
|
+
t = (n -= new Date().valueOf() - f);
|
|
41
|
+
const o = a.getAttribute(rn);
|
|
42
42
|
o && ((t = parseInt(o)), isNaN(t) || (n -= new Date().valueOf() - t)),
|
|
43
43
|
setTimeout(
|
|
44
44
|
function () {
|
|
@@ -49,22 +49,22 @@ export function showContentCards(n, t) {
|
|
|
49
49
|
}
|
|
50
50
|
let r = n.cards;
|
|
51
51
|
"function" == typeof t && (r = t(r.slice())),
|
|
52
|
-
|
|
52
|
+
cn(s, r, n.lastUpdated, a, o);
|
|
53
53
|
});
|
|
54
|
-
|
|
54
|
+
an(l, a);
|
|
55
55
|
const u = function (n) {
|
|
56
56
|
const t = n.querySelectorAll(".ab-feed");
|
|
57
57
|
let o = null;
|
|
58
58
|
for (let e = 0; e < t.length; e++) t[e].parentNode === n && (o = t[e]);
|
|
59
59
|
null != o
|
|
60
|
-
? (
|
|
60
|
+
? (nn(o), null != o.parentNode && o.parentNode.replaceChild(a, o))
|
|
61
61
|
: n.appendChild(a),
|
|
62
62
|
setTimeout(function () {
|
|
63
63
|
a.className = a.className.replace("ab-hide", "ab-show");
|
|
64
64
|
}, 0),
|
|
65
65
|
e && a.focus(),
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
en(s, a),
|
|
67
|
+
tn(s.cards, n);
|
|
68
68
|
};
|
|
69
69
|
var d;
|
|
70
70
|
null != n
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import aa from "../managers/braze-instance.js";
|
|
2
2
|
import BrazeSdkMetadata from "./braze-sdk-metadata.js";
|
|
3
3
|
import {
|
|
4
|
-
isArray as
|
|
4
|
+
isArray as D,
|
|
5
5
|
validateValueIsFromEnum as ta,
|
|
6
6
|
} from "../util/code-utils.js";
|
|
7
7
|
import { logger as N } from "../../shared-lib/index.js";
|
|
@@ -9,7 +9,7 @@ export function addSdkMetadata(a) {
|
|
|
9
9
|
if (!aa.rr()) return;
|
|
10
10
|
const t = aa.g();
|
|
11
11
|
if (t) {
|
|
12
|
-
if (!
|
|
12
|
+
if (!D(a))
|
|
13
13
|
return (
|
|
14
14
|
N.error("Cannot set SDK metadata because metadata is not an array."), !1
|
|
15
15
|
);
|
package/src/Core/change-user.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import { getByteLength as
|
|
2
|
+
import { getByteLength as rr } from "../util/string-utils.js";
|
|
3
3
|
import { logger as N } from "../../shared-lib/index.js";
|
|
4
4
|
import { User } from "../User/index.js";
|
|
5
|
-
import { validateStandardString as
|
|
5
|
+
import { validateStandardString as er } from "../util/validation-utils.js";
|
|
6
6
|
export function changeUser(e, i) {
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
if (null == e || 0 === e.length || e != e)
|
|
9
9
|
return void N.error("changeUser requires a non-empty userId.");
|
|
10
|
-
if (
|
|
10
|
+
if (rr(e) > User.mr)
|
|
11
11
|
return void N.error(
|
|
12
|
-
`Rejected user id "${e}" because it is longer than ${User.
|
|
12
|
+
`Rejected user id "${e}" because it is longer than ${User.mr} bytes.`,
|
|
13
13
|
);
|
|
14
|
-
if (null != i && !
|
|
15
|
-
const t = r.
|
|
16
|
-
t && t.changeUser(e.toString(), r.
|
|
14
|
+
if (null != i && !er(i, "set signature for new user", "signature")) return;
|
|
15
|
+
const t = r.nn();
|
|
16
|
+
t && t.changeUser(e.toString(), r.lr(), i);
|
|
17
17
|
}
|
package/src/Core/disable-sdk.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import { logger as N, IndexedDBAdapter as
|
|
3
|
-
import
|
|
2
|
+
import { logger as N, IndexedDBAdapter as et } from "../../shared-lib/index.js";
|
|
3
|
+
import ee, { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
4
4
|
export function disableSDK() {
|
|
5
|
-
const e = r.
|
|
5
|
+
const e = r.nn();
|
|
6
6
|
e && e.requestImmediateDataFlush();
|
|
7
|
-
const n = new
|
|
7
|
+
const n = new ee.se(null, !0),
|
|
8
8
|
a = "This-cookie-will-expire-in-" + n.le();
|
|
9
9
|
n.store(s.me, a);
|
|
10
|
-
const i =
|
|
11
|
-
new
|
|
10
|
+
const i = et.Ds.Us;
|
|
11
|
+
new et(i, N).setItem(i.Ls.pe, i.be, !0),
|
|
12
12
|
N.info("disableSDK was called"),
|
|
13
13
|
r.destroy(!1),
|
|
14
14
|
r.fe(!0);
|