@braze/web-sdk 4.10.1 → 5.0.1
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 +26 -111
- 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/indexed-db-adapter.js +352 -1
- package/shared-lib/logger.js +38 -1
- package/shared-lib/supported-options.js +26 -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/captioned-image.js +33 -1
- package/src/Card/models/card.js +197 -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 +31 -1
- package/src/Card/models/index.js +5 -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 +7 -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 +10 -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 +243 -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 +29 -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 +322 -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 +426 -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 +13 -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 +80 -1
- package/src/util/validation-utils.js +217 -1
- package/src/util/window-utils.js +34 -1
- package/src/Card/models/banner.js +0 -1
- package/src/ContentCards/log-content-cards-displayed.js +0 -1
|
@@ -1 +1,352 @@
|
|
|
1
|
-
export default class Oe
|
|
1
|
+
export default class Oe {
|
|
2
|
+
constructor(t, e) {
|
|
3
|
+
(this.database = t),
|
|
4
|
+
(this.j = e),
|
|
5
|
+
(this.parent = "undefined" == typeof window ? self : window),
|
|
6
|
+
(this.database = t),
|
|
7
|
+
(this.j = e);
|
|
8
|
+
}
|
|
9
|
+
td() {
|
|
10
|
+
if ("indexedDB" in this.parent) return this.parent.indexedDB;
|
|
11
|
+
}
|
|
12
|
+
isSupported() {
|
|
13
|
+
var t;
|
|
14
|
+
try {
|
|
15
|
+
if (null == this.td()) return !1;
|
|
16
|
+
{
|
|
17
|
+
const e =
|
|
18
|
+
null === (t = this.td()) || void 0 === t
|
|
19
|
+
? void 0
|
|
20
|
+
: t.open("Braze IndexedDB Support Test");
|
|
21
|
+
if (
|
|
22
|
+
(e &&
|
|
23
|
+
((e.onupgradeneeded = () => e.result.close()),
|
|
24
|
+
(e.onsuccess = () => e.result.close())),
|
|
25
|
+
"undefined" != typeof window)
|
|
26
|
+
) {
|
|
27
|
+
const t = window,
|
|
28
|
+
e = t.chrome || t.browser || t.ed;
|
|
29
|
+
if (e && e.runtime && e.runtime.id)
|
|
30
|
+
return (
|
|
31
|
+
this.j.info(
|
|
32
|
+
"Not using IndexedDB for storage because we are running inside an extension",
|
|
33
|
+
),
|
|
34
|
+
!1
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return !0;
|
|
38
|
+
}
|
|
39
|
+
} catch (t) {
|
|
40
|
+
return (
|
|
41
|
+
this.j.info(
|
|
42
|
+
"Not using IndexedDB for storage due to following error: " + t,
|
|
43
|
+
),
|
|
44
|
+
!1
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
nd(t, e) {
|
|
49
|
+
var n;
|
|
50
|
+
const o =
|
|
51
|
+
null === (n = this.td()) || void 0 === n
|
|
52
|
+
? void 0
|
|
53
|
+
: n.open(this.database.od, this.database.VERSION);
|
|
54
|
+
if (null == o) return "function" == typeof e && e(), !1;
|
|
55
|
+
const i = this;
|
|
56
|
+
return (
|
|
57
|
+
(o.onupgradeneeded = (t) => {
|
|
58
|
+
var e;
|
|
59
|
+
i.j.info(
|
|
60
|
+
"Upgrading indexedDB " +
|
|
61
|
+
i.database.od +
|
|
62
|
+
" to v" +
|
|
63
|
+
i.database.VERSION +
|
|
64
|
+
"...",
|
|
65
|
+
);
|
|
66
|
+
const n = null === (e = t.target) || void 0 === e ? void 0 : e.result;
|
|
67
|
+
for (const t in i.database.rs) {
|
|
68
|
+
const e = t;
|
|
69
|
+
i.database.rs.hasOwnProperty(t) &&
|
|
70
|
+
!n.objectStoreNames.contains(i.database.rs[e]) &&
|
|
71
|
+
n.createObjectStore(i.database.rs[e]);
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
(o.onsuccess = (n) => {
|
|
75
|
+
var o;
|
|
76
|
+
const r = null === (o = n.target) || void 0 === o ? void 0 : o.result;
|
|
77
|
+
(r.onversionchange = () => {
|
|
78
|
+
r.close(),
|
|
79
|
+
"function" == typeof e && e(),
|
|
80
|
+
i.j.error(
|
|
81
|
+
"Needed to close the database unexpectedly because of an upgrade in another tab",
|
|
82
|
+
);
|
|
83
|
+
}),
|
|
84
|
+
t(r);
|
|
85
|
+
}),
|
|
86
|
+
(o.onerror = (t) => {
|
|
87
|
+
var n;
|
|
88
|
+
const o = t;
|
|
89
|
+
return (
|
|
90
|
+
i.j.info(
|
|
91
|
+
"Could not open indexedDB " +
|
|
92
|
+
i.database.od +
|
|
93
|
+
" v" +
|
|
94
|
+
i.database.VERSION +
|
|
95
|
+
": " +
|
|
96
|
+
(null === (n = o.target) || void 0 === n ? void 0 : n.errorCode),
|
|
97
|
+
),
|
|
98
|
+
"function" == typeof e && e(),
|
|
99
|
+
!0
|
|
100
|
+
);
|
|
101
|
+
}),
|
|
102
|
+
!0
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
setItem(t, e, n, o, i) {
|
|
106
|
+
if (!this.isSupported()) return "function" == typeof i && i(), !1;
|
|
107
|
+
const r = this;
|
|
108
|
+
return this.nd((d) => {
|
|
109
|
+
if (!d.objectStoreNames.contains(t))
|
|
110
|
+
return (
|
|
111
|
+
r.j.error(
|
|
112
|
+
"Could not store object " +
|
|
113
|
+
e +
|
|
114
|
+
" in " +
|
|
115
|
+
t +
|
|
116
|
+
" on indexedDB " +
|
|
117
|
+
r.database.od +
|
|
118
|
+
" - " +
|
|
119
|
+
t +
|
|
120
|
+
" is not a valid objectStore",
|
|
121
|
+
),
|
|
122
|
+
"function" == typeof i && i(),
|
|
123
|
+
void d.close()
|
|
124
|
+
);
|
|
125
|
+
const s = d.transaction([t], "readwrite");
|
|
126
|
+
s.oncomplete = () => d.close();
|
|
127
|
+
const u = s.objectStore(t).put(n, e);
|
|
128
|
+
(u.onerror = () => {
|
|
129
|
+
r.j.error(
|
|
130
|
+
"Could not store object " +
|
|
131
|
+
e +
|
|
132
|
+
" in " +
|
|
133
|
+
t +
|
|
134
|
+
" on indexedDB " +
|
|
135
|
+
r.database.od,
|
|
136
|
+
),
|
|
137
|
+
"function" == typeof i && i();
|
|
138
|
+
}),
|
|
139
|
+
(u.onsuccess = () => {
|
|
140
|
+
"function" == typeof o && o();
|
|
141
|
+
});
|
|
142
|
+
}, i);
|
|
143
|
+
}
|
|
144
|
+
getItem(t, e, n) {
|
|
145
|
+
if (!this.isSupported()) return !1;
|
|
146
|
+
const o = this;
|
|
147
|
+
return this.nd((i) => {
|
|
148
|
+
if (!i.objectStoreNames.contains(t))
|
|
149
|
+
return (
|
|
150
|
+
o.j.error(
|
|
151
|
+
"Could not retrieve object " +
|
|
152
|
+
e +
|
|
153
|
+
" in " +
|
|
154
|
+
t +
|
|
155
|
+
" on indexedDB " +
|
|
156
|
+
o.database.od +
|
|
157
|
+
" - " +
|
|
158
|
+
t +
|
|
159
|
+
" is not a valid objectStore",
|
|
160
|
+
),
|
|
161
|
+
void i.close()
|
|
162
|
+
);
|
|
163
|
+
const r = i.transaction([t], "readonly");
|
|
164
|
+
r.oncomplete = () => i.close();
|
|
165
|
+
const d = r.objectStore(t).get(e);
|
|
166
|
+
(d.onerror = () => {
|
|
167
|
+
o.j.error(
|
|
168
|
+
"Could not retrieve object " +
|
|
169
|
+
e +
|
|
170
|
+
" in " +
|
|
171
|
+
t +
|
|
172
|
+
" on indexedDB " +
|
|
173
|
+
o.database.od,
|
|
174
|
+
);
|
|
175
|
+
}),
|
|
176
|
+
(d.onsuccess = (t) => {
|
|
177
|
+
var e;
|
|
178
|
+
const o = null === (e = t.target) || void 0 === e ? void 0 : e.result;
|
|
179
|
+
null != o && n(o);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
hr(t, e, n) {
|
|
184
|
+
if (!this.isSupported()) return "function" == typeof n && n(), !1;
|
|
185
|
+
const o = this;
|
|
186
|
+
return this.nd((i) => {
|
|
187
|
+
if (!i.objectStoreNames.contains(t))
|
|
188
|
+
return (
|
|
189
|
+
o.j.error(
|
|
190
|
+
"Could not retrieve last record from " +
|
|
191
|
+
t +
|
|
192
|
+
" on indexedDB " +
|
|
193
|
+
o.database.od +
|
|
194
|
+
" - " +
|
|
195
|
+
t +
|
|
196
|
+
" is not a valid objectStore",
|
|
197
|
+
),
|
|
198
|
+
"function" == typeof n && n(),
|
|
199
|
+
void i.close()
|
|
200
|
+
);
|
|
201
|
+
const r = i.transaction([t], "readonly");
|
|
202
|
+
r.oncomplete = () => i.close();
|
|
203
|
+
const d = r.objectStore(t).openCursor(null, "prev");
|
|
204
|
+
(d.onerror = () => {
|
|
205
|
+
o.j.error(
|
|
206
|
+
"Could not open cursor for " + t + " on indexedDB " + o.database.od,
|
|
207
|
+
),
|
|
208
|
+
"function" == typeof n && n();
|
|
209
|
+
}),
|
|
210
|
+
(d.onsuccess = (t) => {
|
|
211
|
+
var o;
|
|
212
|
+
const i = null === (o = t.target) || void 0 === o ? void 0 : o.result;
|
|
213
|
+
null != i && null != i.value && null != i.key
|
|
214
|
+
? e(i.key, i.value)
|
|
215
|
+
: "function" == typeof n && n();
|
|
216
|
+
});
|
|
217
|
+
}, n);
|
|
218
|
+
}
|
|
219
|
+
oe(t, e) {
|
|
220
|
+
if (!this.isSupported()) return !1;
|
|
221
|
+
const n = this;
|
|
222
|
+
return this.nd((o) => {
|
|
223
|
+
if (!o.objectStoreNames.contains(t))
|
|
224
|
+
return (
|
|
225
|
+
n.j.error(
|
|
226
|
+
"Could not delete record " +
|
|
227
|
+
e +
|
|
228
|
+
" from " +
|
|
229
|
+
t +
|
|
230
|
+
" on indexedDB " +
|
|
231
|
+
n.database.od +
|
|
232
|
+
" - " +
|
|
233
|
+
t +
|
|
234
|
+
" is not a valid objectStore",
|
|
235
|
+
),
|
|
236
|
+
void o.close()
|
|
237
|
+
);
|
|
238
|
+
const i = o.transaction([t], "readwrite");
|
|
239
|
+
i.oncomplete = () => o.close();
|
|
240
|
+
i.objectStore(t).delete(e).onerror = () => {
|
|
241
|
+
n.j.error(
|
|
242
|
+
"Could not delete record " +
|
|
243
|
+
e +
|
|
244
|
+
" from " +
|
|
245
|
+
t +
|
|
246
|
+
" on indexedDB " +
|
|
247
|
+
n.database.od,
|
|
248
|
+
);
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
ss(t, e) {
|
|
253
|
+
if (!this.isSupported()) return !1;
|
|
254
|
+
const n = this;
|
|
255
|
+
return this.nd((o) => {
|
|
256
|
+
if (!o.objectStoreNames.contains(t))
|
|
257
|
+
return (
|
|
258
|
+
n.j.error(
|
|
259
|
+
"Could not retrieve objects from " +
|
|
260
|
+
t +
|
|
261
|
+
" on indexedDB " +
|
|
262
|
+
n.database.od +
|
|
263
|
+
" - " +
|
|
264
|
+
t +
|
|
265
|
+
" is not a valid objectStore",
|
|
266
|
+
),
|
|
267
|
+
void o.close()
|
|
268
|
+
);
|
|
269
|
+
const i = o.transaction([t], "readwrite");
|
|
270
|
+
i.oncomplete = () => o.close();
|
|
271
|
+
const r = i.objectStore(t),
|
|
272
|
+
d = r.openCursor(),
|
|
273
|
+
s = [];
|
|
274
|
+
(d.onerror = () => {
|
|
275
|
+
s.length > 0
|
|
276
|
+
? (n.j.info(
|
|
277
|
+
"Cursor closed midway through for " +
|
|
278
|
+
t +
|
|
279
|
+
" on indexedDB " +
|
|
280
|
+
n.database.od,
|
|
281
|
+
),
|
|
282
|
+
e(s))
|
|
283
|
+
: n.j.error(
|
|
284
|
+
"Could not open cursor for " +
|
|
285
|
+
t +
|
|
286
|
+
" on indexedDB " +
|
|
287
|
+
n.database.od,
|
|
288
|
+
);
|
|
289
|
+
}),
|
|
290
|
+
(d.onsuccess = (t) => {
|
|
291
|
+
var n;
|
|
292
|
+
const o = null === (n = t.target) || void 0 === n ? void 0 : n.result;
|
|
293
|
+
if (null != o) {
|
|
294
|
+
if (null != o.value && null != o.key) {
|
|
295
|
+
r.delete(o.key).onsuccess = () => {
|
|
296
|
+
s.push(o.value);
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
"function" == typeof o.continue && o.continue();
|
|
300
|
+
} else s.length > 0 && e(s);
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
clearData() {
|
|
305
|
+
if (!this.isSupported()) return !1;
|
|
306
|
+
const t = [];
|
|
307
|
+
for (const e in this.database.rs) {
|
|
308
|
+
const n = e;
|
|
309
|
+
this.database.rs.hasOwnProperty(e) &&
|
|
310
|
+
this.database.rs[n] !== this.database.rs.se &&
|
|
311
|
+
t.push(this.database.rs[n]);
|
|
312
|
+
}
|
|
313
|
+
const e = this;
|
|
314
|
+
return this.nd(function (n) {
|
|
315
|
+
const o = n.transaction(t, "readwrite");
|
|
316
|
+
o.oncomplete = () => n.close();
|
|
317
|
+
for (let n = 0; n < t.length; n++) {
|
|
318
|
+
const i = t[n];
|
|
319
|
+
o.objectStore(i).clear().onerror = function () {
|
|
320
|
+
e.j.error(
|
|
321
|
+
"Could not clear " +
|
|
322
|
+
this.source.name +
|
|
323
|
+
" on indexedDB " +
|
|
324
|
+
e.database.od,
|
|
325
|
+
);
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
o.onerror = function () {
|
|
329
|
+
e.j.error(
|
|
330
|
+
"Could not clear object stores on indexedDB " + e.database.od,
|
|
331
|
+
);
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
Oe.ep = {
|
|
337
|
+
Zt: {
|
|
338
|
+
od: "AppboyServiceWorkerAsyncStorage",
|
|
339
|
+
VERSION: 6,
|
|
340
|
+
rs: {
|
|
341
|
+
Na: "data",
|
|
342
|
+
kr: "pushClicks",
|
|
343
|
+
cu: "pushSubscribed",
|
|
344
|
+
dd: "fallbackDevice",
|
|
345
|
+
hs: "cardUpdates",
|
|
346
|
+
se: "optOut",
|
|
347
|
+
wr: "pendingData",
|
|
348
|
+
qh: "sdkAuthenticationSignature",
|
|
349
|
+
},
|
|
350
|
+
ie: 1,
|
|
351
|
+
},
|
|
352
|
+
};
|
package/shared-lib/logger.js
CHANGED
|
@@ -1 +1,38 @@
|
|
|
1
|
-
const Ue
|
|
1
|
+
const Ue = {
|
|
2
|
+
init: function (n) {
|
|
3
|
+
(void 0 === n && void 0 !== Ue.zg) || (Ue.zg = !!n), Ue.t || (Ue.t = !0);
|
|
4
|
+
},
|
|
5
|
+
destroy: function () {
|
|
6
|
+
(Ue.t = !1), (Ue.zg = void 0), (Ue.j = void 0);
|
|
7
|
+
},
|
|
8
|
+
setLogger: function (n) {
|
|
9
|
+
"function" == typeof n
|
|
10
|
+
? (Ue.init(), (Ue.j = n))
|
|
11
|
+
: Ue.info("Ignoring setLogger call since logger is not a function");
|
|
12
|
+
},
|
|
13
|
+
toggleLogging: function () {
|
|
14
|
+
Ue.init(),
|
|
15
|
+
Ue.zg
|
|
16
|
+
? (console.log("Disabling Braze logging"), (Ue.zg = !1))
|
|
17
|
+
: (console.log("Enabled Braze logging"), (Ue.zg = !0));
|
|
18
|
+
},
|
|
19
|
+
info: function (n) {
|
|
20
|
+
if (Ue.zg) {
|
|
21
|
+
const o = "Braze: " + n;
|
|
22
|
+
null != Ue.j ? Ue.j(o) : console.log(o);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
warn: function (n) {
|
|
26
|
+
if (Ue.zg) {
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v5.0.1)";
|
|
28
|
+
null != Ue.j ? Ue.j(o) : console.warn(o);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
error: function (n) {
|
|
32
|
+
if (Ue.zg) {
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v5.0.1)";
|
|
34
|
+
null != Ue.j ? Ue.j(o) : console.error(o);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
export default Ue;
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
export default{
|
|
1
|
+
export default {
|
|
2
|
+
ho: "allowCrawlerActivity",
|
|
3
|
+
_o: "baseUrl",
|
|
4
|
+
Eo: "noCookies",
|
|
5
|
+
Io: "devicePropertyAllowlist",
|
|
6
|
+
Aa: "disablePushTokenMaintenance",
|
|
7
|
+
Ao: "enableLogging",
|
|
8
|
+
So: "enableSdkAuthentication",
|
|
9
|
+
qa: "manageServiceWorkerExternally",
|
|
10
|
+
No: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
11
|
+
Oo: "sessionTimeoutInSeconds",
|
|
12
|
+
wo: "appVersion",
|
|
13
|
+
Po: "appVersionNumber",
|
|
14
|
+
_a: "serviceWorkerLocation",
|
|
15
|
+
ka: "safariWebsitePushId",
|
|
16
|
+
Ba: "localization",
|
|
17
|
+
po: "contentSecurityNonce",
|
|
18
|
+
Ro: "allowUserSuppliedJavascript",
|
|
19
|
+
lo: "inAppMessageZIndex",
|
|
20
|
+
fo: "openInAppMessagesInNewTab",
|
|
21
|
+
en: "openNewsFeedCardsInNewTab",
|
|
22
|
+
mh: "requireExplicitInAppMessageDismissal",
|
|
23
|
+
Co: "doNotLoadFontAwesome",
|
|
24
|
+
Lo: "sdkFlavor",
|
|
25
|
+
tn: "openCardsInNewTab",
|
|
26
|
+
};
|
package/shared-lib/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export {};
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import a from"./card-manager.js";
|
|
1
|
+
import a from "./card-manager.js";
|
|
2
|
+
import e from "../managers/braze-instance.js";
|
|
3
|
+
const n = {
|
|
4
|
+
t: !1,
|
|
5
|
+
i: null,
|
|
6
|
+
m: () => (n.o(), n.i || (n.i = new a(e.l())), n.i),
|
|
7
|
+
o: () => {
|
|
8
|
+
n.t || (e.g(n), (n.t = !0));
|
|
9
|
+
},
|
|
10
|
+
destroy: () => {
|
|
11
|
+
(n.i = null), (n.t = !1);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default n;
|
package/src/Card/card-manager.js
CHANGED
|
@@ -1 +1,78 @@
|
|
|
1
|
-
import{ControlCard}from"./models/index.js";
|
|
1
|
+
import { ControlCard } from "./models/index.js";
|
|
2
|
+
import s from "../common/event-logger.js";
|
|
3
|
+
import t from "../models/request-result.js";
|
|
4
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
5
|
+
import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
|
|
6
|
+
export default class a {
|
|
7
|
+
constructor(s) {
|
|
8
|
+
(this.u = s), (this.u = s);
|
|
9
|
+
}
|
|
10
|
+
h(n, o) {
|
|
11
|
+
const e = new t();
|
|
12
|
+
if ((n.p(), null == n.url || "" === n.url))
|
|
13
|
+
return (
|
|
14
|
+
r.j.info(
|
|
15
|
+
`Card ${n.id} has no url. Not logging click to Braze servers.`,
|
|
16
|
+
),
|
|
17
|
+
e
|
|
18
|
+
);
|
|
19
|
+
if (o && n.id && this.u) {
|
|
20
|
+
const s = this.u.v(i.k.C) || {};
|
|
21
|
+
(s[n.id] = !0), this.u.D(i.k.C, s);
|
|
22
|
+
}
|
|
23
|
+
const l = this.I([n]);
|
|
24
|
+
if (null == l) return e;
|
|
25
|
+
const u = o ? r.q.$ : r.q.B;
|
|
26
|
+
return s.N(u, l);
|
|
27
|
+
}
|
|
28
|
+
A(n) {
|
|
29
|
+
const o = new t();
|
|
30
|
+
if (!n.F())
|
|
31
|
+
return (
|
|
32
|
+
r.j.info(
|
|
33
|
+
`Card ${n.id} refused this dismissal. Ignoring analytics event.`,
|
|
34
|
+
),
|
|
35
|
+
o
|
|
36
|
+
);
|
|
37
|
+
if (n.id && this.u) {
|
|
38
|
+
const s = this.u.v(i.k.G) || {};
|
|
39
|
+
(s[n.id] = !0), this.u.D(i.k.G, s);
|
|
40
|
+
}
|
|
41
|
+
const e = this.I([n]);
|
|
42
|
+
return null == e ? o : s.N(r.q.H, e);
|
|
43
|
+
}
|
|
44
|
+
J(n, o) {
|
|
45
|
+
const e = new t(!0),
|
|
46
|
+
l = [],
|
|
47
|
+
u = [];
|
|
48
|
+
let a = {};
|
|
49
|
+
this.u && (a = o ? this.u.v(i.k.K) || {} : this.u.v(i.k.L) || {});
|
|
50
|
+
for (const s of n)
|
|
51
|
+
s.M(),
|
|
52
|
+
s instanceof ControlCard ? u.push(s) : l.push(s),
|
|
53
|
+
s.id && (a[s.id] = !0);
|
|
54
|
+
const h = this.I(l),
|
|
55
|
+
c = this.I(u);
|
|
56
|
+
if (null == h && null == c) return (e.O = !1), e;
|
|
57
|
+
if ((this.u && (o ? this.u.D(i.k.K, a) : this.u.D(i.k.L, a)), null != h)) {
|
|
58
|
+
const t = o ? r.q.P : r.q.R,
|
|
59
|
+
n = s.N(t, h);
|
|
60
|
+
e.S(n);
|
|
61
|
+
}
|
|
62
|
+
if (null != c && o) {
|
|
63
|
+
const t = s.N(r.q.T, c);
|
|
64
|
+
e.S(t);
|
|
65
|
+
}
|
|
66
|
+
return e;
|
|
67
|
+
}
|
|
68
|
+
I(s) {
|
|
69
|
+
let t,
|
|
70
|
+
r = null;
|
|
71
|
+
for (let n = 0; n < s.length; n++)
|
|
72
|
+
(t = s[n].id),
|
|
73
|
+
null != t &&
|
|
74
|
+
"" !== t &&
|
|
75
|
+
((r = r || {}), (r.ids = r.ids || []), r.ids.push(t));
|
|
76
|
+
return r;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1 +1,138 @@
|
|
|
1
|
-
import{createCloseButton as o}from"../../util/component-utils.js";
|
|
1
|
+
import { createCloseButton as o } from "../../util/component-utils.js";
|
|
2
|
+
import { detectSwipe as d, DIRECTIONS as c } from "../../util/dom-utils.js";
|
|
3
|
+
import { _handleBrazeAction as m } from "../../Core/handle-braze-action.js";
|
|
4
|
+
import { logCardDismissal } from "../index.js";
|
|
5
|
+
import r from "../../../shared-lib/braze-shared-lib.js";
|
|
6
|
+
export const TOP_IMPRESSION_DATA_ATTRIBUTE = "data-ab-had-top-impression";
|
|
7
|
+
export const BOTTOM_IMPRESSION_DATA_ATTRIBUTE = "data-ab-had-bottom-impression";
|
|
8
|
+
export function topHadImpression(t) {
|
|
9
|
+
return null != t && !!t.getAttribute("data-ab-had-top-impression");
|
|
10
|
+
}
|
|
11
|
+
export function impressOnTop(t) {
|
|
12
|
+
null != t && t.setAttribute("data-ab-had-top-impression", "true");
|
|
13
|
+
}
|
|
14
|
+
export function bottomHadImpression(t) {
|
|
15
|
+
return null != t && !!t.getAttribute("data-ab-had-bottom-impression");
|
|
16
|
+
}
|
|
17
|
+
export function impressOnBottom(t) {
|
|
18
|
+
null != t && t.setAttribute("data-ab-had-bottom-impression", "true");
|
|
19
|
+
}
|
|
20
|
+
export function markCardAsRead(t) {
|
|
21
|
+
if (null != t) {
|
|
22
|
+
const o = t.querySelectorAll(".ab-unread-indicator")[0];
|
|
23
|
+
null != o && (o.className += " read");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function getCardId(t) {
|
|
27
|
+
return t.getAttribute("data-ab-card-id");
|
|
28
|
+
}
|
|
29
|
+
export function _setImageAltText(t, o) {
|
|
30
|
+
let e = "";
|
|
31
|
+
t.title || t.description || (e = "Feed Image"), o.setAttribute("alt", e);
|
|
32
|
+
}
|
|
33
|
+
export function setCardHeight(t, o) {
|
|
34
|
+
const e = o.querySelectorAll(".ab-image-area");
|
|
35
|
+
let a,
|
|
36
|
+
n = 0;
|
|
37
|
+
e.length > 0 && (n = e[0].offsetWidth);
|
|
38
|
+
for (const o of t)
|
|
39
|
+
if (((a = o._), a && o.imageUrl && "number" == typeof o.aspectRatio)) {
|
|
40
|
+
const t = n / o.aspectRatio;
|
|
41
|
+
t && (a.style.height = `${t}px`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function cardToHtml(t, logCardClick, e) {
|
|
45
|
+
const a = document.createElement("div");
|
|
46
|
+
(a.className = "ab-card ab-effect-card " + t.U),
|
|
47
|
+
t.id &&
|
|
48
|
+
(a.setAttribute("data-ab-card-id", t.id), a.setAttribute("id", t.id)),
|
|
49
|
+
a.setAttribute("role", "article"),
|
|
50
|
+
a.setAttribute("tabindex", "0");
|
|
51
|
+
let n = "",
|
|
52
|
+
i = !1;
|
|
53
|
+
t.url && "" !== t.url && ((n = t.url), (i = !0));
|
|
54
|
+
const s = (o) => (markCardAsRead(a), i && (logCardClick(t), m(n, e, o)), !1);
|
|
55
|
+
if (t.pinned) {
|
|
56
|
+
const t = document.createElement("div");
|
|
57
|
+
t.className = "ab-pinned-indicator";
|
|
58
|
+
const o = document.createElement("i");
|
|
59
|
+
(o.className = "fa fa-star"), t.appendChild(o), a.appendChild(t);
|
|
60
|
+
}
|
|
61
|
+
if (t.imageUrl && "" !== t.imageUrl) {
|
|
62
|
+
const o = document.createElement("div");
|
|
63
|
+
o.className = "ab-image-area";
|
|
64
|
+
const e = document.createElement("img");
|
|
65
|
+
if (
|
|
66
|
+
(e.setAttribute("src", t.imageUrl),
|
|
67
|
+
(e.onload = () => {
|
|
68
|
+
a.style.height = "auto";
|
|
69
|
+
}),
|
|
70
|
+
_setImageAltText(t, e),
|
|
71
|
+
o.appendChild(e),
|
|
72
|
+
(a.className += " with-image"),
|
|
73
|
+
i && !t.V)
|
|
74
|
+
) {
|
|
75
|
+
const t = document.createElement("a");
|
|
76
|
+
t.setAttribute("href", n),
|
|
77
|
+
(t.onclick = s),
|
|
78
|
+
t.appendChild(o),
|
|
79
|
+
a.appendChild(t);
|
|
80
|
+
} else a.appendChild(o);
|
|
81
|
+
}
|
|
82
|
+
const u = document.createElement("div");
|
|
83
|
+
if (((u.className = "ab-card-body"), t.dismissible)) {
|
|
84
|
+
t.logCardDismissal = () => logCardDismissal(t);
|
|
85
|
+
const e = o("Dismiss Card", void 0, t.dismissCard.bind(t));
|
|
86
|
+
a.appendChild(e),
|
|
87
|
+
d(u, c.W, (t) => {
|
|
88
|
+
(a.className += " ab-swiped-left"), e.onclick(t);
|
|
89
|
+
}),
|
|
90
|
+
d(u, c.X, (t) => {
|
|
91
|
+
(a.className += " ab-swiped-right"), e.onclick(t);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
let p = "",
|
|
95
|
+
b = !1;
|
|
96
|
+
if ((t.title && "" !== t.title && ((p = t.title), (b = !0)), b)) {
|
|
97
|
+
const t = document.createElement("h1");
|
|
98
|
+
if (
|
|
99
|
+
((t.className = "ab-title"),
|
|
100
|
+
(t.id = r.Z.Y()),
|
|
101
|
+
a.setAttribute("aria-labelledby", t.id),
|
|
102
|
+
i)
|
|
103
|
+
) {
|
|
104
|
+
const o = document.createElement("a");
|
|
105
|
+
o.setAttribute("href", n),
|
|
106
|
+
(o.onclick = s),
|
|
107
|
+
o.appendChild(document.createTextNode(p)),
|
|
108
|
+
t.appendChild(o);
|
|
109
|
+
} else t.appendChild(document.createTextNode(p));
|
|
110
|
+
u.appendChild(t);
|
|
111
|
+
}
|
|
112
|
+
const l = document.createElement("div");
|
|
113
|
+
if (
|
|
114
|
+
((l.className = b ? "ab-description" : "ab-description ab-no-title"),
|
|
115
|
+
(l.id = r.Z.Y()),
|
|
116
|
+
a.setAttribute("aria-describedby", l.id),
|
|
117
|
+
t.description && l.appendChild(document.createTextNode(t.description)),
|
|
118
|
+
i)
|
|
119
|
+
) {
|
|
120
|
+
const o = document.createElement("div");
|
|
121
|
+
o.className = "ab-url-area";
|
|
122
|
+
const e = document.createElement("a");
|
|
123
|
+
e.setAttribute("href", n),
|
|
124
|
+
t.linkText && e.appendChild(document.createTextNode(t.linkText)),
|
|
125
|
+
(e.onclick = s),
|
|
126
|
+
o.appendChild(e),
|
|
127
|
+
l.appendChild(o);
|
|
128
|
+
}
|
|
129
|
+
u.appendChild(l), a.appendChild(u);
|
|
130
|
+
const f = document.createElement("div");
|
|
131
|
+
return (
|
|
132
|
+
(f.className = "ab-unread-indicator"),
|
|
133
|
+
t.viewed && (f.className += " read"),
|
|
134
|
+
a.appendChild(f),
|
|
135
|
+
(t._ = a),
|
|
136
|
+
a
|
|
137
|
+
);
|
|
138
|
+
}
|