@braze/web-sdk 5.9.1 → 6.1.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 +209 -283
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +27 -29
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +22 -22
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +22 -23
- package/src/Banner/banner-factory.js +2 -1
- package/src/Banner/banner-provider-factory.js +7 -7
- package/src/Banner/banner-provider.js +92 -98
- package/src/Banner/banner.js +21 -18
- package/src/Banner/display/banner-to-html.js +18 -30
- package/src/Banner/display/detect-banner-impressions.js +11 -11
- package/src/Banner/get-all-banners.js +5 -5
- package/src/Banner/get-banner.js +7 -7
- package/src/Banner/index.js +0 -1
- package/src/Banner/log-banner-click.js +7 -7
- package/src/Banner/log-banner-impressions.js +9 -9
- package/src/Banner/request-banners-refresh.js +23 -27
- package/src/Banner/subscribe-to-banners-updates.js +9 -9
- package/src/Banner/ui/insert-banner.js +10 -10
- package/src/Card/card-manager-factory.js +7 -7
- package/src/Card/card-manager.js +45 -47
- package/src/Card/display/card-display.js +76 -74
- package/src/Card/index.js +0 -2
- package/src/Card/log-card-dismissal.js +4 -4
- 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 +21 -21
- package/src/Card/models/card.js +116 -110
- package/src/Card/models/classic-card.js +21 -21
- package/src/Card/models/control-card.js +15 -15
- package/src/Card/models/image-only.js +20 -21
- package/src/Card/util/card-factory.js +58 -79
- package/src/ContentCards/content-cards-provider-factory.js +13 -13
- package/src/ContentCards/content-cards-provider.js +148 -148
- 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 +8 -8
- package/src/ContentCards/ui/hide-content-cards.js +5 -5
- package/src/ContentCards/ui/show-content-cards.js +35 -35
- package/src/Core/add-sdk-metadata.js +5 -5
- package/src/Core/change-user.js +7 -7
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +10 -10
- package/src/Core/enable-sdk.js +7 -7
- package/src/Core/get-device-id.js +4 -4
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +10 -10
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/is-initialized.js +1 -1
- package/src/Core/log-custom-event.js +18 -18
- package/src/Core/log-purchase.js +19 -19
- package/src/Core/open-session.js +13 -13
- package/src/Core/request-immediate-data-flush.js +1 -1
- package/src/Core/set-logger.js +2 -2
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +9 -9
- package/src/FeatureFlags/feature-flag-factory.js +10 -10
- package/src/FeatureFlags/feature-flag.js +20 -71
- package/src/FeatureFlags/feature-flags-provider-factory.js +7 -7
- package/src/FeatureFlags/feature-flags-provider.js +86 -86
- package/src/FeatureFlags/get-all-feature-flags.js +3 -3
- package/src/FeatureFlags/get-feature-flag.js +3 -3
- package/src/FeatureFlags/log-feature-flag-impression.js +8 -8
- package/src/FeatureFlags/refresh-feature-flags.js +1 -1
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +3 -3
- package/src/InAppMessage/defer-in-app-message.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +41 -41
- package/src/InAppMessage/display/in-app-message-to-html.js +145 -139
- package/src/InAppMessage/display/modal-utils.js +40 -42
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +24 -16
- package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
- package/src/InAppMessage/in-app-message-manager.js +124 -122
- package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
- package/src/InAppMessage/log-in-app-message-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-html-click.js +11 -11
- package/src/InAppMessage/log-in-app-message-impression.js +4 -4
- package/src/InAppMessage/models/control-message.js +5 -5
- package/src/InAppMessage/models/full-screen-message.js +41 -35
- package/src/InAppMessage/models/html-message.js +28 -26
- package/src/InAppMessage/models/in-app-message-button.js +5 -5
- package/src/InAppMessage/models/in-app-message.js +156 -152
- package/src/InAppMessage/models/modal-message.js +40 -34
- package/src/InAppMessage/models/slide-up-message.js +38 -32
- 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 +68 -74
- 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 +17 -17
- package/src/Push/push-manager.js +127 -127
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/utils/push-utils.js +25 -15
- package/src/User/user-manager.js +20 -20
- package/src/User/user.js +60 -61
- package/src/common/base-provider.js +1 -1
- package/src/common/content-cards-display.js +211 -0
- package/src/common/event-logger.js +12 -12
- package/src/common/properties-base.js +56 -0
- package/src/index.js +0 -1
- package/src/l10n/l10n-manager-factory.js +10 -10
- package/src/l10n/l10n-manager.js +7 -7
- package/src/managers/auth-manager.js +36 -36
- package/src/managers/braze-instance.js +184 -185
- package/src/managers/device-manager.js +26 -26
- package/src/managers/network-manager.js +194 -193
- package/src/managers/server-config-manager.js +75 -75
- package/src/managers/session-manager.js +29 -29
- package/src/managers/storage-manager-factory.js +13 -13
- package/src/managers/storage-manager.js +162 -164
- package/src/managers/subscription-manager.js +12 -12
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +16 -16
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +8 -8
- package/src/models/push-token.js +10 -10
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +33 -33
- package/src/request-controller.js +193 -192
- package/src/triggers/models/custom-event-data.js +7 -7
- package/src/triggers/models/custom-event-property-data.js +8 -8
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +43 -43
- package/src/triggers/models/in-app-message-click-data.js +4 -4
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +6 -6
- package/src/triggers/models/push-click-data.js +2 -2
- package/src/triggers/models/trigger-condition.js +52 -52
- package/src/triggers/models/trigger-events.js +4 -4
- package/src/triggers/models/trigger.js +19 -19
- package/src/triggers/triggers-provider-factory.js +14 -14
- package/src/triggers/triggers-provider.js +70 -70
- 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 +12 -18
- package/src/util/browser-detector.js +27 -20
- package/src/util/client-hints-parser.js +8 -8
- package/src/util/code-utils.js +2 -2
- package/src/util/component-utils.js +14 -14
- package/src/util/deprecation-utils.js +2 -2
- package/src/util/device-constants.js +5 -5
- package/src/util/dom-utils.js +9 -9
- package/src/util/html-display-utils.js +38 -38
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +12 -12
- package/src/util/request-header-utils.js +22 -22
- package/src/util/string-utils.js +2 -2
- package/src/util/user-agent-parser.js +17 -17
- package/src/util/validation-utils.js +28 -28
- package/src/util/window-utils.js +2 -2
- 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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Browsers as
|
|
3
|
-
export default class
|
|
1
|
+
import ge from "./base-device-parser.js";
|
|
2
|
+
import { Browsers as gi, OperatingSystems as so } from "./device-constants.js";
|
|
3
|
+
export default class oi extends ge {
|
|
4
4
|
constructor() {
|
|
5
|
-
super(), (this.fd =
|
|
5
|
+
super(), (this.fd = oi.gc(navigator.userAgent || ""));
|
|
6
6
|
}
|
|
7
7
|
ef() {
|
|
8
8
|
return this.fd[0] || "Unknown Browser";
|
|
@@ -10,19 +10,19 @@ export default class gi extends Oe {
|
|
|
10
10
|
ff() {
|
|
11
11
|
return this.fd[1] || "Unknown Version";
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
Ja(r) {
|
|
14
14
|
for (let n = 0; n < r.length; n++) {
|
|
15
15
|
const e = r[n].string;
|
|
16
|
-
let i =
|
|
16
|
+
let i = oi.nf(e, r[n]);
|
|
17
17
|
if (i)
|
|
18
18
|
return (
|
|
19
|
-
i === so.
|
|
19
|
+
i === so.Og && navigator.maxTouchPoints > 1 && (i = so.co),
|
|
20
20
|
Promise.resolve(i)
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
return Promise.resolve(navigator.platform);
|
|
24
24
|
}
|
|
25
|
-
static
|
|
25
|
+
static gc(r) {
|
|
26
26
|
let n,
|
|
27
27
|
e =
|
|
28
28
|
r.match(
|
|
@@ -41,37 +41,37 @@ export default class gi extends Oe {
|
|
|
41
41
|
if (r.match(/\b(Roku)\b/)) return ["Roku", null];
|
|
42
42
|
if (r.match(/\bAFTM\b/)) return ["Amazon Fire Stick", null];
|
|
43
43
|
if (
|
|
44
|
-
e[1] ===
|
|
44
|
+
e[1] === gi.rO &&
|
|
45
45
|
((n = r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/)),
|
|
46
46
|
null != n)
|
|
47
47
|
)
|
|
48
48
|
return (
|
|
49
49
|
(n = n.slice(1)),
|
|
50
|
-
(n[0] = n[0].replace("OPR",
|
|
51
|
-
(n[0] = n[0].replace("EdgA",
|
|
52
|
-
"Edg" === n[0] && (n[0] =
|
|
50
|
+
(n[0] = n[0].replace("OPR", gi.oO)),
|
|
51
|
+
(n[0] = n[0].replace("EdgA", gi.eO)),
|
|
52
|
+
"Edg" === n[0] && (n[0] = gi.eO),
|
|
53
53
|
[n[0], n[1]]
|
|
54
54
|
);
|
|
55
55
|
if (
|
|
56
|
-
e[1] ===
|
|
56
|
+
e[1] === gi.xg &&
|
|
57
57
|
((n = r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/)), null != n)
|
|
58
58
|
)
|
|
59
59
|
return (
|
|
60
|
-
(n = n.slice(1)), (n[0] = n[0].replace("EdgiOS",
|
|
60
|
+
(n = n.slice(1)), (n[0] = n[0].replace("EdgiOS", gi.eO)), [n[0], n[1]]
|
|
61
61
|
);
|
|
62
62
|
if (
|
|
63
63
|
((e = e[2] ? [e[1], e[2]] : [null, null]),
|
|
64
|
-
e[0] ===
|
|
64
|
+
e[0] === gi.xg &&
|
|
65
65
|
null != (n = r.match(/version\/(\.?\d+(\.\d+)*)/i)) &&
|
|
66
66
|
e.splice(1, 1, n[1]),
|
|
67
67
|
null != (n = r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/)) &&
|
|
68
68
|
e.splice(1, 1, n[2]),
|
|
69
|
-
e[0] ===
|
|
69
|
+
e[0] === gi.oO && null != (n = r.match(/mini\/(\.?\d+(\.\d+)*)/i)))
|
|
70
70
|
)
|
|
71
71
|
return ["Opera Mini", n[1] || ""];
|
|
72
72
|
if (e[0]) {
|
|
73
73
|
const r = e[0].toLowerCase();
|
|
74
|
-
"crios" === r && (e[0] =
|
|
74
|
+
"crios" === r && (e[0] = gi.rO),
|
|
75
75
|
"tizen" === r && ((e[0] = "Samsung Smart TV"), (e[1] = null)),
|
|
76
76
|
"samsungbrowser" === r && (e[0] = "Samsung Browser");
|
|
77
77
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isArray as
|
|
2
|
+
isArray as D,
|
|
3
3
|
isDate as Nt,
|
|
4
|
-
isObject as
|
|
4
|
+
isObject as It,
|
|
5
5
|
keys as C,
|
|
6
6
|
} from "./code-utils.js";
|
|
7
7
|
import { getByteLength as er } from "./string-utils.js";
|
|
8
|
-
import { logger as
|
|
9
|
-
import { toValidBackendTimeString as
|
|
8
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
9
|
+
import { toValidBackendTimeString as Lt } from "./date-utils.js";
|
|
10
10
|
import { BRAZE_ACTIONS as oo } from "./braze-actions.js";
|
|
11
|
-
import { SET_CUSTOM_USER_ATTRIBUTE_STRING as
|
|
11
|
+
import { SET_CUSTOM_USER_ATTRIBUTE_STRING as Ft } from "../common/constants.js";
|
|
12
12
|
export const CUSTOM_DATA_REGEX = /^[^\x00-\x1F\x22]+$/;
|
|
13
13
|
export const CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX = /[$.]/;
|
|
14
14
|
export const CUSTOM_ATTRIBUTE_RESERVED_OPERATORS = [
|
|
@@ -35,14 +35,14 @@ export function validateCustomString(t, e, r) {
|
|
|
35
35
|
null != t &&
|
|
36
36
|
"string" == typeof t &&
|
|
37
37
|
("" === t || null != t.match(CUSTOM_DATA_REGEX));
|
|
38
|
-
return n ||
|
|
38
|
+
return n || E.error(`Cannot ${e} because ${r} "${t}" is invalid.`), n;
|
|
39
39
|
}
|
|
40
40
|
export function validateCustomAttributeKey(t) {
|
|
41
41
|
return (
|
|
42
42
|
null != t &&
|
|
43
43
|
t.match(CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX) &&
|
|
44
44
|
-1 === CUSTOM_ATTRIBUTE_RESERVED_OPERATORS.indexOf(t) &&
|
|
45
|
-
|
|
45
|
+
E.warn("Custom attribute keys cannot contain '$' or '.'"),
|
|
46
46
|
validateCustomString(t, "set custom user attribute", "the given key")
|
|
47
47
|
);
|
|
48
48
|
}
|
|
@@ -55,22 +55,22 @@ export function validatePropertyType(t) {
|
|
|
55
55
|
export function _validateNestedProperties(t, e, r) {
|
|
56
56
|
const n = -1 !== r;
|
|
57
57
|
if (n && r > 50)
|
|
58
|
-
return
|
|
58
|
+
return E.error("Nested attributes cannot be more than 50 levels deep."), !1;
|
|
59
59
|
const o = n ? r + 1 : -1;
|
|
60
|
-
if (
|
|
60
|
+
if (D(t) && D(e)) {
|
|
61
61
|
for (let r = 0; r < t.length && r < e.length; r++)
|
|
62
62
|
if (
|
|
63
|
-
(Nt(t[r]) && (e[r] =
|
|
63
|
+
(Nt(t[r]) && (e[r] = Lt(t[r])),
|
|
64
64
|
!_validateNestedProperties(t[r], e[r], o))
|
|
65
65
|
)
|
|
66
66
|
return !1;
|
|
67
67
|
} else {
|
|
68
|
-
if (!
|
|
68
|
+
if (!It(t)) return validatePropertyType(t);
|
|
69
69
|
for (const r of C(t)) {
|
|
70
70
|
const i = t[r];
|
|
71
71
|
if (n && !validateCustomAttributeKey(r)) return !1;
|
|
72
72
|
if (Nt(i)) {
|
|
73
|
-
e[r] =
|
|
73
|
+
e[r] = Lt(i);
|
|
74
74
|
}
|
|
75
75
|
if (!_validateNestedProperties(i, e[r], o)) return !1;
|
|
76
76
|
}
|
|
@@ -81,29 +81,29 @@ export function _validateEventPropertyValue(t, e, r, n, o) {
|
|
|
81
81
|
let i;
|
|
82
82
|
return (
|
|
83
83
|
(i =
|
|
84
|
-
|
|
84
|
+
It(t) || D(t)
|
|
85
85
|
? _validateNestedProperties(t, e, o ? 1 : -1)
|
|
86
86
|
: validatePropertyType(t)),
|
|
87
|
-
i ||
|
|
87
|
+
i || E.error(`Cannot ${r} because ${n} "${t}" is invalid.`),
|
|
88
88
|
i
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
export function validateStandardString(t, e, r, n = !1) {
|
|
92
92
|
const o = "string" == typeof t || (null === t && n);
|
|
93
|
-
return o ||
|
|
93
|
+
return o || E.error(`Cannot ${e} because ${r} "${t}" is invalid.`), o;
|
|
94
94
|
}
|
|
95
95
|
export function validateCustomProperties(t, e, r, n, o) {
|
|
96
|
-
if ((null == t && (t = {}), "object" != typeof t ||
|
|
96
|
+
if ((null == t && (t = {}), "object" != typeof t || D(t)))
|
|
97
97
|
return (
|
|
98
|
-
|
|
98
|
+
E.error(`${e} requires that ${r} be an object. Ignoring ${o}.`),
|
|
99
99
|
[!1, null]
|
|
100
100
|
);
|
|
101
101
|
let i, a;
|
|
102
|
-
e ===
|
|
102
|
+
e === Ft ? ((i = 76800), (a = "75KB")) : ((i = 51200), (a = "50KB"));
|
|
103
103
|
const s = JSON.stringify(t);
|
|
104
104
|
if (er(s) > i)
|
|
105
105
|
return (
|
|
106
|
-
|
|
106
|
+
E.error(
|
|
107
107
|
`Could not ${n} because ${r} was greater than the max size of ${a}.`,
|
|
108
108
|
),
|
|
109
109
|
[!1, null]
|
|
@@ -113,27 +113,27 @@ export function validateCustomProperties(t, e, r, n, o) {
|
|
|
113
113
|
u = JSON.parse(s);
|
|
114
114
|
} catch (t) {
|
|
115
115
|
return (
|
|
116
|
-
|
|
116
|
+
E.error(`Could not ${n} because ${r} did not contain valid JSON.`),
|
|
117
117
|
[!1, null]
|
|
118
118
|
);
|
|
119
119
|
}
|
|
120
120
|
for (const r in t) {
|
|
121
|
-
if (e ===
|
|
121
|
+
if (e === Ft && !validateCustomAttributeKey(r)) return [!1, null];
|
|
122
122
|
if (!validateCustomString(r, n, `the ${o} property name`))
|
|
123
123
|
return [!1, null];
|
|
124
124
|
const i = t[r];
|
|
125
|
-
if (e !==
|
|
125
|
+
if (e !== Ft && null == i) {
|
|
126
126
|
delete t[r], delete u[r];
|
|
127
127
|
continue;
|
|
128
128
|
}
|
|
129
|
-
Nt(i) && (u[r] =
|
|
129
|
+
Nt(i) && (u[r] = Lt(i));
|
|
130
130
|
if (
|
|
131
131
|
!_validateEventPropertyValue(
|
|
132
132
|
i,
|
|
133
133
|
u[r],
|
|
134
134
|
n,
|
|
135
135
|
`the ${o} property "${r}"`,
|
|
136
|
-
e ===
|
|
136
|
+
e === Ft,
|
|
137
137
|
)
|
|
138
138
|
)
|
|
139
139
|
return [!1, null];
|
|
@@ -144,7 +144,7 @@ export function validateCustomAttributeArrayType(t, e) {
|
|
|
144
144
|
let r = !1,
|
|
145
145
|
n = !1;
|
|
146
146
|
const o = () => {
|
|
147
|
-
|
|
147
|
+
E.error(
|
|
148
148
|
"Custom attribute arrays must be either string arrays or object arrays.",
|
|
149
149
|
);
|
|
150
150
|
};
|
|
@@ -161,12 +161,12 @@ export function validateCustomAttributeArrayType(t, e) {
|
|
|
161
161
|
return [!1, !1];
|
|
162
162
|
r = !0;
|
|
163
163
|
} else {
|
|
164
|
-
if (!
|
|
164
|
+
if (!It(i)) return o(), [!1, !1];
|
|
165
165
|
if (r) return o(), [!1, !1];
|
|
166
166
|
if (
|
|
167
167
|
!validateCustomProperties(
|
|
168
168
|
i,
|
|
169
|
-
|
|
169
|
+
Ft,
|
|
170
170
|
"attribute value",
|
|
171
171
|
`set custom user attribute "${t}"`,
|
|
172
172
|
"custom user attribute",
|
|
@@ -196,8 +196,8 @@ export function isValidBrazeActionJson(t) {
|
|
|
196
196
|
case oo.types.removeFromSubscriptionGroup:
|
|
197
197
|
case oo.types.addToCustomAttributeArray:
|
|
198
198
|
case oo.types.removeFromCustomAttributeArray:
|
|
199
|
-
case oo.types.co:
|
|
200
199
|
case oo.types.mo:
|
|
200
|
+
case oo.types.uo:
|
|
201
201
|
if (oo.properties.so in t) return !0;
|
|
202
202
|
break;
|
|
203
203
|
case oo.types.requestPushPermission:
|
package/src/util/window-utils.js
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Card } from "./models/index.js";
|
|
2
|
-
import _ from "./card-manager-factory.js";
|
|
3
|
-
import { MUST_BE_CARD_WARNING_SUFFIX as L } from "../common/constants.js";
|
|
4
|
-
import r from "../managers/braze-instance.js";
|
|
5
|
-
import { logger as N } from "../../shared-lib/index.js";
|
|
6
|
-
export function logCardClick(o, m) {
|
|
7
|
-
return (
|
|
8
|
-
!!r.rr() &&
|
|
9
|
-
(o instanceof Card ? _.ea().logClick(o, m).tt : (N.error("card " + L), !1))
|
|
10
|
-
);
|
|
11
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Card } from "./models/index.js";
|
|
2
|
-
import _ from "./card-manager-factory.js";
|
|
3
|
-
import r from "../managers/braze-instance.js";
|
|
4
|
-
import { isArray as z } from "../util/code-utils.js";
|
|
5
|
-
import { MUST_BE_CARD_WARNING_SUFFIX as L } from "../common/constants.js";
|
|
6
|
-
import { logger as N } from "../../shared-lib/index.js";
|
|
7
|
-
export function logCardImpressions(o, n) {
|
|
8
|
-
if (!r.rr()) return !1;
|
|
9
|
-
if (!z(o)) return N.error("cards must be an array"), !1;
|
|
10
|
-
for (const r of o)
|
|
11
|
-
if (!(r instanceof Card)) return N.error(`Each card in cards ${L}`), !1;
|
|
12
|
-
return _.ea().Xt(o, n).tt;
|
|
13
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import r from "../managers/braze-instance.js";
|
|
2
|
-
import re from "./feed-provider.js";
|
|
3
|
-
const ie = {
|
|
4
|
-
l: !1,
|
|
5
|
-
provider: null,
|
|
6
|
-
m: () => (
|
|
7
|
-
ie.p(),
|
|
8
|
-
ie.provider || ((ie.provider = new re(r.j(), r.rn())), r._(ie.provider)),
|
|
9
|
-
ie.provider
|
|
10
|
-
),
|
|
11
|
-
p: () => {
|
|
12
|
-
ie.l || (r.h(ie), (ie.l = !0));
|
|
13
|
-
},
|
|
14
|
-
destroy: () => {
|
|
15
|
-
(ie.provider = null), (ie.l = !1);
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
export default ie;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import t from "../common/base-provider.js";
|
|
2
|
-
import r from "../managers/braze-instance.js";
|
|
3
|
-
import Feed from "./feed.js";
|
|
4
|
-
import {
|
|
5
|
-
newCardFromFeedJson as lt,
|
|
6
|
-
newCardFromSerializedValue as tt,
|
|
7
|
-
} from "../Card/util/card-factory.js";
|
|
8
|
-
import { rehydrateDateAfterJsonization as V } from "../util/date-utils.js";
|
|
9
|
-
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
10
|
-
import u from "../managers/subscription-manager.js";
|
|
11
|
-
export default class re extends t {
|
|
12
|
-
constructor(t, s) {
|
|
13
|
-
super(),
|
|
14
|
-
(this.C = t),
|
|
15
|
-
(this.Fi = s),
|
|
16
|
-
(this.cards = []),
|
|
17
|
-
(this.xi = null),
|
|
18
|
-
(this.C = t),
|
|
19
|
-
(this.Fi = s),
|
|
20
|
-
(this.Ts = new u()),
|
|
21
|
-
r.F(this.Ts),
|
|
22
|
-
this.Ds();
|
|
23
|
-
}
|
|
24
|
-
Ds() {
|
|
25
|
-
let t = [];
|
|
26
|
-
this.C && (t = this.C.ft(s.gt.qi) || []);
|
|
27
|
-
const i = [];
|
|
28
|
-
for (let s = 0; s < t.length; s++) {
|
|
29
|
-
const e = tt(t[s]);
|
|
30
|
-
null != e && i.push(e);
|
|
31
|
-
}
|
|
32
|
-
(this.cards = i), this.C && (this.xi = V(this.C.ft(s.gt.zi)));
|
|
33
|
-
}
|
|
34
|
-
Ui(t) {
|
|
35
|
-
const i = [];
|
|
36
|
-
let e = null,
|
|
37
|
-
r = {};
|
|
38
|
-
this.C && (r = this.C.ft(s.gt.Zt) || {});
|
|
39
|
-
const h = {};
|
|
40
|
-
for (let s = 0; s < t.length; s++) {
|
|
41
|
-
e = t[s];
|
|
42
|
-
const o = lt(e);
|
|
43
|
-
if (null != o) {
|
|
44
|
-
const t = o.id;
|
|
45
|
-
t && r[t] && ((o.viewed = !0), (h[t] = !0)), i.push(o);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
(this.cards = i),
|
|
49
|
-
this.Ws(),
|
|
50
|
-
(this.xi = new Date()),
|
|
51
|
-
this.C && (this.C.Bt(s.gt.Zt, h), this.C.Bt(s.gt.zi, this.xi));
|
|
52
|
-
}
|
|
53
|
-
Ws() {
|
|
54
|
-
var t;
|
|
55
|
-
const i = [];
|
|
56
|
-
for (let t = 0; t < this.cards.length; t++) i.push(this.cards[t].bt());
|
|
57
|
-
null === (t = this.C) || void 0 === t || t.Bt(s.gt.qi, i);
|
|
58
|
-
}
|
|
59
|
-
U(t) {
|
|
60
|
-
null != t &&
|
|
61
|
-
t.feed &&
|
|
62
|
-
(this.Ds(),
|
|
63
|
-
this.Ui(t.feed),
|
|
64
|
-
this.Ts.X(new Feed(this.cards.slice(), this.xi)));
|
|
65
|
-
}
|
|
66
|
-
ki() {
|
|
67
|
-
this.Ds();
|
|
68
|
-
const t = [],
|
|
69
|
-
s = new Date();
|
|
70
|
-
for (let i = 0; i < this.cards.length; i++) {
|
|
71
|
-
const e = this.cards[i].expiresAt;
|
|
72
|
-
let r = !0;
|
|
73
|
-
null != e && (r = e >= s), r && t.push(this.cards[i]);
|
|
74
|
-
}
|
|
75
|
-
return new Feed(t, this.xi);
|
|
76
|
-
}
|
|
77
|
-
bi() {
|
|
78
|
-
this.Fi && this.Fi.requestFeedRefresh();
|
|
79
|
-
}
|
|
80
|
-
qt(t) {
|
|
81
|
-
return this.Ts.Dt(t);
|
|
82
|
-
}
|
|
83
|
-
clearData(t) {
|
|
84
|
-
null == t && (t = !1),
|
|
85
|
-
(this.cards = []),
|
|
86
|
-
(this.xi = null),
|
|
87
|
-
t && this.C && (this.C.Ut(s.gt.qi), this.C.Ut(s.gt.zi)),
|
|
88
|
-
this.Ts.X(new Feed(this.cards.slice(), this.xi));
|
|
89
|
-
}
|
|
90
|
-
}
|
package/src/Feed/feed.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import rr from "../common/base-feed.js";
|
|
2
|
-
import { logCardClick, logCardImpressions } from "../Card/index.js";
|
|
3
|
-
import { requestFeedRefresh } from "./request-feed-refresh.js";
|
|
4
|
-
export default class Feed extends rr {
|
|
5
|
-
constructor(r, e) {
|
|
6
|
-
super(r, e);
|
|
7
|
-
}
|
|
8
|
-
logCardImpressions(r) {
|
|
9
|
-
logCardImpressions(r, !1);
|
|
10
|
-
}
|
|
11
|
-
logCardClick(r) {
|
|
12
|
-
return logCardClick(r, !1);
|
|
13
|
-
}
|
|
14
|
-
sr() {
|
|
15
|
-
requestFeedRefresh();
|
|
16
|
-
}
|
|
17
|
-
nr() {
|
|
18
|
-
return !1;
|
|
19
|
-
}
|
|
20
|
-
}
|
package/src/Feed/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { default as Feed } from "./feed.js";
|
|
2
|
-
export { getCachedFeed } from "./get-cached-feed.js";
|
|
3
|
-
export { destroyFeed } from "./ui/hide-feed.js";
|
|
4
|
-
export { logFeedDisplayed } from "./log-feed-displayed.js";
|
|
5
|
-
export { requestFeedRefresh } from "./request-feed-refresh.js";
|
|
6
|
-
export { showFeed } from "./ui/show-feed.js";
|
|
7
|
-
export { subscribeToFeedUpdates } from "./subscribe-to-feed-updates.js";
|
|
8
|
-
export { toggleFeed } from "./ui/toggle-feed.js";
|
package/src/Feed/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/Feed/ui/hide-feed.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import r from "../../managers/braze-instance.js";
|
|
2
|
-
import { destroyFeedHtml as ee } from "../../common/feed-display.js";
|
|
3
|
-
export function destroyFeed() {
|
|
4
|
-
if (!r.rr()) return;
|
|
5
|
-
const e = document.querySelectorAll(".ab-feed");
|
|
6
|
-
for (let o = 0; o < e.length; o++) ee(e[o]);
|
|
7
|
-
}
|
package/src/Feed/ui/show-feed.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import r, { OPTIONS as w } from "../../managers/braze-instance.js";
|
|
2
|
-
import {
|
|
3
|
-
destroyFeedHtml as ee,
|
|
4
|
-
detectFeedImpressions as nn,
|
|
5
|
-
feedToHtml as tn,
|
|
6
|
-
LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as en,
|
|
7
|
-
refreshFeed as on,
|
|
8
|
-
registerFeedSubscriptionId as rn,
|
|
9
|
-
updateFeedCards as an,
|
|
10
|
-
} from "../../common/feed-display.js";
|
|
11
|
-
import { Feed, logFeedDisplayed, subscribeToFeedUpdates } from "../index.js";
|
|
12
|
-
import ie from "../feed-provider-factory.js";
|
|
13
|
-
import { intersection as te } from "../../util/code-utils.js";
|
|
14
|
-
import { setCardHeight as sn } from "../../Card/display/card-display.js";
|
|
15
|
-
import { setupFeedUI as fn } from "../../ui/js/index.js";
|
|
16
|
-
import { logger as N } from "../../../shared-lib/index.js";
|
|
17
|
-
export function showFeed(e, t, n) {
|
|
18
|
-
if (!r.rr()) return;
|
|
19
|
-
fn();
|
|
20
|
-
const o = (e, t) => {
|
|
21
|
-
if (null == t) return e;
|
|
22
|
-
const n = [];
|
|
23
|
-
for (let e = 0; e < t.length; e++) n.push(t[e].toLowerCase());
|
|
24
|
-
const o = [];
|
|
25
|
-
for (let t = 0; t < e.length; t++) {
|
|
26
|
-
const r = [],
|
|
27
|
-
i = e[t].categories || [];
|
|
28
|
-
for (let e = 0; e < i.length; e++) r.push(i[e].toLowerCase());
|
|
29
|
-
te(r, n).length > 0 && o.push(e[t]);
|
|
30
|
-
}
|
|
31
|
-
return o;
|
|
32
|
-
},
|
|
33
|
-
i = r.ee(w.tn) || r.ee(w.en) || !1;
|
|
34
|
-
let s = !1;
|
|
35
|
-
null == e && ((e = document.body), (s = !0));
|
|
36
|
-
let l,
|
|
37
|
-
f = !1;
|
|
38
|
-
null == t
|
|
39
|
-
? ((l = ie.m().ki()),
|
|
40
|
-
an(l, o(l.cards, n), l.lastUpdated, null, i),
|
|
41
|
-
(f = !0))
|
|
42
|
-
: (l = new Feed(o(t, n), new Date()));
|
|
43
|
-
const a = tn(l, i, s);
|
|
44
|
-
if (f) {
|
|
45
|
-
(null == l.lastUpdated ||
|
|
46
|
-
new Date().valueOf() - l.lastUpdated.valueOf() > Feed.dr) &&
|
|
47
|
-
(N.info(
|
|
48
|
-
`Cached feed was older than max TTL of ${Feed.dr} ms, requesting an update from the server.`,
|
|
49
|
-
),
|
|
50
|
-
on(l, a));
|
|
51
|
-
const e = new Date().valueOf(),
|
|
52
|
-
t = subscribeToFeedUpdates(function (t) {
|
|
53
|
-
const r = a.querySelectorAll(".ab-refresh-button")[0];
|
|
54
|
-
if (null != r) {
|
|
55
|
-
let t = 500;
|
|
56
|
-
t -= new Date().valueOf() - e;
|
|
57
|
-
const n = a.getAttribute(en);
|
|
58
|
-
if (n) {
|
|
59
|
-
const e = parseInt(n);
|
|
60
|
-
isNaN(e) || (t -= new Date().valueOf() - e);
|
|
61
|
-
}
|
|
62
|
-
setTimeout(
|
|
63
|
-
function () {
|
|
64
|
-
r.className = r.className.replace(/fa-spin/g, "");
|
|
65
|
-
},
|
|
66
|
-
Math.max(t, 0),
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
an(l, o(t.cards, n), t.lastUpdated, a, i);
|
|
70
|
-
});
|
|
71
|
-
rn(t, a);
|
|
72
|
-
}
|
|
73
|
-
const u = (e) => {
|
|
74
|
-
const t = e.querySelectorAll(".ab-feed");
|
|
75
|
-
let n = null;
|
|
76
|
-
for (let o = 0; o < t.length; o++) t[o].parentNode === e && (n = t[o]);
|
|
77
|
-
null != n
|
|
78
|
-
? (ee(n), n.parentNode && n.parentNode.replaceChild(a, n))
|
|
79
|
-
: e.appendChild(a),
|
|
80
|
-
setTimeout(function () {
|
|
81
|
-
a.className = a.className.replace("ab-hide", "ab-show");
|
|
82
|
-
}, 0),
|
|
83
|
-
s && a.focus(),
|
|
84
|
-
logFeedDisplayed(),
|
|
85
|
-
nn(l, a),
|
|
86
|
-
l && sn(l.cards, e);
|
|
87
|
-
};
|
|
88
|
-
var d;
|
|
89
|
-
null != e
|
|
90
|
-
? u(e)
|
|
91
|
-
: (window.onload =
|
|
92
|
-
((d = window.onload),
|
|
93
|
-
function () {
|
|
94
|
-
"function" == typeof d && d(new Event("oldLoad")), u(document.body);
|
|
95
|
-
}));
|
|
96
|
-
}
|
package/src/common/base-feed.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { logger as N } from "../../shared-lib/index.js";
|
|
2
|
-
import { ControlCard } from "../Card/index.js";
|
|
3
|
-
export const FEED_ANIMATION_DURATION = 500;
|
|
4
|
-
export default class rr {
|
|
5
|
-
constructor(s, e) {
|
|
6
|
-
(this.cards = s),
|
|
7
|
-
(this.lastUpdated = e),
|
|
8
|
-
(this.cards = s),
|
|
9
|
-
(this.lastUpdated = e);
|
|
10
|
-
}
|
|
11
|
-
getUnreadCardCount() {
|
|
12
|
-
let s = 0;
|
|
13
|
-
for (const e of this.cards) e.viewed || e instanceof ControlCard || s++;
|
|
14
|
-
return s;
|
|
15
|
-
}
|
|
16
|
-
nr() {
|
|
17
|
-
N.error("Must be implemented in a subclass");
|
|
18
|
-
}
|
|
19
|
-
logCardImpressions(s) {
|
|
20
|
-
N.error("Must be implemented in a subclass");
|
|
21
|
-
}
|
|
22
|
-
logCardClick(s) {
|
|
23
|
-
N.error("Must be implemented in a subclass");
|
|
24
|
-
}
|
|
25
|
-
sr() {
|
|
26
|
-
N.error("Must be implemented in a subclass");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
(rr.dr = 6e4), (rr.Ih = 500), (rr.Ro = 1e4);
|