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