@braze/web-sdk 4.10.1 → 4.10.2
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 +9 -9
- 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/index.js +6 -0
- package/shared-lib/indexed-db-adapter.js +352 -1
- package/shared-lib/logger.js +38 -1
- package/shared-lib/supported-options.js +27 -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/banner.js +31 -1
- package/src/Card/models/captioned-image.js +33 -1
- package/src/Card/models/card.js +196 -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 +32 -1
- package/src/Card/models/index.js +6 -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 +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 +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 +12 -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 +244 -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 +28 -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 +331 -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 +419 -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 +14 -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 +85 -1
- package/src/util/validation-utils.js +217 -1
- package/src/util/window-utils.js +34 -1
package/src/Card/models/index.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default as Card } from "./card.js";
|
|
2
|
+
export { default as Banner } from "./banner.js";
|
|
3
|
+
export { default as ImageOnly } from "./image-only.js";
|
|
4
|
+
export { default as CaptionedImage } from "./captioned-image.js";
|
|
5
|
+
export { default as ClassicCard } from "./classic-card.js";
|
|
6
|
+
export { default as ControlCard } from "./control-card.js";
|
package/src/Card/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export {};
|
|
@@ -1 +1,104 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
Card,
|
|
3
|
+
CaptionedImage,
|
|
4
|
+
ClassicCard,
|
|
5
|
+
ControlCard,
|
|
6
|
+
ImageOnly,
|
|
7
|
+
} from "../index.js";
|
|
8
|
+
import {
|
|
9
|
+
dateFromUnixTimestamp as l,
|
|
10
|
+
rehydrateDateAfterJsonization as w,
|
|
11
|
+
} from "../../util/date-utils.js";
|
|
12
|
+
import r from "../../../shared-lib/braze-shared-lib.js";
|
|
13
|
+
export function newCard(e, n, t, o, i, l, u, d, a, s, w, f, m, C, p, c, x, F) {
|
|
14
|
+
let b;
|
|
15
|
+
if (n === Card.es.ct || n === Card.es.St)
|
|
16
|
+
b = new ClassicCard(e, t, o, i, l, u, d, a, s, w, f, m, C, p, c, x);
|
|
17
|
+
else if (n === Card.es.tt)
|
|
18
|
+
b = new CaptionedImage(e, t, o, i, l, u, d, a, s, w, f, m, C, p, c, x);
|
|
19
|
+
else if (n === Card.es.rs)
|
|
20
|
+
b = new ImageOnly(e, t, i, u, d, a, s, w, f, m, C, p, c, x);
|
|
21
|
+
else {
|
|
22
|
+
if (n !== Card.es.At)
|
|
23
|
+
return r.j.error("Ignoring card with unknown type " + n), null;
|
|
24
|
+
b = new ControlCard(e, t, d, s, C, p);
|
|
25
|
+
}
|
|
26
|
+
return F && (b.test = F), b;
|
|
27
|
+
}
|
|
28
|
+
export function newCardFromContentCardsJson(e) {
|
|
29
|
+
if (e[Card.Tt.It]) return null;
|
|
30
|
+
const n = e[Card.Tt.ns],
|
|
31
|
+
r = e[Card.Tt.ts],
|
|
32
|
+
t = e[Card.Tt.ls],
|
|
33
|
+
o = e[Card.Tt.st],
|
|
34
|
+
i = e[Card.Tt.os],
|
|
35
|
+
u = e[Card.Tt.it],
|
|
36
|
+
d = l(e[Card.Tt.us]),
|
|
37
|
+
a = d;
|
|
38
|
+
let s;
|
|
39
|
+
s = e[Card.Tt.ds] === Card.Nt ? null : l(e[Card.Tt.ds]);
|
|
40
|
+
return newCard(
|
|
41
|
+
n,
|
|
42
|
+
r,
|
|
43
|
+
t,
|
|
44
|
+
o,
|
|
45
|
+
i,
|
|
46
|
+
u,
|
|
47
|
+
a,
|
|
48
|
+
d,
|
|
49
|
+
null,
|
|
50
|
+
s,
|
|
51
|
+
e[Card.Tt.URL],
|
|
52
|
+
e[Card.Tt.ps],
|
|
53
|
+
e[Card.Tt.fs],
|
|
54
|
+
e[Card.Tt.xs],
|
|
55
|
+
e[Card.Tt.gs],
|
|
56
|
+
e[Card.Tt.js],
|
|
57
|
+
e[Card.Tt.ys],
|
|
58
|
+
e[Card.Tt.zs] || !1,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
export function newCardFromFeedJson(e) {
|
|
62
|
+
return newCard(
|
|
63
|
+
e.id,
|
|
64
|
+
e.type,
|
|
65
|
+
e.viewed,
|
|
66
|
+
e.title,
|
|
67
|
+
e.image,
|
|
68
|
+
e.description,
|
|
69
|
+
l(e.created),
|
|
70
|
+
l(e.updated),
|
|
71
|
+
e.categories,
|
|
72
|
+
l(e.expires_at),
|
|
73
|
+
e.url,
|
|
74
|
+
e.domain,
|
|
75
|
+
e.aspect_ratio,
|
|
76
|
+
e.extras,
|
|
77
|
+
!1,
|
|
78
|
+
!1,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
export function newCardFromSerializedValue(e) {
|
|
82
|
+
return (
|
|
83
|
+
newCard(
|
|
84
|
+
e[Card.hs.ns],
|
|
85
|
+
e[Card.hs.ts],
|
|
86
|
+
e[Card.hs.ls],
|
|
87
|
+
e[Card.hs.st],
|
|
88
|
+
e[Card.hs.os],
|
|
89
|
+
e[Card.hs.it],
|
|
90
|
+
w(e[Card.hs.cs]),
|
|
91
|
+
w(e[Card.hs.us]),
|
|
92
|
+
e[Card.hs.bs],
|
|
93
|
+
w(e[Card.hs.ds]),
|
|
94
|
+
e[Card.hs.URL],
|
|
95
|
+
e[Card.hs.ps],
|
|
96
|
+
e[Card.hs.fs],
|
|
97
|
+
e[Card.hs.xs],
|
|
98
|
+
e[Card.hs.gs],
|
|
99
|
+
e[Card.hs.js],
|
|
100
|
+
e[Card.hs.ys],
|
|
101
|
+
e[Card.hs.zs] || !1,
|
|
102
|
+
) || void 0
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
import e from"../managers/braze-instance.js";
|
|
1
|
+
import e from "../managers/braze-instance.js";
|
|
2
|
+
import v from "./content-cards-provider.js";
|
|
3
|
+
const g = {
|
|
4
|
+
t: !1,
|
|
5
|
+
provider: null,
|
|
6
|
+
er: () => (
|
|
7
|
+
g.o(),
|
|
8
|
+
g.provider ||
|
|
9
|
+
((g.provider = new v(e.ir(), e.l(), e.tr(), e.nr(), e.ar())),
|
|
10
|
+
e.dr(g.provider)),
|
|
11
|
+
g.provider
|
|
12
|
+
),
|
|
13
|
+
o: () => {
|
|
14
|
+
g.t || (e.g(g), (g.t = !0));
|
|
15
|
+
},
|
|
16
|
+
destroy: () => {
|
|
17
|
+
(g.provider = null), (g.t = !1);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
export default g;
|
|
@@ -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.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()),
|
|
32
|
+
e.jt(this.yt),
|
|
33
|
+
(this.kt = 0),
|
|
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);
|
|
40
|
+
}),
|
|
41
|
+
(this.$t = null),
|
|
42
|
+
(this._t = null),
|
|
43
|
+
(this.Bt = null),
|
|
44
|
+
(this.Gt = null),
|
|
45
|
+
(this.Ht = null),
|
|
46
|
+
(this.Kt = 10),
|
|
47
|
+
(this.Ot = 0);
|
|
48
|
+
}
|
|
49
|
+
Qt() {
|
|
50
|
+
return this.$t;
|
|
51
|
+
}
|
|
52
|
+
Vt(t) {
|
|
53
|
+
this.$t = t;
|
|
54
|
+
}
|
|
55
|
+
Wt() {
|
|
56
|
+
return this._t;
|
|
57
|
+
}
|
|
58
|
+
Xt(t) {
|
|
59
|
+
this._t = t;
|
|
60
|
+
}
|
|
61
|
+
Lt() {
|
|
62
|
+
if (!this.u) return;
|
|
63
|
+
const t = this.u.v(i.k.Yt) || [],
|
|
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.Zt(this.Cs(s, !1))),
|
|
70
|
+
(this.kt = this.u.v(i.k.ws) || this.kt),
|
|
71
|
+
(this.Ut = this.u.v(i.k.vs) || this.Ut);
|
|
72
|
+
}
|
|
73
|
+
Ns(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.ot(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.Zt(this.Cs(r, s))),
|
|
103
|
+
this.Rs(),
|
|
104
|
+
(this.kt = e),
|
|
105
|
+
(this.Ut = h),
|
|
106
|
+
this.u && (this.u.D(i.k.ws, this.kt), this.u.D(i.k.vs, this.Ut));
|
|
107
|
+
}
|
|
108
|
+
Ts(t) {
|
|
109
|
+
if (this.Ds() && null != t && t.cards) {
|
|
110
|
+
this.u && this.u.D(i.k.Ss, e.ks());
|
|
111
|
+
const s = t.full_sync;
|
|
112
|
+
s || this.Lt(),
|
|
113
|
+
this.Ns(t.cards, s, t.last_full_sync_at, t.last_card_updated_at),
|
|
114
|
+
this.yt.Et(this.Us(!0));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
As(t) {
|
|
118
|
+
this.u && this.u.D(i.k.Ls, t);
|
|
119
|
+
}
|
|
120
|
+
Fs(t, e, h) {
|
|
121
|
+
const n = () => {
|
|
122
|
+
this.Ms(e, h, !0);
|
|
123
|
+
},
|
|
124
|
+
o = t ? b(t) : null;
|
|
125
|
+
let l;
|
|
126
|
+
if ((this.Es(), !o || !o["retry-after"])) return void this.As(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.As(0);
|
|
135
|
+
}
|
|
136
|
+
l = 1e3 * parseFloat(a.toString());
|
|
137
|
+
}
|
|
138
|
+
this.Bt = window.setTimeout(() => {
|
|
139
|
+
n();
|
|
140
|
+
}, l);
|
|
141
|
+
let u = 0;
|
|
142
|
+
this.u && (u = this.u.v(i.k.Ls)),
|
|
143
|
+
(null == u || isNaN(parseInt(u.toString()))) && (u = 0),
|
|
144
|
+
this.As(parseInt(u.toString()) + 1);
|
|
145
|
+
}
|
|
146
|
+
Pt(t) {
|
|
147
|
+
if (!this.Ds()) return;
|
|
148
|
+
this.Lt();
|
|
149
|
+
const s = this.cards.slice();
|
|
150
|
+
let i = null;
|
|
151
|
+
this.ft && (i = this.ft.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.ot(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.Zt(this.Cs(s, !1))), this.Rs(), this.yt.Et(this.Us(!0));
|
|
174
|
+
}
|
|
175
|
+
Cs(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
|
+
Zt(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.vt && 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
|
+
Rs() {
|
|
226
|
+
if (!this.u) return;
|
|
227
|
+
const t = [];
|
|
228
|
+
for (let s = 0; s < this.cards.length; s++) t.push(this.cards[s].ss());
|
|
229
|
+
this.u.D(i.k.Yt, t);
|
|
230
|
+
}
|
|
231
|
+
Es() {
|
|
232
|
+
this.Bt && (clearTimeout(this.Bt), (this.Bt = null));
|
|
233
|
+
}
|
|
234
|
+
Is() {
|
|
235
|
+
null != this.Gt && (clearTimeout(this.Gt), (this.Gt = null));
|
|
236
|
+
}
|
|
237
|
+
Js(t = 1e3 * this.Kt, s, i) {
|
|
238
|
+
this.Is(),
|
|
239
|
+
(this.Gt = window.setTimeout(() => {
|
|
240
|
+
this.Ms(s, i, !0);
|
|
241
|
+
}, t)),
|
|
242
|
+
(this.Ht = t);
|
|
243
|
+
}
|
|
244
|
+
Ms(t, s, h = !1, n = !0) {
|
|
245
|
+
var o;
|
|
246
|
+
const l = this.gt,
|
|
247
|
+
a = this.u;
|
|
248
|
+
if (!l || !a) return void ("function" == typeof s && s());
|
|
249
|
+
const u = !h;
|
|
250
|
+
if ((u && (this.Es(), this.As(0)), !this.Ds()))
|
|
251
|
+
return void (
|
|
252
|
+
this.wt &&
|
|
253
|
+
this.wt.Ps(() => {
|
|
254
|
+
this.Ms(t, s);
|
|
255
|
+
})
|
|
256
|
+
);
|
|
257
|
+
let c = !0;
|
|
258
|
+
if (
|
|
259
|
+
(u &&
|
|
260
|
+
(null === (o = this.wt) || 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.Ss) !== e.ks() && this.Gs(),
|
|
268
|
+
(f.last_full_sync_at = this.kt),
|
|
269
|
+
(f.last_card_updated_at = this.Ut);
|
|
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.Fs(e, t, s),
|
|
286
|
+
this.Ts(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.Gt && this.Ot + 1 < S) {
|
|
298
|
+
T.hi(this.u, T.Os.Ks);
|
|
299
|
+
let i = this.Ht;
|
|
300
|
+
(null == i || i < 1e3 * this.Kt) && (i = 1e3 * this.Kt),
|
|
301
|
+
this.Js(Math.min(3e5, D(1e3 * this.Kt, 3 * i)), t, s),
|
|
302
|
+
(this.Ot = this.Ot + 1);
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
Us(t) {
|
|
309
|
+
t || this.Lt();
|
|
310
|
+
const s = this.Zt(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.Ut || 0, this.kt || 0);
|
|
323
|
+
return (
|
|
324
|
+
0 === e && (e = void 0),
|
|
325
|
+
this.u && this.u.v(i.k.vs) === this.Ut && void 0 === e && (e = this.Ut),
|
|
326
|
+
new ContentCards(s, l(e))
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
ri(t) {
|
|
330
|
+
return this.yt.lt(t);
|
|
331
|
+
}
|
|
332
|
+
Gs() {
|
|
333
|
+
(this.kt = 0),
|
|
334
|
+
(this.Ut = 0),
|
|
335
|
+
this.u && (this.u.ni(i.k.ws), this.u.ni(i.k.vs));
|
|
336
|
+
}
|
|
337
|
+
changeUser(t) {
|
|
338
|
+
t ||
|
|
339
|
+
((this.cards = []),
|
|
340
|
+
this.yt.Et(new ContentCards(this.cards.slice(), null)),
|
|
341
|
+
this.u &&
|
|
342
|
+
(this.u.ni(i.k.Yt),
|
|
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.Ut = 0),
|
|
351
|
+
(this.cards = []),
|
|
352
|
+
this.yt.Et(new ContentCards(this.cards.slice(), null)),
|
|
353
|
+
t &&
|
|
354
|
+
this.u &&
|
|
355
|
+
(this.u.ni(i.k.Yt),
|
|
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.ws),
|
|
360
|
+
this.u.ni(i.k.vs));
|
|
361
|
+
}
|
|
362
|
+
Ds() {
|
|
363
|
+
return !(this.wt && !this.wt.oi()) || (0 !== this.wt.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.wt;
|
|
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.yt.Et(new ContentCards([], new Date())), this.u && this.u.ni(i.k.Yt);
|
|
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().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 z } from "../util/deprecation-utils.js";
|
|
3
|
+
export function logContentCardsDisplayed() {
|
|
4
|
+
if (e.rr()) return z("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().Ms(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.Wt()) {
|
|
8
|
+
const r = e.cr();
|
|
9
|
+
if (r) {
|
|
10
|
+
const n = r.pr(() => {
|
|
11
|
+
t.Ms();
|
|
12
|
+
});
|
|
13
|
+
n && t.Xt(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 k } 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)) && k(o[e]);
|
|
8
|
+
}
|