@braze/web-sdk 5.1.1 → 5.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 +14 -8
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +18 -18
- package/shared-lib/indexed-db-adapter.js +32 -32
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +22 -21
- package/src/InAppMessage/display/html-message-to-html.js +38 -35
- package/src/InAppMessage/display/in-app-message-to-html.js +2 -2
- package/src/InAppMessage/display/modal-utils.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +21 -19
- package/src/InAppMessage/in-app-message-manager.js +58 -78
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/control-message.js +4 -2
- package/src/InAppMessage/models/full-screen-message.js +5 -2
- package/src/InAppMessage/models/html-message.js +6 -4
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +51 -46
- package/src/InAppMessage/models/modal-message.js +5 -2
- package/src/InAppMessage/models/slide-up-message.js +33 -8
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/ui/show-in-app-message.js +28 -34
- package/src/InAppMessage/utils/in-app-message-utils.js +18 -1
- package/src/Push/push-manager-factory.js +3 -3
- package/src/Push/push-manager.js +118 -110
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +4 -4
- package/src/User/user.js +17 -17
- package/src/common/base-feed.js +1 -1
- package/src/common/feed-display.js +12 -12
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +26 -26
- package/src/managers/braze-instance.js +59 -52
- package/src/managers/device-manager.js +15 -15
- package/src/managers/network-manager.js +98 -93
- package/src/managers/server-config-manager.js +9 -9
- package/src/managers/storage-manager.js +99 -96
- package/src/managers/utils.js +6 -0
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +20 -12
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +33 -19
- package/src/models/push-token.js +4 -4
- package/src/models/server-config.js +6 -6
- package/src/request-controller.js +76 -73
- package/src/triggers/models/custom-event-data.js +2 -2
- package/src/triggers/models/custom-event-property-data.js +4 -4
- package/src/triggers/models/filter-set.js +5 -5
- package/src/triggers/models/filter.js +6 -6
- package/src/triggers/models/in-app-message-click-data.js +1 -1
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +41 -41
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +36 -36
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +71 -82
- package/src/ui/js/attach-css.js +2 -2
- 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 +4 -4
- package/src/util/browser-detector.js +9 -8
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/component-utils.js +2 -2
- package/src/util/device-constants.js +2 -2
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +6 -6
- package/src/util/user-agent-parser.js +5 -5
- package/src/util/validation-utils.js +2 -0
- package/src/util/window-utils.js +3 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import ts from "./custom-event-data.js";
|
|
2
|
+
import rs from "./custom-event-property-data.js";
|
|
3
|
+
import is from "./filter-set.js";
|
|
4
4
|
import ni from "./in-app-message-click-data.js";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import ns from "./purchase-data.js";
|
|
6
|
+
import hs from "./purchase-property-data.js";
|
|
7
7
|
import ur from "./push-click-data.js";
|
|
8
8
|
import tt from "./trigger-events.js";
|
|
9
9
|
import { logger as r } from "../../../shared-lib/index.js";
|
|
@@ -15,7 +15,7 @@ export default class ri {
|
|
|
15
15
|
sc(e, t) {
|
|
16
16
|
return ri.cc[this.type] === e && (null == this.data || this.data.Jl(t));
|
|
17
17
|
}
|
|
18
|
-
static
|
|
18
|
+
static Gu(e, t) {
|
|
19
19
|
let s = null;
|
|
20
20
|
try {
|
|
21
21
|
s = window.atob(e);
|
|
@@ -28,25 +28,25 @@ export default class ri {
|
|
|
28
28
|
const t = e.type;
|
|
29
29
|
let r = null;
|
|
30
30
|
switch (t) {
|
|
31
|
-
case ri.
|
|
32
|
-
case ri.
|
|
31
|
+
case ri.Or.OPEN:
|
|
32
|
+
case ri.Or.kt:
|
|
33
33
|
break;
|
|
34
|
-
case ri.
|
|
35
|
-
r = rs.fromJson(e.data);
|
|
36
|
-
break;
|
|
37
|
-
case ri.Kr.nc:
|
|
34
|
+
case ri.Or.Rr:
|
|
38
35
|
r = ns.fromJson(e.data);
|
|
39
36
|
break;
|
|
40
|
-
case ri.
|
|
37
|
+
case ri.Or.nc:
|
|
38
|
+
r = hs.fromJson(e.data);
|
|
39
|
+
break;
|
|
40
|
+
case ri.Or.vr:
|
|
41
41
|
r = ur.fromJson(e.data);
|
|
42
42
|
break;
|
|
43
|
-
case ri.
|
|
44
|
-
r =
|
|
43
|
+
case ri.Or.ue:
|
|
44
|
+
r = ts.fromJson(e.data);
|
|
45
45
|
break;
|
|
46
|
-
case ri.
|
|
47
|
-
r =
|
|
46
|
+
case ri.Or.lc:
|
|
47
|
+
r = rs.fromJson(e.data);
|
|
48
48
|
break;
|
|
49
|
-
case ri.
|
|
49
|
+
case ri.Or.Zr:
|
|
50
50
|
r = ni.fromJson(e.data);
|
|
51
51
|
}
|
|
52
52
|
return new ri(t, r);
|
|
@@ -54,50 +54,50 @@ export default class ri {
|
|
|
54
54
|
Y() {
|
|
55
55
|
return { t: this.type, d: this.data ? this.data.Y() : null };
|
|
56
56
|
}
|
|
57
|
-
static
|
|
57
|
+
static qn(e) {
|
|
58
58
|
let t,
|
|
59
59
|
r = null;
|
|
60
60
|
switch (e.t) {
|
|
61
|
-
case ri.
|
|
62
|
-
case ri.
|
|
61
|
+
case ri.Or.OPEN:
|
|
62
|
+
case ri.Or.kt:
|
|
63
63
|
break;
|
|
64
|
-
case ri.
|
|
65
|
-
r = new
|
|
64
|
+
case ri.Or.Rr:
|
|
65
|
+
r = new ns(e.d);
|
|
66
66
|
break;
|
|
67
|
-
case ri.
|
|
68
|
-
(t = e.d || {}), (r = new
|
|
67
|
+
case ri.Or.nc:
|
|
68
|
+
(t = e.d || {}), (r = new hs(t.id, is.qn(t.pf || [])));
|
|
69
69
|
break;
|
|
70
|
-
case ri.
|
|
70
|
+
case ri.Or.vr:
|
|
71
71
|
r = new ur(e.d);
|
|
72
72
|
break;
|
|
73
|
-
case ri.
|
|
74
|
-
r = new
|
|
73
|
+
case ri.Or.ue:
|
|
74
|
+
r = new ts(e.d);
|
|
75
75
|
break;
|
|
76
|
-
case ri.
|
|
77
|
-
(t = e.d || {}), (r = new
|
|
76
|
+
case ri.Or.lc:
|
|
77
|
+
(t = e.d || {}), (r = new rs(t.e, is.qn(t.pf || [])));
|
|
78
78
|
break;
|
|
79
|
-
case ri.
|
|
79
|
+
case ri.Or.Zr:
|
|
80
80
|
r = new ni(e.d);
|
|
81
81
|
}
|
|
82
82
|
return new ri(e.t, r);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
(ri.
|
|
85
|
+
(ri.Or = {
|
|
86
86
|
OPEN: "open",
|
|
87
87
|
Rr: "purchase",
|
|
88
88
|
nc: "purchase_property",
|
|
89
89
|
vr: "push_click",
|
|
90
90
|
ue: "custom_event",
|
|
91
91
|
lc: "custom_event_property",
|
|
92
|
-
|
|
92
|
+
Zr: "iam_click",
|
|
93
93
|
kt: "test",
|
|
94
94
|
}),
|
|
95
95
|
(ri.cc = {}),
|
|
96
|
-
(ri.cc[ri.
|
|
97
|
-
(ri.cc[ri.
|
|
98
|
-
(ri.cc[ri.
|
|
99
|
-
(ri.cc[ri.
|
|
100
|
-
(ri.cc[ri.
|
|
101
|
-
(ri.cc[ri.
|
|
102
|
-
(ri.cc[ri.
|
|
103
|
-
(ri.cc[ri.
|
|
96
|
+
(ri.cc[ri.Or.OPEN] = tt.OPEN),
|
|
97
|
+
(ri.cc[ri.Or.Rr] = tt.Rr),
|
|
98
|
+
(ri.cc[ri.Or.nc] = tt.Rr),
|
|
99
|
+
(ri.cc[ri.Or.vr] = tt.vr),
|
|
100
|
+
(ri.cc[ri.Or.ue] = tt.ue),
|
|
101
|
+
(ri.cc[ri.Or.lc] = tt.ue),
|
|
102
|
+
(ri.cc[ri.Or.Zr] = tt.Zr),
|
|
103
|
+
(ri.cc[ri.Or.kt] = tt.kt);
|
|
@@ -5,55 +5,55 @@ import {
|
|
|
5
5
|
import { logger as r } from "../../../shared-lib/index.js";
|
|
6
6
|
import ri from "./trigger-condition.js";
|
|
7
7
|
import { validateValueIsFromEnum as J } from "../../util/code-utils.js";
|
|
8
|
-
export default class
|
|
9
|
-
constructor(t, i = [], s, e, r = 0, h, l, o = 0, n =
|
|
8
|
+
export default class mt {
|
|
9
|
+
constructor(t, i = [], s, e, r = 0, h, l, o = 0, n = mt.Vu, a, u, d) {
|
|
10
10
|
(this.id = t),
|
|
11
|
-
(this.
|
|
11
|
+
(this.Ku = i),
|
|
12
12
|
(this.startTime = s),
|
|
13
13
|
(this.endTime = e),
|
|
14
14
|
(this.priority = r),
|
|
15
15
|
(this.type = h),
|
|
16
16
|
(this.data = l),
|
|
17
|
-
(this.
|
|
18
|
-
(this.
|
|
19
|
-
(this.
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
17
|
+
(this.Wu = o),
|
|
18
|
+
(this.Yu = n),
|
|
19
|
+
(this.Kr = a),
|
|
20
|
+
(this.Zu = u),
|
|
21
|
+
(this.td = d),
|
|
22
22
|
(this.id = t),
|
|
23
|
-
(this.
|
|
23
|
+
(this.Ku = i || []),
|
|
24
24
|
void 0 === s && (s = null),
|
|
25
25
|
(this.startTime = s),
|
|
26
26
|
void 0 === e && (e = null),
|
|
27
27
|
(this.endTime = e),
|
|
28
28
|
(this.priority = r || 0),
|
|
29
29
|
(this.type = h),
|
|
30
|
-
(this.
|
|
31
|
-
null == a && (a = 1e3 * (this.
|
|
32
|
-
(this.
|
|
30
|
+
(this.Wu = o || 0),
|
|
31
|
+
null == a && (a = 1e3 * (this.Wu + 30)),
|
|
32
|
+
(this.Kr = a),
|
|
33
33
|
(this.data = l),
|
|
34
|
-
null != n && (this.
|
|
35
|
-
(this.
|
|
36
|
-
(this.
|
|
34
|
+
null != n && (this.Yu = n),
|
|
35
|
+
(this.Zu = u),
|
|
36
|
+
(this.td = d || null);
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
sd(t) {
|
|
39
39
|
return (
|
|
40
|
-
null == this.
|
|
40
|
+
null == this.td || (this.Yu !== mt.Vu && t - this.td >= 1e3 * this.Yu)
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
this.
|
|
43
|
+
ed(t) {
|
|
44
|
+
this.td = t;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
const i = t + 1e3 * this.
|
|
46
|
+
rd(t) {
|
|
47
|
+
const i = t + 1e3 * this.Wu;
|
|
48
48
|
return Math.max(i - new Date().valueOf(), 0);
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
hd(t) {
|
|
51
51
|
const i = new Date().valueOf() - t,
|
|
52
|
-
s = null == t || isNaN(i) || null == this.
|
|
52
|
+
s = null == t || isNaN(i) || null == this.Kr || i < this.Kr;
|
|
53
53
|
return (
|
|
54
54
|
s ||
|
|
55
55
|
r.info(
|
|
56
|
-
`Trigger action ${this.type} is no longer eligible for display - fired ${i}ms ago and has a timeout of ${this.
|
|
56
|
+
`Trigger action ${this.type} is no longer eligible for display - fired ${i}ms ago and has a timeout of ${this.Kr}ms.`,
|
|
57
57
|
),
|
|
58
58
|
!s
|
|
59
59
|
);
|
|
@@ -73,17 +73,17 @@ export default class pt {
|
|
|
73
73
|
d = t.data,
|
|
74
74
|
m = t.min_seconds_since_last_trigger;
|
|
75
75
|
return J(
|
|
76
|
-
|
|
76
|
+
mt.Or,
|
|
77
77
|
o,
|
|
78
78
|
"Could not construct Trigger from server data",
|
|
79
79
|
"Trigger.Types",
|
|
80
80
|
)
|
|
81
|
-
? new
|
|
81
|
+
? new mt(i, s, e, r, h, o, d, n, a, u, m)
|
|
82
82
|
: null;
|
|
83
83
|
}
|
|
84
84
|
Y() {
|
|
85
85
|
const t = [];
|
|
86
|
-
for (let i = 0; i < this.
|
|
86
|
+
for (let i = 0; i < this.Ku.length; i++) t.push(this.Ku[i].Y());
|
|
87
87
|
return {
|
|
88
88
|
i: this.id,
|
|
89
89
|
c: t,
|
|
@@ -92,18 +92,18 @@ export default class pt {
|
|
|
92
92
|
p: this.priority,
|
|
93
93
|
t: this.type,
|
|
94
94
|
da: this.data,
|
|
95
|
-
d: this.
|
|
96
|
-
r: this.
|
|
97
|
-
tm: this.
|
|
98
|
-
ss: this.
|
|
99
|
-
ld: this.
|
|
95
|
+
d: this.Wu,
|
|
96
|
+
r: this.Yu,
|
|
97
|
+
tm: this.Kr,
|
|
98
|
+
ss: this.Zu,
|
|
99
|
+
ld: this.td,
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
static
|
|
102
|
+
static qn(t) {
|
|
103
103
|
const i = [],
|
|
104
104
|
s = t.c || [];
|
|
105
|
-
for (let t = 0; t < s.length; t++) i.push(ri.
|
|
106
|
-
return new
|
|
105
|
+
for (let t = 0; t < s.length; t++) i.push(ri.qn(s[t]));
|
|
106
|
+
return new mt(
|
|
107
107
|
t.i,
|
|
108
108
|
i,
|
|
109
109
|
w(t.s),
|
|
@@ -119,4 +119,4 @@ export default class pt {
|
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
(
|
|
122
|
+
(mt.Or = { Cr: "inapp", od: "templated_iam" }), (mt.Vu = -1);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import y from "../common/base-provider.js";
|
|
2
|
-
import { newInAppMessageFromJson as
|
|
2
|
+
import { newInAppMessageFromJson as pt } from "../InAppMessage/in-app-message-factory.js";
|
|
3
3
|
import ue from "../models/braze-event.js";
|
|
4
|
-
import { InAppMessage } from "../InAppMessage/index.js";
|
|
5
4
|
import {
|
|
6
5
|
isArray as j,
|
|
7
6
|
isEqual as ii,
|
|
@@ -9,7 +8,7 @@ import {
|
|
|
9
8
|
} from "../util/code-utils.js";
|
|
10
9
|
import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
11
10
|
import wt from "../InAppMessage/models/templated-in-app-message.js";
|
|
12
|
-
import
|
|
11
|
+
import mt from "./models/trigger.js";
|
|
13
12
|
import tt from "./models/trigger-events.js";
|
|
14
13
|
import { logger as r } from "../../shared-lib/index.js";
|
|
15
14
|
export default class gr extends y {
|
|
@@ -31,8 +30,8 @@ export default class gr extends y {
|
|
|
31
30
|
(this.ng = {}),
|
|
32
31
|
(this.og = {}),
|
|
33
32
|
(this.triggers = []),
|
|
34
|
-
(this.
|
|
35
|
-
this.
|
|
33
|
+
(this.lg = 0),
|
|
34
|
+
this.ag(),
|
|
36
35
|
this.gg();
|
|
37
36
|
}
|
|
38
37
|
fg() {
|
|
@@ -42,16 +41,16 @@ export default class gr extends y {
|
|
|
42
41
|
(this.og = this.u.j(o.C.nE) || this.og);
|
|
43
42
|
for (let t = 0; t < this.triggers.length; t++) {
|
|
44
43
|
const i = this.triggers[t];
|
|
45
|
-
i.id && null != this.og[i.id] && i.
|
|
44
|
+
i.id && null != this.og[i.id] && i.ed(this.og[i.id]);
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
|
-
|
|
48
|
+
ag() {
|
|
50
49
|
if (!this.u) return;
|
|
51
|
-
this.
|
|
50
|
+
this.lg = this.u.j(o.C.oE) || 0;
|
|
52
51
|
const t = this.u.j(o.C.rE) || [],
|
|
53
52
|
i = [];
|
|
54
|
-
for (let s = 0; s < t.length; s++) i.push(
|
|
53
|
+
for (let s = 0; s < t.length; s++) i.push(mt.qn(t[s]));
|
|
55
54
|
(this.triggers = i), this.fg();
|
|
56
55
|
}
|
|
57
56
|
gg() {
|
|
@@ -71,19 +70,19 @@ export default class gr extends y {
|
|
|
71
70
|
h = [];
|
|
72
71
|
for (let e = 0; e < t.length; e++) {
|
|
73
72
|
const n = t[e],
|
|
74
|
-
o = r.
|
|
73
|
+
o = r.rd(n.Jr || 0);
|
|
75
74
|
if (o > 0) {
|
|
76
75
|
let t, e;
|
|
77
76
|
h.push(n),
|
|
78
77
|
null != n.ug && (t = n.ug),
|
|
79
|
-
null != n.dg && ue.
|
|
80
|
-
const
|
|
78
|
+
null != n.dg && ue.AE(n.dg) && (e = ue.qn(n.dg));
|
|
79
|
+
const l = [];
|
|
81
80
|
if (n.pg && j(n.pg))
|
|
82
81
|
for (let t = 0; t < n.pg.length; t++) {
|
|
83
82
|
const i = s[n.pg[t]];
|
|
84
|
-
null != i &&
|
|
83
|
+
null != i && l.push(i);
|
|
85
84
|
}
|
|
86
|
-
this.eg.push(window.setTimeout(i(r, n.
|
|
85
|
+
this.eg.push(window.setTimeout(i(r, n.Jr || 0, t, e, l), o));
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
this.ng[r.id].length > h.length &&
|
|
@@ -98,30 +97,30 @@ export default class gr extends y {
|
|
|
98
97
|
if (!this.u) return;
|
|
99
98
|
const t = [];
|
|
100
99
|
for (let i = 0; i < this.triggers.length; i++) t.push(this.triggers[i].Y());
|
|
101
|
-
(this.
|
|
100
|
+
(this.lg = new Date().valueOf()),
|
|
102
101
|
this.u.k(o.C.rE, t),
|
|
103
|
-
this.u.k(o.C.oE, this.
|
|
102
|
+
this.u.k(o.C.oE, this.lg);
|
|
104
103
|
}
|
|
105
104
|
bg() {
|
|
106
105
|
if (!this.u) return;
|
|
107
|
-
(this.u.j(o.C.oE) || 0) > this.
|
|
106
|
+
(this.u.j(o.C.oE) || 0) > this.lg ? this.ag() : this.fg();
|
|
108
107
|
}
|
|
109
108
|
Rs(t) {
|
|
110
109
|
let i = !1;
|
|
111
110
|
if (null != t && t.triggers) {
|
|
112
|
-
this.ig.
|
|
111
|
+
this.ig.Yr(), this.fg();
|
|
113
112
|
const s = {},
|
|
114
113
|
e = {};
|
|
115
114
|
this.triggers = [];
|
|
116
115
|
for (let r = 0; r < t.triggers.length; r++) {
|
|
117
|
-
const h =
|
|
116
|
+
const h = mt.fromJson(t.triggers[r]);
|
|
118
117
|
if (h) {
|
|
119
118
|
h.id &&
|
|
120
119
|
null != this.og[h.id] &&
|
|
121
|
-
(h.
|
|
120
|
+
(h.ed(this.og[h.id]), (s[h.id] = this.og[h.id])),
|
|
122
121
|
h.id && null != this.ng[h.id] && (e[h.id] = this.ng[h.id]);
|
|
123
|
-
for (let t = 0; t < h.
|
|
124
|
-
if (h.
|
|
122
|
+
for (let t = 0; t < h.Ku.length; t++)
|
|
123
|
+
if (h.Ku[t].sc(tt.kt, null)) {
|
|
125
124
|
i = !0;
|
|
126
125
|
break;
|
|
127
126
|
}
|
|
@@ -146,40 +145,33 @@ export default class gr extends y {
|
|
|
146
145
|
const n = (e) => {
|
|
147
146
|
this.fg();
|
|
148
147
|
const h = new Date().valueOf();
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
?
|
|
148
|
+
t.hd(i) ||
|
|
149
|
+
(!1 === navigator.onLine && t.type === mt.Or.Cr && e.imageUrl
|
|
150
|
+
? r.info(
|
|
152
151
|
`Not showing ${t.type} trigger action ${t.id} due to offline state.`,
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
));
|
|
164
|
-
t.type === pt.Kr.nd
|
|
165
|
-
? this.ig.Ve(t.id, InAppMessage.Me.Or)
|
|
166
|
-
: this.ig.Ve(t.id, InAppMessage.Me.bh);
|
|
152
|
+
)
|
|
153
|
+
: t.sd(h) && this.wg(t, h, s)
|
|
154
|
+
? 0 === this.Jt.ic()
|
|
155
|
+
? r.info(
|
|
156
|
+
`Not displaying trigger ${t.id} because neither automaticallyShowInAppMessages() nor subscribeToInAppMessage() were called.`,
|
|
157
|
+
)
|
|
158
|
+
: (this.Jt.Dt([e]), this.yg(t, h))
|
|
159
|
+
: r.info(
|
|
160
|
+
`Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`,
|
|
161
|
+
));
|
|
167
162
|
},
|
|
168
163
|
o = () => {
|
|
169
164
|
this.fg();
|
|
170
165
|
const n = h.pop();
|
|
171
166
|
if (null != n)
|
|
172
|
-
if ((this.Tg(n, i, s, e, h), n.
|
|
167
|
+
if ((this.Tg(n, i, s, e, h), n.hd(i))) {
|
|
173
168
|
let t = `Server aborted in-app message display, but the timeout on fallback trigger ${n.id} has already elapsed.`;
|
|
174
|
-
h.length > 0 && (t += " Continuing to fall back."),
|
|
175
|
-
r.info(t),
|
|
176
|
-
this.ig.Ve(n.id, InAppMessage.Me.bh),
|
|
177
|
-
o();
|
|
169
|
+
h.length > 0 && (t += " Continuing to fall back."), r.info(t), o();
|
|
178
170
|
} else {
|
|
179
171
|
r.info(
|
|
180
172
|
`Server aborted in-app message display. Falling back to lower priority ${n.type} trigger action ${t.id}.`,
|
|
181
173
|
);
|
|
182
|
-
const o = 1e3 * n.
|
|
174
|
+
const o = 1e3 * n.Wu - (new Date().valueOf() - i);
|
|
183
175
|
o > 0
|
|
184
176
|
? this.eg.push(
|
|
185
177
|
window.setTimeout(() => {
|
|
@@ -189,40 +181,37 @@ export default class gr extends y {
|
|
|
189
181
|
: this.cg(n, i, s, e, h);
|
|
190
182
|
}
|
|
191
183
|
};
|
|
192
|
-
let
|
|
184
|
+
let l, a, g;
|
|
193
185
|
switch (t.type) {
|
|
194
|
-
case
|
|
195
|
-
if (((
|
|
186
|
+
case mt.Or.Cr:
|
|
187
|
+
if (((l = pt(t.data)), null == l)) {
|
|
196
188
|
r.error(
|
|
197
189
|
`Could not parse trigger data for trigger ${t.id}, ignoring.`,
|
|
198
|
-
)
|
|
199
|
-
this.ig.Ve(t.id, InAppMessage.Me.Lr);
|
|
190
|
+
);
|
|
200
191
|
break;
|
|
201
192
|
}
|
|
202
|
-
if (((
|
|
203
|
-
r.error(
|
|
193
|
+
if (((a = this.ig.Qi(l)), a)) {
|
|
194
|
+
r.error(a), o();
|
|
204
195
|
break;
|
|
205
196
|
}
|
|
206
|
-
n(
|
|
197
|
+
n(l);
|
|
207
198
|
break;
|
|
208
|
-
case
|
|
209
|
-
if (((g = wt.fromJson(t.data, n, o, i, t.
|
|
199
|
+
case mt.Or.od:
|
|
200
|
+
if (((g = wt.fromJson(t.data, n, o, i, t.Kr || 0)), null == g)) {
|
|
210
201
|
r.error(
|
|
211
202
|
`Could not parse trigger data for trigger ${t.id}, ignoring.`,
|
|
212
|
-
)
|
|
213
|
-
this.ig.Ve(t.id, InAppMessage.Me.Lr);
|
|
203
|
+
);
|
|
214
204
|
break;
|
|
215
205
|
}
|
|
216
|
-
this.ig.
|
|
206
|
+
this.ig.Yi(g, s, e);
|
|
217
207
|
break;
|
|
218
208
|
default:
|
|
219
|
-
r.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`)
|
|
220
|
-
this.ig.Ve(t.id, InAppMessage.Me.Lr);
|
|
209
|
+
r.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`);
|
|
221
210
|
}
|
|
222
211
|
}
|
|
223
212
|
fe(t, i = null, s) {
|
|
224
213
|
if (!J(tt, t, "Cannot fire trigger action.", "TriggerEvents")) return;
|
|
225
|
-
if (this.Ei && this.Ei.
|
|
214
|
+
if (this.Ei && this.Ei.Tu())
|
|
226
215
|
return (
|
|
227
216
|
r.info(
|
|
228
217
|
"Trigger sync is currently in progress, awaiting sync completion before firing trigger event.",
|
|
@@ -234,22 +223,22 @@ export default class gr extends y {
|
|
|
234
223
|
h = e - (this.hg || 0);
|
|
235
224
|
let n = !0,
|
|
236
225
|
o = !0;
|
|
237
|
-
const
|
|
226
|
+
const l = [];
|
|
238
227
|
for (let s = 0; s < this.triggers.length; s++) {
|
|
239
228
|
const r = this.triggers[s],
|
|
240
|
-
h = e + 1e3 * r.
|
|
229
|
+
h = e + 1e3 * r.Wu;
|
|
241
230
|
if (
|
|
242
|
-
r.
|
|
231
|
+
r.sd(h) &&
|
|
243
232
|
(null == r.startTime || r.startTime.valueOf() <= e) &&
|
|
244
233
|
(null == r.endTime || r.endTime.valueOf() >= e)
|
|
245
234
|
) {
|
|
246
235
|
let s = !1;
|
|
247
|
-
for (let e = 0; e < r.
|
|
248
|
-
if (r.
|
|
236
|
+
for (let e = 0; e < r.Ku.length; e++)
|
|
237
|
+
if (r.Ku[e].sc(t, i)) {
|
|
249
238
|
s = !0;
|
|
250
239
|
break;
|
|
251
240
|
}
|
|
252
|
-
s && ((n = !1), this.wg(r, h, t) && ((o = !1),
|
|
241
|
+
s && ((n = !1), this.wg(r, h, t) && ((o = !1), l.push(r)));
|
|
253
242
|
}
|
|
254
243
|
}
|
|
255
244
|
if (n)
|
|
@@ -262,19 +251,19 @@ export default class gr extends y {
|
|
|
262
251
|
h / 1e3
|
|
263
252
|
}s ago.`,
|
|
264
253
|
);
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
null !=
|
|
254
|
+
l.sort((t, i) => t.priority - i.priority);
|
|
255
|
+
const a = l.pop();
|
|
256
|
+
null != a &&
|
|
268
257
|
(r.info(
|
|
269
|
-
`Firing ${
|
|
258
|
+
`Firing ${a.type} trigger action ${a.id} from trigger event ${t}.`,
|
|
270
259
|
),
|
|
271
|
-
this.Tg(
|
|
272
|
-
0 ===
|
|
273
|
-
? this.cg(
|
|
260
|
+
this.Tg(a, e, t, s, l),
|
|
261
|
+
0 === a.Wu
|
|
262
|
+
? this.cg(a, e, t, s, l)
|
|
274
263
|
: this.eg.push(
|
|
275
264
|
window.setTimeout(() => {
|
|
276
|
-
this.cg(
|
|
277
|
-
}, 1e3 *
|
|
265
|
+
this.cg(a, e, t, s, l);
|
|
266
|
+
}, 1e3 * a.Wu),
|
|
278
267
|
));
|
|
279
268
|
}
|
|
280
269
|
changeUser(t = !1) {
|
|
@@ -299,23 +288,23 @@ export default class gr extends y {
|
|
|
299
288
|
),
|
|
300
289
|
!0
|
|
301
290
|
);
|
|
302
|
-
let e = t.
|
|
291
|
+
let e = t.Zu;
|
|
303
292
|
return null == e && (e = this.tg), i - this.hg >= 1e3 * e;
|
|
304
293
|
}
|
|
305
294
|
Tg(t, i, s, e, r) {
|
|
306
295
|
this.fg(), t.id && (this.ng[t.id] = this.ng[t.id] || []);
|
|
307
296
|
const h = {};
|
|
308
297
|
let n;
|
|
309
|
-
(h.
|
|
310
|
-
const
|
|
311
|
-
for (const t of r) t.id &&
|
|
312
|
-
(h.pg =
|
|
298
|
+
(h.Jr = i), (h.ug = s), null != e && (n = e.Y()), (h.dg = n);
|
|
299
|
+
const l = [];
|
|
300
|
+
for (const t of r) t.id && l.push(t.id);
|
|
301
|
+
(h.pg = l),
|
|
313
302
|
t.id && this.ng[t.id].push(h),
|
|
314
303
|
this.u && this.u.k(o.C.iE, this.ng);
|
|
315
304
|
}
|
|
316
305
|
yg(t, i) {
|
|
317
306
|
this.fg(),
|
|
318
|
-
t.
|
|
307
|
+
t.ed(i),
|
|
319
308
|
(this.hg = i),
|
|
320
309
|
t.id && (this.og[t.id] = i),
|
|
321
310
|
this.u && (this.u.k(o.C.aE, i), this.u.k(o.C.nE, this.og));
|
package/src/ui/js/attach-css.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import e, { OPTIONS as L } from "../../managers/braze-instance.js";
|
|
2
2
|
export function attachCSS(n, t, o) {
|
|
3
3
|
const c = n || document.querySelector("head"),
|
|
4
|
-
s = `ab-${t}-css-definitions-${"5.
|
|
4
|
+
s = `ab-${t}-css-definitions-${"5.2.0".replace(/\./g, "-")}`;
|
|
5
5
|
if (!c) return;
|
|
6
6
|
const a = c.ownerDocument || document;
|
|
7
7
|
if (null == a.getElementById(s)) {
|
|
8
8
|
const n = a.createElement("style");
|
|
9
9
|
(n.innerHTML = o || ""), (n.id = s);
|
|
10
|
-
const t = e.nn(L.
|
|
10
|
+
const t = e.nn(L.ho);
|
|
11
11
|
null != t && n.setAttribute("nonce", t), c.appendChild(n);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import e, { OPTIONS as L } from "../../managers/braze-instance.js";
|
|
2
2
|
export function loadFontAwesome() {
|
|
3
|
-
if (e.nn(L.
|
|
3
|
+
if (e.nn(L.Mo)) return;
|
|
4
4
|
const t = "https://use.fontawesome.com/7f85a56ba4.css";
|
|
5
5
|
if (
|
|
6
6
|
!(null !== document.querySelector('link[rel=stylesheet][href="' + t + '"]'))
|
|
@@ -25,14 +25,14 @@ export const BRAZE_ACTIONS = {
|
|
|
25
25
|
properties: { type: "type", oo: "steps", eo: "args" },
|
|
26
26
|
};
|
|
27
27
|
export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES = {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
Vi: "unknownBrazeAction",
|
|
29
|
+
Xi: "noPushPrompt",
|
|
30
30
|
};
|
|
31
31
|
export const ineligibleBrazeActionURLErrorMessage = (t, o) => {
|
|
32
32
|
switch (t) {
|
|
33
|
-
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.
|
|
33
|
+
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Vi:
|
|
34
34
|
return `${o} contains an unknown braze action type and will not be displayed.`;
|
|
35
|
-
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.
|
|
35
|
+
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Xi:
|
|
36
36
|
return `${o} contains a push prompt braze action, but is not eligible for a push prompt. Ignoring.`;
|
|
37
37
|
default:
|
|
38
38
|
return "";
|