@braze/web-sdk 4.10.1 → 5.0.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 +26 -111
- 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 +34 -1
- package/shared-lib/guid.js +10 -1
- package/shared-lib/indexed-db-adapter.js +352 -1
- package/shared-lib/logger.js +38 -1
- package/shared-lib/supported-options.js +26 -1
- package/shared-lib/types.js +1 -1
- package/src/Card/card-manager-factory.js +14 -1
- package/src/Card/card-manager.js +78 -1
- package/src/Card/display/card-display.js +138 -1
- package/src/Card/index.js +6 -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-click.js +4 -1
- package/src/Card/log-content-card-impressions.js +4 -1
- package/src/Card/models/captioned-image.js +33 -1
- package/src/Card/models/card.js +197 -1
- package/src/Card/models/classic-card.js +32 -1
- package/src/Card/models/control-card.js +23 -1
- package/src/Card/models/image-only.js +31 -1
- package/src/Card/models/index.js +5 -1
- package/src/Card/types.js +1 -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 +391 -1
- package/src/ContentCards/content-cards.js +24 -1
- package/src/ContentCards/get-cached-content-cards.js +5 -1
- package/src/ContentCards/index.js +7 -1
- package/src/ContentCards/request-content-cards-refresh.js +5 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +17 -1
- package/src/ContentCards/types.js +1 -1
- package/src/ContentCards/ui/hide-content-cards.js +8 -1
- package/src/ContentCards/ui/show-content-cards.js +77 -1
- package/src/ContentCards/ui/toggle-content-cards.js +8 -1
- package/src/Core/add-sdk-metadata.js +26 -1
- package/src/Core/braze-sdk-metadata.js +10 -1
- package/src/Core/change-user.js +17 -1
- package/src/Core/destroy.js +5 -1
- package/src/Core/device-properties.js +9 -1
- package/src/Core/disable-sdk.js +15 -1
- package/src/Core/enable-sdk.js +11 -1
- package/src/Core/get-device-id.js +13 -1
- package/src/Core/get-user.js +4 -1
- package/src/Core/handle-braze-action.js +87 -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 +38 -1
- package/src/Core/log-purchase.js +245 -1
- package/src/Core/open-session.js +25 -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 +6 -1
- package/src/Core/set-logger.js +4 -1
- package/src/Core/set-sdk-authentication-signature.js +8 -1
- package/src/Core/subscribe-to-sdk-authentication-failures.js +6 -1
- package/src/Core/toggle-logging.js +4 -1
- package/src/Core/types.js +1 -1
- package/src/Core/wipe-data.js +16 -1
- package/src/FeatureFlags/feature-flag-factory.js +24 -1
- package/src/FeatureFlags/feature-flag.js +64 -1
- package/src/FeatureFlags/feature-flags-provider-factory.js +19 -1
- package/src/FeatureFlags/feature-flags-provider.js +145 -1
- package/src/FeatureFlags/get-all-feature-flags.js +12 -1
- package/src/FeatureFlags/get-feature-flag.js +10 -1
- package/src/FeatureFlags/index.js +6 -1
- package/src/FeatureFlags/log-feature-flag-impression.js +23 -1
- package/src/FeatureFlags/refresh-feature-flags.js +9 -1
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +9 -1
- package/src/FeatureFlags/types.js +1 -1
- package/src/Feed/feed-provider-factory.js +18 -1
- package/src/Feed/feed-provider.js +90 -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 +7 -1
- package/src/Feed/request-feed-refresh.js +5 -1
- package/src/Feed/subscribe-to-feed-updates.js +5 -1
- package/src/Feed/types.js +1 -1
- package/src/Feed/ui/hide-feed.js +7 -1
- package/src/Feed/ui/show-feed.js +96 -1
- package/src/Feed/ui/toggle-feed.js +8 -1
- package/src/InAppMessage/defer-in-app-message.js +13 -1
- package/src/InAppMessage/display/get-animation-effect.js +19 -1
- package/src/InAppMessage/display/html-message-to-html.js +243 -1
- package/src/InAppMessage/display/in-app-message-to-html.js +188 -1
- package/src/InAppMessage/display/modal-utils.js +73 -1
- package/src/InAppMessage/get-deferred-in-app-message.js +5 -1
- package/src/InAppMessage/in-app-message-factory.js +166 -1
- package/src/InAppMessage/in-app-message-manager-factory.js +16 -1
- package/src/InAppMessage/in-app-message-manager.js +248 -1
- package/src/InAppMessage/index.js +16 -1
- package/src/InAppMessage/log-in-app-message-button-click.js +27 -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 +11 -1
- package/src/InAppMessage/models/full-screen-message.js +105 -1
- package/src/InAppMessage/models/html-message.js +68 -1
- package/src/InAppMessage/models/in-app-message-button.js +47 -1
- package/src/InAppMessage/models/in-app-message.js +382 -1
- package/src/InAppMessage/models/modal-message.js +101 -1
- package/src/InAppMessage/models/slide-up-message.js +84 -1
- package/src/InAppMessage/models/templated-in-app-message.js +19 -1
- package/src/InAppMessage/subscribe-to-in-app-message.js +10 -1
- package/src/InAppMessage/types.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +15 -1
- package/src/InAppMessage/ui/show-in-app-message.js +181 -1
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -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 +387 -1
- package/src/Push/request-push-permission.js +9 -1
- package/src/Push/types.js +1 -1
- package/src/Push/unregister-push.js +5 -1
- package/src/Push/utils/push-utils.js +36 -1
- package/src/User/index.js +1 -1
- package/src/User/types.js +1 -1
- package/src/User/user-manager.js +73 -1
- package/src/User/user.js +302 -1
- package/src/common/base-feed.js +29 -1
- package/src/common/base-provider.js +6 -1
- package/src/common/constants.js +14 -1
- package/src/common/event-logger.js +31 -1
- package/src/common/feed-display.js +210 -1
- package/src/common/translations.js +148 -1
- package/src/common/types.js +1 -1
- package/src/index.js +9 -1
- package/src/l10n/l10n-manager-factory.js +22 -1
- package/src/l10n/l10n-manager.js +25 -1
- package/src/l10n/types.js +1 -1
- package/src/managers/auth-manager.js +51 -1
- package/src/managers/braze-instance.js +322 -1
- package/src/managers/device-manager.js +85 -1
- package/src/managers/network-manager.js +256 -1
- package/src/managers/server-config-manager.js +108 -1
- package/src/managers/session-manager.js +75 -1
- package/src/managers/storage-manager-factory.js +42 -1
- package/src/managers/storage-manager.js +426 -1
- package/src/managers/subscription-manager.js +28 -1
- package/src/managers/types.js +1 -1
- package/src/models/backend-errors.js +8 -1
- package/src/models/braze-event.js +47 -1
- package/src/models/braze-sdk-metadata.js +10 -1
- package/src/models/device.js +18 -1
- package/src/models/identifier.js +19 -1
- package/src/models/push-token.js +27 -1
- package/src/models/request-result.js +8 -1
- package/src/models/server-config.js +48 -1
- package/src/models/types.js +1 -1
- package/src/request-controller.js +311 -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 +102 -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 +105 -1
- package/src/triggers/models/trigger-events.js +8 -1
- package/src/triggers/models/trigger.js +122 -1
- package/src/triggers/triggers-provider-factory.js +34 -1
- package/src/triggers/triggers-provider.js +326 -1
- package/src/triggers/types.js +1 -1
- package/src/types.js +1 -1
- package/src/ui/js/attach-css.js +13 -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 +84 -1
- package/src/util/browser-detector.js +84 -1
- package/src/util/client-hints-parser.js +66 -1
- package/src/util/code-utils.js +100 -1
- package/src/util/color-utils.js +29 -1
- package/src/util/component-utils.js +26 -1
- package/src/util/date-utils.js +28 -1
- package/src/util/deprecation-utils.js +5 -1
- package/src/util/device-constants.js +13 -1
- package/src/util/dom-utils.js +91 -1
- package/src/util/error-utils.js +2 -1
- package/src/util/key-codes.js +1 -1
- package/src/util/math.js +5 -1
- package/src/util/net.js +71 -1
- package/src/util/request-header-utils.js +46 -1
- package/src/util/string-utils.js +22 -1
- package/src/util/types.js +1 -1
- package/src/util/url-utils.js +20 -1
- package/src/util/user-agent-parser.js +80 -1
- package/src/util/validation-utils.js +217 -1
- package/src/util/window-utils.js +34 -1
- package/src/Card/models/banner.js +0 -1
- package/src/ContentCards/log-content-cards-displayed.js +0 -1
|
@@ -1 +1,85 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Q from "../util/browser-detector.js";
|
|
2
|
+
import xt from "../models/device.js";
|
|
3
|
+
import DeviceProperties from "../Core/device-properties.js";
|
|
4
|
+
import _t from "../models/identifier.js";
|
|
5
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
6
|
+
import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
|
|
7
|
+
import { values as Pt } from "../util/code-utils.js";
|
|
8
|
+
import { getErrorMessage as ei } from "../util/error-utils.js";
|
|
9
|
+
export default class Ot {
|
|
10
|
+
constructor(t, e) {
|
|
11
|
+
(this.u = t),
|
|
12
|
+
(this.Qo = e),
|
|
13
|
+
(this.u = t),
|
|
14
|
+
null == e && (e = Pt(DeviceProperties)),
|
|
15
|
+
(this.Qo = e);
|
|
16
|
+
}
|
|
17
|
+
ce(t = !0) {
|
|
18
|
+
let e = this.u.tu(i.eu.Zo);
|
|
19
|
+
null == e && ((e = new _t(r.Z.Y())), t && this.u.uu(i.eu.Zo, e));
|
|
20
|
+
const s = new xt(e.iu);
|
|
21
|
+
for (let t = 0; t < this.Qo.length; t++) {
|
|
22
|
+
switch (this.Qo[t]) {
|
|
23
|
+
case DeviceProperties.BROWSER:
|
|
24
|
+
s.browser = Q.browser;
|
|
25
|
+
break;
|
|
26
|
+
case DeviceProperties.BROWSER_VERSION:
|
|
27
|
+
s.Ia = Q.version;
|
|
28
|
+
break;
|
|
29
|
+
case DeviceProperties.OS:
|
|
30
|
+
s.os = this.Ta();
|
|
31
|
+
break;
|
|
32
|
+
case DeviceProperties.RESOLUTION:
|
|
33
|
+
s.Da = screen.width + "x" + screen.height;
|
|
34
|
+
break;
|
|
35
|
+
case DeviceProperties.LANGUAGE:
|
|
36
|
+
s.language = Q.language;
|
|
37
|
+
break;
|
|
38
|
+
case DeviceProperties.TIME_ZONE:
|
|
39
|
+
s.timeZone = this.Oa(new Date());
|
|
40
|
+
break;
|
|
41
|
+
case DeviceProperties.USER_AGENT:
|
|
42
|
+
s.userAgent = Q.userAgent;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return s;
|
|
46
|
+
}
|
|
47
|
+
Ta() {
|
|
48
|
+
if (Q.Ca()) return Q.Ca();
|
|
49
|
+
const t = this.u.v(i.k.Fa);
|
|
50
|
+
return t && t.os_version ? t.os_version : Q.Ta();
|
|
51
|
+
}
|
|
52
|
+
Oa(t) {
|
|
53
|
+
let e = !1;
|
|
54
|
+
if ("undefined" != typeof Intl && "function" == typeof Intl.DateTimeFormat)
|
|
55
|
+
try {
|
|
56
|
+
if ("function" == typeof Intl.DateTimeFormat().resolvedOptions) {
|
|
57
|
+
const t = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
58
|
+
if (null != t && "" !== t) return t;
|
|
59
|
+
}
|
|
60
|
+
} catch (t) {
|
|
61
|
+
r.j.info(
|
|
62
|
+
"Intl.DateTimeFormat threw an error, cannot detect user's time zone:" +
|
|
63
|
+
ei(t),
|
|
64
|
+
),
|
|
65
|
+
(e = !0);
|
|
66
|
+
}
|
|
67
|
+
if (e) return "";
|
|
68
|
+
const s = t.getTimezoneOffset();
|
|
69
|
+
return this.Ga(s);
|
|
70
|
+
}
|
|
71
|
+
Ga(t) {
|
|
72
|
+
const e = Math.trunc(t / 60),
|
|
73
|
+
r = Math.trunc(t % 60);
|
|
74
|
+
let s = "GMT";
|
|
75
|
+
return (
|
|
76
|
+
0 !== t &&
|
|
77
|
+
((s += t < 0 ? "+" : "-"),
|
|
78
|
+
(s +=
|
|
79
|
+
("00" + Math.abs(e)).slice(-2) +
|
|
80
|
+
":" +
|
|
81
|
+
("00" + Math.abs(r)).slice(-2))),
|
|
82
|
+
s
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -1 +1,256 @@
|
|
|
1
|
-
import qt from"../models/backend-errors.js";
|
|
1
|
+
import qt from "../models/backend-errors.js";
|
|
2
|
+
import ue from "../models/braze-event.js";
|
|
3
|
+
import {
|
|
4
|
+
convertMsToSeconds as h,
|
|
5
|
+
convertSecondsToMs as Xt,
|
|
6
|
+
} from "../util/date-utils.js";
|
|
7
|
+
import s from "../common/event-logger.js";
|
|
8
|
+
import { isArray as p, isEqual as ii } from "../util/code-utils.js";
|
|
9
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
10
|
+
import { STORAGE_KEYS as i } from "./storage-manager.js";
|
|
11
|
+
import T from "../util/request-header-utils.js";
|
|
12
|
+
import { LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as Ht } from "../common/constants.js";
|
|
13
|
+
export default class Rt {
|
|
14
|
+
constructor(t, e, s, i, r, o, n, h, a, u, c, l) {
|
|
15
|
+
(this.fn = t),
|
|
16
|
+
(this.u = e),
|
|
17
|
+
(this.Mo = s),
|
|
18
|
+
(this.wt = i),
|
|
19
|
+
(this._e = r),
|
|
20
|
+
(this.yt = o),
|
|
21
|
+
(this.cn = n),
|
|
22
|
+
(this.Uo = h),
|
|
23
|
+
(this.jo = a),
|
|
24
|
+
(this.Do = u),
|
|
25
|
+
(this.appVersion = c),
|
|
26
|
+
(this.Xh = l),
|
|
27
|
+
(this.fn = t),
|
|
28
|
+
(this.u = e),
|
|
29
|
+
(this.Mo = s),
|
|
30
|
+
(this.wt = i),
|
|
31
|
+
(this._e = r),
|
|
32
|
+
(this.yt = o),
|
|
33
|
+
(this.cn = n),
|
|
34
|
+
(this.Uo = h),
|
|
35
|
+
(this.jo = a),
|
|
36
|
+
(this.Do = u),
|
|
37
|
+
(this.appVersion = c),
|
|
38
|
+
(this.Xh = l),
|
|
39
|
+
(this.$h = ["npm"]);
|
|
40
|
+
}
|
|
41
|
+
Bs(t, e = !1, s = !1) {
|
|
42
|
+
const r = this.fn.ce(!s),
|
|
43
|
+
o = r.Kr(),
|
|
44
|
+
n = this.u.v(i.k.Fa);
|
|
45
|
+
ii(n, o) || (t.device = o),
|
|
46
|
+
(t.api_key = this.cn),
|
|
47
|
+
(t.time = h(new Date().valueOf(), !0));
|
|
48
|
+
const a = this.u.v(i.k.Kh) || [],
|
|
49
|
+
u = this.u.v(i.k.Wh) || "";
|
|
50
|
+
if (
|
|
51
|
+
(this.$h.length > 0 &&
|
|
52
|
+
(!ii(a, this.$h) || u !== this._e.Yh()) &&
|
|
53
|
+
(t.sdk_metadata = this.$h),
|
|
54
|
+
(t.sdk_version = this.jo),
|
|
55
|
+
this.Do && (t.sdk_flavor = this.Do),
|
|
56
|
+
(t.app_version = this.appVersion),
|
|
57
|
+
(t.app_version_code = this.Xh),
|
|
58
|
+
(t.device_id = r.id),
|
|
59
|
+
e)
|
|
60
|
+
) {
|
|
61
|
+
const e = this.wt.getUserId();
|
|
62
|
+
null != e && (t.user_id = e);
|
|
63
|
+
}
|
|
64
|
+
return t;
|
|
65
|
+
}
|
|
66
|
+
Zs(t, e, i) {
|
|
67
|
+
const o = e.auth_error,
|
|
68
|
+
n = e.error;
|
|
69
|
+
if (!o && !n) return !0;
|
|
70
|
+
if (o) {
|
|
71
|
+
let e;
|
|
72
|
+
this.Mo.Hh();
|
|
73
|
+
const s = { errorCode: o.error_code };
|
|
74
|
+
for (const t of i)
|
|
75
|
+
p(t) && "X-Braze-Auth-Signature" === t[0] && (s.signature = t[1]);
|
|
76
|
+
t.respond_with && t.respond_with.user_id
|
|
77
|
+
? (s.userId = t.respond_with.user_id)
|
|
78
|
+
: t.user_id && (s.userId = t.user_id);
|
|
79
|
+
const n = o.reason;
|
|
80
|
+
return (
|
|
81
|
+
n
|
|
82
|
+
? ((s.reason = n), (e = `due to ${n}`))
|
|
83
|
+
: (e = `with error code ${o.error_code}.`),
|
|
84
|
+
this.Mo.wh() ||
|
|
85
|
+
(e +=
|
|
86
|
+
' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
|
|
87
|
+
r.j.error(`SDK Authentication failed ${e}`),
|
|
88
|
+
this.Qh(t.events || [], t.attributes || []),
|
|
89
|
+
this.Mo.Bh(s),
|
|
90
|
+
!1
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (n) {
|
|
94
|
+
let i,
|
|
95
|
+
o = n;
|
|
96
|
+
switch (o) {
|
|
97
|
+
case qt.Vh:
|
|
98
|
+
return (
|
|
99
|
+
(i = "Received successful response with empty body."),
|
|
100
|
+
s.N(r.q.qs, { e: i }),
|
|
101
|
+
r.j.info(i),
|
|
102
|
+
!1
|
|
103
|
+
);
|
|
104
|
+
case qt.Zh:
|
|
105
|
+
return (
|
|
106
|
+
(i = "Received successful response with invalid JSON"),
|
|
107
|
+
s.N(r.q.qs, { e: i + ": " + e.response }),
|
|
108
|
+
r.j.info(i),
|
|
109
|
+
!1
|
|
110
|
+
);
|
|
111
|
+
case qt.Ra:
|
|
112
|
+
o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Uo}`;
|
|
113
|
+
break;
|
|
114
|
+
case qt.Xa:
|
|
115
|
+
o =
|
|
116
|
+
"Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
|
|
117
|
+
break;
|
|
118
|
+
case qt.Ea:
|
|
119
|
+
o = "No device identifier. Please contact support@braze.com";
|
|
120
|
+
}
|
|
121
|
+
r.j.error("Backend error: " + o);
|
|
122
|
+
}
|
|
123
|
+
return !1;
|
|
124
|
+
}
|
|
125
|
+
Pa(t, e, s, i) {
|
|
126
|
+
return !!((t && 0 !== t.length) || (e && 0 !== e.length) || s || i);
|
|
127
|
+
}
|
|
128
|
+
$a(t, e, s, i, r = !1) {
|
|
129
|
+
const o = [],
|
|
130
|
+
n = (t) => t || "",
|
|
131
|
+
h = n(this.wt.getUserId());
|
|
132
|
+
let a = this.Jr(t, e);
|
|
133
|
+
const u = [],
|
|
134
|
+
c = [];
|
|
135
|
+
let l,
|
|
136
|
+
f = null;
|
|
137
|
+
if (s.length > 0) {
|
|
138
|
+
const t = [];
|
|
139
|
+
for (const e of s) {
|
|
140
|
+
if (((l = e.Kr()), this.Mo.wh())) {
|
|
141
|
+
if (h && !l.user_id) {
|
|
142
|
+
f || (f = {}), f.events || (f.events = []), f.events.push(l);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (n(l.user_id) !== h) {
|
|
146
|
+
c.push(l);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
t.push(l);
|
|
151
|
+
}
|
|
152
|
+
t.length > 0 && (a.events = t);
|
|
153
|
+
}
|
|
154
|
+
if (i.length > 0) {
|
|
155
|
+
const t = [];
|
|
156
|
+
for (const e of i)
|
|
157
|
+
e && (this.Mo.wh() && n(e.user_id) !== h ? u.push(e) : t.push(e));
|
|
158
|
+
t.length > 0 && (a.attributes = t);
|
|
159
|
+
}
|
|
160
|
+
if ((this.Qh(c, u), (a = this.Bs(a, !0, r)), f)) {
|
|
161
|
+
f = this.Bs(f, !1, r);
|
|
162
|
+
const t = { requestData: f, headers: this.Hs(f, T.Os.Na) };
|
|
163
|
+
o.push(t);
|
|
164
|
+
}
|
|
165
|
+
if (a && !this.Pa(a.events, a.attributes, t, e)) return f ? o : null;
|
|
166
|
+
const d = { requestData: a, headers: this.Hs(a, T.Os.Na) };
|
|
167
|
+
return o.push(d), o;
|
|
168
|
+
}
|
|
169
|
+
Qh(t, e) {
|
|
170
|
+
if (t) {
|
|
171
|
+
const e = [];
|
|
172
|
+
for (const s of t) {
|
|
173
|
+
const t = ue.fromJson(s);
|
|
174
|
+
(t.time = Xt(t.time)), e.push(t);
|
|
175
|
+
}
|
|
176
|
+
this.u.bo(e);
|
|
177
|
+
}
|
|
178
|
+
if (e) for (const t of e) this.u.Ha(t);
|
|
179
|
+
}
|
|
180
|
+
ii(t, e) {
|
|
181
|
+
let s = "HTTP error ";
|
|
182
|
+
null != t && (s += t + " "), (s += e), r.j.error(s);
|
|
183
|
+
}
|
|
184
|
+
qr(t) {
|
|
185
|
+
return s.N(r.q.Ka, { n: t });
|
|
186
|
+
}
|
|
187
|
+
Jr(t, e, s) {
|
|
188
|
+
const i = {};
|
|
189
|
+
t && (i.feed = !0), e && (i.triggers = !0);
|
|
190
|
+
const r = null != s ? s : this.wt.getUserId();
|
|
191
|
+
return (
|
|
192
|
+
r && (i.user_id = r),
|
|
193
|
+
(i.config = { config_time: this.yt.li() }),
|
|
194
|
+
{ respond_with: i }
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
Ua(t) {
|
|
198
|
+
const e = new Date().valueOf();
|
|
199
|
+
let s = Ht.toString();
|
|
200
|
+
const i = T.La(this.u, t);
|
|
201
|
+
if (-1 !== i) {
|
|
202
|
+
s = (e - i).toString();
|
|
203
|
+
}
|
|
204
|
+
return s;
|
|
205
|
+
}
|
|
206
|
+
Hs(t, e, s = !1) {
|
|
207
|
+
const r = [["X-Braze-Api-Key", this.cn]],
|
|
208
|
+
o = this.Ua(e);
|
|
209
|
+
r.push(["X-Braze-Last-Req-Ms-Ago", o]);
|
|
210
|
+
const n = T.Wa(this.u, e).toString();
|
|
211
|
+
r.push(["X-Braze-Req-Attempt", n]);
|
|
212
|
+
let h = !1;
|
|
213
|
+
if (
|
|
214
|
+
(null != t.respond_with &&
|
|
215
|
+
t.respond_with.triggers &&
|
|
216
|
+
(r.push(["X-Braze-TriggersRequest", "true"]), (h = !0)),
|
|
217
|
+
null != t.respond_with &&
|
|
218
|
+
t.respond_with.feed &&
|
|
219
|
+
(r.push(["X-Braze-FeedRequest", "true"]), (h = !0)),
|
|
220
|
+
e === T.Os.Ks)
|
|
221
|
+
) {
|
|
222
|
+
r.push(["X-Braze-ContentCardsRequest", "true"]);
|
|
223
|
+
let t = this.u.v(i.k.zs);
|
|
224
|
+
(t && s) || ((t = 0), this.u.D(i.k.zs, t)),
|
|
225
|
+
r.push(["BRAZE-SYNC-RETRY-COUNT", t.toString()]),
|
|
226
|
+
(h = !0);
|
|
227
|
+
}
|
|
228
|
+
if (
|
|
229
|
+
(e === T.Os.Si &&
|
|
230
|
+
(r.push(["X-Braze-FeatureFlagsRequest", "true"]), (h = !0)),
|
|
231
|
+
h && r.push(["X-Braze-DataRequest", "true"]),
|
|
232
|
+
this.Mo.wh())
|
|
233
|
+
) {
|
|
234
|
+
const t = this.Mo.jh();
|
|
235
|
+
null != t && r.push(["X-Braze-Auth-Signature", t]);
|
|
236
|
+
}
|
|
237
|
+
return r;
|
|
238
|
+
}
|
|
239
|
+
Qs(t, e) {
|
|
240
|
+
const s = t.device;
|
|
241
|
+
s && s.os_version instanceof Promise
|
|
242
|
+
? s.os_version.then((s) => {
|
|
243
|
+
(t.device.os_version = s), e();
|
|
244
|
+
})
|
|
245
|
+
: e();
|
|
246
|
+
}
|
|
247
|
+
ti() {
|
|
248
|
+
this.Mo.ti();
|
|
249
|
+
}
|
|
250
|
+
Ys() {
|
|
251
|
+
return this.Uo;
|
|
252
|
+
}
|
|
253
|
+
addSdkMetadata(t) {
|
|
254
|
+
for (const e of t) -1 === this.$h.indexOf(e) && this.$h.push(e);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -1 +1,108 @@
|
|
|
1
|
-
import{STORAGE_KEYS as i}from"./storage-manager.js";
|
|
1
|
+
import { STORAGE_KEYS as i } from "./storage-manager.js";
|
|
2
|
+
import E from "./subscription-manager.js";
|
|
3
|
+
import Kt from "../models/server-config.js";
|
|
4
|
+
import s from "../common/event-logger.js";
|
|
5
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
6
|
+
import {
|
|
7
|
+
CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT as Vt,
|
|
8
|
+
CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT as Gt,
|
|
9
|
+
} from "../common/constants.js";
|
|
10
|
+
export default class jt {
|
|
11
|
+
constructor(t) {
|
|
12
|
+
(this.u = t),
|
|
13
|
+
(this.u = t),
|
|
14
|
+
(this.tl = new E()),
|
|
15
|
+
(this.el = new E()),
|
|
16
|
+
(this.sl = new E()),
|
|
17
|
+
(this.il = null),
|
|
18
|
+
(this.rl = null);
|
|
19
|
+
}
|
|
20
|
+
ll() {
|
|
21
|
+
if (null == this.rl) {
|
|
22
|
+
const t = this.u.v(i.k.hl);
|
|
23
|
+
this.rl = null != t ? Kt.Yn(t) : new Kt();
|
|
24
|
+
}
|
|
25
|
+
return this.rl;
|
|
26
|
+
}
|
|
27
|
+
li() {
|
|
28
|
+
return this.ll().ol;
|
|
29
|
+
}
|
|
30
|
+
ul(t) {
|
|
31
|
+
if (null != t && null != t.config) {
|
|
32
|
+
const e = t.config;
|
|
33
|
+
if (e.time > this.ll().ol) {
|
|
34
|
+
const t = new Kt(
|
|
35
|
+
e.time,
|
|
36
|
+
e.events_blacklist,
|
|
37
|
+
e.attributes_blacklist,
|
|
38
|
+
e.purchases_blacklist,
|
|
39
|
+
e.messaging_session_timeout,
|
|
40
|
+
e.vapid_public_key,
|
|
41
|
+
e.content_cards,
|
|
42
|
+
e.feature_flags,
|
|
43
|
+
);
|
|
44
|
+
let s = !1;
|
|
45
|
+
null != t.al && this.En() !== t.al && (s = !0);
|
|
46
|
+
let r = !1;
|
|
47
|
+
null != t.ml.enabled && this.oi() !== t.ml.enabled && (r = !0);
|
|
48
|
+
let n = !1;
|
|
49
|
+
null != t.gi.enabled && this.yi() !== t.gi.enabled && (n = !0),
|
|
50
|
+
(this.rl = t),
|
|
51
|
+
this.u.D(i.k.hl, t.tt()),
|
|
52
|
+
s && this.tl.Dt(),
|
|
53
|
+
r && this.el.Dt(),
|
|
54
|
+
n && this.sl.Dt();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
Rn(t) {
|
|
59
|
+
const e = this.tl.It(t);
|
|
60
|
+
return this.il && this.tl.removeSubscription(this.il), (this.il = e), e;
|
|
61
|
+
}
|
|
62
|
+
Ps(t) {
|
|
63
|
+
return this.el.It(t);
|
|
64
|
+
}
|
|
65
|
+
Ci(t) {
|
|
66
|
+
return this.sl.It(t);
|
|
67
|
+
}
|
|
68
|
+
ge(t) {
|
|
69
|
+
return -1 !== this.ll().cl.indexOf(t);
|
|
70
|
+
}
|
|
71
|
+
hu(t) {
|
|
72
|
+
return -1 !== this.ll().gl.indexOf(t);
|
|
73
|
+
}
|
|
74
|
+
Dr(t) {
|
|
75
|
+
return -1 !== this.ll().fl.indexOf(t);
|
|
76
|
+
}
|
|
77
|
+
dl() {
|
|
78
|
+
return this.ll().bl;
|
|
79
|
+
}
|
|
80
|
+
En() {
|
|
81
|
+
return this.ll().al;
|
|
82
|
+
}
|
|
83
|
+
oi() {
|
|
84
|
+
return this.ll().ml.enabled || !1;
|
|
85
|
+
}
|
|
86
|
+
$s() {
|
|
87
|
+
const t = this.ll().ml.rate_limit;
|
|
88
|
+
return !(!t || null == t.enabled) && t.enabled;
|
|
89
|
+
}
|
|
90
|
+
di() {
|
|
91
|
+
if (!this.$s()) return -1;
|
|
92
|
+
const t = this.ll().ml.rate_limit;
|
|
93
|
+
return null == t.capacity ? Vt : t.capacity <= 0 ? -1 : t.capacity;
|
|
94
|
+
}
|
|
95
|
+
mi() {
|
|
96
|
+
if (!this.$s()) return -1;
|
|
97
|
+
const t = this.ll().ml.rate_limit;
|
|
98
|
+
return null == t.refill_rate ? Gt : t.refill_rate <= 0 ? -1 : t.refill_rate;
|
|
99
|
+
}
|
|
100
|
+
yi() {
|
|
101
|
+
return this.ll().gi.enabled && null == this.Mi()
|
|
102
|
+
? (s.N(r.q.qs, { e: "Missing feature flag refresh_rate_limit." }), !1)
|
|
103
|
+
: this.ll().gi.enabled || !1;
|
|
104
|
+
}
|
|
105
|
+
Mi() {
|
|
106
|
+
return this.ll().gi.refresh_rate_limit;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -1 +1,75 @@
|
|
|
1
|
-
import{STORAGE_KEYS as i}from"../managers/storage-manager.js";
|
|
1
|
+
import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
|
|
2
|
+
import ue from "../models/braze-event.js";
|
|
3
|
+
import _t from "../models/identifier.js";
|
|
4
|
+
import { convertMsToSeconds as h } from "../util/date-utils.js";
|
|
5
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
6
|
+
export default class Dt {
|
|
7
|
+
constructor(s, t, i, e) {
|
|
8
|
+
(this.u = s),
|
|
9
|
+
(this.wt = t),
|
|
10
|
+
(this.yt = i),
|
|
11
|
+
(this.wl = e),
|
|
12
|
+
(this.u = s),
|
|
13
|
+
(this.wt = t),
|
|
14
|
+
(this.yt = i),
|
|
15
|
+
(this.Sl = 1e3),
|
|
16
|
+
(null == e || isNaN(e)) && (e = 1800),
|
|
17
|
+
e < this.Sl / 1e3 &&
|
|
18
|
+
(r.j.info(
|
|
19
|
+
"Specified session timeout of " +
|
|
20
|
+
e +
|
|
21
|
+
"s is too small, using the minimum session timeout of " +
|
|
22
|
+
this.Sl / 1e3 +
|
|
23
|
+
"s instead.",
|
|
24
|
+
),
|
|
25
|
+
(e = this.Sl / 1e3)),
|
|
26
|
+
(this.wl = e);
|
|
27
|
+
}
|
|
28
|
+
jl(s, t) {
|
|
29
|
+
return new ue(this.wt.getUserId(), r.q.xl, s, t.iu, { d: h(s - t.vl) });
|
|
30
|
+
}
|
|
31
|
+
Yh() {
|
|
32
|
+
const s = this.u.tu(i.eu.Dl);
|
|
33
|
+
return null == s ? null : s.iu;
|
|
34
|
+
}
|
|
35
|
+
El() {
|
|
36
|
+
const s = new Date().valueOf(),
|
|
37
|
+
t = this.yt.dl(),
|
|
38
|
+
e = this.u.v(i.k.zl);
|
|
39
|
+
if (null != e && null == t) return !1;
|
|
40
|
+
let n = !1;
|
|
41
|
+
return (
|
|
42
|
+
null == e ? (n = !0) : null != t && (n = s - e > 1e3 * t),
|
|
43
|
+
n && this.u.D(i.k.zl, s),
|
|
44
|
+
n
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
Cl(s, t) {
|
|
48
|
+
return null == t || null == t.Gl || (!(s - t.vl < this.Sl) && t.Gl < s);
|
|
49
|
+
}
|
|
50
|
+
co() {
|
|
51
|
+
const s = new Date().valueOf(),
|
|
52
|
+
t = s + 1e3 * this.wl,
|
|
53
|
+
e = this.u.tu(i.eu.Dl);
|
|
54
|
+
if (this.Cl(s, e)) {
|
|
55
|
+
let n = "Generating session start event with time " + s;
|
|
56
|
+
if (null != e) {
|
|
57
|
+
let s = e.Nl;
|
|
58
|
+
s - e.vl < this.Sl && (s = e.vl + this.Sl),
|
|
59
|
+
this.u.Hl(this.jl(s, e)),
|
|
60
|
+
(n += " (old session ended " + s + ")");
|
|
61
|
+
}
|
|
62
|
+
(n += ". Will expire " + t.valueOf()), r.j.info(n);
|
|
63
|
+
const l = new _t(r.Z.Y(), t);
|
|
64
|
+
this.u.Hl(new ue(this.wt.getUserId(), r.q.Wl, s, l.iu)),
|
|
65
|
+
this.u.uu(i.eu.Dl, l);
|
|
66
|
+
return null == this.u.v(i.k.zl) && this.u.D(i.k.zl, s), l.iu;
|
|
67
|
+
}
|
|
68
|
+
if (null != e) return (e.Nl = s), (e.Gl = t), this.u.uu(i.eu.Dl, e), e.iu;
|
|
69
|
+
}
|
|
70
|
+
kl() {
|
|
71
|
+
const s = this.u.tu(i.eu.Dl);
|
|
72
|
+
null != s &&
|
|
73
|
+
(this.u.ql(i.eu.Dl), this.u.Hl(this.jl(new Date().valueOf(), s)));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1 +1,42 @@
|
|
|
1
|
-
import
|
|
1
|
+
import J, { STORAGE_KEYS as i } from "./storage-manager.js";
|
|
2
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
3
|
+
const Mt = {
|
|
4
|
+
xo: function (e, o = !1) {
|
|
5
|
+
let t = !1;
|
|
6
|
+
try {
|
|
7
|
+
if (localStorage && localStorage.getItem)
|
|
8
|
+
try {
|
|
9
|
+
localStorage.setItem(i.k.Qa, "true"),
|
|
10
|
+
localStorage.getItem(i.k.Qa) &&
|
|
11
|
+
(localStorage.removeItem(i.k.Qa), (t = !0));
|
|
12
|
+
} catch (e) {
|
|
13
|
+
if (
|
|
14
|
+
!(
|
|
15
|
+
e instanceof Error &&
|
|
16
|
+
("QuotaExceededError" === e.name ||
|
|
17
|
+
"NS_ERROR_DOM_QUOTA_REACHED" === e.name) &&
|
|
18
|
+
localStorage.length > 0
|
|
19
|
+
)
|
|
20
|
+
)
|
|
21
|
+
throw e;
|
|
22
|
+
t = !0;
|
|
23
|
+
}
|
|
24
|
+
} catch (e) {
|
|
25
|
+
r.j.info("Local Storage not supported!");
|
|
26
|
+
}
|
|
27
|
+
const a = Mt.Ja(),
|
|
28
|
+
n = new J.Va(e, a && !o, t);
|
|
29
|
+
let c;
|
|
30
|
+
return (c = t ? new J.Ya(e) : new J.Za()), new J(n, c);
|
|
31
|
+
},
|
|
32
|
+
Ja: function () {
|
|
33
|
+
return (
|
|
34
|
+
navigator.cookieEnabled ||
|
|
35
|
+
("cookie" in document &&
|
|
36
|
+
(document.cookie.length > 0 ||
|
|
37
|
+
(document.cookie = "test").indexOf.call(document.cookie, "test") >
|
|
38
|
+
-1))
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export default Mt;
|