@braze/web-sdk 4.7.1 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +27 -24
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +5 -5
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +24 -24
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +17 -17
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +18 -18
- package/src/Card/card-manager-factory.js +2 -2
- package/src/Card/card-manager.js +47 -41
- package/src/Card/display/card-display.js +70 -67
- package/src/Card/log-card-click.js +1 -1
- package/src/Card/log-card-dismissal.js +1 -1
- package/src/Card/log-card-impressions.js +3 -3
- package/src/Card/models/banner.js +3 -2
- package/src/Card/models/captioned-image.js +6 -5
- package/src/Card/models/card.js +107 -87
- package/src/Card/models/classic-card.js +5 -5
- package/src/Card/models/control-card.js +5 -21
- package/src/Card/types.js +1 -0
- package/src/Card/util/card-factory.js +32 -32
- package/src/ContentCards/content-cards-provider-factory.js +3 -3
- package/src/ContentCards/content-cards-provider.js +283 -175
- package/src/ContentCards/content-cards.js +2 -2
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/log-content-cards-displayed.js +2 -2
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +9 -6
- package/src/ContentCards/types.js +1 -0
- package/src/ContentCards/ui/hide-content-cards.js +2 -2
- package/src/ContentCards/ui/show-content-cards.js +35 -33
- package/src/Core/add-sdk-metadata.js +17 -18
- package/src/Core/change-user.js +12 -14
- package/src/Core/destroy.js +1 -1
- package/src/Core/disable-sdk.js +7 -6
- package/src/Core/enable-sdk.js +4 -4
- package/src/Core/get-device-id.js +7 -6
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +57 -40
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/log-custom-event.js +22 -15
- package/src/Core/log-purchase.js +33 -33
- package/src/Core/open-session.js +17 -15
- package/src/Core/request-immediate-data-flush.js +4 -2
- package/src/Core/set-logger.js +1 -1
- package/src/Core/set-sdk-authentication-signature.js +5 -6
- package/src/Core/subscribe-to-sdk-authentication-failures.js +3 -1
- package/src/Core/toggle-logging.js +1 -1
- package/src/Core/types.js +1 -0
- package/src/Core/wipe-data.js +11 -10
- package/src/FeatureFlags/feature-flag-factory.js +6 -6
- package/src/FeatureFlags/feature-flag.js +17 -17
- package/src/FeatureFlags/feature-flags-provider-factory.js +2 -2
- package/src/FeatureFlags/feature-flags-provider.js +67 -65
- package/src/FeatureFlags/get-all-feature-flags.js +3 -3
- package/src/FeatureFlags/get-feature-flag.js +4 -4
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -1
- package/src/Feed/feed-provider-factory.js +8 -8
- package/src/Feed/feed-provider.js +57 -46
- package/src/Feed/feed.js +1 -1
- package/src/Feed/get-cached-feed.js +2 -2
- package/src/Feed/log-feed-displayed.js +3 -1
- package/src/Feed/request-feed-refresh.js +2 -2
- package/src/Feed/subscribe-to-feed-updates.js +2 -2
- package/src/Feed/types.js +1 -0
- package/src/Feed/ui/hide-feed.js +2 -2
- package/src/Feed/ui/show-feed.js +40 -36
- package/src/InAppMessage/display/html-message-to-html.js +125 -119
- package/src/InAppMessage/display/in-app-message-to-html.js +72 -69
- package/src/InAppMessage/display/modal-utils.js +18 -13
- package/src/InAppMessage/in-app-message-factory.js +9 -8
- package/src/InAppMessage/in-app-message-manager-factory.js +7 -7
- package/src/InAppMessage/in-app-message-manager.js +122 -108
- package/src/InAppMessage/log-in-app-message-button-click.js +10 -10
- package/src/InAppMessage/log-in-app-message-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-html-click.js +10 -10
- package/src/InAppMessage/log-in-app-message-impression.js +5 -5
- package/src/InAppMessage/models/control-message.js +4 -1
- package/src/InAppMessage/models/full-screen-message.js +35 -37
- package/src/InAppMessage/models/html-message.js +34 -33
- package/src/InAppMessage/models/in-app-message-button.js +23 -16
- package/src/InAppMessage/models/in-app-message.js +147 -105
- package/src/InAppMessage/models/modal-message.js +34 -36
- package/src/InAppMessage/models/slide-up-message.js +25 -27
- package/src/InAppMessage/models/templated-in-app-message.js +12 -7
- package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
- package/src/InAppMessage/types.js +1 -0
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
- package/src/InAppMessage/ui/show-in-app-message.js +95 -89
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -0
- package/src/Push/is-push-blocked.js +2 -2
- package/src/Push/is-push-permission-granted.js +2 -2
- package/src/Push/is-push-supported.js +2 -2
- package/src/Push/push-manager-factory.js +20 -20
- package/src/Push/push-manager.js +192 -174
- package/src/Push/request-push-permission.js +4 -3
- package/src/Push/types.js +1 -0
- package/src/Push/unregister-push.js +2 -2
- package/src/Push/utils/push-utils.js +10 -10
- package/src/User/types.js +1 -0
- package/src/User/user-manager.js +24 -24
- package/src/User/user.js +117 -105
- package/src/common/base-feed.js +7 -7
- package/src/common/base-provider.js +2 -2
- package/src/common/constants.js +6 -0
- package/src/common/event-logger.js +6 -6
- package/src/common/feed-display.js +18 -18
- package/src/common/types.js +1 -0
- package/src/l10n/l10n-manager-factory.js +5 -5
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +204 -202
- package/src/managers/device-manager.js +23 -23
- package/src/managers/network-manager.js +96 -82
- package/src/managers/server-config-manager.js +60 -42
- package/src/managers/session-manager.js +41 -41
- package/src/managers/storage-manager-factory.js +15 -15
- package/src/managers/storage-manager.js +165 -155
- package/src/managers/subscription-manager.js +11 -11
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +7 -7
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +7 -7
- package/src/models/push-token.js +7 -7
- package/src/models/request-result.js +3 -3
- package/src/models/server-config.js +20 -20
- package/src/request-controller.js +176 -174
- package/src/triggers/models/custom-event-data.js +6 -6
- package/src/triggers/models/custom-event-property-data.js +9 -9
- package/src/triggers/models/filter-set.js +9 -9
- package/src/triggers/models/filter.js +64 -64
- package/src/triggers/models/in-app-message-click-data.js +12 -12
- package/src/triggers/models/purchase-data.js +3 -3
- package/src/triggers/models/purchase-property-data.js +9 -9
- package/src/triggers/models/push-click-data.js +5 -5
- package/src/triggers/models/trigger-condition.js +52 -52
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +42 -42
- package/src/triggers/triggers-provider-factory.js +8 -8
- package/src/triggers/triggers-provider.js +171 -168
- package/src/types.js +1 -0
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +20 -20
- package/src/util/browser-detector.js +22 -22
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/code-utils.js +1 -1
- package/src/util/color-utils.js +2 -2
- package/src/util/component-utils.js +2 -2
- package/src/util/deprecation-utils.js +1 -1
- package/src/util/device-constants.js +5 -5
- package/src/util/dom-utils.js +2 -2
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +11 -11
- package/src/util/request-header-utils.js +23 -0
- package/src/util/string-utils.js +1 -1
- package/src/util/user-agent-parser.js +20 -20
- package/src/util/validation-utils.js +44 -44
- package/src/util/window-utils.js +3 -3
|
@@ -1,149 +1,169 @@
|
|
|
1
|
-
import
|
|
1
|
+
import C, { readResponseHeaders as b } from "../util/net.js";
|
|
2
2
|
import y from "../common/base-provider.js";
|
|
3
3
|
import e 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 l } from "../util/date-utils.js";
|
|
6
|
+
import { isURIJavascriptOrData as N } from "../util/url-utils.js";
|
|
7
7
|
import {
|
|
8
|
-
newCardFromContentCardsJson as
|
|
9
|
-
newCardFromSerializedValue as
|
|
8
|
+
newCardFromContentCardsJson as j,
|
|
9
|
+
newCardFromSerializedValue as R
|
|
10
10
|
} from "../Card/util/card-factory.js";
|
|
11
11
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
12
|
-
import { STORAGE_KEYS as
|
|
13
|
-
import
|
|
12
|
+
import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
|
|
13
|
+
import E from "../managers/subscription-manager.js";
|
|
14
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";
|
|
15
18
|
export default class v extends y {
|
|
16
19
|
constructor(t, s, i, h, n) {
|
|
17
20
|
super(),
|
|
18
|
-
(this.
|
|
19
|
-
(this.
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
23
|
-
(this.
|
|
21
|
+
(this.ft = t),
|
|
22
|
+
(this.u = s),
|
|
23
|
+
(this.wt = i),
|
|
24
|
+
(this.vt = h),
|
|
25
|
+
(this.gt = n),
|
|
26
|
+
(this.ft = t),
|
|
27
|
+
(this.u = s),
|
|
28
|
+
(this.wt = i),
|
|
29
|
+
(this.vt = h),
|
|
30
|
+
(this.gt = n),
|
|
31
|
+
(this.yt = new E()),
|
|
24
32
|
e.jt(this.yt),
|
|
25
|
-
(this.Ut = 0),
|
|
26
33
|
(this.kt = 0),
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
(this.Ut = 0),
|
|
35
|
+
(this.cards = []),
|
|
36
|
+
this.Lt();
|
|
37
|
+
const o = r.zt.Ft;
|
|
38
|
+
new r.xt(o, r.j).Mt(o.Jt.qt, t => {
|
|
39
|
+
this.Pt(t);
|
|
31
40
|
}),
|
|
32
|
-
(this
|
|
41
|
+
(this.$t = null),
|
|
42
|
+
(this._t = null),
|
|
43
|
+
(this.Bt = null),
|
|
44
|
+
(this.Gt = null),
|
|
45
|
+
(this.Ht = null),
|
|
46
|
+
(this.Kt = null),
|
|
47
|
+
(this.Ot = 10),
|
|
48
|
+
(this.Qt = 0);
|
|
33
49
|
}
|
|
34
|
-
|
|
35
|
-
return this.
|
|
50
|
+
Vt() {
|
|
51
|
+
return this._t;
|
|
36
52
|
}
|
|
37
|
-
|
|
38
|
-
this.
|
|
53
|
+
Wt(t) {
|
|
54
|
+
this._t = t;
|
|
39
55
|
}
|
|
40
|
-
|
|
41
|
-
return this.
|
|
56
|
+
Xt() {
|
|
57
|
+
return this.Bt;
|
|
42
58
|
}
|
|
43
|
-
|
|
44
|
-
this.
|
|
59
|
+
Yt(t) {
|
|
60
|
+
this.Bt = t;
|
|
45
61
|
}
|
|
46
|
-
|
|
47
|
-
|
|
62
|
+
Lt() {
|
|
63
|
+
if (!this.u) return;
|
|
64
|
+
const t = this.u.v(i.k.Zt) || [],
|
|
48
65
|
s = [];
|
|
49
66
|
for (let i = 0; i < t.length; i++) {
|
|
50
|
-
const e =
|
|
67
|
+
const e = R(t[i]);
|
|
51
68
|
null != e && s.push(e);
|
|
52
69
|
}
|
|
53
|
-
(this.
|
|
54
|
-
(this.
|
|
55
|
-
(this.
|
|
70
|
+
(this.cards = this.Cs(this.ws(s, !1))),
|
|
71
|
+
(this.kt = this.u.v(i.k.vs) || this.kt),
|
|
72
|
+
(this.Ut = this.u.v(i.k.ys) || this.Ut);
|
|
56
73
|
}
|
|
57
|
-
Ns(t, s,
|
|
58
|
-
let
|
|
74
|
+
Ns(t, s = !1, e = 0, h = 0) {
|
|
75
|
+
let r;
|
|
59
76
|
if (s) {
|
|
60
|
-
|
|
61
|
-
for (const t of this.
|
|
62
|
-
} else
|
|
77
|
+
r = [];
|
|
78
|
+
for (const t of this.cards) t.test && r.push(t);
|
|
79
|
+
} else r = this.cards.slice();
|
|
63
80
|
for (let i = 0; i < t.length; i++) {
|
|
64
81
|
const e = t[i];
|
|
65
|
-
let
|
|
66
|
-
for (let t = 0; t < this.
|
|
67
|
-
if (e.id === this.
|
|
68
|
-
|
|
82
|
+
let h = null;
|
|
83
|
+
for (let t = 0; t < this.cards.length; t++)
|
|
84
|
+
if (e.id === this.cards[t].id) {
|
|
85
|
+
h = this.cards[t];
|
|
69
86
|
break;
|
|
70
87
|
}
|
|
71
88
|
if (s) {
|
|
72
|
-
const t =
|
|
73
|
-
null !=
|
|
74
|
-
} else if (null ==
|
|
75
|
-
const t =
|
|
76
|
-
null != t &&
|
|
89
|
+
const t = j(e);
|
|
90
|
+
null != h && h.viewed && t && (t.viewed = !0), null != t && r.push(t);
|
|
91
|
+
} else if (null == h) {
|
|
92
|
+
const t = j(e);
|
|
93
|
+
null != t && r.push(t);
|
|
77
94
|
} else {
|
|
78
|
-
if (!
|
|
79
|
-
for (let t = 0; t <
|
|
80
|
-
if (e.id ===
|
|
81
|
-
|
|
95
|
+
if (!h.ot(e))
|
|
96
|
+
for (let t = 0; t < r.length; t++)
|
|
97
|
+
if (e.id === r[t].id) {
|
|
98
|
+
r.splice(t, 1);
|
|
82
99
|
break;
|
|
83
100
|
}
|
|
84
101
|
}
|
|
85
102
|
}
|
|
86
|
-
(this.
|
|
87
|
-
this.
|
|
88
|
-
(this.
|
|
89
|
-
|
|
90
|
-
(this.kt
|
|
91
|
-
this.h.B(o.q.ys, this.kt);
|
|
103
|
+
(this.cards = this.Cs(this.ws(r, s))),
|
|
104
|
+
this.Rs(),
|
|
105
|
+
(this.kt = e),
|
|
106
|
+
(this.Ut = h),
|
|
107
|
+
this.u && (this.u.D(i.k.vs, this.kt), this.u.D(i.k.ys, this.Ut));
|
|
92
108
|
}
|
|
93
|
-
|
|
94
|
-
if (this.
|
|
95
|
-
this.
|
|
109
|
+
Ts(t) {
|
|
110
|
+
if (this.Ds() && null != t && t.cards) {
|
|
111
|
+
this.u && this.u.D(i.k.Ss, e.Us());
|
|
96
112
|
const s = t.full_sync;
|
|
97
|
-
s || this.
|
|
113
|
+
s || this.Lt(),
|
|
98
114
|
this.Ns(t.cards, s, t.last_full_sync_at, t.last_card_updated_at),
|
|
99
|
-
this.yt.
|
|
115
|
+
this.yt.Et(this.As(!0));
|
|
100
116
|
}
|
|
101
117
|
}
|
|
102
|
-
|
|
103
|
-
this.
|
|
118
|
+
Ls(t) {
|
|
119
|
+
this.u && this.u.D(i.k.Fs, t);
|
|
104
120
|
}
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
this.
|
|
121
|
+
Ms(t, e, h) {
|
|
122
|
+
const n = () => {
|
|
123
|
+
this.Es(e, h, !0);
|
|
108
124
|
},
|
|
109
|
-
|
|
110
|
-
let
|
|
111
|
-
if ((this.
|
|
112
|
-
|
|
113
|
-
|
|
125
|
+
o = b(t);
|
|
126
|
+
let l;
|
|
127
|
+
if ((this.qs(), !o["retry-after"])) return void this.Ls(0);
|
|
128
|
+
const a = o["retry-after"];
|
|
129
|
+
if (isNaN(a) && !isNaN(Date.parse(a)))
|
|
130
|
+
(l = Date.parse(a) - new Date().getTime()), l < 0 && n();
|
|
114
131
|
else {
|
|
115
|
-
if (isNaN(parseFloat(a))) {
|
|
132
|
+
if (isNaN(parseFloat(a.toString()))) {
|
|
116
133
|
const t =
|
|
117
134
|
"Received unexpected value for retry-after header in /sync response";
|
|
118
|
-
return s.
|
|
135
|
+
return s.N(r.q.Is, { e: t + ": " + a }), void this.Ls(0);
|
|
119
136
|
}
|
|
120
|
-
l = 1e3 * a;
|
|
137
|
+
l = 1e3 * parseFloat(a.toString());
|
|
121
138
|
}
|
|
122
|
-
this.Gt = setTimeout(() => {
|
|
123
|
-
|
|
139
|
+
this.Gt = window.setTimeout(() => {
|
|
140
|
+
n();
|
|
124
141
|
}, l);
|
|
125
|
-
let
|
|
126
|
-
|
|
142
|
+
let u = 0;
|
|
143
|
+
this.u && (u = this.u.v(i.k.Fs)),
|
|
144
|
+
(null == u || isNaN(parseInt(u.toString()))) && (u = 0),
|
|
145
|
+
this.Ls(parseInt(u.toString()) + 1);
|
|
127
146
|
}
|
|
128
|
-
|
|
129
|
-
if (!this.
|
|
130
|
-
this.
|
|
131
|
-
const s = this.
|
|
132
|
-
|
|
147
|
+
Pt(t) {
|
|
148
|
+
if (!this.Ds()) return;
|
|
149
|
+
this.Lt();
|
|
150
|
+
const s = this.cards.slice();
|
|
151
|
+
let i = null;
|
|
152
|
+
this.ft && (i = this.ft.getUserId());
|
|
133
153
|
for (let e = 0; e < t.length; e++)
|
|
134
154
|
if (i === t[e].userId || (null == i && null == t[e].userId)) {
|
|
135
155
|
const i = t[e].card;
|
|
136
156
|
let h = null;
|
|
137
|
-
for (let t = 0; t < this.
|
|
138
|
-
if (i.id === this.
|
|
139
|
-
h = this.
|
|
157
|
+
for (let t = 0; t < this.cards.length; t++)
|
|
158
|
+
if (i.id === this.cards[t].id) {
|
|
159
|
+
h = this.cards[t];
|
|
140
160
|
break;
|
|
141
161
|
}
|
|
142
162
|
if (null == h) {
|
|
143
|
-
const t =
|
|
163
|
+
const t = j(i);
|
|
144
164
|
null != t && s.push(t);
|
|
145
165
|
} else {
|
|
146
|
-
if (!h.
|
|
166
|
+
if (!h.ot(i))
|
|
147
167
|
for (let t = 0; t < s.length; t++)
|
|
148
168
|
if (i.id === s[t].id) {
|
|
149
169
|
s.splice(t, 1);
|
|
@@ -151,133 +171,221 @@ export default class v extends y {
|
|
|
151
171
|
}
|
|
152
172
|
}
|
|
153
173
|
}
|
|
154
|
-
(this.
|
|
174
|
+
(this.cards = this.Cs(this.ws(s, !1))), this.Rs(), this.yt.Et(this.As(!0));
|
|
155
175
|
}
|
|
156
176
|
ws(t, s) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
177
|
+
let e = {},
|
|
178
|
+
h = {},
|
|
179
|
+
r = {};
|
|
180
|
+
this.u &&
|
|
181
|
+
((e = this.u.v(i.k.C) || {}),
|
|
182
|
+
(h = this.u.v(i.k.K) || {}),
|
|
183
|
+
(r = this.u.v(i.k.G) || {}));
|
|
184
|
+
const n = {},
|
|
185
|
+
o = {},
|
|
186
|
+
l = {};
|
|
187
|
+
for (let s = 0; s < t.length; s++) {
|
|
188
|
+
const i = t[s].id;
|
|
189
|
+
i &&
|
|
190
|
+
(e[i] && ((t[s].clicked = !0), (n[i] = !0)),
|
|
191
|
+
h[i] && ((t[s].viewed = !0), (o[i] = !0)),
|
|
192
|
+
r[i] && ((t[s].dismissed = !0), (l[i] = !0)));
|
|
193
|
+
}
|
|
194
|
+
return (
|
|
195
|
+
s &&
|
|
196
|
+
this.u &&
|
|
197
|
+
(this.u.D(i.k.C, n), this.u.D(i.k.K, o), this.u.D(i.k.G, l)),
|
|
198
|
+
t
|
|
199
|
+
);
|
|
168
200
|
}
|
|
169
201
|
Cs(t) {
|
|
170
202
|
const s = [],
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
203
|
+
e = new Date();
|
|
204
|
+
let h = {};
|
|
205
|
+
this.u && (h = this.u.v(i.k.G) || {});
|
|
206
|
+
let n = !1;
|
|
207
|
+
for (let i = 0; i < t.length; i++) {
|
|
208
|
+
const o = t[i].url;
|
|
209
|
+
if (!this.vt && o && N(o)) {
|
|
210
|
+
r.j.error(
|
|
211
|
+
`Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`
|
|
212
|
+
);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const l = t[i].expiresAt;
|
|
216
|
+
let a = !0;
|
|
217
|
+
if ((null != l && (a = l >= e), (a = a && !t[i].dismissed), a))
|
|
218
|
+
s.push(t[i]);
|
|
219
|
+
else {
|
|
220
|
+
const s = t[i].id;
|
|
221
|
+
s && (h[s] = !0), (n = !0);
|
|
222
|
+
}
|
|
183
223
|
}
|
|
184
|
-
return
|
|
224
|
+
return n && this.u && this.u.D(i.k.G, h), s;
|
|
185
225
|
}
|
|
186
|
-
|
|
226
|
+
Rs() {
|
|
227
|
+
if (!this.u) return;
|
|
187
228
|
const t = [];
|
|
188
|
-
for (let s = 0; s < this.
|
|
189
|
-
this.
|
|
229
|
+
for (let s = 0; s < this.cards.length; s++) t.push(this.cards[s].ss());
|
|
230
|
+
this.u.D(i.k.Zt, t);
|
|
190
231
|
}
|
|
191
|
-
|
|
232
|
+
qs() {
|
|
192
233
|
this.Gt && (clearTimeout(this.Gt), (this.Gt = null));
|
|
193
234
|
}
|
|
194
|
-
|
|
195
|
-
|
|
235
|
+
Js() {
|
|
236
|
+
null != this.Ht && (clearTimeout(this.Ht), (this.Ht = null));
|
|
237
|
+
}
|
|
238
|
+
Ps(t = 1e3 * this.Ot, s, i) {
|
|
239
|
+
this.Js(),
|
|
240
|
+
(this.Ht = window.setTimeout(() => {
|
|
241
|
+
this.Es(s, i, !0);
|
|
242
|
+
}, t)),
|
|
243
|
+
(this.Kt = t);
|
|
244
|
+
}
|
|
245
|
+
Es(t, s, h = !1, n = !0) {
|
|
246
|
+
var o;
|
|
247
|
+
const l = this.gt,
|
|
248
|
+
a = this.u;
|
|
249
|
+
if (!l || !a) return void ("function" == typeof s && s());
|
|
250
|
+
const u = !h;
|
|
251
|
+
if ((u && (this.qs(), this.Ls(0)), !this.Ds()))
|
|
196
252
|
return void (
|
|
197
|
-
this
|
|
198
|
-
|
|
199
|
-
|
|
253
|
+
!this.$t &&
|
|
254
|
+
this.wt &&
|
|
255
|
+
(this.$t = this.wt.$s(() => {
|
|
256
|
+
this.Es(t, s);
|
|
200
257
|
}))
|
|
201
258
|
);
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
259
|
+
let c = !0;
|
|
260
|
+
if (
|
|
261
|
+
(u &&
|
|
262
|
+
(null === (o = this.wt) || void 0 === o ? void 0 : o._s()) &&
|
|
263
|
+
(c = this.Bs()),
|
|
264
|
+
!c)
|
|
265
|
+
)
|
|
266
|
+
return void r.j.info("Content card sync being throttled.");
|
|
267
|
+
n && this.Js();
|
|
268
|
+
const f = l.Gs({}, !0);
|
|
269
|
+
a.v(i.k.Ss) !== e.Us() && this.Hs(),
|
|
270
|
+
(f.last_full_sync_at = this.kt),
|
|
271
|
+
(f.last_card_updated_at = this.Ut);
|
|
272
|
+
const d = l.Ks(f, T.Qs.Os, h);
|
|
273
|
+
let m = !1;
|
|
274
|
+
l.Vs(f, () => {
|
|
275
|
+
if (this.u) {
|
|
276
|
+
const t = new Date().valueOf();
|
|
277
|
+
u && this.u.D(i.k.Ws, t), T.Xs(this.u, T.Qs.Os, t);
|
|
278
|
+
}
|
|
279
|
+
C.Ys({
|
|
280
|
+
url: l.Zs() + "/content_cards/sync",
|
|
281
|
+
data: f,
|
|
282
|
+
headers: d,
|
|
283
|
+
O: (i, e) => {
|
|
284
|
+
if (!l.ti(f, i, d))
|
|
285
|
+
return (m = !0), void ("function" == typeof s && s());
|
|
286
|
+
l.si(),
|
|
287
|
+
this.Ms(e, t, s),
|
|
288
|
+
this.Ts(i),
|
|
289
|
+
(m = !1),
|
|
290
|
+
"function" == typeof t && t();
|
|
219
291
|
},
|
|
220
292
|
error: t => {
|
|
221
|
-
|
|
293
|
+
l.ii(t, "retrieving content cards"),
|
|
294
|
+
(m = !0),
|
|
222
295
|
"function" == typeof s && s();
|
|
296
|
+
},
|
|
297
|
+
ei: () => {
|
|
298
|
+
if (m && n && !this.Ht && this.Qt + 1 < S) {
|
|
299
|
+
let i = this.Kt;
|
|
300
|
+
(null == i || i < 1e3 * this.Ot) && (i = 1e3 * this.Ot),
|
|
301
|
+
this.Ps(Math.min(3e5, D(1e3 * this.Ot, 3 * i)), t, s),
|
|
302
|
+
(this.Qt = this.Qt + 1);
|
|
303
|
+
}
|
|
223
304
|
}
|
|
224
305
|
});
|
|
225
306
|
});
|
|
226
307
|
}
|
|
227
|
-
|
|
228
|
-
t || this.
|
|
229
|
-
const s = this.Cs(this.
|
|
308
|
+
As(t) {
|
|
309
|
+
t || this.Lt();
|
|
310
|
+
const s = this.Cs(this.cards);
|
|
230
311
|
s.sort((t, s) =>
|
|
231
312
|
t.pinned && !s.pinned
|
|
232
313
|
? -1
|
|
233
314
|
: s.pinned && !t.pinned
|
|
234
315
|
? 1
|
|
235
|
-
: t.updated > s.updated
|
|
316
|
+
: t.updated && s.updated && t.updated > s.updated
|
|
236
317
|
? -1
|
|
237
|
-
: s.updated > t.updated
|
|
318
|
+
: t.updated && s.updated && s.updated > t.updated
|
|
238
319
|
? 1
|
|
239
320
|
: 0
|
|
240
321
|
);
|
|
241
|
-
let
|
|
322
|
+
let e = Math.max(this.Ut || 0, this.kt || 0);
|
|
242
323
|
return (
|
|
243
|
-
0 ===
|
|
244
|
-
this.
|
|
245
|
-
new ContentCards(s,
|
|
324
|
+
0 === e && (e = void 0),
|
|
325
|
+
this.u && this.u.v(i.k.ys) === this.Ut && void 0 === e && (e = this.Ut),
|
|
326
|
+
new ContentCards(s, l(e))
|
|
246
327
|
);
|
|
247
328
|
}
|
|
248
|
-
|
|
249
|
-
return this.yt.
|
|
329
|
+
hi(t) {
|
|
330
|
+
return this.yt.lt(t);
|
|
250
331
|
}
|
|
251
|
-
|
|
252
|
-
(this.
|
|
332
|
+
Hs() {
|
|
333
|
+
(this.kt = 0),
|
|
334
|
+
(this.Ut = 0),
|
|
335
|
+
this.u && (this.u.ri(i.k.vs), this.u.ri(i.k.ys));
|
|
253
336
|
}
|
|
254
337
|
changeUser(t) {
|
|
255
338
|
t ||
|
|
256
|
-
((this.
|
|
257
|
-
this.yt.
|
|
258
|
-
this.
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
339
|
+
((this.cards = []),
|
|
340
|
+
this.yt.Et(new ContentCards(this.cards.slice(), null)),
|
|
341
|
+
this.u &&
|
|
342
|
+
(this.u.ri(i.k.Zt),
|
|
343
|
+
this.u.ri(i.k.C),
|
|
344
|
+
this.u.ri(i.k.K),
|
|
345
|
+
this.u.ri(i.k.G))),
|
|
346
|
+
this.Hs();
|
|
263
347
|
}
|
|
264
348
|
clearData(t) {
|
|
265
|
-
(this.
|
|
266
|
-
(this.
|
|
267
|
-
(this.
|
|
268
|
-
this.yt.
|
|
349
|
+
(this.kt = 0),
|
|
350
|
+
(this.Ut = 0),
|
|
351
|
+
(this.cards = []),
|
|
352
|
+
this.yt.Et(new ContentCards(this.cards.slice(), null)),
|
|
269
353
|
t &&
|
|
270
|
-
|
|
271
|
-
this.
|
|
272
|
-
this.
|
|
273
|
-
this.
|
|
274
|
-
this.
|
|
275
|
-
this.
|
|
354
|
+
this.u &&
|
|
355
|
+
(this.u.ri(i.k.Zt),
|
|
356
|
+
this.u.ri(i.k.C),
|
|
357
|
+
this.u.ri(i.k.K),
|
|
358
|
+
this.u.ri(i.k.G),
|
|
359
|
+
this.u.ri(i.k.vs),
|
|
360
|
+
this.u.ri(i.k.ys));
|
|
361
|
+
}
|
|
362
|
+
Ds() {
|
|
363
|
+
return !(this.wt && !this.wt.ni()) || (0 !== this.wt.oi() && this.li(), !1);
|
|
364
|
+
}
|
|
365
|
+
ai(t) {
|
|
366
|
+
this.u && this.u.D(i.k.ui, t);
|
|
276
367
|
}
|
|
277
|
-
|
|
278
|
-
return
|
|
368
|
+
ci() {
|
|
369
|
+
return this.u ? this.u.v(i.k.ui) : null;
|
|
370
|
+
}
|
|
371
|
+
Bs() {
|
|
372
|
+
const t = this.u,
|
|
373
|
+
s = this.wt;
|
|
374
|
+
if (!t || !s) return !0;
|
|
375
|
+
const e = t.v(i.k.Ws);
|
|
376
|
+
if (null == e || isNaN(e)) return !0;
|
|
377
|
+
const h = s.fi(),
|
|
378
|
+
r = s.di();
|
|
379
|
+
if (-1 === h || -1 === r) return !0;
|
|
380
|
+
let n = this.ci();
|
|
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.ai(n), !0)
|
|
386
|
+
);
|
|
279
387
|
}
|
|
280
|
-
|
|
281
|
-
this.yt.
|
|
388
|
+
li() {
|
|
389
|
+
this.yt.Et(new ContentCards([], new Date())), this.u && this.u.ri(i.k.Zt);
|
|
282
390
|
}
|
|
283
391
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import { logDeprecationWarning as
|
|
2
|
+
import { logDeprecationWarning as z } from "../util/deprecation-utils.js";
|
|
3
3
|
export function logContentCardsDisplayed() {
|
|
4
|
-
if (e.rr()) return
|
|
4
|
+
if (e.rr()) return z("logContentCardsDisplayed", "method"), !0;
|
|
5
5
|
}
|
|
@@ -3,12 +3,15 @@ import g from "./content-cards-provider-factory.js";
|
|
|
3
3
|
export function subscribeToContentCardsUpdates(r) {
|
|
4
4
|
if (!e.rr()) return;
|
|
5
5
|
const t = g.er(),
|
|
6
|
-
n = t.
|
|
7
|
-
if (!t.
|
|
8
|
-
const r = e.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
n = t.hi(r);
|
|
7
|
+
if (!t.Xt()) {
|
|
8
|
+
const r = e.cr();
|
|
9
|
+
if (r) {
|
|
10
|
+
const n = r.pr(() => {
|
|
11
|
+
t.Es();
|
|
12
|
+
});
|
|
13
|
+
n && t.Yt(n);
|
|
14
|
+
}
|
|
12
15
|
}
|
|
13
16
|
return n;
|
|
14
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import e from "../../managers/braze-instance.js";
|
|
2
|
-
import { destroyFeedHtml as
|
|
2
|
+
import { destroyFeedHtml as k } from "../../common/feed-display.js";
|
|
3
3
|
export function hideContentCards(n) {
|
|
4
4
|
if (!e.rr()) return;
|
|
5
5
|
const o = document.querySelectorAll(".ab-feed");
|
|
6
6
|
for (let e = 0; e < o.length; e++)
|
|
7
|
-
(null == n || (null != n && o[e].parentNode === n)) &&
|
|
7
|
+
(null == n || (null != n && o[e].parentNode === n)) && k(o[e]);
|
|
8
8
|
}
|