@braze/web-sdk 4.7.1 → 4.8.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 +27 -24
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +5 -5
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +24 -24
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +17 -17
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +18 -18
- package/src/Card/card-manager-factory.js +2 -2
- package/src/Card/card-manager.js +47 -41
- package/src/Card/display/card-display.js +70 -67
- package/src/Card/log-card-click.js +1 -1
- package/src/Card/log-card-dismissal.js +1 -1
- package/src/Card/log-card-impressions.js +3 -3
- package/src/Card/models/banner.js +3 -2
- package/src/Card/models/captioned-image.js +6 -5
- package/src/Card/models/card.js +107 -87
- package/src/Card/models/classic-card.js +5 -5
- package/src/Card/models/control-card.js +5 -21
- package/src/Card/types.js +1 -0
- package/src/Card/util/card-factory.js +32 -32
- package/src/ContentCards/content-cards-provider-factory.js +3 -3
- package/src/ContentCards/content-cards-provider.js +283 -175
- package/src/ContentCards/content-cards.js +2 -2
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/log-content-cards-displayed.js +2 -2
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +9 -6
- package/src/ContentCards/types.js +1 -0
- package/src/ContentCards/ui/hide-content-cards.js +2 -2
- package/src/ContentCards/ui/show-content-cards.js +35 -33
- package/src/Core/add-sdk-metadata.js +17 -18
- package/src/Core/change-user.js +12 -14
- package/src/Core/destroy.js +1 -1
- package/src/Core/disable-sdk.js +7 -6
- package/src/Core/enable-sdk.js +4 -4
- package/src/Core/get-device-id.js +7 -6
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +57 -40
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/log-custom-event.js +22 -15
- package/src/Core/log-purchase.js +33 -33
- package/src/Core/open-session.js +17 -15
- package/src/Core/request-immediate-data-flush.js +4 -2
- package/src/Core/set-logger.js +1 -1
- package/src/Core/set-sdk-authentication-signature.js +5 -6
- package/src/Core/subscribe-to-sdk-authentication-failures.js +3 -1
- package/src/Core/toggle-logging.js +1 -1
- package/src/Core/types.js +1 -0
- package/src/Core/wipe-data.js +11 -10
- package/src/FeatureFlags/feature-flag-factory.js +6 -6
- package/src/FeatureFlags/feature-flag.js +17 -17
- package/src/FeatureFlags/feature-flags-provider-factory.js +2 -2
- package/src/FeatureFlags/feature-flags-provider.js +67 -65
- package/src/FeatureFlags/get-all-feature-flags.js +3 -3
- package/src/FeatureFlags/get-feature-flag.js +4 -4
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -1
- package/src/Feed/feed-provider-factory.js +8 -8
- package/src/Feed/feed-provider.js +57 -46
- package/src/Feed/feed.js +1 -1
- package/src/Feed/get-cached-feed.js +2 -2
- package/src/Feed/log-feed-displayed.js +3 -1
- package/src/Feed/request-feed-refresh.js +2 -2
- package/src/Feed/subscribe-to-feed-updates.js +2 -2
- package/src/Feed/types.js +1 -0
- package/src/Feed/ui/hide-feed.js +2 -2
- package/src/Feed/ui/show-feed.js +40 -36
- package/src/InAppMessage/display/html-message-to-html.js +125 -119
- package/src/InAppMessage/display/in-app-message-to-html.js +72 -69
- package/src/InAppMessage/display/modal-utils.js +18 -13
- package/src/InAppMessage/in-app-message-factory.js +9 -8
- package/src/InAppMessage/in-app-message-manager-factory.js +7 -7
- package/src/InAppMessage/in-app-message-manager.js +122 -108
- package/src/InAppMessage/log-in-app-message-button-click.js +10 -10
- package/src/InAppMessage/log-in-app-message-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-html-click.js +10 -10
- package/src/InAppMessage/log-in-app-message-impression.js +5 -5
- package/src/InAppMessage/models/control-message.js +4 -1
- package/src/InAppMessage/models/full-screen-message.js +35 -37
- package/src/InAppMessage/models/html-message.js +34 -33
- package/src/InAppMessage/models/in-app-message-button.js +23 -16
- package/src/InAppMessage/models/in-app-message.js +147 -105
- package/src/InAppMessage/models/modal-message.js +34 -36
- package/src/InAppMessage/models/slide-up-message.js +25 -27
- package/src/InAppMessage/models/templated-in-app-message.js +12 -7
- package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
- package/src/InAppMessage/types.js +1 -0
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
- package/src/InAppMessage/ui/show-in-app-message.js +95 -89
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -0
- 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 +20 -20
- package/src/Push/push-manager.js +192 -174
- package/src/Push/request-push-permission.js +4 -3
- package/src/Push/types.js +1 -0
- package/src/Push/unregister-push.js +2 -2
- package/src/Push/utils/push-utils.js +10 -10
- package/src/User/types.js +1 -0
- package/src/User/user-manager.js +24 -24
- package/src/User/user.js +117 -105
- package/src/common/base-feed.js +7 -7
- package/src/common/base-provider.js +2 -2
- package/src/common/constants.js +6 -0
- package/src/common/event-logger.js +6 -6
- package/src/common/feed-display.js +18 -18
- package/src/common/types.js +1 -0
- package/src/l10n/l10n-manager-factory.js +5 -5
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +204 -202
- package/src/managers/device-manager.js +23 -23
- package/src/managers/network-manager.js +96 -82
- package/src/managers/server-config-manager.js +60 -42
- package/src/managers/session-manager.js +41 -41
- package/src/managers/storage-manager-factory.js +15 -15
- package/src/managers/storage-manager.js +165 -155
- package/src/managers/subscription-manager.js +11 -11
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +7 -7
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +7 -7
- package/src/models/push-token.js +7 -7
- package/src/models/request-result.js +3 -3
- package/src/models/server-config.js +20 -20
- package/src/request-controller.js +176 -174
- package/src/triggers/models/custom-event-data.js +6 -6
- package/src/triggers/models/custom-event-property-data.js +9 -9
- package/src/triggers/models/filter-set.js +9 -9
- package/src/triggers/models/filter.js +64 -64
- package/src/triggers/models/in-app-message-click-data.js +12 -12
- package/src/triggers/models/purchase-data.js +3 -3
- package/src/triggers/models/purchase-property-data.js +9 -9
- package/src/triggers/models/push-click-data.js +5 -5
- package/src/triggers/models/trigger-condition.js +52 -52
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +42 -42
- package/src/triggers/triggers-provider-factory.js +8 -8
- package/src/triggers/triggers-provider.js +171 -168
- package/src/types.js +1 -0
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +20 -20
- package/src/util/browser-detector.js +22 -22
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/code-utils.js +1 -1
- package/src/util/color-utils.js +2 -2
- package/src/util/component-utils.js +2 -2
- package/src/util/deprecation-utils.js +1 -1
- package/src/util/device-constants.js +5 -5
- package/src/util/dom-utils.js +2 -2
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +11 -11
- package/src/util/request-header-utils.js +23 -0
- package/src/util/string-utils.js +1 -1
- package/src/util/user-agent-parser.js +20 -20
- package/src/util/validation-utils.js +44 -44
- package/src/util/window-utils.js +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import e, { OPTIONS as
|
|
1
|
+
import ea from "../InAppMessage/in-app-message-manager-factory.js";
|
|
2
|
+
import e, { OPTIONS as L } from "../managers/braze-instance.js";
|
|
3
3
|
import gr from "./triggers-provider.js";
|
|
4
4
|
export const TriggersProviderFactory = {
|
|
5
5
|
t: !1,
|
|
@@ -7,21 +7,21 @@ export const TriggersProviderFactory = {
|
|
|
7
7
|
er: () => (TriggersProviderFactory.init(), TriggersProviderFactory.provider),
|
|
8
8
|
rg: () => {
|
|
9
9
|
if (!TriggersProviderFactory.provider) {
|
|
10
|
-
const r = e.nn(
|
|
10
|
+
const r = e.nn(L.No);
|
|
11
11
|
(TriggersProviderFactory.provider = new gr(
|
|
12
12
|
null != r ? r : 30,
|
|
13
|
-
|
|
13
|
+
ea.m().Ue(),
|
|
14
14
|
e.l(),
|
|
15
|
-
e.
|
|
16
|
-
|
|
15
|
+
e.cr(),
|
|
16
|
+
ea.m()
|
|
17
17
|
)),
|
|
18
|
-
e.
|
|
18
|
+
e.dr(TriggersProviderFactory.provider);
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
init: () => {
|
|
22
22
|
TriggersProviderFactory.t ||
|
|
23
23
|
(TriggersProviderFactory.rg(),
|
|
24
|
-
e.
|
|
24
|
+
e.g(TriggersProviderFactory),
|
|
25
25
|
(TriggersProviderFactory.t = !0));
|
|
26
26
|
},
|
|
27
27
|
destroy: () => {
|
|
@@ -1,305 +1,308 @@
|
|
|
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
4
|
import { InAppMessage } from "../InAppMessage/index.js";
|
|
5
5
|
import {
|
|
6
6
|
isArray as p,
|
|
7
7
|
isEqual as ii,
|
|
8
|
-
validateValueIsFromEnum as
|
|
8
|
+
validateValueIsFromEnum as H
|
|
9
9
|
} from "../util/code-utils.js";
|
|
10
|
-
import { STORAGE_KEYS as
|
|
10
|
+
import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
|
|
11
11
|
import wt from "../InAppMessage/models/templated-in-app-message.js";
|
|
12
|
-
import
|
|
13
|
-
import
|
|
12
|
+
import mt from "./models/trigger.js";
|
|
13
|
+
import tt from "./models/trigger-events.js";
|
|
14
14
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
15
15
|
export default class gr extends y {
|
|
16
16
|
constructor(t, i, s, e, r) {
|
|
17
17
|
super(),
|
|
18
18
|
(this.tg = t),
|
|
19
|
-
(this.
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
23
|
-
(this.sg = []),
|
|
19
|
+
(this.ig = i),
|
|
20
|
+
(this.Jn = s),
|
|
21
|
+
(this.Ch = e),
|
|
22
|
+
(this.sg = r),
|
|
24
23
|
(this.eg = []),
|
|
25
|
-
(this.hg =
|
|
26
|
-
(this.og =
|
|
24
|
+
(this.hg = []),
|
|
25
|
+
(this.og = null),
|
|
27
26
|
(this.ng = {}),
|
|
28
|
-
this.lg
|
|
29
|
-
this.ag()
|
|
27
|
+
(this.lg = {}),
|
|
28
|
+
this.ag(),
|
|
29
|
+
this.gg();
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
(this.
|
|
33
|
-
(this.
|
|
34
|
-
(this.
|
|
35
|
-
for (let t = 0; t < this.
|
|
36
|
-
const i = this.
|
|
37
|
-
null != this.
|
|
31
|
+
fg() {
|
|
32
|
+
(this.og = this.Jn.v(i.k.La) || this.og),
|
|
33
|
+
(this.ng = this.Jn.v(i.k.Fa) || this.ng),
|
|
34
|
+
(this.lg = this.Jn.v(i.k.Ua) || this.lg);
|
|
35
|
+
for (let t = 0; t < this.cg.length; t++) {
|
|
36
|
+
const i = this.cg[t];
|
|
37
|
+
null != this.lg[i.id] && i.Bu(this.lg[i.id]);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
lg() {
|
|
41
|
-
this.cg = this.h.I(o.q.Ya) || 0;
|
|
42
|
-
const t = this.h.I(o.q.Ka) || [],
|
|
43
|
-
i = [];
|
|
44
|
-
for (let s = 0; s < t.length; s++) i.push(pt.Pn(t[s]));
|
|
45
|
-
(this.fg = i), this.gg();
|
|
46
|
-
}
|
|
47
40
|
ag() {
|
|
41
|
+
this.ug = this.Jn.v(i.k.Ga) || 0;
|
|
42
|
+
const t = this.Jn.v(i.k.Na) || [],
|
|
43
|
+
s = [];
|
|
44
|
+
for (let i = 0; i < t.length; i++) s.push(mt.Tn(t[i]));
|
|
45
|
+
(this.cg = s), this.fg();
|
|
46
|
+
}
|
|
47
|
+
gg() {
|
|
48
48
|
const t = this,
|
|
49
|
-
|
|
49
|
+
s = function(i, s, e, r, h) {
|
|
50
50
|
return function() {
|
|
51
|
-
t.
|
|
51
|
+
t.dg(i, s, e, r, h);
|
|
52
52
|
};
|
|
53
53
|
},
|
|
54
|
-
|
|
55
|
-
for (let t = 0; t < this.
|
|
56
|
-
let
|
|
57
|
-
for (let t = 0; t < this.
|
|
58
|
-
const
|
|
59
|
-
if (null != this.
|
|
60
|
-
const t = this.
|
|
54
|
+
e = {};
|
|
55
|
+
for (let t = 0; t < this.cg.length; t++) e[this.cg[t].id] = this.cg[t];
|
|
56
|
+
let r = !1;
|
|
57
|
+
for (let t = 0; t < this.cg.length; t++) {
|
|
58
|
+
const i = this.cg[t];
|
|
59
|
+
if (null != this.ng[i.id]) {
|
|
60
|
+
const t = this.ng[i.id],
|
|
61
61
|
h = [];
|
|
62
|
-
for (let
|
|
63
|
-
const o = t[
|
|
64
|
-
n =
|
|
62
|
+
for (let r = 0; r < t.length; r++) {
|
|
63
|
+
const o = t[r],
|
|
64
|
+
n = i.Cu(o.Hr);
|
|
65
65
|
if (n > 0) {
|
|
66
|
-
let t,
|
|
66
|
+
let t, r;
|
|
67
67
|
h.push(o),
|
|
68
|
-
null != o.
|
|
69
|
-
null != o.
|
|
68
|
+
null != o.mg && (t = o.mg),
|
|
69
|
+
null != o.pg && ue.Za(o.pg) && (r = ue.Tn(o.pg));
|
|
70
70
|
const l = [];
|
|
71
|
-
if (p(o.
|
|
72
|
-
for (let t = 0; t < o.
|
|
73
|
-
const i =
|
|
71
|
+
if (p(o.bg))
|
|
72
|
+
for (let t = 0; t < o.bg.length; t++) {
|
|
73
|
+
const i = e[o.bg[t]];
|
|
74
74
|
null != i && l.push(i);
|
|
75
75
|
}
|
|
76
|
-
this.
|
|
76
|
+
this.hg.push(setTimeout(s(i, o.Hr, t, r, l), n));
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
this.
|
|
80
|
-
((this.
|
|
81
|
-
(
|
|
82
|
-
0 === this.
|
|
79
|
+
this.ng[i.id].length > h.length &&
|
|
80
|
+
((this.ng[i.id] = h),
|
|
81
|
+
(r = !0),
|
|
82
|
+
0 === this.ng[i.id].length && delete this.ng[i.id]);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
r && this.Jn.D(i.k.Fa, this.ng);
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
Tg() {
|
|
88
88
|
const t = [];
|
|
89
|
-
for (let i = 0; i < this.
|
|
90
|
-
(this.
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
89
|
+
for (let i = 0; i < this.cg.length; i++) t.push(this.cg[i].ss());
|
|
90
|
+
(this.ug = new Date().valueOf()),
|
|
91
|
+
this.Jn.D(i.k.Na, t),
|
|
92
|
+
this.Jn.D(i.k.Ga, this.ug);
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
(this.
|
|
94
|
+
yg() {
|
|
95
|
+
(this.Jn.v(i.k.Ga) || 0) > this.ug ? this.ag() : this.fg();
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
let
|
|
97
|
+
Ts(t) {
|
|
98
|
+
let s = !1;
|
|
99
99
|
if (null != t && t.triggers) {
|
|
100
|
-
this.
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
this.
|
|
104
|
-
for (let
|
|
105
|
-
const
|
|
106
|
-
null != this.
|
|
107
|
-
(
|
|
108
|
-
null != this.
|
|
109
|
-
for (let t = 0; t <
|
|
110
|
-
if (
|
|
111
|
-
|
|
100
|
+
this.fg();
|
|
101
|
+
const e = {},
|
|
102
|
+
h = {};
|
|
103
|
+
this.cg = [];
|
|
104
|
+
for (let i = 0; i < t.triggers.length; i++) {
|
|
105
|
+
const r = mt.fromJson(t.triggers[i]);
|
|
106
|
+
null != this.lg[r.id] &&
|
|
107
|
+
(r.Bu(this.lg[r.id]), (e[r.id] = this.lg[r.id])),
|
|
108
|
+
null != this.ng[r.id] && (h[r.id] = this.ng[r.id]);
|
|
109
|
+
for (let t = 0; t < r.Du.length; t++)
|
|
110
|
+
if (r.Du[t].ec(tt.ks, null)) {
|
|
111
|
+
s = !0;
|
|
112
112
|
break;
|
|
113
113
|
}
|
|
114
|
-
null !=
|
|
114
|
+
null != r && this.cg.push(r);
|
|
115
115
|
}
|
|
116
|
-
ii(this.
|
|
117
|
-
ii(this.
|
|
118
|
-
this.
|
|
119
|
-
|
|
120
|
-
(r.
|
|
121
|
-
this.je(
|
|
122
|
-
this.je(
|
|
123
|
-
const
|
|
124
|
-
this.
|
|
125
|
-
for (let t = 0; t <
|
|
116
|
+
ii(this.lg, e) || ((this.lg = e), this.Jn.D(i.k.Ua, this.lg)),
|
|
117
|
+
ii(this.ng, h) || ((this.ng = h), this.Jn.D(i.k.Fa, this.ng)),
|
|
118
|
+
this.Tg(),
|
|
119
|
+
s &&
|
|
120
|
+
(r.j.info("Trigger with test condition found, firing test."),
|
|
121
|
+
this.je(tt.ks)),
|
|
122
|
+
this.je(tt.OPEN);
|
|
123
|
+
const o = this.eg;
|
|
124
|
+
this.eg = [];
|
|
125
|
+
for (let t = 0; t < o.length; t++) this.je.apply(this, o[t]);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
dg(t, i, s, e, h) {
|
|
129
129
|
const o = e => {
|
|
130
|
-
this.
|
|
130
|
+
this.fg();
|
|
131
131
|
const h = new Date().valueOf();
|
|
132
|
-
if (!t.
|
|
133
|
-
return !1 === navigator.onLine && t.type ===
|
|
134
|
-
? (r.
|
|
132
|
+
if (!t.Hu(i))
|
|
133
|
+
return !1 === navigator.onLine && t.type === mt._r.Mr && e.imageUrl
|
|
134
|
+
? (r.j.info(
|
|
135
135
|
`Not showing ${t.type} trigger action ${t.id} due to offline state.`
|
|
136
136
|
),
|
|
137
|
-
void this.
|
|
138
|
-
: void (t.
|
|
139
|
-
? 0 === this.
|
|
140
|
-
? r.
|
|
137
|
+
void this.sg.Ye(t.id, InAppMessage.Me.Dh))
|
|
138
|
+
: void (t.xu(h) && this.vg(t, h, s)
|
|
139
|
+
? 0 === this.ig.fu()
|
|
140
|
+
? r.j.info(
|
|
141
141
|
`Not displaying trigger ${t.id} because neither automaticallyShowInAppMessages() nor subscribeToInAppMessage() were called.`
|
|
142
142
|
)
|
|
143
|
-
: (this.
|
|
144
|
-
: r.
|
|
143
|
+
: (this.ig.Et([e]), this.wg(t, h))
|
|
144
|
+
: r.j.info(
|
|
145
145
|
`Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`
|
|
146
146
|
));
|
|
147
|
-
t.type ===
|
|
148
|
-
? this.
|
|
149
|
-
: this.
|
|
147
|
+
t.type === mt._r.Ju
|
|
148
|
+
? this.sg.Ye(t.id, InAppMessage.Me.Yi)
|
|
149
|
+
: this.sg.Ye(t.id, InAppMessage.Me.Mh);
|
|
150
150
|
},
|
|
151
151
|
n = () => {
|
|
152
|
-
this.
|
|
152
|
+
this.fg();
|
|
153
153
|
const o = h.pop();
|
|
154
154
|
if (null != o)
|
|
155
|
-
if ((this
|
|
155
|
+
if ((this.$g(o, i, s, e, h), o.Hu(i))) {
|
|
156
156
|
let t = `Server aborted in-app message display, but the timeout on fallback trigger ${o.id} has already elapsed.`;
|
|
157
157
|
h.length > 0 && (t += " Continuing to fall back."),
|
|
158
|
-
r.
|
|
159
|
-
this.
|
|
158
|
+
r.j.info(t),
|
|
159
|
+
this.sg.Ye(o.id, InAppMessage.Me.Mh),
|
|
160
160
|
n();
|
|
161
161
|
} else {
|
|
162
|
-
r.
|
|
162
|
+
r.j.info(
|
|
163
163
|
`Server aborted in-app message display. Falling back to lower priority ${o.type} trigger action ${t.id}.`
|
|
164
164
|
);
|
|
165
|
-
const n = 1e3 * o.
|
|
165
|
+
const n = 1e3 * o.Pu - (new Date().valueOf() - i);
|
|
166
166
|
n > 0
|
|
167
|
-
? this.
|
|
167
|
+
? this.hg.push(
|
|
168
168
|
setTimeout(() => {
|
|
169
|
-
this.
|
|
169
|
+
this.dg(o, i, s, e, h);
|
|
170
170
|
}, n)
|
|
171
171
|
)
|
|
172
|
-
: this.
|
|
172
|
+
: this.dg(o, i, s, e, h);
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
175
|
let l, a, g;
|
|
176
176
|
switch (t.type) {
|
|
177
|
-
case
|
|
178
|
-
if (((l =
|
|
179
|
-
r.
|
|
177
|
+
case mt._r.Mr:
|
|
178
|
+
if (((l = pt(t.data)), null == l)) {
|
|
179
|
+
r.j.error(
|
|
180
180
|
`Could not parse trigger data for trigger ${t.id}, ignoring.`
|
|
181
181
|
),
|
|
182
|
-
this.
|
|
182
|
+
this.sg.Ye(t.id, InAppMessage.Me.Gr);
|
|
183
183
|
break;
|
|
184
184
|
}
|
|
185
|
-
if (((a = this.
|
|
186
|
-
r.
|
|
185
|
+
if (((a = this.sg.Hi(l)), a)) {
|
|
186
|
+
r.j.error(a), n();
|
|
187
187
|
break;
|
|
188
188
|
}
|
|
189
189
|
o(l);
|
|
190
190
|
break;
|
|
191
|
-
case
|
|
192
|
-
if (((g = wt.fromJson(t.data, o, n, i, t.
|
|
193
|
-
r.
|
|
191
|
+
case mt._r.Ju:
|
|
192
|
+
if (((g = wt.fromJson(t.data, o, n, i, t.Jr)), null == g)) {
|
|
193
|
+
r.j.error(
|
|
194
194
|
`Could not parse trigger data for trigger ${t.id}, ignoring.`
|
|
195
195
|
),
|
|
196
|
-
this.
|
|
196
|
+
this.sg.Ye(t.id, InAppMessage.Me.Gr);
|
|
197
197
|
break;
|
|
198
198
|
}
|
|
199
|
-
this.
|
|
199
|
+
this.sg.Qi(g, s, e);
|
|
200
200
|
break;
|
|
201
201
|
default:
|
|
202
|
-
r.
|
|
202
|
+
r.j.error(
|
|
203
203
|
`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`
|
|
204
204
|
),
|
|
205
|
-
this.
|
|
205
|
+
this.sg.Ye(t.id, InAppMessage.Me.Gr);
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
je(t, i, s) {
|
|
209
|
-
if (!
|
|
210
|
-
if (this.
|
|
209
|
+
if (!H(tt, t, "Cannot fire trigger action.", "TriggerEvents")) return;
|
|
210
|
+
if (this.Ch._l())
|
|
211
211
|
return (
|
|
212
|
-
r.
|
|
212
|
+
r.j.info(
|
|
213
213
|
"Trigger sync is currently in progress, awaiting sync completion before firing trigger event."
|
|
214
214
|
),
|
|
215
|
-
void this.
|
|
215
|
+
void this.eg.push(arguments)
|
|
216
216
|
);
|
|
217
|
-
this.
|
|
217
|
+
this.yg();
|
|
218
218
|
const e = new Date().valueOf(),
|
|
219
|
-
h = e - this.
|
|
219
|
+
h = e - this.og;
|
|
220
220
|
let o = !0,
|
|
221
221
|
n = !0;
|
|
222
222
|
const l = [];
|
|
223
|
-
for (let s = 0; s < this.
|
|
224
|
-
const r = this.
|
|
225
|
-
h = e + 1e3 * r.
|
|
223
|
+
for (let s = 0; s < this.cg.length; s++) {
|
|
224
|
+
const r = this.cg[s],
|
|
225
|
+
h = e + 1e3 * r.Pu;
|
|
226
226
|
if (
|
|
227
|
-
r.
|
|
227
|
+
r.xu(h) &&
|
|
228
228
|
(null == r.startTime || r.startTime <= e) &&
|
|
229
229
|
(null == r.endTime || r.endTime >= e)
|
|
230
230
|
) {
|
|
231
231
|
let s = !1;
|
|
232
|
-
for (let e = 0; e < r.
|
|
233
|
-
if (r.
|
|
232
|
+
for (let e = 0; e < r.Du.length; e++)
|
|
233
|
+
if (r.Du[e].ec(t, i)) {
|
|
234
234
|
s = !0;
|
|
235
235
|
break;
|
|
236
236
|
}
|
|
237
|
-
s && ((o = !1), this.
|
|
237
|
+
s && ((o = !1), this.vg(r, h, t) && ((n = !1), l.push(r)));
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
if (o)
|
|
241
|
-
return void r.
|
|
241
|
+
return void r.j.info(
|
|
242
242
|
`Trigger event ${t} did not match any trigger conditions.`
|
|
243
243
|
);
|
|
244
244
|
if (n)
|
|
245
|
-
return void r.
|
|
245
|
+
return void r.j.info(
|
|
246
246
|
`Ignoring ${t} trigger event because a trigger was displayed ${h /
|
|
247
247
|
1e3}s ago.`
|
|
248
248
|
);
|
|
249
249
|
l.sort((t, i) => t.priority - i.priority);
|
|
250
250
|
const a = l.pop();
|
|
251
251
|
null != a &&
|
|
252
|
-
(r.
|
|
252
|
+
(r.j.info(
|
|
253
253
|
`Firing ${a.type} trigger action ${a.id} from trigger event ${t}.`
|
|
254
254
|
),
|
|
255
|
-
this
|
|
256
|
-
0 === a.
|
|
257
|
-
? this.
|
|
258
|
-
: this.
|
|
255
|
+
this.$g(a, e, t, s, l),
|
|
256
|
+
0 === a.Pu
|
|
257
|
+
? this.dg(a, e, t, s, l)
|
|
258
|
+
: this.hg.push(
|
|
259
259
|
setTimeout(() => {
|
|
260
|
-
this.
|
|
261
|
-
}, 1e3 * a.
|
|
260
|
+
this.dg(a, e, t, s, l);
|
|
261
|
+
}, 1e3 * a.Pu)
|
|
262
262
|
));
|
|
263
263
|
}
|
|
264
264
|
changeUser(t) {
|
|
265
|
-
if (((this.
|
|
266
|
-
(this.
|
|
267
|
-
for (let t = 0; t < this.
|
|
268
|
-
(this.
|
|
265
|
+
if (((this.cg = []), this.Jn.ri(i.k.Na), !t)) {
|
|
266
|
+
(this.eg = []), (this.og = null), (this.lg = {}), (this.ng = {});
|
|
267
|
+
for (let t = 0; t < this.hg.length; t++) clearTimeout(this.hg[t]);
|
|
268
|
+
(this.hg = []),
|
|
269
|
+
this.Jn.ri(i.k.La),
|
|
270
|
+
this.Jn.ri(i.k.Ua),
|
|
271
|
+
this.Jn.ri(i.k.Fa);
|
|
269
272
|
}
|
|
270
273
|
}
|
|
271
274
|
clearData() {
|
|
272
|
-
(this.
|
|
273
|
-
for (let t = 0; t < this.
|
|
274
|
-
this.
|
|
275
|
+
(this.cg = []), (this.og = null), (this.lg = {}), (this.ng = {});
|
|
276
|
+
for (let t = 0; t < this.hg.length; t++) clearTimeout(this.hg[t]);
|
|
277
|
+
this.hg = [];
|
|
275
278
|
}
|
|
276
|
-
|
|
277
|
-
if (null == this.
|
|
278
|
-
if (s ===
|
|
279
|
+
vg(t, i, s) {
|
|
280
|
+
if (null == this.og) return !0;
|
|
281
|
+
if (s === tt.ks)
|
|
279
282
|
return (
|
|
280
|
-
r.
|
|
283
|
+
r.j.info(
|
|
281
284
|
"Ignoring minimum interval between trigger because it is a test type."
|
|
282
285
|
),
|
|
283
286
|
!0
|
|
284
287
|
);
|
|
285
|
-
let e = t.
|
|
286
|
-
return null == e && (e = this.tg), i - this.
|
|
288
|
+
let e = t.Iu;
|
|
289
|
+
return null == e && (e = this.tg), i - this.og >= 1e3 * e;
|
|
287
290
|
}
|
|
288
|
-
|
|
289
|
-
this.
|
|
290
|
-
const
|
|
291
|
+
$g(t, s, e, r, h) {
|
|
292
|
+
this.fg(), (this.ng[t.id] = this.ng[t.id] || []);
|
|
293
|
+
const o = {};
|
|
291
294
|
let n;
|
|
292
|
-
(
|
|
295
|
+
(o.Hr = s), (o.mg = e), null != r && (n = r.ss()), (o.pg = n);
|
|
293
296
|
const l = [];
|
|
294
|
-
for (let t = 0; t <
|
|
295
|
-
(
|
|
297
|
+
for (let t = 0; t < h.length; t++) l.push(h[t].id);
|
|
298
|
+
(o.bg = l), this.ng[t.id].push(o), this.Jn.D(i.k.Fa, this.ng);
|
|
296
299
|
}
|
|
297
|
-
|
|
298
|
-
this.
|
|
299
|
-
t.
|
|
300
|
-
(this.
|
|
301
|
-
this.
|
|
302
|
-
(this.
|
|
303
|
-
this.
|
|
300
|
+
wg(t, s) {
|
|
301
|
+
this.fg(),
|
|
302
|
+
t.Bu(s),
|
|
303
|
+
(this.og = s),
|
|
304
|
+
this.Jn.D(i.k.La, s),
|
|
305
|
+
(this.lg[t.id] = s),
|
|
306
|
+
this.Jn.D(i.k.Ua, this.lg);
|
|
304
307
|
}
|
|
305
308
|
}
|
package/src/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/src/ui/js/attach-css.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import e, { OPTIONS as
|
|
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-${"4.
|
|
4
|
+
s = `ab-${t}-css-definitions-${"4.8.0".replace(/\./g, "-")}`,
|
|
5
5
|
a = c.ownerDocument || document;
|
|
6
6
|
if (null == a.getElementById(s)) {
|
|
7
7
|
const n = a.createElement("style");
|
|
8
8
|
(n.innerHTML = o), (n.id = s);
|
|
9
|
-
const t = e.nn(
|
|
9
|
+
const t = e.nn(L.lo);
|
|
10
10
|
null != t && n.setAttribute("nonce", t), c.appendChild(n);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import e, { OPTIONS as
|
|
1
|
+
import e, { OPTIONS as L } from "../../managers/braze-instance.js";
|
|
2
2
|
export function loadFontAwesome() {
|
|
3
|
-
if (e.nn(
|
|
3
|
+
if (e.nn(L.Lo)) return;
|
|
4
4
|
const t = "https://use.fontawesome.com/7f85a56ba4.css";
|
|
5
5
|
if (
|
|
6
6
|
!(null !== document.querySelector('link[rel=stylesheet][href="' + t + '"]'))
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
2
|
import { decodeBrazeActions as to } from "./string-utils.js";
|
|
3
3
|
import {
|
|
4
|
-
BRAZE_ACTION_URI_REGEX as
|
|
5
|
-
isValidBrazeActionType as
|
|
6
|
-
isValidBrazeActionJson as
|
|
4
|
+
BRAZE_ACTION_URI_REGEX as X,
|
|
5
|
+
isValidBrazeActionType as ro,
|
|
6
|
+
isValidBrazeActionJson as Y
|
|
7
7
|
} from "./validation-utils.js";
|
|
8
8
|
export const BRAZE_ACTIONS = {
|
|
9
9
|
types: {
|
|
10
|
-
|
|
10
|
+
le: "container",
|
|
11
11
|
logCustomEvent: "logCustomEvent",
|
|
12
12
|
setEmailNotificationSubscriptionType:
|
|
13
13
|
"setEmailNotificationSubscriptionType",
|
|
@@ -21,17 +21,17 @@ export const BRAZE_ACTIONS = {
|
|
|
21
21
|
de: "openLink",
|
|
22
22
|
pe: "openLinkInWebView"
|
|
23
23
|
},
|
|
24
|
-
properties: { type: "type",
|
|
24
|
+
properties: { type: "type", ce: "steps", me: "args" }
|
|
25
25
|
};
|
|
26
26
|
export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES = {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
Ji: "unknownBrazeAction",
|
|
28
|
+
Li: "noPushPrompt"
|
|
29
29
|
};
|
|
30
30
|
export const ineligibleBrazeActionURLErrorMessage = (t, o) => {
|
|
31
31
|
switch (t) {
|
|
32
|
-
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.
|
|
32
|
+
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Ji:
|
|
33
33
|
return `${o} contains an unknown braze action type and will not be displayed.`;
|
|
34
|
-
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.
|
|
34
|
+
case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Li:
|
|
35
35
|
return `${o} contains a push prompt braze action, but is not eligible for a push prompt. Ignoring.`;
|
|
36
36
|
default:
|
|
37
37
|
return "";
|
|
@@ -39,23 +39,23 @@ export const ineligibleBrazeActionURLErrorMessage = (t, o) => {
|
|
|
39
39
|
};
|
|
40
40
|
export function getDecodedBrazeAction(t) {
|
|
41
41
|
try {
|
|
42
|
-
let o = t.match(
|
|
42
|
+
let o = t.match(X)[0].length;
|
|
43
43
|
const e = t.substring(o);
|
|
44
44
|
if (o > t.length - 1 || !e)
|
|
45
|
-
return void r.
|
|
45
|
+
return void r.j.error(
|
|
46
46
|
`Did not find base64 encoded brazeAction in url to process : ${t}`
|
|
47
47
|
);
|
|
48
48
|
const n = to(e);
|
|
49
49
|
return n
|
|
50
50
|
? JSON.parse(n)
|
|
51
|
-
: void r.
|
|
51
|
+
: void r.j.error(`Failed to decode base64 encoded brazeAction: ${e}`);
|
|
52
52
|
} catch (o) {
|
|
53
|
-
return void r.
|
|
53
|
+
return void r.j.error(
|
|
54
54
|
`Failed to process brazeAction URL ${t} : ${o.message}`
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function eo(t, o) {
|
|
59
59
|
let r = !1;
|
|
60
60
|
for (const e of o) if (((r = r || t(e)), r)) return !0;
|
|
61
61
|
return !1;
|
|
@@ -63,17 +63,17 @@ function ro(t, o) {
|
|
|
63
63
|
export function containsUnknownBrazeAction(t) {
|
|
64
64
|
try {
|
|
65
65
|
const o = t[BRAZE_ACTIONS.properties.type];
|
|
66
|
-
return o === BRAZE_ACTIONS.types.
|
|
67
|
-
?
|
|
68
|
-
: !
|
|
66
|
+
return o === BRAZE_ACTIONS.types.le
|
|
67
|
+
? eo(containsUnknownBrazeAction, t[BRAZE_ACTIONS.properties.ce])
|
|
68
|
+
: !ro(o);
|
|
69
69
|
} catch (t) {
|
|
70
70
|
return !0;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
export function containsPushPrimerBrazeAction(t) {
|
|
74
|
-
if (!
|
|
74
|
+
if (!Y(t)) return !1;
|
|
75
75
|
const o = t[BRAZE_ACTIONS.properties.type];
|
|
76
|
-
return o === BRAZE_ACTIONS.types.
|
|
77
|
-
?
|
|
76
|
+
return o === BRAZE_ACTIONS.types.le
|
|
77
|
+
? eo(containsPushPrimerBrazeAction, t[BRAZE_ACTIONS.properties.ce])
|
|
78
78
|
: o === BRAZE_ACTIONS.types.requestPushPermission;
|
|
79
79
|
}
|