@braze/web-sdk 4.7.2 → 4.8.1
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 +32 -26
- 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 +25 -25
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +74 -74
- 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 +48 -42
- 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 +36 -34
- 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 +8 -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 +41 -37
- 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 +130 -110
- 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 +193 -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 +95 -85
- package/src/common/types.js +1 -0
- package/src/l10n/l10n-manager-factory.js +10 -10
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +37 -34
- package/src/managers/braze-instance.js +209 -193
- package/src/managers/device-manager.js +43 -38
- package/src/managers/network-manager.js +119 -96
- package/src/managers/server-config-manager.js +68 -48
- package/src/managers/session-manager.js +52 -45
- package/src/managers/storage-manager-factory.js +29 -22
- package/src/managers/storage-manager.js +288 -273
- package/src/managers/subscription-manager.js +9 -6
- package/src/managers/types.js +1 -0
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +14 -8
- package/src/models/device.js +10 -18
- package/src/models/identifier.js +10 -11
- package/src/models/push-token.js +17 -12
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +36 -20
- package/src/models/types.js +1 -0
- 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 +7 -7
- package/src/triggers/models/trigger-condition.js +57 -57
- 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 +173 -170
- 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 +2 -2
- package/src/util/braze-actions.js +20 -20
- package/src/util/browser-detector.js +22 -22
- package/src/util/client-hints-parser.js +7 -7
- 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 +3 -3
- package/src/util/dom-utils.js +7 -7
- package/src/util/error-utils.js +2 -0
- 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 +21 -21
- package/src/util/validation-utils.js +44 -44
- package/src/util/window-utils.js +3 -3
|
@@ -1,294 +1,310 @@
|
|
|
1
|
-
import
|
|
1
|
+
import jt from "./auth-manager.js";
|
|
2
2
|
import y from "../common/base-provider.js";
|
|
3
|
-
import
|
|
3
|
+
import V from "../util/browser-detector.js";
|
|
4
4
|
import Ot from "./device-manager.js";
|
|
5
5
|
import DeviceProperties from "../Core/device-properties.js";
|
|
6
6
|
import {
|
|
7
7
|
isArray as p,
|
|
8
|
-
keys as
|
|
9
|
-
validateValueIsFromEnum as
|
|
8
|
+
keys as oo,
|
|
9
|
+
validateValueIsFromEnum as H,
|
|
10
10
|
values as Lt
|
|
11
11
|
} from "../util/code-utils.js";
|
|
12
|
-
import { logDeprecationWarning as
|
|
12
|
+
import { logDeprecationWarning as z } from "../util/deprecation-utils.js";
|
|
13
13
|
import Pt from "./network-manager.js";
|
|
14
14
|
import Rt from "../request-controller.js";
|
|
15
15
|
import Mt from "./server-config-manager.js";
|
|
16
|
-
import
|
|
16
|
+
import Dt from "./session-manager.js";
|
|
17
17
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { TriggersProviderFactory as
|
|
18
|
+
import O, { STORAGE_KEYS as i } from "./storage-manager.js";
|
|
19
|
+
import Bt from "./storage-manager-factory.js";
|
|
20
|
+
import E from "./subscription-manager.js";
|
|
21
|
+
import { TriggersProviderFactory as et } from "../triggers/triggers-provider-factory.js";
|
|
22
22
|
import bt from "../User/user-manager.js";
|
|
23
23
|
import { User } from "../User/index.js";
|
|
24
|
-
import { parseQueryStringKeyValues as
|
|
25
|
-
import { WindowUtils as
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
import { parseQueryStringKeyValues as ct } from "../util/url-utils.js";
|
|
25
|
+
import { WindowUtils as Z } from "../util/window-utils.js";
|
|
26
|
+
import { BRAZE_MUST_BE_INITIALIZED_ERROR as P } from "../common/constants.js";
|
|
27
|
+
const L = {
|
|
28
|
+
ho: "allowCrawlerActivity",
|
|
29
|
+
Eo: "baseUrl",
|
|
30
|
+
_o: "noCookies",
|
|
31
|
+
Io: "devicePropertyAllowlist",
|
|
31
32
|
ia: "disablePushTokenMaintenance",
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
Ao: "enableLogging",
|
|
34
|
+
So: "enableSdkAuthentication",
|
|
34
35
|
ta: "manageServiceWorkerExternally",
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
No: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
37
|
+
wo: "sessionTimeoutInSeconds",
|
|
38
|
+
To: "appVersion",
|
|
38
39
|
na: "serviceWorkerLocation",
|
|
39
40
|
ra: "safariWebsitePushId",
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
Mn: "localization",
|
|
42
|
+
lo: "contentSecurityNonce",
|
|
43
|
+
Oo: "enableHtmlInAppMessages",
|
|
44
|
+
Co: "allowUserSuppliedJavascript",
|
|
45
|
+
mo: "inAppMessageZIndex",
|
|
46
|
+
po: "openInAppMessagesInNewTab",
|
|
46
47
|
tn: "openCardsInNewTab",
|
|
47
48
|
en: "openNewsFeedCardsInNewTab",
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
Lh: "requireExplicitInAppMessageDismissal",
|
|
50
|
+
Lo: "doNotLoadFontAwesome",
|
|
51
|
+
Po: "sdkFlavor"
|
|
51
52
|
};
|
|
52
|
-
class
|
|
53
|
+
class Wt {
|
|
53
54
|
constructor() {
|
|
54
|
-
(this.
|
|
55
|
-
(this.
|
|
56
|
-
(this.
|
|
57
|
-
(this.
|
|
58
|
-
(this.
|
|
59
|
-
(this.
|
|
60
|
-
(this.
|
|
55
|
+
(this.Xr = ""),
|
|
56
|
+
(this.Ro = ""),
|
|
57
|
+
(this.Mo = void 0),
|
|
58
|
+
(this.jo = null),
|
|
59
|
+
(this.Zr = null),
|
|
60
|
+
(this.gt = null),
|
|
61
|
+
(this.Ci = null),
|
|
62
|
+
(this.wt = null),
|
|
63
|
+
(this._e = null),
|
|
64
|
+
(this.u = null),
|
|
65
|
+
(this.ft = null),
|
|
66
|
+
(this.Do = ""),
|
|
67
|
+
(this.Uo = !1),
|
|
68
|
+
(this.Bo = !1),
|
|
69
|
+
(this.Wo = new E()),
|
|
70
|
+
(this.zo = new E()),
|
|
71
|
+
(this.options = {}),
|
|
72
|
+
(this.Vo = []),
|
|
73
|
+
(this.Go = []),
|
|
61
74
|
(this.Se = []),
|
|
62
|
-
(this.
|
|
75
|
+
(this.Ro = "4.8.1");
|
|
63
76
|
}
|
|
64
|
-
|
|
65
|
-
this.
|
|
77
|
+
Ko(t) {
|
|
78
|
+
this.Wo.lt(t);
|
|
66
79
|
}
|
|
67
|
-
|
|
68
|
-
this.
|
|
80
|
+
Nh(t) {
|
|
81
|
+
this.zo.lt(t);
|
|
69
82
|
}
|
|
70
|
-
initialize(t,
|
|
71
|
-
if (this.
|
|
83
|
+
initialize(t, s) {
|
|
84
|
+
if (this.ue())
|
|
72
85
|
return (
|
|
73
|
-
r.
|
|
86
|
+
r.j.info("Braze has already been initialized with an API key."), !0
|
|
74
87
|
);
|
|
75
|
-
this.
|
|
76
|
-
let
|
|
77
|
-
const
|
|
88
|
+
this.options = s || {};
|
|
89
|
+
let e = this.nn(L.Ao);
|
|
90
|
+
const n = ct(Z.jn());
|
|
78
91
|
if (
|
|
79
|
-
(
|
|
80
|
-
r.
|
|
81
|
-
r.
|
|
92
|
+
(n && "true" === n.brazeLogging && (e = !0),
|
|
93
|
+
r.j.init(e),
|
|
94
|
+
r.j.info(
|
|
95
|
+
`Initialization Options: ${JSON.stringify(this.options, null, 2)}`
|
|
96
|
+
),
|
|
82
97
|
null == t || "" === t || "string" != typeof t)
|
|
83
98
|
)
|
|
84
|
-
return r.
|
|
85
|
-
this.
|
|
86
|
-
let
|
|
87
|
-
if (null ==
|
|
88
|
-
return r.
|
|
89
|
-
!1 === /^https?:/.test(
|
|
90
|
-
|
|
99
|
+
return r.j.error("Braze requires a valid API key to be initialized."), !1;
|
|
100
|
+
this.Xr = t;
|
|
101
|
+
let o = this.nn(L.Eo);
|
|
102
|
+
if (null == o || "" === o || "string" != typeof o)
|
|
103
|
+
return r.j.error("Braze requires a valid baseUrl to be initialized."), !1;
|
|
104
|
+
!1 === /^https?:/.test(o) && (o = `https://${o}`);
|
|
105
|
+
const h = o;
|
|
91
106
|
if (
|
|
92
|
-
((
|
|
93
|
-
(
|
|
94
|
-
"/" ===
|
|
95
|
-
(this.
|
|
96
|
-
|
|
107
|
+
((o = document.createElement("a")),
|
|
108
|
+
(o.href = h),
|
|
109
|
+
"/" === o.pathname && (o = `${o}api/v3`),
|
|
110
|
+
(this.Do = o.toString()),
|
|
111
|
+
V.Ho && !this.nn(L.ho))
|
|
97
112
|
)
|
|
98
113
|
return (
|
|
99
|
-
r.
|
|
100
|
-
(this.
|
|
114
|
+
r.j.info("Ignoring activity from crawler bot " + navigator.userAgent),
|
|
115
|
+
(this.Bo = !0),
|
|
101
116
|
!1
|
|
102
117
|
);
|
|
103
|
-
const a = this.nn(
|
|
118
|
+
const a = this.nn(L._o) || !1;
|
|
104
119
|
if (
|
|
105
|
-
((this.
|
|
120
|
+
((this.u = Bt.$o(t, a)), a && this.u.qo(t), new O.ee(null, !0).wr(i.ne))
|
|
106
121
|
)
|
|
107
122
|
return (
|
|
108
|
-
r.
|
|
109
|
-
(this.
|
|
123
|
+
r.j.info("Ignoring all activity due to previous opt out"),
|
|
124
|
+
(this.Bo = !0),
|
|
110
125
|
!1
|
|
111
126
|
);
|
|
112
|
-
for (const t of
|
|
113
|
-
-1 === Lt(r.
|
|
114
|
-
r.
|
|
127
|
+
for (const t of oo(this.options))
|
|
128
|
+
-1 === Lt(r.xo).indexOf(t) &&
|
|
129
|
+
r.j.warn(`Ignoring unknown initialization option '${t}'.`);
|
|
115
130
|
const l = ["mparticle", "wordpress", "tealium"];
|
|
116
|
-
if (null != this.nn(
|
|
117
|
-
const t = this.nn(
|
|
131
|
+
if (null != this.nn(L.Po)) {
|
|
132
|
+
const t = this.nn(L.Po);
|
|
118
133
|
-1 !== l.indexOf(t)
|
|
119
|
-
? (this.
|
|
120
|
-
: r.
|
|
134
|
+
? (this.Mo = t)
|
|
135
|
+
: r.j.error("Invalid sdk flavor passed: " + t);
|
|
121
136
|
}
|
|
122
|
-
let
|
|
123
|
-
if (null !=
|
|
124
|
-
if (p(
|
|
137
|
+
let u = this.nn(r.xo.Io);
|
|
138
|
+
if (null != u)
|
|
139
|
+
if (p(u)) {
|
|
125
140
|
const t = [];
|
|
126
|
-
for (let i = 0; i <
|
|
127
|
-
|
|
141
|
+
for (let i = 0; i < u.length; i++)
|
|
142
|
+
H(
|
|
128
143
|
DeviceProperties,
|
|
129
|
-
|
|
144
|
+
u[i],
|
|
130
145
|
"devicePropertyAllowlist contained an invalid value.",
|
|
131
146
|
"DeviceProperties"
|
|
132
|
-
) && t.push(
|
|
133
|
-
|
|
147
|
+
) && t.push(u[i]);
|
|
148
|
+
u = t;
|
|
134
149
|
} else
|
|
135
|
-
r.
|
|
150
|
+
r.j.error(
|
|
136
151
|
"devicePropertyAllowlist must be an array. Defaulting to all properties."
|
|
137
152
|
),
|
|
138
|
-
(
|
|
139
|
-
(this.
|
|
140
|
-
(this.
|
|
141
|
-
(this.
|
|
142
|
-
(this.
|
|
143
|
-
const
|
|
153
|
+
(u = null);
|
|
154
|
+
(this.Zr = new Ot(this.u, u)),
|
|
155
|
+
(this.wt = new Mt(this.u)),
|
|
156
|
+
(this.ft = new bt(this.wt, this.u)),
|
|
157
|
+
(this._e = new Dt(this.u, this.ft, this.wt, this.nn(L.wo)));
|
|
158
|
+
const f = new E();
|
|
144
159
|
return (
|
|
145
|
-
(this.
|
|
146
|
-
this.jt(
|
|
147
|
-
(this.
|
|
148
|
-
this.
|
|
149
|
-
this.
|
|
150
|
-
this.Go,
|
|
151
|
-
this.v,
|
|
152
|
-
this.j,
|
|
153
|
-
this.gt,
|
|
154
|
-
this._r,
|
|
155
|
-
this.Uo,
|
|
160
|
+
(this.jo = new jt(this.u, this.nn(L.So), f)),
|
|
161
|
+
this.jt(f),
|
|
162
|
+
(this.gt = new Pt(
|
|
163
|
+
this.Zr,
|
|
164
|
+
this.u,
|
|
156
165
|
this.jo,
|
|
157
|
-
this.
|
|
158
|
-
this.
|
|
166
|
+
this.ft,
|
|
167
|
+
this._e,
|
|
168
|
+
this.wt,
|
|
169
|
+
this.Xr,
|
|
170
|
+
this.Do,
|
|
171
|
+
this.Ro,
|
|
172
|
+
this.Mo || "",
|
|
173
|
+
this.nn(L.To)
|
|
159
174
|
)),
|
|
160
175
|
(this.Ci = new Rt(
|
|
161
|
-
this.
|
|
162
|
-
this.
|
|
163
|
-
this.
|
|
164
|
-
this.
|
|
165
|
-
this.
|
|
166
|
-
this.
|
|
167
|
-
this.
|
|
176
|
+
this.Xr,
|
|
177
|
+
this.Do,
|
|
178
|
+
this._e,
|
|
179
|
+
this.Zr,
|
|
180
|
+
this.ft,
|
|
181
|
+
this.wt,
|
|
182
|
+
this.u,
|
|
168
183
|
t => {
|
|
169
|
-
if (this.
|
|
184
|
+
if (this.ue()) for (const i of this.gr()) i.Ts(t);
|
|
170
185
|
},
|
|
171
|
-
this.
|
|
172
|
-
this.
|
|
186
|
+
this.jo,
|
|
187
|
+
this.gt
|
|
173
188
|
)),
|
|
174
189
|
this.Ci.initialize(),
|
|
175
|
-
r.
|
|
190
|
+
r.j.info(
|
|
176
191
|
`Initialized for the Braze backend at "${this.nn(
|
|
177
|
-
|
|
178
|
-
)}" with API key "${this.
|
|
192
|
+
L.Eo
|
|
193
|
+
)}" with API key "${this.Xr}".`
|
|
179
194
|
),
|
|
180
|
-
null != this.nn(
|
|
181
|
-
|
|
195
|
+
null != this.nn(L.Oo) &&
|
|
196
|
+
z(
|
|
182
197
|
"enableHtmlInAppMessages",
|
|
183
198
|
"initialization option",
|
|
184
199
|
"allowUserSuppliedJavascript"
|
|
185
200
|
),
|
|
186
|
-
|
|
187
|
-
this.
|
|
188
|
-
this.
|
|
189
|
-
this.
|
|
201
|
+
et.init(),
|
|
202
|
+
this.wt.Ni(() => {
|
|
203
|
+
this.Uo &&
|
|
204
|
+
this.wt &&
|
|
205
|
+
this.wt.bi() &&
|
|
190
206
|
import("../FeatureFlags/refresh-feature-flags.js").then(t => {
|
|
191
|
-
if (!this.
|
|
207
|
+
if (!this.Uo) return;
|
|
192
208
|
(0, t.default)();
|
|
193
209
|
});
|
|
194
210
|
}),
|
|
195
|
-
this.Ci.
|
|
196
|
-
this.
|
|
197
|
-
this.
|
|
211
|
+
this.Ci.pr(() => {
|
|
212
|
+
this.Uo &&
|
|
213
|
+
this.wt &&
|
|
214
|
+
this.wt.bi() &&
|
|
198
215
|
import("../FeatureFlags/refresh-feature-flags.js").then(t => {
|
|
199
|
-
if (!this.
|
|
216
|
+
if (!this.Uo) return;
|
|
200
217
|
(0, t.default)(null, null, !0);
|
|
201
218
|
});
|
|
202
219
|
}),
|
|
203
|
-
this.
|
|
204
|
-
(this.
|
|
220
|
+
this.Wo.Et(this.options),
|
|
221
|
+
(this.Uo = !0),
|
|
205
222
|
!0
|
|
206
223
|
);
|
|
207
224
|
}
|
|
208
225
|
destroy(t) {
|
|
209
|
-
if ((r.
|
|
210
|
-
this.
|
|
211
|
-
for (const t of this.
|
|
212
|
-
this.
|
|
213
|
-
for (const t of this.
|
|
214
|
-
(this.
|
|
226
|
+
if ((r.j.destroy(), this.ue())) {
|
|
227
|
+
this.zo.Et(), this.zo.removeAllSubscriptions();
|
|
228
|
+
for (const t of this.Vo) t.destroy();
|
|
229
|
+
this.Vo = [];
|
|
230
|
+
for (const t of this.Go) t.clearData(!1);
|
|
231
|
+
(this.Go = []),
|
|
215
232
|
this.removeAllSubscriptions(),
|
|
216
233
|
(this.Se = []),
|
|
217
|
-
this.Ci.destroy(),
|
|
234
|
+
null != this.Ci && this.Ci.destroy(),
|
|
218
235
|
(this.Ci = null),
|
|
219
|
-
(this.
|
|
220
|
-
(this.
|
|
221
|
-
(this.vt = null),
|
|
236
|
+
(this.jo = null),
|
|
237
|
+
(this.Zr = null),
|
|
222
238
|
(this.gt = null),
|
|
223
|
-
(this.
|
|
224
|
-
(this.
|
|
225
|
-
(this.
|
|
226
|
-
(this.
|
|
227
|
-
(this.
|
|
228
|
-
(this.
|
|
229
|
-
|
|
239
|
+
(this.wt = null),
|
|
240
|
+
(this._e = null),
|
|
241
|
+
(this.ft = null),
|
|
242
|
+
(this.options = {}),
|
|
243
|
+
(this.Mo = void 0),
|
|
244
|
+
(this.Uo = !1),
|
|
245
|
+
(this.Bo = !1),
|
|
246
|
+
t && (this.u = null);
|
|
230
247
|
}
|
|
231
248
|
}
|
|
232
249
|
rr() {
|
|
233
|
-
if (this.
|
|
234
|
-
if (!this.
|
|
235
|
-
throw new Error("Braze must be initialized before calling methods.");
|
|
250
|
+
if (this.Jo()) return !1;
|
|
251
|
+
if (!this.ue()) throw new Error(P);
|
|
236
252
|
return !0;
|
|
237
253
|
}
|
|
238
254
|
ea() {
|
|
239
|
-
return this.
|
|
255
|
+
return this.Xr;
|
|
240
256
|
}
|
|
241
|
-
|
|
242
|
-
return this.
|
|
257
|
+
Sr() {
|
|
258
|
+
return this.jo;
|
|
243
259
|
}
|
|
244
|
-
|
|
245
|
-
return this.
|
|
260
|
+
Zs() {
|
|
261
|
+
return this.Do;
|
|
246
262
|
}
|
|
247
|
-
|
|
248
|
-
return this.
|
|
263
|
+
ie() {
|
|
264
|
+
return this.Zr;
|
|
249
265
|
}
|
|
250
|
-
|
|
251
|
-
return this.
|
|
266
|
+
ar() {
|
|
267
|
+
return this.gt;
|
|
252
268
|
}
|
|
253
269
|
nn(t) {
|
|
254
|
-
return this.
|
|
270
|
+
return this.options[t];
|
|
255
271
|
}
|
|
256
|
-
|
|
257
|
-
return this.
|
|
272
|
+
gr() {
|
|
273
|
+
return this.Go;
|
|
258
274
|
}
|
|
259
|
-
|
|
275
|
+
cr() {
|
|
260
276
|
return this.Ci;
|
|
261
277
|
}
|
|
262
|
-
|
|
263
|
-
return this.
|
|
278
|
+
tr() {
|
|
279
|
+
return this.wt;
|
|
264
280
|
}
|
|
265
|
-
|
|
266
|
-
return this.
|
|
281
|
+
aa() {
|
|
282
|
+
return this._e;
|
|
267
283
|
}
|
|
268
284
|
l() {
|
|
269
|
-
return this.
|
|
285
|
+
return this.u;
|
|
270
286
|
}
|
|
271
|
-
|
|
272
|
-
if (this.
|
|
287
|
+
jr() {
|
|
288
|
+
if (this.ft && this.Ci) return new User(this.ft, this.Ci);
|
|
273
289
|
}
|
|
274
|
-
|
|
275
|
-
return this.
|
|
290
|
+
ir() {
|
|
291
|
+
return this.ft;
|
|
276
292
|
}
|
|
277
|
-
|
|
278
|
-
return !0 === this.nn(
|
|
293
|
+
nr() {
|
|
294
|
+
return !0 === this.nn(L.Co) || !0 === this.nn(L.Oo);
|
|
279
295
|
}
|
|
280
|
-
|
|
296
|
+
g(t) {
|
|
281
297
|
let i = !1;
|
|
282
|
-
for (const s of this.
|
|
283
|
-
i || this.
|
|
298
|
+
for (const s of this.Vo) s === t && (i = !0);
|
|
299
|
+
i || this.Vo.push(t);
|
|
284
300
|
}
|
|
285
|
-
|
|
301
|
+
dr(t) {
|
|
286
302
|
let i = !1;
|
|
287
|
-
for (const s of this.
|
|
288
|
-
t instanceof y && !i && this.
|
|
303
|
+
for (const s of this.Go) s.constructor === t.constructor && (i = !0);
|
|
304
|
+
t instanceof y && !i && this.Go.push(t);
|
|
289
305
|
}
|
|
290
306
|
jt(t) {
|
|
291
|
-
t instanceof
|
|
307
|
+
t instanceof E && this.Se.push(t);
|
|
292
308
|
}
|
|
293
309
|
removeAllSubscriptions() {
|
|
294
310
|
if (this.rr()) for (const t of this.Se) t.removeAllSubscriptions();
|
|
@@ -296,18 +312,18 @@ class Bt {
|
|
|
296
312
|
removeSubscription(t) {
|
|
297
313
|
if (this.rr()) for (const i of this.Se) i.removeSubscription(t);
|
|
298
314
|
}
|
|
299
|
-
|
|
300
|
-
this.
|
|
315
|
+
ae(t) {
|
|
316
|
+
this.Bo = t;
|
|
301
317
|
}
|
|
302
|
-
|
|
303
|
-
return this.
|
|
318
|
+
ue() {
|
|
319
|
+
return this.Uo;
|
|
304
320
|
}
|
|
305
|
-
|
|
306
|
-
return this.
|
|
321
|
+
Jo() {
|
|
322
|
+
return this.Bo;
|
|
307
323
|
}
|
|
308
|
-
|
|
309
|
-
return this.
|
|
324
|
+
Us() {
|
|
325
|
+
return this.Ro;
|
|
310
326
|
}
|
|
311
327
|
}
|
|
312
|
-
const e = new
|
|
313
|
-
export { e as default,
|
|
328
|
+
const e = new Wt();
|
|
329
|
+
export { e as default, Wt as BrazeSdkInstance, L as OPTIONS };
|
|
@@ -1,77 +1,82 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import V from "../util/browser-detector.js";
|
|
2
|
+
import xt from "../models/device.js";
|
|
3
3
|
import DeviceProperties from "../Core/device-properties.js";
|
|
4
4
|
import _t from "../models/identifier.js";
|
|
5
5
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
6
|
-
import { STORAGE_KEYS as
|
|
6
|
+
import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
|
|
7
7
|
import { values as Lt } from "../util/code-utils.js";
|
|
8
|
+
import { getErrorMessage as ei } from "../util/error-utils.js";
|
|
8
9
|
export default class Ot {
|
|
9
|
-
constructor(
|
|
10
|
-
(this.
|
|
10
|
+
constructor(t, e) {
|
|
11
|
+
(this.u = t),
|
|
12
|
+
(this.Qo = e),
|
|
13
|
+
(this.u = t),
|
|
14
|
+
null == e && (e = Lt(DeviceProperties)),
|
|
15
|
+
(this.Qo = e);
|
|
11
16
|
}
|
|
12
17
|
te() {
|
|
13
|
-
let
|
|
14
|
-
null ==
|
|
15
|
-
const
|
|
16
|
-
for (let
|
|
17
|
-
|
|
18
|
-
switch (r) {
|
|
18
|
+
let t = this.u.tu(i.eu.Xo);
|
|
19
|
+
null == t && ((t = new _t(r.Z.Y())), this.u.uu(i.eu.Xo, t));
|
|
20
|
+
const e = new xt(t.iu);
|
|
21
|
+
for (let t = 0; t < this.Qo.length; t++) {
|
|
22
|
+
switch (this.Qo[t]) {
|
|
19
23
|
case DeviceProperties.BROWSER:
|
|
20
|
-
|
|
24
|
+
e.browser = V.browser;
|
|
21
25
|
break;
|
|
22
26
|
case DeviceProperties.BROWSER_VERSION:
|
|
23
|
-
|
|
27
|
+
e.Yo = V.version;
|
|
24
28
|
break;
|
|
25
29
|
case DeviceProperties.OS:
|
|
26
|
-
|
|
30
|
+
e.os = this.Zo();
|
|
27
31
|
break;
|
|
28
32
|
case DeviceProperties.RESOLUTION:
|
|
29
|
-
|
|
33
|
+
e.sa = screen.width + "x" + screen.height;
|
|
30
34
|
break;
|
|
31
35
|
case DeviceProperties.LANGUAGE:
|
|
32
|
-
|
|
36
|
+
e.language = V.language;
|
|
33
37
|
break;
|
|
34
38
|
case DeviceProperties.TIME_ZONE:
|
|
35
|
-
|
|
39
|
+
e.timeZone = this.oa(new Date());
|
|
36
40
|
break;
|
|
37
41
|
case DeviceProperties.USER_AGENT:
|
|
38
|
-
|
|
42
|
+
e.userAgent = V.userAgent;
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
|
-
return
|
|
45
|
+
return e;
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
return
|
|
47
|
+
Zo() {
|
|
48
|
+
if (V.ca()) return V.ca();
|
|
49
|
+
const t = this.u.v(i.k.la);
|
|
50
|
+
return t && t.os_version ? t.os_version : V.Zo();
|
|
47
51
|
}
|
|
48
|
-
|
|
52
|
+
oa(t) {
|
|
53
|
+
let e = !1;
|
|
49
54
|
if ("undefined" != typeof Intl && "function" == typeof Intl.DateTimeFormat)
|
|
50
55
|
try {
|
|
51
56
|
if ("function" == typeof Intl.DateTimeFormat().resolvedOptions) {
|
|
52
|
-
const
|
|
53
|
-
if (null !=
|
|
57
|
+
const t = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
58
|
+
if (null != t && "" !== t) return t;
|
|
54
59
|
}
|
|
55
60
|
} catch (t) {
|
|
56
|
-
r.
|
|
61
|
+
r.j.info(
|
|
57
62
|
"Intl.DateTimeFormat threw an error, cannot detect user's time zone:" +
|
|
58
|
-
t
|
|
63
|
+
ei(t)
|
|
59
64
|
),
|
|
60
|
-
(e =
|
|
65
|
+
(e = !0);
|
|
61
66
|
}
|
|
62
|
-
if (
|
|
63
|
-
const
|
|
64
|
-
return this.
|
|
67
|
+
if (e) return "";
|
|
68
|
+
const s = t.getTimezoneOffset();
|
|
69
|
+
return this.fa(s);
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
r =
|
|
71
|
+
fa(t) {
|
|
72
|
+
const e = Math.trunc(t / 60),
|
|
73
|
+
r = Math.trunc(t % 60);
|
|
69
74
|
let s = "GMT";
|
|
70
75
|
return (
|
|
71
|
-
0 !==
|
|
72
|
-
((s +=
|
|
76
|
+
0 !== t &&
|
|
77
|
+
((s += t < 0 ? "+" : "-"),
|
|
73
78
|
(s +=
|
|
74
|
-
("00" + Math.abs(
|
|
79
|
+
("00" + Math.abs(e)).slice(-2) +
|
|
75
80
|
":" +
|
|
76
81
|
("00" + Math.abs(r)).slice(-2))),
|
|
77
82
|
s
|