@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
|
@@ -5,34 +5,34 @@ import {
|
|
|
5
5
|
newBannerFromSerializedValue as o,
|
|
6
6
|
} from "./banner-factory.js";
|
|
7
7
|
import h from "../util/request-header-utils.js";
|
|
8
|
-
import
|
|
9
|
-
import { randomInclusive as
|
|
8
|
+
import a from "../util/net.js";
|
|
9
|
+
import { randomInclusive as l } from "../util/math.js";
|
|
10
10
|
import u from "../managers/subscription-manager.js";
|
|
11
11
|
import r from "../managers/braze-instance.js";
|
|
12
12
|
import c from "../common/event-logger.js";
|
|
13
|
-
import { EventTypes as
|
|
13
|
+
import { EventTypes as m } from "../../shared-lib/event-types.js";
|
|
14
14
|
export default class e extends t {
|
|
15
15
|
constructor(t, s, i, e) {
|
|
16
16
|
super(),
|
|
17
|
-
(this.
|
|
18
|
-
(this.
|
|
19
|
-
(this.
|
|
20
|
-
(this.
|
|
17
|
+
(this.h = t),
|
|
18
|
+
(this.B = s),
|
|
19
|
+
(this.j = i),
|
|
20
|
+
(this.C = e),
|
|
21
21
|
(this.banners = {}),
|
|
22
|
-
(this.
|
|
23
|
-
(this.
|
|
24
|
-
(this.
|
|
25
|
-
(this.
|
|
26
|
-
(this.
|
|
22
|
+
(this.h = t),
|
|
23
|
+
(this.B = s),
|
|
24
|
+
(this.j = i),
|
|
25
|
+
(this.C = e),
|
|
26
|
+
(this.S = 10),
|
|
27
|
+
(this.T = null),
|
|
27
28
|
(this.I = null),
|
|
28
|
-
(this.
|
|
29
|
-
(this.
|
|
30
|
-
|
|
31
|
-
(this.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (this.L() && null != t && t.banners) {
|
|
29
|
+
(this.R = new u()),
|
|
30
|
+
r.q(this.R),
|
|
31
|
+
(this.D = null),
|
|
32
|
+
(this.F = null);
|
|
33
|
+
}
|
|
34
|
+
N(t) {
|
|
35
|
+
if (this.k() && null != t && t.banners) {
|
|
36
36
|
this.banners = {};
|
|
37
37
|
const s = t.banners;
|
|
38
38
|
for (const t in s) {
|
|
@@ -41,91 +41,91 @@ export default class e extends t {
|
|
|
41
41
|
null != i && null != i.banner && (e = n(i.banner)),
|
|
42
42
|
e && (this.banners[t] = e);
|
|
43
43
|
}
|
|
44
|
-
this.
|
|
44
|
+
this.U(), this.R.L(this.banners);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
M(t, s, i, e = !0) {
|
|
48
48
|
var n;
|
|
49
49
|
const r = () => {
|
|
50
50
|
"function" == typeof i && i();
|
|
51
51
|
};
|
|
52
|
-
if (!this.
|
|
52
|
+
if (!this.k())
|
|
53
53
|
return void (
|
|
54
|
-
null === (n = this.
|
|
54
|
+
null === (n = this.h) ||
|
|
55
55
|
void 0 === n ||
|
|
56
|
-
n.
|
|
57
|
-
this
|
|
56
|
+
n.P(() => {
|
|
57
|
+
this.M(t, s, i);
|
|
58
58
|
})
|
|
59
59
|
);
|
|
60
|
-
const o = this.
|
|
60
|
+
const o = this.B;
|
|
61
61
|
if (!o) return void r();
|
|
62
|
-
e && this.
|
|
63
|
-
const u = o
|
|
62
|
+
e && this.X();
|
|
63
|
+
const u = o.$({}, !0),
|
|
64
64
|
c = [];
|
|
65
65
|
for (const s of t) c.push({ id: s });
|
|
66
66
|
u.placements = c;
|
|
67
|
-
const
|
|
68
|
-
let
|
|
69
|
-
o.
|
|
67
|
+
const m = o.A(u, h.H.G);
|
|
68
|
+
let d = !1;
|
|
69
|
+
o.J(
|
|
70
70
|
u,
|
|
71
71
|
(e = -1) => {
|
|
72
|
-
const n = this.
|
|
72
|
+
const n = this.B;
|
|
73
73
|
if (!n) return void r();
|
|
74
74
|
const o = new Date().valueOf();
|
|
75
|
-
h.
|
|
76
|
-
-1 !== e &&
|
|
77
|
-
|
|
78
|
-
url: `${n.
|
|
79
|
-
headers:
|
|
75
|
+
h.K(this.j, h.H.G, o),
|
|
76
|
+
-1 !== e && m.push(["X-Braze-Req-Tokens-Remaining", e.toString()]),
|
|
77
|
+
a.O({
|
|
78
|
+
url: `${n.V()}/banners/sync`,
|
|
79
|
+
headers: m,
|
|
80
80
|
data: u,
|
|
81
|
-
|
|
82
|
-
if (!n.
|
|
83
|
-
n.
|
|
81
|
+
W: (t) => {
|
|
82
|
+
if (!n.Y(u, t, m)) return (d = !0), void r();
|
|
83
|
+
n.Z(), this.N(t), (d = !1), "function" == typeof s && s();
|
|
84
84
|
},
|
|
85
85
|
error: (t) => {
|
|
86
|
-
n.
|
|
86
|
+
n._(t, "retrieving banners"), (d = !0), r();
|
|
87
87
|
},
|
|
88
|
-
|
|
88
|
+
tt: (e, r) => {
|
|
89
89
|
let o;
|
|
90
|
-
if (((this.
|
|
91
|
-
let t = this.
|
|
92
|
-
(null == t || t < 1e3 * this.
|
|
93
|
-
(o = Math.min(3e5,
|
|
90
|
+
if (((this.F = t), d)) {
|
|
91
|
+
let t = this.T;
|
|
92
|
+
(null == t || t < 1e3 * this.S) && (t = 1e3 * this.S),
|
|
93
|
+
(o = Math.min(3e5, l(1e3 * this.S, 3 * t)));
|
|
94
94
|
}
|
|
95
|
-
n.
|
|
95
|
+
n.st(
|
|
96
96
|
r,
|
|
97
97
|
() => {
|
|
98
|
-
this
|
|
98
|
+
this.M(t, s, i, !1);
|
|
99
99
|
},
|
|
100
|
-
h.
|
|
101
|
-
(t) => this.
|
|
102
|
-
() => this.
|
|
100
|
+
h.H.G,
|
|
101
|
+
(t) => this.it(t),
|
|
102
|
+
() => this.X(),
|
|
103
103
|
o,
|
|
104
104
|
);
|
|
105
105
|
},
|
|
106
106
|
});
|
|
107
107
|
},
|
|
108
|
-
h.
|
|
108
|
+
h.H.G,
|
|
109
109
|
i,
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
return this.
|
|
112
|
+
et() {
|
|
113
|
+
return this.F;
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
nt(t, s) {
|
|
116
116
|
const i = { id: t.id };
|
|
117
117
|
s && (i.bid = s);
|
|
118
|
-
return c.
|
|
118
|
+
return c.rt(m.ot, i).W;
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
null != this.
|
|
120
|
+
X() {
|
|
121
|
+
null != this.I && (clearTimeout(this.I), (this.I = null));
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
this.
|
|
123
|
+
it(t) {
|
|
124
|
+
this.X(), (this.I = t);
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
ht() {
|
|
127
127
|
let t = {};
|
|
128
|
-
this.
|
|
128
|
+
this.j && (t = this.j.lt(s.ct.ut));
|
|
129
129
|
const i = {};
|
|
130
130
|
for (const s in t) {
|
|
131
131
|
let e = null;
|
|
@@ -133,72 +133,66 @@ export default class e extends t {
|
|
|
133
133
|
}
|
|
134
134
|
return i;
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
U() {
|
|
137
137
|
var t;
|
|
138
|
-
if (!this.
|
|
138
|
+
if (!this.j) return;
|
|
139
139
|
const i = {};
|
|
140
140
|
for (const s in this.banners) {
|
|
141
141
|
const e =
|
|
142
|
-
(null === (t = this.banners[s]) || void 0 === t ? void 0 : t.
|
|
142
|
+
(null === (t = this.banners[s]) || void 0 === t ? void 0 : t.dt()) ||
|
|
143
143
|
null;
|
|
144
144
|
i[s] = e;
|
|
145
145
|
}
|
|
146
|
-
this.
|
|
146
|
+
this.j.ft(s.ct.ut, i), this.vt();
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
vt() {
|
|
149
149
|
var t, i;
|
|
150
|
-
null === (t = this.
|
|
150
|
+
null === (t = this.j) ||
|
|
151
151
|
void 0 === t ||
|
|
152
|
-
t.
|
|
152
|
+
t.ft(s.ct.gt, null === (i = this.C) || void 0 === i ? void 0 : i.bt());
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
Bt() {
|
|
155
155
|
var t;
|
|
156
156
|
return (
|
|
157
|
-
(null === (t = this.
|
|
157
|
+
(null === (t = this.j) || void 0 === t ? void 0 : t.lt(s.ct.gt)) || null
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
|
-
|
|
161
|
-
return this.
|
|
162
|
-
}
|
|
163
|
-
Tt(t) {
|
|
164
|
-
this.N = t;
|
|
160
|
+
jt() {
|
|
161
|
+
return this.D;
|
|
165
162
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const s = null === (t = this.T) || void 0 === t ? void 0 : t.St(),
|
|
169
|
-
i = this.wt();
|
|
170
|
-
return null != i && s === i;
|
|
163
|
+
yt(t) {
|
|
164
|
+
this.D = t;
|
|
171
165
|
}
|
|
172
|
-
|
|
166
|
+
Ct() {
|
|
173
167
|
var t;
|
|
174
|
-
const s = null === (t = this.
|
|
175
|
-
i = this.
|
|
168
|
+
const s = null === (t = this.C) || void 0 === t ? void 0 : t.bt(),
|
|
169
|
+
i = this.Bt();
|
|
176
170
|
return null == i || s === i;
|
|
177
171
|
}
|
|
178
|
-
|
|
179
|
-
return this.
|
|
172
|
+
St(t) {
|
|
173
|
+
return this.R.wt(t);
|
|
180
174
|
}
|
|
181
|
-
|
|
175
|
+
Tt() {
|
|
182
176
|
var t;
|
|
183
177
|
return (
|
|
184
|
-
(null === (t = this.
|
|
178
|
+
(null === (t = this.j) || void 0 === t ? void 0 : t.lt(s.ct.It)) || {}
|
|
185
179
|
);
|
|
186
180
|
}
|
|
187
|
-
|
|
188
|
-
this.
|
|
181
|
+
Rt(t) {
|
|
182
|
+
this.j && this.j.ft(s.ct.It, t);
|
|
189
183
|
}
|
|
190
184
|
changeUser() {
|
|
191
|
-
this.
|
|
185
|
+
this.qt(), this.X();
|
|
192
186
|
}
|
|
193
187
|
clearData() {
|
|
194
|
-
this.
|
|
188
|
+
this.X();
|
|
195
189
|
}
|
|
196
|
-
|
|
197
|
-
return !!this.
|
|
190
|
+
k() {
|
|
191
|
+
return !!this.h && (!!this.h.Dt() || (0 !== this.h.Ft() && this.qt(), !1));
|
|
198
192
|
}
|
|
199
|
-
|
|
193
|
+
qt() {
|
|
200
194
|
(this.banners = {}),
|
|
201
|
-
this.
|
|
202
|
-
this.
|
|
195
|
+
this.j && (this.j.Nt(s.ct.ut), this.j.Nt(s.ct.It)),
|
|
196
|
+
this.R.L({});
|
|
203
197
|
}
|
|
204
198
|
}
|
package/src/Banner/banner.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
(this.
|
|
6
|
-
(this.
|
|
1
|
+
import { PropertiesBase as p } from "../common/properties-base.js";
|
|
2
|
+
export default class Banner extends p {
|
|
3
|
+
constructor(t, s, i, h = !1, r = !1, e = -1, o = {}) {
|
|
4
|
+
super(o),
|
|
5
|
+
(this.id = t),
|
|
6
|
+
(this.placementId = s),
|
|
7
|
+
(this.html = i),
|
|
8
|
+
(this.xt = h),
|
|
7
9
|
(this.isControl = r),
|
|
8
|
-
(this.
|
|
10
|
+
(this.zt = e),
|
|
9
11
|
(this.id = t),
|
|
10
|
-
(this.placementId =
|
|
11
|
-
(this.html =
|
|
12
|
-
(this.
|
|
12
|
+
(this.placementId = s),
|
|
13
|
+
(this.html = i),
|
|
14
|
+
(this.xt = h),
|
|
13
15
|
(this.isControl = r),
|
|
14
|
-
(this.
|
|
15
|
-
(this.
|
|
16
|
+
(this.zt = e),
|
|
17
|
+
(this.kt = !1);
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
At() {
|
|
18
20
|
return this.isControl;
|
|
19
21
|
}
|
|
20
|
-
|
|
22
|
+
dt() {
|
|
21
23
|
return {
|
|
22
24
|
id: this.id,
|
|
23
|
-
|
|
25
|
+
pid: this.placementId,
|
|
24
26
|
html: this.html,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
its: this.xt,
|
|
28
|
+
ic: this.isControl,
|
|
29
|
+
eat: this.zt,
|
|
30
|
+
pr: this.properties,
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
attachHtmlToIframeWithNonce as
|
|
3
|
-
buildBrazeBridge as
|
|
2
|
+
attachHtmlToIframeWithNonce as b,
|
|
3
|
+
buildBrazeBridge as N,
|
|
4
4
|
} from "../../util/html-display-utils.js";
|
|
5
|
-
import
|
|
6
|
-
import { logBannerClick as
|
|
5
|
+
import E from "../../../shared-lib/logger.js";
|
|
6
|
+
import { logBannerClick as _ } from "../log-banner-click.js";
|
|
7
7
|
export const BANNER_PLACEMENT_ID = "data-ab-banner-placement-id";
|
|
8
8
|
export const BANNER_HTML_CLASS = "ab-html-banner";
|
|
9
9
|
export const CONTROL_BANNER_HTML_CLASS = "ab-html-control-banner";
|
|
@@ -17,7 +17,7 @@ export function controlBannerToHtml(n) {
|
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
export function bannerToHtml(n, t) {
|
|
20
|
-
if (n.
|
|
20
|
+
if (n.At()) return controlBannerToHtml(n);
|
|
21
21
|
const e = document.createElement("iframe");
|
|
22
22
|
return (
|
|
23
23
|
(e.id = n.id),
|
|
@@ -25,19 +25,19 @@ export function bannerToHtml(n, t) {
|
|
|
25
25
|
(e.className = "ab-html-banner"),
|
|
26
26
|
e.setAttribute(BANNER_PLACEMENT_ID, n.placementId),
|
|
27
27
|
e.setAttribute("title", "Banner"),
|
|
28
|
-
|
|
28
|
+
b(e, n.html, t),
|
|
29
29
|
(e.onload = () => {
|
|
30
30
|
const t = e.contentWindow,
|
|
31
31
|
o = t.document.getElementsByTagName("title");
|
|
32
32
|
o && o.length > 0 && e.setAttribute("title", o[0].textContent || "");
|
|
33
|
-
const r = Object.assign(Object.assign({},
|
|
33
|
+
const r = Object.assign(Object.assign({}, N(e)), {
|
|
34
34
|
logClick: function () {
|
|
35
|
-
|
|
35
|
+
_(n, ...arguments);
|
|
36
36
|
},
|
|
37
37
|
closeMessage: function () {},
|
|
38
38
|
setBannerHeight: (n) => {
|
|
39
39
|
isNaN(n) || !isFinite(n) || n < 0
|
|
40
|
-
?
|
|
40
|
+
? E.warn(`Invalid banner height: ${n}`)
|
|
41
41
|
: (e.style.height = `${n}px`);
|
|
42
42
|
},
|
|
43
43
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { removeSubscription } from "../../Core/remove-subscription.js";
|
|
2
|
-
import { SUBSCRIPTION_ID_DATA_ATTRIBUTE as
|
|
2
|
+
import { SUBSCRIPTION_ID_DATA_ATTRIBUTE as f } from "../../common/constants.js";
|
|
3
3
|
export function destroyBannerHtml(o) {
|
|
4
|
-
const n = o.getAttribute(
|
|
4
|
+
const n = o.getAttribute(f);
|
|
5
5
|
null != n && removeSubscription(n),
|
|
6
6
|
o && o.parentNode && o.parentNode.removeChild(o);
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
impressOnBottom as
|
|
2
|
+
impressOnBottom as d,
|
|
3
3
|
impressOnTop as j,
|
|
4
4
|
detectImpression as $,
|
|
5
5
|
} from "../../common/detect-impression.js";
|
|
@@ -22,7 +22,7 @@ export function detectBannerImpressions() {
|
|
|
22
22
|
if (m && r) continue;
|
|
23
23
|
const e = g(s),
|
|
24
24
|
c = x(s);
|
|
25
|
-
e && !m && j(s), c && !r &&
|
|
25
|
+
e && !m && j(s), c && !r && d(s), $.oo(s) && $.no(s) && t.push(i);
|
|
26
26
|
}
|
|
27
27
|
t.length > 0 && B(t);
|
|
28
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger as
|
|
1
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
import { BANNERS_DISABLED_MESSAGE as v } from "../common/constants.js";
|
|
3
3
|
import r from "../managers/braze-instance.js";
|
|
4
4
|
import i from "./banner-provider-factory.js";
|
|
@@ -6,13 +6,13 @@ import { getBannerIfNotExpired as y } from "./get-banner.js";
|
|
|
6
6
|
export function getAllBanners() {
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
const n = {},
|
|
9
|
-
o = r.
|
|
9
|
+
o = r.l();
|
|
10
10
|
if (
|
|
11
|
-
(!1 === (null == o ? void 0 : o.
|
|
12
|
-
!(null == o ? void 0 : o.
|
|
11
|
+
(!1 === (null == o ? void 0 : o.Dt()) && E.error(v),
|
|
12
|
+
!(null == o ? void 0 : o.Dt()))
|
|
13
13
|
)
|
|
14
14
|
return n;
|
|
15
|
-
const t = i.
|
|
15
|
+
const t = i.o().ht();
|
|
16
16
|
for (const r in t) n[r] = y(t, r);
|
|
17
17
|
return n;
|
|
18
18
|
}
|
package/src/Banner/get-banner.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { logger as
|
|
1
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
import { BANNERS_DISABLED_MESSAGE as v } from "../common/constants.js";
|
|
3
3
|
import r from "../managers/braze-instance.js";
|
|
4
4
|
import i from "./banner-provider-factory.js";
|
|
5
5
|
export function getBannerIfNotExpired(n, r) {
|
|
6
6
|
const e = n[r];
|
|
7
7
|
if (!e) return null;
|
|
8
|
-
const t = e.
|
|
8
|
+
const t = e.zt,
|
|
9
9
|
o = new Date().valueOf();
|
|
10
10
|
return -1 !== t && 1e3 * t < o
|
|
11
|
-
? (
|
|
11
|
+
? (E.info(`Banner with ID: ${e.id} and placement ID: ${r} has expired.`),
|
|
12
12
|
null)
|
|
13
13
|
: e;
|
|
14
14
|
}
|
|
15
15
|
export function getBanner(n) {
|
|
16
16
|
var e;
|
|
17
17
|
if (!r.rr()) return;
|
|
18
|
-
!1 === (null === (e = r.
|
|
19
|
-
const t = i.
|
|
20
|
-
if (!t.
|
|
21
|
-
return getBannerIfNotExpired(t.
|
|
18
|
+
!1 === (null === (e = r.l()) || void 0 === e ? void 0 : e.Dt()) && E.error(v);
|
|
19
|
+
const t = i.o();
|
|
20
|
+
if (!t.k()) return null;
|
|
21
|
+
return getBannerIfNotExpired(t.ht(), n);
|
|
22
22
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
2
|
import Banner from "./banner.js";
|
|
3
|
-
import { logger as
|
|
3
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
4
4
|
import i from "./banner-provider-factory.js";
|
|
5
5
|
import { keys as C } from "../util/code-utils.js";
|
|
6
6
|
export function logBannerClick(n, o) {
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
if (!(n instanceof Banner))
|
|
9
9
|
return (
|
|
10
|
-
|
|
10
|
+
E.error("Banner argument to logBannerClick must be an Banner object."), !1
|
|
11
11
|
);
|
|
12
|
-
const e = i.
|
|
13
|
-
t = e.
|
|
12
|
+
const e = i.o(),
|
|
13
|
+
t = e.ht();
|
|
14
14
|
return 0 === C(t).length
|
|
15
|
-
? (
|
|
15
|
+
? (E.info("Not logging banner click. No banners exist."), !1)
|
|
16
16
|
: t[n.placementId]
|
|
17
|
-
? e.
|
|
18
|
-
: (
|
|
17
|
+
? e.nt(n, o)
|
|
18
|
+
: (E.info(
|
|
19
19
|
`Not logging banner click for ID ${n.placementId}. The placement ID did not correspond to any banner.`,
|
|
20
20
|
),
|
|
21
21
|
!1);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger as
|
|
1
|
+
import { logger as E, EventTypes as m } from "../../shared-lib/index.js";
|
|
2
2
|
import c from "../common/event-logger.js";
|
|
3
3
|
import r from "../managers/braze-instance.js";
|
|
4
4
|
import { keys as C } from "../util/code-utils.js";
|
|
@@ -6,26 +6,26 @@ import i from "./banner-provider-factory.js";
|
|
|
6
6
|
export function logBannerImpressions(o) {
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
if (!o || o.length <= 0) return !1;
|
|
9
|
-
const n = i.
|
|
10
|
-
s = n.
|
|
9
|
+
const n = i.o(),
|
|
10
|
+
s = n.ht();
|
|
11
11
|
if (0 === C(s).length)
|
|
12
|
-
return
|
|
13
|
-
const e = n.
|
|
12
|
+
return E.info("Not logging banners impression. No banners exist."), !1;
|
|
13
|
+
const e = n.Tt(),
|
|
14
14
|
t = [];
|
|
15
15
|
for (const r of o) {
|
|
16
16
|
const o = s[r];
|
|
17
17
|
o
|
|
18
18
|
? e[o.placementId]
|
|
19
|
-
?
|
|
19
|
+
? E.info(
|
|
20
20
|
`Not logging banners impression for ID ${r}. This ID was already logged this session.`,
|
|
21
21
|
)
|
|
22
22
|
: ((e[o.placementId] = !0), t.push(o.id))
|
|
23
|
-
:
|
|
23
|
+
: E.info(
|
|
24
24
|
`Not logging banners impression for ID ${r}. The placement ID did not correspond to any banner.`,
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
if (0 === t.length) return !1;
|
|
28
|
-
n.
|
|
28
|
+
n.Rt(e);
|
|
29
29
|
const a = { ids: t };
|
|
30
|
-
return c.
|
|
30
|
+
return c.rt(m.ro, a).W;
|
|
31
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger as
|
|
1
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
2
2
|
import {
|
|
3
3
|
BANNERS_DISABLED_MESSAGE as v,
|
|
4
4
|
BRAZE_MUST_BE_INITIALIZED_ERROR as w,
|
|
@@ -7,28 +7,24 @@ import r, { OPTIONS as z } from "../managers/braze-instance.js";
|
|
|
7
7
|
import { isArray as D } from "../util/code-utils.js";
|
|
8
8
|
import { isValidBannerPlacementId as R } from "../util/validation-utils.js";
|
|
9
9
|
import i from "./banner-provider-factory.js";
|
|
10
|
-
export function requestBannersRefresh(e,
|
|
11
|
-
if (!r.rr()) return void
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
10
|
+
export function requestBannersRefresh(e, t, n) {
|
|
11
|
+
if (!r.rr()) return void E.warn(w);
|
|
12
|
+
const o = r.l();
|
|
13
|
+
if (!o) return;
|
|
14
14
|
if (!D(e) || 0 === e.length)
|
|
15
|
-
return void
|
|
15
|
+
return void E.warn("placementIds should be a non-empty array.");
|
|
16
16
|
if (!r.ee(z.re))
|
|
17
|
-
return void
|
|
17
|
+
return void E.error(
|
|
18
18
|
"Banners are disabled. Use the 'allowUserSuppliedJavascript' option for braze.initialize to enable these messages.",
|
|
19
19
|
);
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
return void
|
|
23
|
-
|
|
24
|
-
);
|
|
25
|
-
if ((!1 === s.zt() && N.error(v), !o.L()))
|
|
26
|
-
return void s.A(() => {
|
|
27
|
-
requestBannersRefresh(e, n, t);
|
|
20
|
+
const s = i.o();
|
|
21
|
+
if ((!1 === o.Dt() && E.error(v), !s.k()))
|
|
22
|
+
return void o.P(() => {
|
|
23
|
+
requestBannersRefresh(e, t, n);
|
|
28
24
|
});
|
|
29
|
-
const a =
|
|
25
|
+
const a = o.te();
|
|
30
26
|
e.length > a &&
|
|
31
|
-
(
|
|
27
|
+
(E.warn(
|
|
32
28
|
`Number of placement IDs requested exceeds the max allowed. Trimming placementIds array from length ${e.length} to ${a} (max allowed).`,
|
|
33
29
|
),
|
|
34
30
|
(e = e.slice(0, a))),
|
|
@@ -36,11 +32,11 @@ export function requestBannersRefresh(e, n, t) {
|
|
|
36
32
|
(e = e.filter(
|
|
37
33
|
(e) =>
|
|
38
34
|
!!R(e) ||
|
|
39
|
-
(
|
|
35
|
+
(E.warn(
|
|
40
36
|
`Placement ID should be a valid utf8 string with no whitespaces, filtering out: ${e}`,
|
|
41
37
|
),
|
|
42
38
|
!1),
|
|
43
39
|
)).length &&
|
|
44
|
-
(
|
|
45
|
-
|
|
40
|
+
(E.info(`Requesting banners for placement IDs: ${JSON.stringify(e)}`),
|
|
41
|
+
s.M(e, t, n));
|
|
46
42
|
}
|
|
@@ -4,21 +4,21 @@ import { getAllBanners } from "./get-all-banners.js";
|
|
|
4
4
|
export function subscribeToBannersUpdates(n) {
|
|
5
5
|
var o;
|
|
6
6
|
if (!r.rr()) return;
|
|
7
|
-
const t = i.
|
|
8
|
-
if (t.
|
|
7
|
+
const t = i.o();
|
|
8
|
+
if (t.Ct()) {
|
|
9
9
|
const r = getAllBanners();
|
|
10
10
|
r && "function" == typeof n && n(r);
|
|
11
11
|
}
|
|
12
|
-
const s = t.
|
|
13
|
-
if (!t.
|
|
12
|
+
const s = t.St(n);
|
|
13
|
+
if (!t.jt()) {
|
|
14
14
|
const n =
|
|
15
15
|
null === (o = r.nn()) || void 0 === o
|
|
16
16
|
? void 0
|
|
17
17
|
: o.rn(() => {
|
|
18
|
-
const n = t.
|
|
19
|
-
n && n.length > 0 && t
|
|
18
|
+
const n = t.et();
|
|
19
|
+
n && n.length > 0 && t.M(n);
|
|
20
20
|
});
|
|
21
|
-
n && t.
|
|
21
|
+
n && t.yt(n);
|
|
22
22
|
}
|
|
23
23
|
return s;
|
|
24
24
|
}
|