@braze/web-sdk 6.0.0 → 6.2.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 +103 -33
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +22 -22
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +19 -19
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +15 -15
- 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 +9 -9
- package/src/Banner/display/destroy-banner-html.js +2 -2
- package/src/Banner/display/detect-banner-impressions.js +2 -2
- package/src/Banner/get-all-banners.js +5 -5
- package/src/Banner/get-banner.js +7 -7
- 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 +16 -20
- package/src/Banner/subscribe-to-banners-updates.js +7 -7
- package/src/Banner/ui/insert-banner.js +6 -6
- package/src/Card/card-manager-factory.js +7 -7
- package/src/Card/card-manager.js +35 -35
- package/src/Card/display/card-display.js +11 -11
- package/src/Card/log-card-dismissal.js +4 -4
- package/src/Card/log-content-card-click.js +4 -4
- package/src/Card/log-content-card-impressions.js +6 -6
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +68 -68
- package/src/Card/models/classic-card.js +21 -21
- package/src/Card/models/control-card.js +11 -11
- package/src/Card/models/image-only.js +18 -18
- package/src/Card/util/card-factory.js +35 -35
- package/src/ContentCards/content-cards-provider-factory.js +13 -13
- package/src/ContentCards/content-cards-provider.js +136 -136
- 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 +6 -6
- package/src/ContentCards/ui/show-content-cards.js +7 -7
- package/src/Core/add-sdk-metadata.js +3 -3
- package/src/Core/change-user.js +7 -7
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +8 -8
- package/src/Core/enable-sdk.js +6 -6
- package/src/Core/get-device-id.js +4 -4
- package/src/Core/handle-braze-action.js +5 -5
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +10 -10
- package/src/Core/log-purchase.js +13 -13
- package/src/Core/open-session.js +10 -10
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +7 -7
- 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 +12 -12
- package/src/FeatureFlags/feature-flags-provider.js +87 -87
- package/src/FeatureFlags/get-all-feature-flags.js +4 -4
- package/src/FeatureFlags/get-feature-flag.js +4 -4
- package/src/FeatureFlags/log-feature-flag-impression.js +9 -9
- package/src/FeatureFlags/refresh-feature-flags.js +2 -2
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -4
- package/src/InAppMessage/defer-in-app-message.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +10 -10
- package/src/InAppMessage/display/in-app-message-to-html.js +28 -28
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/in-app-message-factory.js +15 -15
- package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
- package/src/InAppMessage/in-app-message-manager.js +100 -100
- package/src/InAppMessage/log-in-app-message-button-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-click.js +6 -6
- package/src/InAppMessage/log-in-app-message-html-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-impression.js +4 -4
- package/src/InAppMessage/models/control-message.js +4 -4
- package/src/InAppMessage/models/full-screen-message.js +35 -35
- package/src/InAppMessage/models/html-message.js +21 -21
- package/src/InAppMessage/models/in-app-message-button.js +5 -5
- package/src/InAppMessage/models/in-app-message.js +75 -75
- package/src/InAppMessage/models/modal-message.js +34 -34
- package/src/InAppMessage/models/slide-up-message.js +31 -31
- 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 +19 -19
- package/src/Push/push-manager-factory.js +9 -9
- package/src/Push/push-manager.js +118 -118
- package/src/Push/utils/push-utils.js +9 -9
- package/src/User/user-manager.js +20 -20
- package/src/User/user.js +44 -45
- package/src/common/base-provider.js +1 -1
- package/src/common/content-cards-display.js +18 -18
- package/src/common/event-logger.js +10 -10
- package/src/common/properties-base.js +56 -0
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +143 -143
- package/src/managers/device-manager.js +22 -22
- package/src/managers/network-manager.js +172 -168
- package/src/managers/server-config-manager.js +73 -73
- package/src/managers/session-manager.js +40 -40
- package/src/managers/storage-manager-factory.js +6 -6
- package/src/managers/storage-manager.js +97 -97
- 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 +5 -5
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +12 -12
- package/src/models/push-token.js +13 -13
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +31 -31
- package/src/request-controller.js +159 -159
- package/src/triggers/models/custom-event-data.js +1 -1
- package/src/triggers/models/custom-event-property-data.js +2 -2
- package/src/triggers/models/filter-set.js +6 -6
- package/src/triggers/models/filter.js +26 -26
- package/src/triggers/models/in-app-message-click-data.js +1 -1
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +2 -2
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +37 -37
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +16 -16
- package/src/triggers/triggers-provider-factory.js +12 -12
- package/src/triggers/triggers-provider.js +61 -61
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +6 -6
- package/src/util/browser-detector.js +22 -13
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/code-utils.js +2 -2
- package/src/util/component-utils.js +1 -1
- package/src/util/deprecation-utils.js +2 -2
- package/src/util/device-constants.js +4 -4
- package/src/util/dom-utils.js +9 -9
- package/src/util/html-display-utils.js +7 -7
- 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 +16 -16
- package/src/util/validation-utils.js +12 -12
- package/src/util/window-utils.js +2 -2
|
@@ -10,18 +10,18 @@ import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
|
10
10
|
import wt from "../InAppMessage/models/templated-in-app-message.js";
|
|
11
11
|
import pt from "./models/trigger.js";
|
|
12
12
|
import ot from "./models/trigger-events.js";
|
|
13
|
-
import { logger as
|
|
13
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
14
14
|
export default class gr extends t {
|
|
15
15
|
constructor(t, i, s, e, r) {
|
|
16
16
|
super(),
|
|
17
17
|
(this.tg = t),
|
|
18
|
-
(this.
|
|
19
|
-
(this.
|
|
18
|
+
(this.ws = i),
|
|
19
|
+
(this.j = s),
|
|
20
20
|
(this.Cn = e),
|
|
21
21
|
(this.ig = r),
|
|
22
22
|
(this.tg = t),
|
|
23
|
-
(this.
|
|
24
|
-
(this.
|
|
23
|
+
(this.ws = i),
|
|
24
|
+
(this.j = s),
|
|
25
25
|
(this.Cn = e),
|
|
26
26
|
(this.ig = r),
|
|
27
27
|
(this.sg = []),
|
|
@@ -35,10 +35,10 @@ export default class gr extends t {
|
|
|
35
35
|
this.gg();
|
|
36
36
|
}
|
|
37
37
|
fg() {
|
|
38
|
-
if (this.
|
|
39
|
-
(this.hg = this.
|
|
40
|
-
(this.ng = this.
|
|
41
|
-
(this.og = this.
|
|
38
|
+
if (this.j) {
|
|
39
|
+
(this.hg = this.j.lt(s.ct.iE) || this.hg),
|
|
40
|
+
(this.ng = this.j.lt(s.ct.EE) || this.ng),
|
|
41
|
+
(this.og = this.j.lt(s.ct.aE) || this.og);
|
|
42
42
|
for (let t = 0; t < this.triggers.length; t++) {
|
|
43
43
|
const i = this.triggers[t];
|
|
44
44
|
i.id && null != this.og[i.id] && i.ad(this.og[i.id]);
|
|
@@ -46,11 +46,11 @@ export default class gr extends t {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
ag() {
|
|
49
|
-
if (!this.
|
|
50
|
-
this.lg = this.
|
|
51
|
-
const t = this.
|
|
49
|
+
if (!this.j) return;
|
|
50
|
+
this.lg = this.j.lt(s.ct.nE) || 0;
|
|
51
|
+
const t = this.j.lt(s.ct.oE) || [],
|
|
52
52
|
i = [];
|
|
53
|
-
for (let s = 0; s < t.length; s++) i.push(pt.
|
|
53
|
+
for (let s = 0; s < t.length; s++) i.push(pt.qn(t[s]));
|
|
54
54
|
(this.triggers = i), this.fg();
|
|
55
55
|
}
|
|
56
56
|
gg() {
|
|
@@ -70,19 +70,19 @@ export default class gr extends t {
|
|
|
70
70
|
h = [];
|
|
71
71
|
for (let r = 0; r < t.length; r++) {
|
|
72
72
|
const n = t[r],
|
|
73
|
-
o = s.ud(n.
|
|
73
|
+
o = s.ud(n.Er || 0);
|
|
74
74
|
if (o > 0) {
|
|
75
75
|
let t, r;
|
|
76
76
|
h.push(n),
|
|
77
77
|
null != n.ug && (t = n.ug),
|
|
78
|
-
null != n.dg && ue.gE(n.dg) && (r = ue.
|
|
78
|
+
null != n.dg && ue.gE(n.dg) && (r = ue.qn(n.dg));
|
|
79
79
|
const l = [];
|
|
80
80
|
if (n.pg && D(n.pg))
|
|
81
81
|
for (let t = 0; t < n.pg.length; t++) {
|
|
82
82
|
const i = e[n.pg[t]];
|
|
83
83
|
null != i && l.push(i);
|
|
84
84
|
}
|
|
85
|
-
this.eg.push(window.setTimeout(i(s, n.
|
|
85
|
+
this.eg.push(window.setTimeout(i(s, n.Er || 0, t, r, l), o));
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
this.ng[s.id].length > h.length &&
|
|
@@ -91,22 +91,22 @@ export default class gr extends t {
|
|
|
91
91
|
0 === this.ng[s.id].length && delete this.ng[s.id]);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
r && this.
|
|
94
|
+
r && this.j && this.j.ft(s.ct.EE, this.ng);
|
|
95
95
|
}
|
|
96
96
|
mg() {
|
|
97
|
-
if (!this.
|
|
97
|
+
if (!this.j) return;
|
|
98
98
|
const t = [];
|
|
99
99
|
for (let i = 0; i < this.triggers.length; i++)
|
|
100
|
-
t.push(this.triggers[i].
|
|
100
|
+
t.push(this.triggers[i].dt());
|
|
101
101
|
(this.lg = new Date().valueOf()),
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
102
|
+
this.j.ft(s.ct.oE, t),
|
|
103
|
+
this.j.ft(s.ct.nE, this.lg);
|
|
104
104
|
}
|
|
105
105
|
bg() {
|
|
106
|
-
if (!this.
|
|
107
|
-
(this.
|
|
106
|
+
if (!this.j) return;
|
|
107
|
+
(this.j.lt(s.ct.nE) || 0) > this.lg ? this.ag() : this.fg();
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
N(t) {
|
|
110
110
|
let i = !1;
|
|
111
111
|
if (null != t && t.triggers) {
|
|
112
112
|
this.ig.Lr(), this.fg();
|
|
@@ -121,26 +121,26 @@ export default class gr extends t {
|
|
|
121
121
|
(h.ad(this.og[h.id]), (e[h.id] = this.og[h.id])),
|
|
122
122
|
h.id && null != this.ng[h.id] && (r[h.id] = this.ng[h.id]);
|
|
123
123
|
for (let t = 0; t < h.sd.length; t++)
|
|
124
|
-
if (h.sd[t].kc(ot.
|
|
124
|
+
if (h.sd[t].kc(ot.qs, null)) {
|
|
125
125
|
i = !0;
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
128
128
|
this.triggers.push(h);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
ii(this.og, e) || ((this.og = e), this.
|
|
131
|
+
ii(this.og, e) || ((this.og = e), this.j && this.j.ft(s.ct.aE, this.og)),
|
|
132
132
|
ii(this.ng, r) ||
|
|
133
|
-
((this.ng = r), this.
|
|
133
|
+
((this.ng = r), this.j && this.j.ft(s.ct.EE, this.ng)),
|
|
134
134
|
this.mg(),
|
|
135
135
|
i &&
|
|
136
|
-
(
|
|
137
|
-
this.
|
|
138
|
-
this.
|
|
136
|
+
(E.info("Trigger with test condition found, firing test."),
|
|
137
|
+
this.ve(ot.qs)),
|
|
138
|
+
this.ve(ot.OPEN);
|
|
139
139
|
const h = this.sg;
|
|
140
140
|
let n;
|
|
141
141
|
this.sg = [];
|
|
142
142
|
for (let t = 0; t < h.length; t++)
|
|
143
|
-
(n = Array.prototype.slice.call(h[t])), this.
|
|
143
|
+
(n = Array.prototype.slice.call(h[t])), this.ve(...n);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
cg(t, i, s, e, r) {
|
|
@@ -148,17 +148,17 @@ export default class gr extends t {
|
|
|
148
148
|
this.fg();
|
|
149
149
|
const r = new Date().valueOf();
|
|
150
150
|
t.dd(i) ||
|
|
151
|
-
(!1 === navigator.onLine && t.type === pt.
|
|
152
|
-
?
|
|
151
|
+
(!1 === navigator.onLine && t.type === pt._r.Br && e.imageUrl
|
|
152
|
+
? E.info(
|
|
153
153
|
`Not showing ${t.type} trigger action ${t.id} due to offline state.`,
|
|
154
154
|
)
|
|
155
155
|
: t.nd(r) && this.wg(t, r, s)
|
|
156
|
-
? 0 === this.
|
|
157
|
-
?
|
|
156
|
+
? 0 === this.ws.sc()
|
|
157
|
+
? E.info(
|
|
158
158
|
`Not displaying trigger ${t.id} because neither automaticallyShowInAppMessages() nor subscribeToInAppMessage() were called.`,
|
|
159
159
|
)
|
|
160
|
-
: (this.
|
|
161
|
-
:
|
|
160
|
+
: (this.ws.L([e]), this.yg(t, r))
|
|
161
|
+
: E.info(
|
|
162
162
|
`Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`,
|
|
163
163
|
));
|
|
164
164
|
},
|
|
@@ -168,9 +168,9 @@ export default class gr extends t {
|
|
|
168
168
|
if (null != h)
|
|
169
169
|
if ((this.Tg(h, i, s, e, r), h.dd(i))) {
|
|
170
170
|
let t = `Server aborted in-app message display, but the timeout on fallback trigger ${h.id} has already elapsed.`;
|
|
171
|
-
r.length > 0 && (t += " Continuing to fall back."),
|
|
171
|
+
r.length > 0 && (t += " Continuing to fall back."), E.info(t), n();
|
|
172
172
|
} else {
|
|
173
|
-
|
|
173
|
+
E.info(
|
|
174
174
|
`Server aborted in-app message display. Falling back to lower priority ${h.type} trigger action ${t.id}.`,
|
|
175
175
|
);
|
|
176
176
|
const n = 1e3 * h.ed - (new Date().valueOf() - i);
|
|
@@ -185,37 +185,37 @@ export default class gr extends t {
|
|
|
185
185
|
};
|
|
186
186
|
let o, l, a;
|
|
187
187
|
switch (t.type) {
|
|
188
|
-
case pt.
|
|
188
|
+
case pt._r.Br:
|
|
189
189
|
if (((o = ut(t.data)), null == o)) {
|
|
190
|
-
|
|
190
|
+
E.error(
|
|
191
191
|
`Could not parse trigger data for trigger ${t.id}, ignoring.`,
|
|
192
192
|
);
|
|
193
193
|
break;
|
|
194
194
|
}
|
|
195
|
-
if (((l = this.ig.
|
|
196
|
-
|
|
195
|
+
if (((l = this.ig.Ki(o)), l)) {
|
|
196
|
+
E.error(l), n();
|
|
197
197
|
break;
|
|
198
198
|
}
|
|
199
199
|
h(o);
|
|
200
200
|
break;
|
|
201
|
-
case pt.
|
|
202
|
-
if (((a = wt.fromJson(t.data, h, n, i, t.
|
|
203
|
-
|
|
201
|
+
case pt._r.md:
|
|
202
|
+
if (((a = wt.fromJson(t.data, h, n, i, t.Gr || 0)), null == a)) {
|
|
203
|
+
E.error(
|
|
204
204
|
`Could not parse trigger data for trigger ${t.id}, ignoring.`,
|
|
205
205
|
);
|
|
206
206
|
break;
|
|
207
207
|
}
|
|
208
|
-
this.ig.
|
|
208
|
+
this.ig.Zi(a, s, e);
|
|
209
209
|
break;
|
|
210
210
|
default:
|
|
211
|
-
|
|
211
|
+
E.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
|
|
214
|
+
ve(t, i = null, s) {
|
|
215
215
|
if (!ta(ot, t, "Cannot fire trigger action.", "TriggerEvents")) return;
|
|
216
|
-
if (this.Cn && this.Cn.
|
|
216
|
+
if (this.Cn && this.Cn.Yl())
|
|
217
217
|
return (
|
|
218
|
-
|
|
218
|
+
E.info(
|
|
219
219
|
"Trigger sync is currently in progress, awaiting sync completion before firing trigger event.",
|
|
220
220
|
),
|
|
221
221
|
void this.sg.push(arguments)
|
|
@@ -244,11 +244,11 @@ export default class gr extends t {
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
if (h)
|
|
247
|
-
return void
|
|
247
|
+
return void E.info(
|
|
248
248
|
`Trigger event ${t} did not match any trigger conditions.`,
|
|
249
249
|
);
|
|
250
250
|
if (n)
|
|
251
|
-
return void
|
|
251
|
+
return void E.info(
|
|
252
252
|
`Ignoring ${t} trigger event because a trigger was displayed ${
|
|
253
253
|
r / 1e3
|
|
254
254
|
}s ago.`,
|
|
@@ -256,7 +256,7 @@ export default class gr extends t {
|
|
|
256
256
|
o.sort((t, i) => t.priority - i.priority);
|
|
257
257
|
const l = o.pop();
|
|
258
258
|
null != l &&
|
|
259
|
-
(
|
|
259
|
+
(E.info(
|
|
260
260
|
`Firing ${l.type} trigger action ${l.id} from trigger event ${t}.`,
|
|
261
261
|
),
|
|
262
262
|
this.Tg(l, e, t, s, o),
|
|
@@ -269,11 +269,11 @@ export default class gr extends t {
|
|
|
269
269
|
));
|
|
270
270
|
}
|
|
271
271
|
changeUser(t = !1) {
|
|
272
|
-
if (((this.triggers = []), this.
|
|
272
|
+
if (((this.triggers = []), this.j && this.j.Nt(s.ct.oE), !t)) {
|
|
273
273
|
(this.sg = []), (this.hg = null), (this.og = {}), (this.ng = {});
|
|
274
274
|
for (let t = 0; t < this.eg.length; t++) clearTimeout(this.eg[t]);
|
|
275
275
|
(this.eg = []),
|
|
276
|
-
this.
|
|
276
|
+
this.j && (this.j.Nt(s.ct.iE), this.j.Nt(s.ct.aE), this.j.Nt(s.ct.EE));
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
clearData() {
|
|
@@ -283,9 +283,9 @@ export default class gr extends t {
|
|
|
283
283
|
}
|
|
284
284
|
wg(t, i, s) {
|
|
285
285
|
if (null == this.hg) return !0;
|
|
286
|
-
if (s === ot.
|
|
286
|
+
if (s === ot.qs)
|
|
287
287
|
return (
|
|
288
|
-
|
|
288
|
+
E.info(
|
|
289
289
|
"Ignoring minimum interval between trigger because it is a test type.",
|
|
290
290
|
),
|
|
291
291
|
!0
|
|
@@ -297,18 +297,18 @@ export default class gr extends t {
|
|
|
297
297
|
this.fg(), t.id && (this.ng[t.id] = this.ng[t.id] || []);
|
|
298
298
|
const n = {};
|
|
299
299
|
let o;
|
|
300
|
-
(n.
|
|
300
|
+
(n.Er = i), (n.ug = e), null != r && (o = r.dt()), (n.dg = o);
|
|
301
301
|
const l = [];
|
|
302
302
|
for (const t of h) t.id && l.push(t.id);
|
|
303
303
|
(n.pg = l),
|
|
304
304
|
t.id && this.ng[t.id].push(n),
|
|
305
|
-
this.
|
|
305
|
+
this.j && this.j.ft(s.ct.EE, this.ng);
|
|
306
306
|
}
|
|
307
307
|
yg(t, i) {
|
|
308
308
|
this.fg(),
|
|
309
309
|
t.ad(i),
|
|
310
310
|
(this.hg = i),
|
|
311
311
|
t.id && (this.og[t.id] = i),
|
|
312
|
-
this.
|
|
312
|
+
this.j && (this.j.ft(s.ct.iE, i), this.j.ft(s.ct.aE, this.og));
|
|
313
313
|
}
|
|
314
314
|
}
|
package/src/ui/js/attach-css.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import r, { OPTIONS as z } from "../../managers/braze-instance.js";
|
|
2
2
|
export function attachCSS(n, t, o) {
|
|
3
3
|
const c = n || document.querySelector("head"),
|
|
4
|
-
e = `ab-${t}-css-definitions-${"6.
|
|
4
|
+
e = `ab-${t}-css-definitions-${"6.2.0".replace(/\./g, "-")}`;
|
|
5
5
|
if (!c) return;
|
|
6
6
|
const s = c.ownerDocument || document;
|
|
7
7
|
if (null == s.getElementById(e)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import r, { OPTIONS as z } from "../../managers/braze-instance.js";
|
|
2
2
|
export function loadFontAwesome() {
|
|
3
|
-
if (r.ee(z
|
|
3
|
+
if (r.ee(z.$h)) return;
|
|
4
4
|
const e = "https://use.fontawesome.com/7f85a56ba4.css";
|
|
5
5
|
if (
|
|
6
6
|
!(null !== document.querySelector('link[rel=stylesheet][href="' + e + '"]'))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger as
|
|
1
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
import { getErrorMessage as si } from "./error-utils.js";
|
|
3
3
|
import { decodeBrazeActions as uo } from "./string-utils.js";
|
|
4
4
|
import {
|
|
@@ -25,11 +25,11 @@ export const BRAZE_ACTIONS = {
|
|
|
25
25
|
properties: { type: "type", eo: "steps", so: "args" },
|
|
26
26
|
};
|
|
27
27
|
export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES = {
|
|
28
|
-
|
|
28
|
+
Li: "unknownBrazeAction",
|
|
29
29
|
Ac: "noPushPrompt",
|
|
30
30
|
};
|
|
31
31
|
export const ineligibleBrazeActionURLErrorMessage = (t, o) =>
|
|
32
|
-
t === INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.
|
|
32
|
+
t === INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Li
|
|
33
33
|
? `${o} contains an unknown braze action type and will not be displayed.`
|
|
34
34
|
: "";
|
|
35
35
|
export function getDecodedBrazeAction(t) {
|
|
@@ -38,15 +38,15 @@ export function getDecodedBrazeAction(t) {
|
|
|
38
38
|
r = o ? o[0].length : null,
|
|
39
39
|
n = r ? t.substring(r) : null;
|
|
40
40
|
if (null == r || r > t.length - 1 || !n)
|
|
41
|
-
return void
|
|
41
|
+
return void E.error(
|
|
42
42
|
`Did not find base64 encoded brazeAction in url to process : ${t}`,
|
|
43
43
|
);
|
|
44
44
|
const e = uo(n);
|
|
45
45
|
return e
|
|
46
46
|
? JSON.parse(e)
|
|
47
|
-
: void
|
|
47
|
+
: void E.error(`Failed to decode base64 encoded brazeAction: ${n}`);
|
|
48
48
|
} catch (o) {
|
|
49
|
-
return void
|
|
49
|
+
return void E.error(`Failed to process brazeAction URL ${t} : ${si(o)}`);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
function po(t, o) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import ai from "./client-hints-parser.js";
|
|
2
|
-
import
|
|
3
|
-
import { Browsers as
|
|
2
|
+
import oi from "./user-agent-parser.js";
|
|
3
|
+
import { Browsers as gi, OperatingSystems as so } from "./device-constants.js";
|
|
4
4
|
class di {
|
|
5
5
|
constructor() {
|
|
6
|
-
const t = navigator.userAgentData ? ai :
|
|
6
|
+
const t = navigator.userAgentData ? ai : oi;
|
|
7
7
|
(this.Sg = new t()),
|
|
8
8
|
(this.userAgent = navigator.userAgent),
|
|
9
9
|
(this.browser = this.Sg.ef()),
|
|
10
10
|
(this.version = this.Sg.ff()),
|
|
11
11
|
(this.OS = null),
|
|
12
|
-
this.
|
|
12
|
+
this.Ja().then((t) => (this.OS = t));
|
|
13
13
|
const i = navigator;
|
|
14
14
|
(this.language = (
|
|
15
15
|
i.userLanguage ||
|
|
@@ -18,18 +18,18 @@ class di {
|
|
|
18
18
|
i.systemLanguage ||
|
|
19
19
|
""
|
|
20
20
|
).toLowerCase()),
|
|
21
|
-
(this.
|
|
21
|
+
(this.Pa = di.vg(this.userAgent));
|
|
22
22
|
}
|
|
23
23
|
bE() {
|
|
24
|
-
return this.browser ===
|
|
24
|
+
return this.browser === gi.xg;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
Ka() {
|
|
27
27
|
return this.OS || null;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
Ja() {
|
|
30
30
|
return this.OS
|
|
31
31
|
? Promise.resolve(this.OS)
|
|
32
|
-
: this.Sg.
|
|
32
|
+
: this.Sg.Ja(di.kg).then((t) => ((this.OS = t), t));
|
|
33
33
|
}
|
|
34
34
|
static vg(t) {
|
|
35
35
|
t = t.toLowerCase();
|
|
@@ -51,14 +51,21 @@ class di {
|
|
|
51
51
|
"mediapartners-google",
|
|
52
52
|
"teoma",
|
|
53
53
|
"taiko",
|
|
54
|
+
"petalbot",
|
|
55
|
+
"facebookexternalhit",
|
|
56
|
+
"facebookcatalog",
|
|
57
|
+
"meta-webindexer",
|
|
58
|
+
"meta-externalads",
|
|
59
|
+
"meta-externalagent",
|
|
60
|
+
"meta-externalfetcher",
|
|
54
61
|
];
|
|
55
62
|
for (let n = 0; n < i.length; n++) if (-1 !== t.indexOf(i[n])) return !0;
|
|
56
63
|
return !1;
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
di.kg = [
|
|
60
|
-
{ string: navigator.platform, cf: "Win", identity: so.
|
|
61
|
-
{ string: navigator.platform, cf: "Mac", identity: so.
|
|
67
|
+
{ string: navigator.platform, cf: "Win", identity: so.Bg },
|
|
68
|
+
{ string: navigator.platform, cf: "Mac", identity: so.Og },
|
|
62
69
|
{ string: navigator.platform, cf: "BlackBerry", identity: "BlackBerry" },
|
|
63
70
|
{ string: navigator.platform, cf: "FreeBSD", identity: "FreeBSD" },
|
|
64
71
|
{ string: navigator.platform, cf: "OpenBSD", identity: "OpenBSD" },
|
|
@@ -74,12 +81,14 @@ di.kg = [
|
|
|
74
81
|
{ string: navigator.platform, cf: "Pike v", identity: so.co },
|
|
75
82
|
{ string: navigator.userAgent, cf: ["Web0S"], identity: "WebOS" },
|
|
76
83
|
{ string: navigator.userAgent, cf: "Tizen", identity: "Tizen" },
|
|
84
|
+
{ string: navigator.userAgent, cf: "Coolita", identity: "Other Smart TV" },
|
|
85
|
+
{ string: navigator.userAgent, cf: "WhaleTV", identity: "Other Smart TV" },
|
|
77
86
|
{
|
|
78
87
|
string: navigator.platform,
|
|
79
88
|
cf: ["Linux armv7l", "Android"],
|
|
80
|
-
identity: so.
|
|
89
|
+
identity: so.Pg,
|
|
81
90
|
},
|
|
82
|
-
{ string: navigator.userAgent, cf: ["Android"], identity: so.
|
|
91
|
+
{ string: navigator.userAgent, cf: ["Android"], identity: so.Pg },
|
|
83
92
|
{ string: navigator.platform, cf: "Linux", identity: "Linux" },
|
|
84
93
|
];
|
|
85
94
|
const ro = new di();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ge from "./base-device-parser.js";
|
|
2
|
-
import { Browsers as
|
|
2
|
+
import { Browsers as gi } from "./device-constants.js";
|
|
3
3
|
export default class ai extends ge {
|
|
4
4
|
constructor() {
|
|
5
5
|
if (
|
|
@@ -9,7 +9,7 @@ export default class ai extends ge {
|
|
|
9
9
|
(this.version = null),
|
|
10
10
|
this.userAgentData)
|
|
11
11
|
) {
|
|
12
|
-
const t = this.
|
|
12
|
+
const t = this.gc();
|
|
13
13
|
(this.browser = t.browser || "Unknown Browser"),
|
|
14
14
|
(this.version = t.version || "Unknown Version");
|
|
15
15
|
}
|
|
@@ -21,7 +21,7 @@ export default class ai extends ge {
|
|
|
21
21
|
ff() {
|
|
22
22
|
return this.version;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
Ja(t) {
|
|
25
25
|
if (this.OS) return Promise.resolve(this.OS);
|
|
26
26
|
const s = (s) => {
|
|
27
27
|
for (let r = 0; r < t.length; r++) {
|
|
@@ -36,12 +36,12 @@ export default class ai extends ge {
|
|
|
36
36
|
.then((t) => (t.platform ? s(t.platform) : navigator.platform))
|
|
37
37
|
.catch(() => navigator.platform);
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
gc() {
|
|
40
40
|
const t = {},
|
|
41
41
|
s = this.userAgentData.brands;
|
|
42
42
|
if (s && s.length)
|
|
43
43
|
for (const r of s) {
|
|
44
|
-
const s = this.
|
|
44
|
+
const s = this.vc(gi),
|
|
45
45
|
i = r.brand.match(s);
|
|
46
46
|
if (i && i.length > 0) {
|
|
47
47
|
(t.browser = i[0]), (t.version = r.version);
|
|
@@ -50,7 +50,7 @@ export default class ai extends ge {
|
|
|
50
50
|
}
|
|
51
51
|
return t;
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
vc(t) {
|
|
54
54
|
const s = [];
|
|
55
55
|
for (const r in t) {
|
|
56
56
|
const i = r;
|
package/src/util/code-utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger as
|
|
1
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
export function values(t) {
|
|
3
3
|
const e = [];
|
|
4
4
|
let r;
|
|
@@ -13,7 +13,7 @@ export function validateValueIsFromEnum(t, e, r, n) {
|
|
|
13
13
|
const o = values(t);
|
|
14
14
|
return (
|
|
15
15
|
-1 !== o.indexOf(e) ||
|
|
16
|
-
(
|
|
16
|
+
(E.error(`${r} Valid values from ${n} are "${o.join('"/"')}".`), !1)
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
export function isArray(t) {
|
|
@@ -16,7 +16,7 @@ export function createCloseButton(t, o, e, r = "ltr") {
|
|
|
16
16
|
n.appendChild(l),
|
|
17
17
|
l.setAttribute("aria-hidden", "true"),
|
|
18
18
|
n.addEventListener("keydown", (t) => {
|
|
19
|
-
(t.keyCode !== ie
|
|
19
|
+
(t.keyCode !== ie.lo && t.keyCode !== ie.Ze) ||
|
|
20
20
|
(e(), t.stopPropagation());
|
|
21
21
|
}),
|
|
22
22
|
(n.onclick = (t) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { logger as
|
|
1
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
export function logDeprecationWarning(e, i, n) {
|
|
3
3
|
let r = `The '${e}' ${i} is deprecated.`;
|
|
4
|
-
n && (r += ` Please use '${n}' instead.`),
|
|
4
|
+
n && (r += ` Please use '${n}' instead.`), E.warn(r);
|
|
5
5
|
}
|
|
@@ -2,12 +2,12 @@ export const Browsers = {
|
|
|
2
2
|
rO: "Chrome",
|
|
3
3
|
eO: "Edge",
|
|
4
4
|
oO: "Opera",
|
|
5
|
-
|
|
5
|
+
xg: "Safari",
|
|
6
6
|
OO: "Firefox",
|
|
7
7
|
};
|
|
8
8
|
export const OperatingSystems = {
|
|
9
|
-
|
|
9
|
+
Pg: "Android",
|
|
10
10
|
co: "iOS",
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
Og: "Mac",
|
|
12
|
+
Bg: "Windows",
|
|
13
13
|
};
|
package/src/util/dom-utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger as
|
|
1
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
import { getErrorMessage as si } from "./error-utils.js";
|
|
3
3
|
export function _isInView(t, n = !1, e = !1, s = !1) {
|
|
4
4
|
if (null == t) return !1;
|
|
@@ -18,8 +18,8 @@ export function _isInView(t, n = !1, e = !1, s = !1) {
|
|
|
18
18
|
!s)
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
export const DOMUtils = { Ic: null,
|
|
22
|
-
export const DIRECTIONS = {
|
|
21
|
+
export const DOMUtils = { Ic: null, Mo: _isInView };
|
|
22
|
+
export const DIRECTIONS = { ko: "up", xo: "down", Zt: "left", ae: "right" };
|
|
23
23
|
export function supportsPassive() {
|
|
24
24
|
if (null == DOMUtils.Ic) {
|
|
25
25
|
DOMUtils.Ic = !1;
|
|
@@ -32,7 +32,7 @@ export function supportsPassive() {
|
|
|
32
32
|
window.addEventListener("testPassive", () => {}, t),
|
|
33
33
|
window.removeEventListener("testPassive", () => {}, t);
|
|
34
34
|
} catch (t) {
|
|
35
|
-
|
|
35
|
+
E.error(si(t));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
return DOMUtils.Ic;
|
|
@@ -41,10 +41,10 @@ export function addPassiveEventListener(t, n, e = () => {}) {
|
|
|
41
41
|
t.addEventListener(n, e, !!supportsPassive() && { passive: !0 });
|
|
42
42
|
}
|
|
43
43
|
export function topIsInView(t) {
|
|
44
|
-
return DOMUtils.
|
|
44
|
+
return DOMUtils.Mo(t, !0, !1, !1);
|
|
45
45
|
}
|
|
46
46
|
export function bottomIsInView(t) {
|
|
47
|
-
return DOMUtils.
|
|
47
|
+
return DOMUtils.Mo(t, !1, !0, !1);
|
|
48
48
|
}
|
|
49
49
|
export function clickElement(t) {
|
|
50
50
|
if (t.onclick) {
|
|
@@ -63,15 +63,15 @@ export function detectSwipe(t, n, e) {
|
|
|
63
63
|
const l = s - o.touches[0].clientX,
|
|
64
64
|
u = i - o.touches[0].clientY;
|
|
65
65
|
Math.abs(l) > Math.abs(u) && Math.abs(l) >= 25
|
|
66
|
-
? (((l > 0 && n === DIRECTIONS.
|
|
66
|
+
? (((l > 0 && n === DIRECTIONS.Zt) || (l < 0 && n === DIRECTIONS.ae)) &&
|
|
67
67
|
e(o),
|
|
68
68
|
(s = null),
|
|
69
69
|
(i = null))
|
|
70
70
|
: Math.abs(u) >= 25 &&
|
|
71
71
|
(((u > 0 &&
|
|
72
|
-
n === DIRECTIONS.
|
|
72
|
+
n === DIRECTIONS.ko &&
|
|
73
73
|
t.scrollTop === t.scrollHeight - t.offsetHeight) ||
|
|
74
|
-
(u < 0 && n === DIRECTIONS.
|
|
74
|
+
(u < 0 && n === DIRECTIONS.xo && 0 === t.scrollTop)) &&
|
|
75
75
|
e(o),
|
|
76
76
|
(s = null),
|
|
77
77
|
(i = null));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger as
|
|
1
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
import { getUser as ao } from "../Core/get-user.js";
|
|
3
3
|
import { BRAZE_MUST_BE_INITIALIZED_ERROR as w } from "../common/constants.js";
|
|
4
4
|
import r from "../managers/braze-instance.js";
|
|
@@ -11,7 +11,7 @@ export const buildBrazeBridge = (t, e) => {
|
|
|
11
11
|
import("../Push/request-push-permission.js").then((e) => {
|
|
12
12
|
r.ao()
|
|
13
13
|
? e.requestPushPermission(...Array.prototype.slice.call(t))
|
|
14
|
-
:
|
|
14
|
+
: E.error(w);
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
},
|
|
@@ -22,7 +22,7 @@ export const buildBrazeBridge = (t, e) => {
|
|
|
22
22
|
({ requestImmediateDataFlush: requestImmediateDataFlush }) => {
|
|
23
23
|
r.ao()
|
|
24
24
|
? requestImmediateDataFlush(...Array.prototype.slice.call(t))
|
|
25
|
-
:
|
|
25
|
+
: E.error(w);
|
|
26
26
|
},
|
|
27
27
|
);
|
|
28
28
|
},
|
|
@@ -30,7 +30,7 @@ export const buildBrazeBridge = (t, e) => {
|
|
|
30
30
|
const t = arguments;
|
|
31
31
|
import("../Core/log-custom-event.js").then(
|
|
32
32
|
({ logCustomEvent: logCustomEvent }) => {
|
|
33
|
-
if (!r.ao()) return void
|
|
33
|
+
if (!r.ao()) return void E.error(w);
|
|
34
34
|
logCustomEvent(...Array.prototype.slice.call(t));
|
|
35
35
|
},
|
|
36
36
|
);
|
|
@@ -39,7 +39,7 @@ export const buildBrazeBridge = (t, e) => {
|
|
|
39
39
|
const t = arguments;
|
|
40
40
|
import("../Core/log-purchase.js").then(
|
|
41
41
|
({ logPurchase: logPurchase }) => {
|
|
42
|
-
if (!r.ao()) return void
|
|
42
|
+
if (!r.ao()) return void E.error(w);
|
|
43
43
|
logPurchase(...Array.prototype.slice.call(t));
|
|
44
44
|
},
|
|
45
45
|
);
|
|
@@ -50,7 +50,7 @@ export const buildBrazeBridge = (t, e) => {
|
|
|
50
50
|
({ unregisterPush: unregisterPush }) => {
|
|
51
51
|
r.ao()
|
|
52
52
|
? unregisterPush(...Array.prototype.slice.call(t))
|
|
53
|
-
:
|
|
53
|
+
: E.error(w);
|
|
54
54
|
},
|
|
55
55
|
);
|
|
56
56
|
},
|
|
@@ -58,7 +58,7 @@ export const buildBrazeBridge = (t, e) => {
|
|
|
58
58
|
changeUser: function () {
|
|
59
59
|
const t = arguments;
|
|
60
60
|
import("../Core/change-user.js").then(({ changeUser: changeUser }) => {
|
|
61
|
-
if (!r.ao()) return void
|
|
61
|
+
if (!r.ao()) return void E.error(w);
|
|
62
62
|
changeUser(...Array.prototype.slice.call(t));
|
|
63
63
|
});
|
|
64
64
|
},
|
package/src/util/key-codes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const KeyCodes = {
|
|
1
|
+
export const KeyCodes = { lo: 32, yo: 9, Ze: 13, Oh: 27 };
|