@braze/web-sdk 4.3.0 → 4.5.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 +68 -6
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +8 -1
- package/shared-lib/encoding-utils.js +12 -1
- package/shared-lib/event-types.js +32 -1
- package/shared-lib/guid.js +10 -1
- package/shared-lib/indexed-db-adapter.js +315 -1
- package/shared-lib/logger.js +38 -1
- package/shared-lib/supported-options.js +26 -1
- package/src/Card/card-manager-factory.js +14 -1
- package/src/Card/card-manager.js +72 -1
- package/src/Card/display/card-display.js +134 -1
- package/src/Card/index.js +5 -1
- package/src/Card/log-card-click.js +11 -1
- package/src/Card/log-card-dismissal.js +11 -1
- package/src/Card/log-card-impressions.js +13 -1
- package/src/Card/log-content-card-impressions.js +4 -1
- package/src/Card/models/banner.js +30 -1
- package/src/Card/models/captioned-image.js +32 -1
- package/src/Card/models/card.js +175 -1
- package/src/Card/models/classic-card.js +32 -1
- package/src/Card/models/control-card.js +39 -1
- package/src/Card/models/index.js +5 -1
- package/src/Card/util/card-factory.js +104 -1
- package/src/ContentCards/content-cards-provider-factory.js +20 -1
- package/src/ContentCards/content-cards-provider.js +283 -1
- package/src/ContentCards/content-cards.js +24 -1
- package/src/ContentCards/get-cached-content-cards.js +5 -1
- package/src/ContentCards/index.js +8 -1
- package/src/ContentCards/log-content-cards-displayed.js +5 -1
- package/src/ContentCards/request-content-cards-refresh.js +5 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +14 -1
- package/src/ContentCards/ui/hide-content-cards.js +8 -1
- package/src/ContentCards/ui/show-content-cards.js +72 -1
- package/src/ContentCards/ui/toggle-content-cards.js +8 -1
- package/src/Core/add-sdk-metadata.js +27 -1
- package/src/Core/braze-sdk-metadata.js +10 -1
- package/src/Core/change-user.js +19 -1
- package/src/Core/destroy.js +5 -1
- package/src/Core/device-properties.js +9 -1
- package/src/Core/disable-sdk.js +10 -1
- package/src/Core/enable-sdk.js +8 -1
- package/src/Core/get-device-id.js +10 -1
- package/src/Core/get-user.js +4 -1
- package/src/Core/handle-braze-action.js +64 -1
- package/src/Core/index.js +23 -1
- package/src/Core/initialize.js +4 -1
- package/src/Core/is-disabled.js +4 -1
- package/src/Core/log-custom-event.js +36 -1
- package/src/Core/log-purchase.js +245 -1
- package/src/Core/open-session.js +23 -1
- package/src/Core/remove-all-subscriptions.js +4 -1
- package/src/Core/remove-subscription.js +4 -1
- package/src/Core/request-immediate-data-flush.js +4 -1
- package/src/Core/set-logger.js +4 -1
- package/src/Core/set-sdk-authentication-signature.js +9 -1
- package/src/Core/subscribe-to-sdk-authentication-failures.js +4 -1
- package/src/Core/toggle-logging.js +4 -1
- package/src/Core/wipe-data.js +15 -1
- package/src/FeatureFlags/feature-flag-factory.js +14 -0
- package/src/FeatureFlags/feature-flag.js +16 -0
- package/src/FeatureFlags/feature-flags-provider-factory.js +19 -0
- package/src/FeatureFlags/feature-flags-provider.js +94 -0
- package/src/FeatureFlags/get-all-feature-flags.js +12 -0
- package/src/FeatureFlags/get-feature-flag.js +12 -0
- package/src/FeatureFlags/index.js +4 -0
- package/src/FeatureFlags/refresh-feature-flags.js +9 -0
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +6 -0
- package/src/Feed/feed-provider-factory.js +18 -1
- package/src/Feed/feed-provider.js +79 -1
- package/src/Feed/feed.js +20 -1
- package/src/Feed/get-cached-feed.js +5 -1
- package/src/Feed/index.js +8 -1
- package/src/Feed/log-feed-displayed.js +5 -1
- package/src/Feed/request-feed-refresh.js +5 -1
- package/src/Feed/subscribe-to-feed-updates.js +5 -1
- package/src/Feed/ui/hide-feed.js +7 -1
- package/src/Feed/ui/show-feed.js +89 -1
- package/src/Feed/ui/toggle-feed.js +8 -1
- package/src/InAppMessage/display/get-animation-effect.js +19 -1
- package/src/InAppMessage/display/html-message-to-html.js +223 -1
- package/src/InAppMessage/display/in-app-message-to-html.js +152 -1
- package/src/InAppMessage/display/modal-utils.js +68 -1
- package/src/InAppMessage/in-app-message-factory.js +145 -1
- package/src/InAppMessage/in-app-message-manager-factory.js +16 -1
- package/src/InAppMessage/in-app-message-manager.js +189 -1
- package/src/InAppMessage/index.js +14 -1
- package/src/InAppMessage/log-in-app-message-button-click.js +19 -1
- package/src/InAppMessage/log-in-app-message-click.js +19 -1
- package/src/InAppMessage/log-in-app-message-html-click.js +23 -1
- package/src/InAppMessage/log-in-app-message-impression.js +13 -1
- package/src/InAppMessage/models/control-message.js +8 -1
- package/src/InAppMessage/models/full-screen-message.js +71 -1
- package/src/InAppMessage/models/html-message.js +54 -1
- package/src/InAppMessage/models/in-app-message-button.js +40 -1
- package/src/InAppMessage/models/in-app-message.js +271 -1
- package/src/InAppMessage/models/modal-message.js +68 -1
- package/src/InAppMessage/models/slide-up-message.js +58 -1
- package/src/InAppMessage/models/templated-in-app-message.js +14 -1
- package/src/InAppMessage/subscribe-to-in-app-message.js +10 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +15 -1
- package/src/InAppMessage/ui/show-in-app-message.js +170 -1
- package/src/Push/index.js +5 -1
- package/src/Push/is-push-blocked.js +5 -1
- package/src/Push/is-push-permission-granted.js +5 -1
- package/src/Push/is-push-supported.js +5 -1
- package/src/Push/push-manager-factory.js +30 -1
- package/src/Push/push-manager.js +360 -1
- package/src/Push/request-push-permission.js +8 -1
- package/src/Push/unregister-push.js +5 -1
- package/src/Push/utils/push-utils.js +34 -1
- package/src/User/index.js +1 -1
- package/src/User/user-manager.js +70 -1
- package/src/User/user.js +278 -1
- package/src/common/base-feed.js +25 -1
- package/src/common/base-provider.js +6 -1
- package/src/common/constants.js +5 -1
- package/src/common/event-logger.js +24 -1
- package/src/common/feed-display.js +200 -1
- package/src/common/translations.js +148 -1
- package/src/index.js +9 -1
- package/src/l10n/l10n-manager-factory.js +22 -1
- package/src/l10n/l10n-manager.js +21 -1
- package/src/managers/auth-manager.js +48 -1
- package/src/managers/braze-instance.js +307 -1
- package/src/managers/device-manager.js +80 -1
- package/src/managers/network-manager.js +219 -1
- package/src/managers/server-config-manager.js +88 -1
- package/src/managers/session-manager.js +68 -1
- package/src/managers/storage-manager-factory.js +35 -1
- package/src/managers/storage-manager.js +394 -1
- package/src/managers/subscription-manager.js +25 -1
- package/src/models/backend-errors.js +8 -1
- package/src/models/braze-event.js +41 -1
- package/src/models/braze-sdk-metadata.js +10 -1
- package/src/models/device.js +26 -1
- package/src/models/identifier.js +20 -1
- package/src/models/push-token.js +22 -1
- package/src/models/request-result.js +8 -1
- package/src/models/server-config.js +32 -1
- package/src/request-controller.js +288 -1
- package/src/triggers/models/custom-event-data.js +14 -1
- package/src/triggers/models/custom-event-property-data.js +21 -1
- package/src/triggers/models/filter-set.js +55 -1
- package/src/triggers/models/filter.js +98 -1
- package/src/triggers/models/in-app-message-click-data.js +25 -1
- package/src/triggers/models/purchase-data.js +14 -1
- package/src/triggers/models/purchase-property-data.js +21 -1
- package/src/triggers/models/push-click-data.js +15 -1
- package/src/triggers/models/trigger-condition.js +109 -1
- package/src/triggers/models/trigger-events.js +8 -1
- package/src/triggers/models/trigger.js +110 -1
- package/src/triggers/triggers-provider-factory.js +30 -1
- package/src/triggers/triggers-provider.js +307 -1
- package/src/ui/js/attach-css.js +12 -1
- package/src/ui/js/feed-css.js +12 -1
- package/src/ui/js/iam-css.js +12 -1
- package/src/ui/js/index.js +3 -1
- package/src/ui/js/load-font-awesome.js +13 -1
- package/src/util/base-device-parser.js +14 -1
- package/src/util/braze-actions.js +79 -1
- package/src/util/browser-detector.js +85 -1
- package/src/util/client-hints-parser.js +60 -1
- package/src/util/code-utils.js +92 -1
- package/src/util/color-utils.js +23 -1
- package/src/util/component-utils.js +26 -1
- package/src/util/date-utils.js +27 -1
- package/src/util/deprecation-utils.js +5 -1
- package/src/util/device-constants.js +14 -1
- package/src/util/dom-utils.js +87 -1
- package/src/util/key-codes.js +1 -1
- package/src/util/math.js +5 -1
- package/src/util/net.js +75 -1
- package/src/util/string-utils.js +22 -1
- package/src/util/url-utils.js +23 -1
- package/src/util/user-agent-parser.js +85 -1
- package/src/util/validation-utils.js +136 -1
- package/src/util/window-utils.js +35 -1
|
@@ -1 +1,110 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
dateFromUnixTimestamp as h,
|
|
3
|
+
rehydrateDateAfterJsonization as w
|
|
4
|
+
} from "../../util/date-utils.js";
|
|
5
|
+
import r from "../../../shared-lib/braze-shared-lib.js";
|
|
6
|
+
import Kt from "./trigger-condition.js";
|
|
7
|
+
import { validateValueIsFromEnum as F } from "../../util/code-utils.js";
|
|
8
|
+
export default class mt {
|
|
9
|
+
constructor(t, i, s, e, r, l, o, n, h, a, u, d) {
|
|
10
|
+
(this.id = t),
|
|
11
|
+
(this.Ph = i || []),
|
|
12
|
+
void 0 === s && (s = null),
|
|
13
|
+
(this.startTime = s),
|
|
14
|
+
void 0 === e && (e = null),
|
|
15
|
+
(this.endTime = e),
|
|
16
|
+
(this.priority = r || 0),
|
|
17
|
+
(this.type = l),
|
|
18
|
+
(this.$h = n || 0),
|
|
19
|
+
null == a && (a = 1e3 * (this.$h + 30)),
|
|
20
|
+
(this.$i = a),
|
|
21
|
+
(this.data = o),
|
|
22
|
+
null == h && (h = mt.Vh),
|
|
23
|
+
(this.qh = h),
|
|
24
|
+
(this.Kh = u),
|
|
25
|
+
(this.Wh = d || null);
|
|
26
|
+
}
|
|
27
|
+
Yh(t) {
|
|
28
|
+
return (
|
|
29
|
+
null == this.Wh || (this.qh !== mt.Vh && t - this.Wh >= 1e3 * this.qh)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
Zh(t) {
|
|
33
|
+
this.Wh = t;
|
|
34
|
+
}
|
|
35
|
+
gu(t) {
|
|
36
|
+
const i = t + 1e3 * this.$h;
|
|
37
|
+
return Math.max(i - new Date().valueOf(), 0);
|
|
38
|
+
}
|
|
39
|
+
pu(t) {
|
|
40
|
+
const i = new Date().valueOf() - t,
|
|
41
|
+
s = null == t || isNaN(i) || null == this.$i || i < this.$i;
|
|
42
|
+
return (
|
|
43
|
+
s ||
|
|
44
|
+
r.D.info(
|
|
45
|
+
`Trigger action ${this.type} is no longer eligible for display - fired ${i}ms ago and has a timeout of ${this.$i}ms.`
|
|
46
|
+
),
|
|
47
|
+
!s
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
static fromJson(t) {
|
|
51
|
+
const i = t.id,
|
|
52
|
+
s = [];
|
|
53
|
+
for (let i = 0; i < t.trigger_condition.length; i++)
|
|
54
|
+
s.push(Kt.fromJson(t.trigger_condition[i]));
|
|
55
|
+
const e = h(t.start_time),
|
|
56
|
+
r = h(t.end_time),
|
|
57
|
+
l = t.priority,
|
|
58
|
+
o = t.type,
|
|
59
|
+
n = t.delay,
|
|
60
|
+
a = t.re_eligibility,
|
|
61
|
+
u = t.timeout,
|
|
62
|
+
d = t.data,
|
|
63
|
+
m = t.min_seconds_since_last_trigger;
|
|
64
|
+
return F(
|
|
65
|
+
mt._i,
|
|
66
|
+
o,
|
|
67
|
+
"Could not construct Trigger from server data",
|
|
68
|
+
"Trigger.Types"
|
|
69
|
+
)
|
|
70
|
+
? new mt(i, s, e, r, l, o, d, n, a, u, m)
|
|
71
|
+
: null;
|
|
72
|
+
}
|
|
73
|
+
ss() {
|
|
74
|
+
const t = [];
|
|
75
|
+
for (let i = 0; i < this.Ph.length; i++) t.push(this.Ph[i].ss());
|
|
76
|
+
return {
|
|
77
|
+
i: this.id,
|
|
78
|
+
c: t,
|
|
79
|
+
s: this.startTime,
|
|
80
|
+
e: this.endTime,
|
|
81
|
+
p: this.priority,
|
|
82
|
+
t: this.type,
|
|
83
|
+
da: this.data,
|
|
84
|
+
d: this.$h,
|
|
85
|
+
r: this.qh,
|
|
86
|
+
tm: this.$i,
|
|
87
|
+
ss: this.Kh,
|
|
88
|
+
ld: this.Wh
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
static Sn(t) {
|
|
92
|
+
const i = [];
|
|
93
|
+
for (let s = 0; s < t.c.length; s++) i.push(Kt.Sn(t.c[s]));
|
|
94
|
+
return new mt(
|
|
95
|
+
t.i,
|
|
96
|
+
i,
|
|
97
|
+
w(t.s),
|
|
98
|
+
w(t.e),
|
|
99
|
+
t.p,
|
|
100
|
+
t.t,
|
|
101
|
+
t.da,
|
|
102
|
+
t.d,
|
|
103
|
+
t.r,
|
|
104
|
+
t.tm,
|
|
105
|
+
t.ss,
|
|
106
|
+
t.ld
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
(mt.Vh = -1), (mt._i = { Ti: "inapp", Tu: "templated_iam" });
|
|
@@ -1 +1,30 @@
|
|
|
1
|
-
import pe from"../InAppMessage/in-app-message-manager-factory.js";
|
|
1
|
+
import pe from "../InAppMessage/in-app-message-manager-factory.js";
|
|
2
|
+
import e, { OPTIONS as T } from "../managers/braze-instance.js";
|
|
3
|
+
import gr from "./triggers-provider.js";
|
|
4
|
+
export const TriggersProviderFactory = {
|
|
5
|
+
t: !1,
|
|
6
|
+
provider: null,
|
|
7
|
+
er: () => (TriggersProviderFactory.init(), TriggersProviderFactory.provider),
|
|
8
|
+
rg: () => {
|
|
9
|
+
if (!TriggersProviderFactory.provider) {
|
|
10
|
+
const r = e.nn(T.Ao);
|
|
11
|
+
(TriggersProviderFactory.provider = new gr(
|
|
12
|
+
null != r ? r : 30,
|
|
13
|
+
pe.m().Ve(),
|
|
14
|
+
e.l(),
|
|
15
|
+
e.mr(),
|
|
16
|
+
pe.m()
|
|
17
|
+
)),
|
|
18
|
+
e.ar(TriggersProviderFactory.provider);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
init: () => {
|
|
22
|
+
TriggersProviderFactory.t ||
|
|
23
|
+
(TriggersProviderFactory.rg(),
|
|
24
|
+
e.u(TriggersProviderFactory),
|
|
25
|
+
(TriggersProviderFactory.t = !0));
|
|
26
|
+
},
|
|
27
|
+
destroy: () => {
|
|
28
|
+
(TriggersProviderFactory.provider = null), (TriggersProviderFactory.t = !1);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -1 +1,307 @@
|
|
|
1
|
-
import y from"../common/base-provider.js";
|
|
1
|
+
import y from "../common/base-provider.js";
|
|
2
|
+
import { newInAppMessageFromJson as lt } from "../InAppMessage/in-app-message-factory.js";
|
|
3
|
+
import ue from "../models/braze-event.js";
|
|
4
|
+
import { InAppMessage } from "../InAppMessage/index.js";
|
|
5
|
+
import {
|
|
6
|
+
isArray as p,
|
|
7
|
+
isEqual as ii,
|
|
8
|
+
validateValueIsFromEnum as F
|
|
9
|
+
} from "../util/code-utils.js";
|
|
10
|
+
import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
11
|
+
import wt from "../InAppMessage/models/templated-in-app-message.js";
|
|
12
|
+
import mt from "./models/trigger.js";
|
|
13
|
+
import V from "./models/trigger-events.js";
|
|
14
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
15
|
+
export default class gr extends y {
|
|
16
|
+
constructor(t, i, s, e, r) {
|
|
17
|
+
super(),
|
|
18
|
+
(this.tg = t),
|
|
19
|
+
(this.yt = i),
|
|
20
|
+
(this.h = s),
|
|
21
|
+
(this.si = e),
|
|
22
|
+
(this.ig = r),
|
|
23
|
+
(this.sg = []),
|
|
24
|
+
(this.eg = []),
|
|
25
|
+
(this.hg = null),
|
|
26
|
+
(this.og = {}),
|
|
27
|
+
(this.ng = {}),
|
|
28
|
+
this.ag(),
|
|
29
|
+
this.lg();
|
|
30
|
+
}
|
|
31
|
+
gg() {
|
|
32
|
+
(this.hg = this.h.I(o.q.Na) || this.hg),
|
|
33
|
+
(this.og = this.h.I(o.q.va) || this.og),
|
|
34
|
+
(this.ng = this.h.I(o.q.Ga) || this.ng);
|
|
35
|
+
for (let t = 0; t < this.cg.length; t++) {
|
|
36
|
+
const i = this.cg[t];
|
|
37
|
+
null != this.ng[i.id] && i.Zh(this.ng[i.id]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
ag() {
|
|
41
|
+
this.fg = this.h.I(o.q.Da) || 0;
|
|
42
|
+
const t = this.h.I(o.q.Ya) || [],
|
|
43
|
+
i = [];
|
|
44
|
+
for (let s = 0; s < t.length; s++) i.push(mt.Sn(t[s]));
|
|
45
|
+
(this.cg = i), this.gg();
|
|
46
|
+
}
|
|
47
|
+
lg() {
|
|
48
|
+
const t = this,
|
|
49
|
+
i = function(i, s, e, r, h) {
|
|
50
|
+
return function() {
|
|
51
|
+
t.ug(i, s, e, r, h);
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
s = {};
|
|
55
|
+
for (let t = 0; t < this.cg.length; t++) s[this.cg[t].id] = this.cg[t];
|
|
56
|
+
let e = !1;
|
|
57
|
+
for (let t = 0; t < this.cg.length; t++) {
|
|
58
|
+
const r = this.cg[t];
|
|
59
|
+
if (null != this.og[r.id]) {
|
|
60
|
+
const t = this.og[r.id],
|
|
61
|
+
h = [];
|
|
62
|
+
for (let e = 0; e < t.length; e++) {
|
|
63
|
+
const o = t[e],
|
|
64
|
+
n = r.gu(o.Si);
|
|
65
|
+
if (n > 0) {
|
|
66
|
+
let t, e;
|
|
67
|
+
h.push(o),
|
|
68
|
+
null != o.dg && (t = o.dg),
|
|
69
|
+
null != o.mg && ue.Fa(o.mg) && (e = ue.Sn(o.mg));
|
|
70
|
+
const a = [];
|
|
71
|
+
if (p(o.pg))
|
|
72
|
+
for (let t = 0; t < o.pg.length; t++) {
|
|
73
|
+
const i = s[o.pg[t]];
|
|
74
|
+
null != i && a.push(i);
|
|
75
|
+
}
|
|
76
|
+
this.eg.push(setTimeout(i(r, o.Si, t, e, a), n));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
this.og[r.id].length > h.length &&
|
|
80
|
+
((this.og[r.id] = h),
|
|
81
|
+
(e = !0),
|
|
82
|
+
0 === this.og[r.id].length && delete this.og[r.id]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
e && this.h.B(o.q.va, this.og);
|
|
86
|
+
}
|
|
87
|
+
bg() {
|
|
88
|
+
const t = [];
|
|
89
|
+
for (let i = 0; i < this.cg.length; i++) t.push(this.cg[i].ss());
|
|
90
|
+
(this.fg = new Date().valueOf()),
|
|
91
|
+
this.h.B(o.q.Ya, t),
|
|
92
|
+
this.h.B(o.q.Da, this.fg);
|
|
93
|
+
}
|
|
94
|
+
Tg() {
|
|
95
|
+
(this.h.I(o.q.Da) || 0) > this.fg ? this.ag() : this.gg();
|
|
96
|
+
}
|
|
97
|
+
Rs(t) {
|
|
98
|
+
let i = !1;
|
|
99
|
+
if (null != t && t.triggers) {
|
|
100
|
+
this.gg();
|
|
101
|
+
const s = {},
|
|
102
|
+
e = {};
|
|
103
|
+
this.cg = [];
|
|
104
|
+
for (let r = 0; r < t.triggers.length; r++) {
|
|
105
|
+
const h = mt.fromJson(t.triggers[r]);
|
|
106
|
+
null != this.ng[h.id] &&
|
|
107
|
+
(h.Zh(this.ng[h.id]), (s[h.id] = this.ng[h.id])),
|
|
108
|
+
null != this.og[h.id] && (e[h.id] = this.og[h.id]);
|
|
109
|
+
for (let t = 0; t < h.Ph.length; t++)
|
|
110
|
+
if (h.Ph[t].ec(V.ks, null)) {
|
|
111
|
+
i = !0;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
null != h && this.cg.push(h);
|
|
115
|
+
}
|
|
116
|
+
ii(this.ng, s) || ((this.ng = s), this.h.B(o.q.Ga, this.ng)),
|
|
117
|
+
ii(this.og, e) || ((this.og = e), this.h.B(o.q.va, this.og)),
|
|
118
|
+
this.bg(),
|
|
119
|
+
i &&
|
|
120
|
+
(r.D.info("Trigger with test condition found, firing test."),
|
|
121
|
+
this.je(V.ks)),
|
|
122
|
+
this.je(V.OPEN);
|
|
123
|
+
const h = this.sg;
|
|
124
|
+
this.sg = [];
|
|
125
|
+
for (let t = 0; t < h.length; t++) this.je.apply(this, h[t]);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async ug(t, i, s, e, h) {
|
|
129
|
+
const o = e => {
|
|
130
|
+
this.gg();
|
|
131
|
+
const h = new Date().valueOf();
|
|
132
|
+
if (!t.pu(i))
|
|
133
|
+
return !1 === navigator.onLine && t.type === mt._i.Ti && e.imageUrl
|
|
134
|
+
? (r.D.info(
|
|
135
|
+
`Not showing ${t.type} trigger action ${t.id} due to offline state.`
|
|
136
|
+
),
|
|
137
|
+
void this.ig.ni(t.id, InAppMessage.li.nh))
|
|
138
|
+
: void (t.Yh(h) && this.yg(t, h, s)
|
|
139
|
+
? 0 === this.yt.bu()
|
|
140
|
+
? r.D.info(
|
|
141
|
+
`Not displaying trigger ${t.id} because neither automaticallyShowInAppMessages() nor subscribeToInAppMessage() were called.`
|
|
142
|
+
)
|
|
143
|
+
: (this.yt.St([e]), this.vg(t, h))
|
|
144
|
+
: r.D.info(
|
|
145
|
+
`Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`
|
|
146
|
+
));
|
|
147
|
+
t.type === mt._i.Tu
|
|
148
|
+
? this.ig.ni(t.id, InAppMessage.li.zi)
|
|
149
|
+
: this.ig.ni(t.id, InAppMessage.li.rh);
|
|
150
|
+
},
|
|
151
|
+
n = () => {
|
|
152
|
+
this.gg();
|
|
153
|
+
const o = h.pop();
|
|
154
|
+
if (null != o)
|
|
155
|
+
if ((this.wg(o, i, s, e, h), o.pu(i))) {
|
|
156
|
+
let t = `Server aborted in-app message display, but the timeout on fallback trigger ${o.id} has already elapsed.`;
|
|
157
|
+
h.length > 0 && (t += " Continuing to fall back."),
|
|
158
|
+
r.D.info(t),
|
|
159
|
+
this.ig.ni(o.id, InAppMessage.li.rh),
|
|
160
|
+
n();
|
|
161
|
+
} else {
|
|
162
|
+
r.D.info(
|
|
163
|
+
`Server aborted in-app message display. Falling back to lower priority ${o.type} trigger action ${t.id}.`
|
|
164
|
+
);
|
|
165
|
+
const n = 1e3 * o.$h - (new Date().valueOf() - i);
|
|
166
|
+
n > 0
|
|
167
|
+
? this.eg.push(
|
|
168
|
+
setTimeout(() => {
|
|
169
|
+
this.ug(o, i, s, e, h);
|
|
170
|
+
}, n)
|
|
171
|
+
)
|
|
172
|
+
: this.ug(o, i, s, e, h);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
switch (t.type) {
|
|
176
|
+
case mt._i.Ti:
|
|
177
|
+
const h = lt(t.data);
|
|
178
|
+
if (null == h) {
|
|
179
|
+
r.D.error(
|
|
180
|
+
`Could not parse trigger data for trigger ${t.id}, ignoring.`
|
|
181
|
+
),
|
|
182
|
+
this.ig.ni(t.id, InAppMessage.li.ki);
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
let a = this.ig.vi(h);
|
|
186
|
+
if (a) {
|
|
187
|
+
r.D.error(a), n();
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
o(h);
|
|
191
|
+
break;
|
|
192
|
+
case mt._i.Tu:
|
|
193
|
+
const l = wt.fromJson(t.data, o, n, i, t.$i);
|
|
194
|
+
if (null == l) {
|
|
195
|
+
r.D.error(
|
|
196
|
+
`Could not parse trigger data for trigger ${t.id}, ignoring.`
|
|
197
|
+
),
|
|
198
|
+
this.ig.ni(t.id, InAppMessage.li.ki);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
this.ig.Ii(l, s, e);
|
|
202
|
+
break;
|
|
203
|
+
default:
|
|
204
|
+
r.D.error(
|
|
205
|
+
`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`
|
|
206
|
+
),
|
|
207
|
+
this.ig.ni(t.id, InAppMessage.li.ki);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
je(t, i, s) {
|
|
211
|
+
if (!F(V, t, "Cannot fire trigger action.", "TriggerEvents")) return;
|
|
212
|
+
if (this.si.Ml())
|
|
213
|
+
return (
|
|
214
|
+
r.D.info(
|
|
215
|
+
"Trigger sync is currently in progress, awaiting sync completion before firing trigger event."
|
|
216
|
+
),
|
|
217
|
+
void this.sg.push(arguments)
|
|
218
|
+
);
|
|
219
|
+
this.Tg();
|
|
220
|
+
const e = new Date().valueOf(),
|
|
221
|
+
h = e - this.hg;
|
|
222
|
+
let o = !0,
|
|
223
|
+
n = !0;
|
|
224
|
+
const a = [];
|
|
225
|
+
for (let s = 0; s < this.cg.length; s++) {
|
|
226
|
+
const r = this.cg[s],
|
|
227
|
+
h = e + 1e3 * r.$h;
|
|
228
|
+
if (
|
|
229
|
+
r.Yh(h) &&
|
|
230
|
+
(null == r.startTime || r.startTime <= e) &&
|
|
231
|
+
(null == r.endTime || r.endTime >= e)
|
|
232
|
+
) {
|
|
233
|
+
let s = !1;
|
|
234
|
+
for (let e = 0; e < r.Ph.length; e++)
|
|
235
|
+
if (r.Ph[e].ec(t, i)) {
|
|
236
|
+
s = !0;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
s && ((o = !1), this.yg(r, h, t) && ((n = !1), a.push(r)));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (o)
|
|
243
|
+
return void r.D.info(
|
|
244
|
+
`Trigger event ${t} did not match any trigger conditions.`
|
|
245
|
+
);
|
|
246
|
+
if (n)
|
|
247
|
+
return void r.D.info(
|
|
248
|
+
`Ignoring ${t} trigger event because a trigger was displayed ${h /
|
|
249
|
+
1e3}s ago.`
|
|
250
|
+
);
|
|
251
|
+
a.sort((t, i) => t.priority - i.priority);
|
|
252
|
+
const l = a.pop();
|
|
253
|
+
null != l &&
|
|
254
|
+
(r.D.info(
|
|
255
|
+
`Firing ${l.type} trigger action ${l.id} from trigger event ${t}.`
|
|
256
|
+
),
|
|
257
|
+
this.wg(l, e, t, s, a),
|
|
258
|
+
0 === l.$h
|
|
259
|
+
? this.ug(l, e, t, s, a)
|
|
260
|
+
: this.eg.push(
|
|
261
|
+
setTimeout(() => {
|
|
262
|
+
this.ug(l, e, t, s, a);
|
|
263
|
+
}, 1e3 * l.$h)
|
|
264
|
+
));
|
|
265
|
+
}
|
|
266
|
+
changeUser(t) {
|
|
267
|
+
if (((this.cg = []), this.h.Xs(o.q.Ya), !t)) {
|
|
268
|
+
(this.sg = []), (this.hg = null), (this.ng = {}), (this.og = {});
|
|
269
|
+
for (let t = 0; t < this.eg.length; t++) clearTimeout(this.eg[t]);
|
|
270
|
+
(this.eg = []), this.h.Xs(o.q.Na), this.h.Xs(o.q.Ga), this.h.Xs(o.q.va);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
clearData() {
|
|
274
|
+
(this.cg = []), (this.hg = null), (this.ng = {}), (this.og = {});
|
|
275
|
+
for (let t = 0; t < this.eg.length; t++) clearTimeout(this.eg[t]);
|
|
276
|
+
this.eg = [];
|
|
277
|
+
}
|
|
278
|
+
yg(t, i, s) {
|
|
279
|
+
if (null == this.hg) return !0;
|
|
280
|
+
if (s === V.ks)
|
|
281
|
+
return (
|
|
282
|
+
r.D.info(
|
|
283
|
+
"Ignoring minimum interval between trigger because it is a test type."
|
|
284
|
+
),
|
|
285
|
+
!0
|
|
286
|
+
);
|
|
287
|
+
let e = t.Kh;
|
|
288
|
+
return null == e && (e = this.tg), i - this.hg >= 1e3 * e;
|
|
289
|
+
}
|
|
290
|
+
wg(t, i, s, e, r) {
|
|
291
|
+
this.gg(), (this.og[t.id] = this.og[t.id] || []);
|
|
292
|
+
const h = {};
|
|
293
|
+
let n;
|
|
294
|
+
(h.Si = i), (h.dg = s), null != e && (n = e.ss()), (h.mg = n);
|
|
295
|
+
const a = [];
|
|
296
|
+
for (let t = 0; t < r.length; t++) a.push(r[t].id);
|
|
297
|
+
(h.pg = a), this.og[t.id].push(h), this.h.B(o.q.va, this.og);
|
|
298
|
+
}
|
|
299
|
+
vg(t, i) {
|
|
300
|
+
this.gg(),
|
|
301
|
+
t.Zh(i),
|
|
302
|
+
(this.hg = i),
|
|
303
|
+
this.h.B(o.q.Na, i),
|
|
304
|
+
(this.ng[t.id] = i),
|
|
305
|
+
this.h.B(o.q.Ga, this.ng);
|
|
306
|
+
}
|
|
307
|
+
}
|
package/src/ui/js/attach-css.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
import e,{OPTIONS as T}from"../../managers/braze-instance.js";
|
|
1
|
+
import e, { OPTIONS as T } from "../../managers/braze-instance.js";
|
|
2
|
+
export function attachCSS(n, t, o) {
|
|
3
|
+
const c = n || document.querySelector("head"),
|
|
4
|
+
s = `ab-${t}-css-definitions-${"4.5.0".replace(/\./g, "-")}`,
|
|
5
|
+
a = c.ownerDocument || document;
|
|
6
|
+
if (null == a.getElementById(s)) {
|
|
7
|
+
const n = a.createElement("style");
|
|
8
|
+
(n.innerHTML = o), (n.id = s);
|
|
9
|
+
const t = e.nn(T.ao);
|
|
10
|
+
null != t && n.setAttribute("nonce", t), c.appendChild(n);
|
|
11
|
+
}
|
|
12
|
+
}
|
package/src/ui/js/feed-css.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
import{attachCSS as
|
|
1
|
+
import { attachCSS as Zt } from "./attach-css.js";
|
|
2
|
+
import { loadFontAwesome as $t } from "./load-font-awesome.js";
|
|
3
|
+
export function attachFeedCSS(t) {
|
|
4
|
+
Zt(
|
|
5
|
+
t,
|
|
6
|
+
"feed",
|
|
7
|
+
"body>.ab-feed{position:fixed;top:0;right:0;bottom:0;width:421px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}body>.ab-feed .ab-feed-body{position:absolute;top:0;left:0;right:0;border:none;border-left:1px solid #d0d0d0;padding-top:70px;min-height:100%}body>.ab-feed .ab-initial-spinner{float:none}body>.ab-feed .ab-no-cards-message{position:absolute;width:100%;margin-left:-20px;top:40%}.ab-feed{-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:0 1px 7px 1px rgba(66,82,113,.15);-moz-box-shadow:0 1px 7px 1px rgba(66,82,113,.15);box-shadow:0 1px 7px 1px rgba(66,82,113,.15);width:402px;background-color:#eee;font-family:'Helvetica Neue Light','Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:13px;line-height:130%;letter-spacing:normal;overflow-y:auto;overflow-x:visible;z-index:9011;-webkit-overflow-scrolling:touch}.ab-feed :focus,.ab-feed:focus{outline:0}.ab-feed .ab-feed-body{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;border:1px solid #d0d0d0;border-top:none;padding:20px 20px 0 20px}.ab-feed.ab-effect-slide{-webkit-transform:translateX(450px);-moz-transform:translateX(450px);-ms-transform:translateX(450px);transform:translateX(450px);-webkit-transition:transform .5s ease-in-out;-moz-transition:transform .5s ease-in-out;-o-transition:transform .5s ease-in-out;transition:transform .5s ease-in-out}.ab-feed.ab-effect-slide.ab-show{-webkit-transform:translateX(0);-moz-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}.ab-feed.ab-effect-slide.ab-hide{-webkit-transform:translateX(450px);-moz-transform:translateX(450px);-ms-transform:translateX(450px);transform:translateX(450px)}.ab-feed .ab-card{position:relative;-webkit-box-shadow:0 2px 3px 0 rgba(178,178,178,.5);-moz-box-shadow:0 2px 3px 0 rgba(178,178,178,.5);box-shadow:0 2px 3px 0 rgba(178,178,178,.5);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;width:100%;border:1px solid #d0d0d0;margin-bottom:20px;overflow:hidden;background-color:#fff;-webkit-transition:height .4s ease-in-out,margin .4s ease-in-out;-moz-transition:height .4s ease-in-out,margin .4s ease-in-out;-o-transition:height .4s ease-in-out,margin .4s ease-in-out;transition:height .4s ease-in-out,margin .4s ease-in-out}.ab-feed .ab-card .ab-pinned-indicator{position:absolute;right:0;top:0;margin-right:-1px;width:0;height:0;border-style:solid;border-width:0 24px 24px 0;border-color:transparent #1676d0 transparent transparent}.ab-feed .ab-card .ab-pinned-indicator .fa-star{position:absolute;right:-21px;top:2px;font-size:9px;color:#fff}.ab-feed .ab-card.ab-effect-card.ab-hide{-webkit-transition:all .5s ease-in-out;-moz-transition:all .5s ease-in-out;-o-transition:all .5s ease-in-out;transition:all .5s ease-in-out}.ab-feed .ab-card.ab-effect-card.ab-hide.ab-swiped-left{-webkit-transform:translateX(-450px);-moz-transform:translateX(-450px);-ms-transform:translateX(-450px);transform:translateX(-450px)}.ab-feed .ab-card.ab-effect-card.ab-hide.ab-swiped-right{-webkit-transform:translateX(450px);-moz-transform:translateX(450px);-ms-transform:translateX(450px);transform:translateX(450px)}.ab-feed .ab-card.ab-effect-card.ab-hide:not(.ab-swiped-left):not(.ab-swiped-right){opacity:0}.ab-feed .ab-card .ab-close-button{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;background-color:transparent;background-size:15px;border:none;width:15px;min-width:15px;height:15px;cursor:pointer;display:block;font-size:15px;line-height:0;padding-top:15px;padding-right:15px;padding-left:15px;padding-bottom:15px;position:absolute;right:0;top:0;z-index:9021;opacity:0;-webkit-transition:.5s;-moz-transition:.5s;-o-transition:.5s;transition:.5s}.ab-feed .ab-card .ab-close-button svg{-webkit-transition:.2s ease;-moz-transition:.2s ease;-o-transition:.2s ease;transition:.2s ease;fill:#9b9b9b}.ab-feed .ab-card .ab-close-button svg.ab-chevron{display:none}.ab-feed .ab-card .ab-close-button:active{background-color:transparent}.ab-feed .ab-card .ab-close-button:focus{background-color:transparent}.ab-feed .ab-card .ab-close-button:hover{background-color:transparent}.ab-feed .ab-card .ab-close-button:hover svg{fill-opacity:.8}.ab-feed .ab-card .ab-close-button:hover{opacity:1}.ab-feed .ab-card .ab-close-button:focus{opacity:1}.ab-feed .ab-card a{float:none;color:inherit;text-decoration:none}.ab-feed .ab-card a:hover{text-decoration:underline}.ab-feed .ab-card .ab-image-area{float:none;display:inline-block;vertical-align:top;line-height:0;overflow:hidden;width:100%;-webkit-box-sizing:initial;-moz-box-sizing:initial;box-sizing:initial}.ab-feed .ab-card .ab-image-area img{float:none;height:auto;width:100%}.ab-feed .ab-card.ab-banner .ab-card-body{display:none}.ab-feed .ab-card .ab-card-body{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:inline-block;width:100%;position:relative}.ab-feed .ab-card .ab-unread-indicator{position:absolute;bottom:0;margin-right:-1px;width:100%;height:5px;background-color:#1676d0}.ab-feed .ab-card .ab-unread-indicator.read{background-color:transparent}.ab-feed .ab-card .ab-title{float:none;letter-spacing:0;margin:0;font-weight:700;font-family:'Helvetica Neue Light','Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;display:block;overflow:hidden;word-wrap:break-word;text-overflow:ellipsis;font-size:18px;line-height:130%;padding:20px 25px 0 25px}.ab-feed .ab-card .ab-description{float:none;color:#545454;padding:15px 25px 20px 25px;word-wrap:break-word;white-space:pre-wrap}.ab-feed .ab-card .ab-description.ab-no-title{padding-top:20px}.ab-feed .ab-card .ab-url-area{float:none;color:#1676d0;margin-top:12px;font-family:'Helvetica Neue Light','Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif}.ab-feed .ab-card.ab-classic-card .ab-card-body{min-height:40px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.ab-feed .ab-card.ab-classic-card.with-image .ab-card-body{min-height:100px;padding-left:72px}.ab-feed .ab-card.ab-classic-card.with-image .ab-image-area{width:60px;height:60px;padding:20px 0 25px 25px;position:absolute}.ab-feed .ab-card.ab-classic-card.with-image .ab-image-area img{-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;max-width:100%;max-height:100%;width:auto;height:auto}.ab-feed .ab-card.ab-classic-card.with-image .ab-title{background-color:transparent;font-size:16px}.ab-feed .ab-card.ab-classic-card.with-image .ab-description{padding-top:10px}.ab-feed .ab-card.ab-control-card{height:0;width:0;margin:0;border:0}.ab-feed .ab-feed-buttons-wrapper{float:none;position:relative;background-color:#282828;height:50px;-webkit-box-shadow:0 2px 3px 0 rgba(178,178,178,.5);-moz-box-shadow:0 2px 3px 0 rgba(178,178,178,.5);box-shadow:0 2px 3px 0 rgba(178,178,178,.5);z-index:1}.ab-feed .ab-feed-buttons-wrapper .ab-close-button,.ab-feed .ab-feed-buttons-wrapper .ab-refresh-button{float:none;cursor:pointer;color:#fff;font-size:18px;padding:16px;-webkit-transition:.2s;-moz-transition:.2s;-o-transition:.2s;transition:.2s}.ab-feed .ab-feed-buttons-wrapper .ab-close-button:hover,.ab-feed .ab-feed-buttons-wrapper .ab-refresh-button:hover{font-size:22px}.ab-feed .ab-feed-buttons-wrapper .ab-close-button{float:right}.ab-feed .ab-feed-buttons-wrapper .ab-close-button:hover{padding-top:12px;padding-right:14px}.ab-feed .ab-feed-buttons-wrapper .ab-refresh-button{padding-left:17px}.ab-feed .ab-feed-buttons-wrapper .ab-refresh-button:hover{padding-top:13px;padding-left:14px}.ab-feed .ab-no-cards-message{text-align:center;margin-bottom:20px}@media (max-width:600px){body>.ab-feed{width:100%}}"
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
export function setupFeedUI() {
|
|
11
|
+
attachFeedCSS(), $t();
|
|
12
|
+
}
|