@braze/web-sdk 6.4.0 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.d.ts +11 -5
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +3 -3
- package/shared-lib/event-types.js +30 -30
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +58 -58
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +17 -16
- package/src/Banner/banner-provider.js +95 -81
- package/src/Banner/banner.js +9 -9
- package/src/Banner/constants.js +4 -0
- package/src/Banner/display/banner-to-html.js +1 -1
- package/src/Banner/display/destroy-banner-html.js +3 -3
- package/src/Banner/display/detect-banner-impressions.js +14 -14
- package/src/Banner/get-all-banners.js +4 -4
- package/src/Banner/get-banner.js +5 -4
- package/src/Banner/log-banner-click.js +2 -2
- package/src/Banner/log-banner-impressions.js +6 -6
- package/src/Banner/request-banners-refresh.js +18 -20
- package/src/Banner/subscribe-to-banners-updates.js +5 -5
- package/src/Banner/ui/insert-banner.js +17 -14
- package/src/Card/card-manager-factory.js +3 -3
- package/src/Card/card-manager.js +32 -32
- package/src/Card/constants.js +1 -0
- package/src/Card/display/card-display.js +11 -11
- package/src/Card/log-card-dismissal.js +2 -2
- package/src/Card/log-content-card-click.js +2 -2
- package/src/Card/log-content-card-impressions.js +5 -5
- package/src/Card/models/captioned-image.js +3 -3
- package/src/Card/models/card.js +16 -16
- package/src/Card/models/classic-card.js +3 -3
- package/src/Card/models/control-card.js +3 -3
- package/src/Card/models/image-only.js +3 -3
- package/src/Card/util/card-factory.js +6 -6
- package/src/ContentCards/content-cards-provider-factory.js +11 -11
- package/src/ContentCards/content-cards-provider.js +110 -96
- package/src/ContentCards/get-cached-content-cards.js +2 -2
- package/src/ContentCards/request-content-cards-refresh.js +2 -2
- package/src/ContentCards/subscribe-to-content-cards-updates.js +5 -5
- package/src/ContentCards/ui/show-content-cards.js +5 -5
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +4 -4
- package/src/Core/disable-sdk.js +9 -8
- package/src/Core/enable-sdk.js +5 -5
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/handle-braze-action.js +3 -3
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +13 -13
- package/src/Core/log-purchase.js +10 -10
- package/src/Core/open-session.js +7 -7
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/wipe-data.js +6 -6
- package/src/DUST/dust-connection-core.js +23 -0
- package/src/DUST/dust-provider-factory.js +10 -8
- package/src/DUST/dust-provider.js +408 -176
- package/src/DUST/dust-shared-worker-code.js +2 -0
- package/src/DUST/dust-shared-worker-impl.js +240 -0
- package/src/DUST/dust-worker-bridge.js +136 -0
- package/src/DUST/index.js +10 -0
- package/src/DUST/subscribe-to-dust.js +13 -13
- package/src/FeatureFlags/feature-flag-factory.js +8 -8
- package/src/FeatureFlags/feature-flag.js +6 -6
- package/src/FeatureFlags/feature-flags-provider-factory.js +9 -9
- package/src/FeatureFlags/feature-flags-provider.js +98 -84
- package/src/FeatureFlags/get-all-feature-flags.js +3 -3
- package/src/FeatureFlags/get-feature-flag.js +3 -3
- package/src/FeatureFlags/log-feature-flag-impression.js +7 -7
- package/src/FeatureFlags/refresh-feature-flags.js +2 -2
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -4
- package/src/InAppMessage/constants.js +4 -0
- package/src/InAppMessage/defer-in-app-message.js +2 -2
- package/src/InAppMessage/display/get-animation-effect.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +6 -6
- package/src/InAppMessage/display/in-app-message-to-html.js +40 -40
- package/src/InAppMessage/display/modal-utils.js +16 -16
- package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager-factory.js +7 -7
- package/src/InAppMessage/in-app-message-manager.js +97 -97
- package/src/InAppMessage/log-in-app-message-button-click.js +14 -14
- package/src/InAppMessage/log-in-app-message-click.js +13 -13
- package/src/InAppMessage/log-in-app-message-html-click.js +11 -11
- package/src/InAppMessage/log-in-app-message-impression.js +8 -8
- package/src/InAppMessage/models/control-message.js +5 -5
- package/src/InAppMessage/models/full-screen-message.js +18 -18
- package/src/InAppMessage/models/html-message.js +19 -19
- package/src/InAppMessage/models/in-app-message-button.js +7 -7
- package/src/InAppMessage/models/in-app-message.js +121 -119
- package/src/InAppMessage/models/modal-message.js +18 -18
- package/src/InAppMessage/models/slide-up-message.js +23 -23
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +5 -5
- package/src/InAppMessage/ui/remove-all-visible-in-app-messages.js +8 -8
- package/src/InAppMessage/ui/show-in-app-message.js +34 -34
- package/src/Push/push-manager-factory.js +14 -14
- package/src/Push/push-manager.js +90 -90
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/unregister-push.js +1 -1
- package/src/Push/utils/push-utils.js +9 -9
- package/src/User/user-manager.js +32 -32
- package/src/User/user.js +71 -71
- package/src/common/constants.js +8 -11
- package/src/common/content-cards-display.js +32 -32
- package/src/common/event-logger.js +10 -10
- package/src/common/properties-base.js +16 -16
- package/src/l10n/l10n-manager-factory.js +11 -11
- package/src/l10n/l10n-manager.js +2 -2
- package/src/managers/auth-manager.js +14 -14
- package/src/managers/braze-instance.js +163 -159
- package/src/managers/device-manager.js +11 -11
- package/src/managers/network-manager.js +154 -154
- package/src/managers/server-config-manager.js +116 -88
- package/src/managers/session-manager.js +41 -41
- package/src/managers/storage-manager-factory.js +13 -13
- package/src/managers/storage-manager.js +130 -131
- package/src/managers/subscription-manager.js +12 -12
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +10 -10
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +17 -17
- package/src/models/push-token.js +14 -14
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +41 -37
- package/src/request-controller.js +163 -160
- package/src/triggers/models/custom-event-data.js +5 -5
- package/src/triggers/models/custom-event-property-data.js +6 -6
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +7 -7
- package/src/triggers/models/in-app-message-click-data.js +13 -13
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +6 -6
- package/src/triggers/models/push-click-data.js +6 -6
- package/src/triggers/models/trigger-condition.js +47 -47
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +42 -42
- package/src/triggers/triggers-provider-factory.js +5 -5
- package/src/triggers/triggers-provider.js +66 -66
- 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 +8 -8
- package/src/util/braze-actions.js +5 -5
- package/src/util/browser-detector.js +33 -33
- package/src/util/client-hints-parser.js +10 -10
- package/src/util/component-utils.js +5 -5
- package/src/util/dom-utils.js +13 -13
- package/src/util/html-display-utils.js +7 -7
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +6 -6
- package/src/util/request-header-utils.js +26 -26
- package/src/util/user-agent-parser.js +20 -20
- package/src/util/validation-utils.js +16 -16
- package/src/util/window-utils.js +3 -3
|
@@ -1,85 +1,87 @@
|
|
|
1
|
-
import
|
|
1
|
+
import De from "../models/braze-event.js";
|
|
2
2
|
import _t from "../models/identifier.js";
|
|
3
3
|
import {
|
|
4
|
-
isArray as
|
|
4
|
+
isArray as R,
|
|
5
5
|
keys as C,
|
|
6
6
|
validateValueIsFromEnum as ta,
|
|
7
7
|
values as Pt,
|
|
8
8
|
} from "../util/code-utils.js";
|
|
9
|
-
import { logger as E, EventTypes as
|
|
9
|
+
import { logger as E, EventTypes as f } from "../../shared-lib/index.js";
|
|
10
10
|
import { User } from "../User/index.js";
|
|
11
11
|
import ro from "../util/browser-detector.js";
|
|
12
|
-
import { getErrorMessage as
|
|
12
|
+
import { getErrorMessage as ai } from "../util/error-utils.js";
|
|
13
13
|
export const STORAGE_KEYS = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
Ou: {
|
|
15
|
+
Cu: "ab.storage.userId",
|
|
16
|
+
il: "ab.storage.deviceId",
|
|
17
|
+
um: "ab.storage.sessionId",
|
|
18
18
|
},
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
ft: {
|
|
20
|
+
Qc: "ab.test",
|
|
21
21
|
tE: "ab.storage.events",
|
|
22
22
|
eE: "ab.storage.attributes",
|
|
23
23
|
sE: "ab.storage.attributes.anonymous_user",
|
|
24
24
|
ac: "ab.storage.device",
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
Tl: "ab.storage.sdk_metadata",
|
|
26
|
+
kl: "ab.storage.session_id_for_cached_metadata",
|
|
27
|
+
Uu: "ab.storage.pushToken",
|
|
28
28
|
rE: "ab.storage.cardImpressions",
|
|
29
|
-
|
|
29
|
+
jc: "ab.storage.serverConfig",
|
|
30
30
|
oE: "ab.storage.triggers",
|
|
31
31
|
nE: "ab.storage.triggers.ts",
|
|
32
|
-
|
|
32
|
+
dm: "ab.storage.messagingSessionStart",
|
|
33
33
|
Ps: "ab.storage.cc",
|
|
34
34
|
Gs: "ab.storage.ccLastFullSync",
|
|
35
35
|
Hs: "ab.storage.ccLastCardUpdated",
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
lc: "ab.storage.globalRateLimitCurrentTokenCount",
|
|
37
|
+
mc: "ab.storage.dynamicRateLimitCurrentTokenCount",
|
|
38
|
+
Jt: "ab.storage.ccClicks",
|
|
39
|
+
Vt: "ab.storage.ccImpressions",
|
|
40
|
+
Pt: "ab.storage.ccDismissals",
|
|
41
41
|
aE: "ab.storage.lastDisplayedTriggerTimesById",
|
|
42
42
|
iE: "ab.storage.lastDisplayedTriggerTime",
|
|
43
43
|
EE: "ab.storage.triggerFireInstancesById",
|
|
44
44
|
xh: "ab.storage.signature",
|
|
45
|
-
|
|
45
|
+
SE: "ab.storage.brazeSyncRetryCount",
|
|
46
46
|
Qs: "ab.storage.sdkVersion",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
lo: "ab.storage.ff",
|
|
48
|
+
vo: "ab.storage.ffImpressions",
|
|
49
|
+
Do: "ab.storage.ffLastRefreshAt",
|
|
50
|
+
Co: "ab.storage.ff.sessionId",
|
|
51
|
+
lE: "ab.storage.lastReqToEndpoint",
|
|
52
52
|
_E: "ab.storage.requestAttempts",
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
Yn: "ab.storage.deferredIam",
|
|
54
|
+
Ql: "ab.storage.lastSdkReq",
|
|
55
55
|
uE: "ab.storage.alias",
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
vt: "ab.storage.banners",
|
|
57
|
+
Dt: "ab.storage.banners.impressions",
|
|
58
|
+
Bt: "ab.storage.banners.sessionId",
|
|
59
|
+
Ne: "ab.storage.dust.mite",
|
|
60
|
+
Te: "ab.storage.dust.host",
|
|
61
|
+
ze: "ab.storage.dust.auth",
|
|
62
|
+
Ae: "ab.storage.dust.expiration",
|
|
61
63
|
},
|
|
62
|
-
|
|
64
|
+
be: "ab.optOut",
|
|
63
65
|
};
|
|
64
66
|
export default class ee {
|
|
65
67
|
constructor(t, e) {
|
|
66
|
-
(this.
|
|
68
|
+
(this.TE = t), (this.cE = e), (this.TE = t), (this.cE = e);
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
const e = C(STORAGE_KEYS.
|
|
70
|
-
s = new ee.
|
|
71
|
-
for (const t of e) s.remove(STORAGE_KEYS.
|
|
70
|
+
Al(t) {
|
|
71
|
+
const e = C(STORAGE_KEYS.Ou),
|
|
72
|
+
s = new ee.me(t);
|
|
73
|
+
for (const t of e) s.remove(STORAGE_KEYS.Ou[t]);
|
|
72
74
|
}
|
|
73
|
-
|
|
75
|
+
Iu(t, e) {
|
|
74
76
|
let s = null;
|
|
75
|
-
null != e && e instanceof _t && (s = e.
|
|
77
|
+
null != e && e instanceof _t && (s = e.gt()), this.TE.store(t, s);
|
|
76
78
|
}
|
|
77
79
|
hE(t) {
|
|
78
|
-
const e = this
|
|
79
|
-
null != e && ((e.
|
|
80
|
+
const e = this.$u(t);
|
|
81
|
+
null != e && ((e.gm = new Date().valueOf()), this.Iu(t, e));
|
|
80
82
|
}
|
|
81
|
-
|
|
82
|
-
const e = this.
|
|
83
|
+
$u(t) {
|
|
84
|
+
const e = this.TE.jr(t),
|
|
83
85
|
s = ((t) => {
|
|
84
86
|
let e;
|
|
85
87
|
try {
|
|
@@ -90,44 +92,44 @@ export default class ee {
|
|
|
90
92
|
return e;
|
|
91
93
|
})(e);
|
|
92
94
|
let r;
|
|
93
|
-
if (s) (r = _t.
|
|
95
|
+
if (s) (r = _t._u(s) || null), r && this.Iu(t, r);
|
|
94
96
|
else {
|
|
95
97
|
const s = _t.AE(e);
|
|
96
|
-
(r = _t.
|
|
98
|
+
(r = _t._u(s) || null), s !== e && r && this.Iu(t, r);
|
|
97
99
|
}
|
|
98
100
|
return r;
|
|
99
101
|
}
|
|
100
|
-
|
|
101
|
-
this.
|
|
102
|
+
xm(t) {
|
|
103
|
+
this.TE.remove(t);
|
|
102
104
|
}
|
|
103
|
-
|
|
104
|
-
const t = C(STORAGE_KEYS.
|
|
105
|
+
Nl() {
|
|
106
|
+
const t = C(STORAGE_KEYS.Ou);
|
|
105
107
|
let e;
|
|
106
108
|
for (const s of t)
|
|
107
|
-
(e = this
|
|
108
|
-
null != e && this.
|
|
109
|
+
(e = this.$u(STORAGE_KEYS.Ou[s])),
|
|
110
|
+
null != e && this.Iu(STORAGE_KEYS.Ou[s], e);
|
|
109
111
|
}
|
|
110
|
-
|
|
112
|
+
ol(t) {
|
|
111
113
|
let e;
|
|
112
114
|
if (null == t || 0 === t.length) return !1;
|
|
113
|
-
e =
|
|
114
|
-
let s = this.
|
|
115
|
-
(null != s &&
|
|
116
|
-
for (let t = 0; t < e.length; t++) s.push(e[t].
|
|
117
|
-
return this.
|
|
115
|
+
e = R(t) ? t : [t];
|
|
116
|
+
let s = this.cE.jr(STORAGE_KEYS.ft.tE);
|
|
117
|
+
(null != s && R(s)) || (s = []);
|
|
118
|
+
for (let t = 0; t < e.length; t++) s.push(e[t].gt());
|
|
119
|
+
return this.cE.store(STORAGE_KEYS.ft.tE, s);
|
|
118
120
|
}
|
|
119
|
-
|
|
120
|
-
return null != t && this.
|
|
121
|
+
wm(t) {
|
|
122
|
+
return null != t && this.ol([t]);
|
|
121
123
|
}
|
|
122
124
|
RE() {
|
|
123
|
-
let t = this.
|
|
124
|
-
this.
|
|
125
|
+
let t = this.cE.jr(STORAGE_KEYS.ft.tE);
|
|
126
|
+
this.cE.remove(STORAGE_KEYS.ft.tE), null == t && (t = []);
|
|
125
127
|
const e = [];
|
|
126
128
|
let s = !1,
|
|
127
129
|
r = null;
|
|
128
|
-
if (
|
|
130
|
+
if (R(t))
|
|
129
131
|
for (let s = 0; s < t.length; s++)
|
|
130
|
-
|
|
132
|
+
De.gE(t[s]) ? e.push(De._u(t[s])) : (r = s);
|
|
131
133
|
else s = !0;
|
|
132
134
|
if (s || null != r) {
|
|
133
135
|
let o = "Stored events could not be deserialized as Events";
|
|
@@ -140,123 +142,123 @@ export default class ee {
|
|
|
140
142
|
typeof t +
|
|
141
143
|
": " +
|
|
142
144
|
JSON.stringify(t)),
|
|
143
|
-
e.push(new
|
|
145
|
+
e.push(new De(null, f.Cl, new Date().valueOf(), null, { e: o }));
|
|
144
146
|
}
|
|
145
147
|
return e;
|
|
146
148
|
}
|
|
147
|
-
|
|
149
|
+
bt(t, e) {
|
|
148
150
|
return (
|
|
149
151
|
!!ta(
|
|
150
|
-
STORAGE_KEYS.
|
|
152
|
+
STORAGE_KEYS.ft,
|
|
151
153
|
t,
|
|
152
154
|
"StorageManager cannot store object.",
|
|
153
155
|
"STORAGE_KEYS.OBJECTS",
|
|
154
|
-
) && this.
|
|
156
|
+
) && this.cE.store(t, e)
|
|
155
157
|
);
|
|
156
158
|
}
|
|
157
|
-
|
|
159
|
+
dt(t) {
|
|
158
160
|
return (
|
|
159
161
|
!!ta(
|
|
160
|
-
STORAGE_KEYS.
|
|
162
|
+
STORAGE_KEYS.ft,
|
|
161
163
|
t,
|
|
162
164
|
"StorageManager cannot retrieve object.",
|
|
163
165
|
"STORAGE_KEYS.OBJECTS",
|
|
164
|
-
) && this.
|
|
166
|
+
) && this.cE.jr(t)
|
|
165
167
|
);
|
|
166
168
|
}
|
|
167
|
-
|
|
169
|
+
zt(t) {
|
|
168
170
|
return (
|
|
169
171
|
!!ta(
|
|
170
|
-
STORAGE_KEYS.
|
|
172
|
+
STORAGE_KEYS.ft,
|
|
171
173
|
t,
|
|
172
174
|
"StorageManager cannot remove object.",
|
|
173
175
|
"STORAGE_KEYS.OBJECTS",
|
|
174
|
-
) && (this.
|
|
176
|
+
) && (this.cE.remove(t), !0)
|
|
175
177
|
);
|
|
176
178
|
}
|
|
177
179
|
clearData() {
|
|
178
|
-
const t = C(STORAGE_KEYS.
|
|
179
|
-
e = C(STORAGE_KEYS.
|
|
180
|
+
const t = C(STORAGE_KEYS.Ou),
|
|
181
|
+
e = C(STORAGE_KEYS.ft);
|
|
180
182
|
for (let e = 0; e < t.length; e++) {
|
|
181
183
|
const s = t[e];
|
|
182
|
-
this.
|
|
184
|
+
this.TE.remove(STORAGE_KEYS.Ou[s]);
|
|
183
185
|
}
|
|
184
186
|
for (let t = 0; t < e.length; t++) {
|
|
185
187
|
const s = e[t];
|
|
186
|
-
this.
|
|
188
|
+
this.cE.remove(STORAGE_KEYS.ft[s]);
|
|
187
189
|
}
|
|
188
190
|
}
|
|
189
191
|
OE(t) {
|
|
190
|
-
return t || STORAGE_KEYS.
|
|
192
|
+
return t || STORAGE_KEYS.ft.sE;
|
|
191
193
|
}
|
|
192
|
-
|
|
193
|
-
let e = this.
|
|
194
|
+
Ll(t) {
|
|
195
|
+
let e = this.cE.jr(STORAGE_KEYS.ft.eE);
|
|
194
196
|
null == e && (e = {});
|
|
195
|
-
const s = this.OE(t[User.
|
|
197
|
+
const s = this.OE(t[User.Wa]),
|
|
196
198
|
r = e[s];
|
|
197
199
|
for (const o in t)
|
|
198
|
-
o !== User.
|
|
200
|
+
o !== User.Wa &&
|
|
199
201
|
(null == e[s] || (r && null == r[o])) &&
|
|
200
|
-
this.
|
|
202
|
+
this.Eu(t[User.Wa], o, t[o]);
|
|
201
203
|
}
|
|
202
|
-
|
|
203
|
-
let r = this.
|
|
204
|
+
Eu(t, e, s) {
|
|
205
|
+
let r = this.cE.jr(STORAGE_KEYS.ft.eE);
|
|
204
206
|
null == r && (r = {});
|
|
205
207
|
const o = this.OE(t);
|
|
206
208
|
let n = r[o];
|
|
207
209
|
if (
|
|
208
|
-
(null == n && ((n = {}), null != t && (n[User.
|
|
210
|
+
(null == n && ((n = {}), null != t && (n[User.Wa] = t)), e === User.Bu)
|
|
209
211
|
) {
|
|
210
212
|
null == n[e] && (n[e] = {});
|
|
211
213
|
for (const t in s) n[e][t] = s[t];
|
|
212
214
|
} else n[e] = s;
|
|
213
|
-
return (r[o] = n), this.
|
|
215
|
+
return (r[o] = n), this.cE.store(STORAGE_KEYS.ft.eE, r);
|
|
214
216
|
}
|
|
215
217
|
IE() {
|
|
216
|
-
const t = this.
|
|
217
|
-
this.
|
|
218
|
+
const t = this.cE.jr(STORAGE_KEYS.ft.eE);
|
|
219
|
+
this.cE.remove(STORAGE_KEYS.ft.eE);
|
|
218
220
|
const e = [];
|
|
219
221
|
for (const s in t) null != t[s] && e.push(t[s]);
|
|
220
222
|
return e;
|
|
221
223
|
}
|
|
222
|
-
|
|
223
|
-
const e = this.
|
|
224
|
+
Lu(t) {
|
|
225
|
+
const e = this.cE.jr(STORAGE_KEYS.ft.eE);
|
|
224
226
|
if (null != e) {
|
|
225
227
|
const s = this.OE(null),
|
|
226
228
|
r = e[s];
|
|
227
229
|
null != r &&
|
|
228
230
|
((e[s] = void 0),
|
|
229
|
-
this.
|
|
230
|
-
(r[User.
|
|
231
|
-
this.
|
|
231
|
+
this.cE.store(STORAGE_KEYS.ft.eE, e),
|
|
232
|
+
(r[User.Wa] = t),
|
|
233
|
+
this.Ll(r));
|
|
232
234
|
}
|
|
233
|
-
const s = this
|
|
235
|
+
const s = this.$u(STORAGE_KEYS.Ou.um);
|
|
234
236
|
let r = null;
|
|
235
|
-
null != s && (r = s.
|
|
237
|
+
null != s && (r = s.Tu);
|
|
236
238
|
const o = this.RE();
|
|
237
239
|
if (null != o)
|
|
238
240
|
for (let e = 0; e < o.length; e++) {
|
|
239
241
|
const s = o[e];
|
|
240
|
-
null == s.userId && s.sessionId == r && (s.userId = t), this
|
|
242
|
+
null == s.userId && s.sessionId == r && (s.userId = t), this.wm(s);
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
245
|
dE() {
|
|
244
|
-
return this.
|
|
246
|
+
return this.cE.bE;
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
|
-
(ee.
|
|
249
|
+
(ee.Xc = class {
|
|
248
250
|
constructor(t) {
|
|
249
|
-
(this.
|
|
251
|
+
(this.tu = t), (this.tu = t), (this.bE = ro.fE() ? 3 : 10);
|
|
250
252
|
}
|
|
251
253
|
mE(t) {
|
|
252
|
-
return t + "." + this.
|
|
254
|
+
return t + "." + this.tu;
|
|
253
255
|
}
|
|
254
256
|
store(t, e) {
|
|
255
257
|
const s = { v: e };
|
|
256
258
|
try {
|
|
257
259
|
return localStorage.setItem(this.mE(t), JSON.stringify(s)), !0;
|
|
258
260
|
} catch (t) {
|
|
259
|
-
return E.info("Storage failure: " +
|
|
261
|
+
return E.info("Storage failure: " + ai(t)), !1;
|
|
260
262
|
}
|
|
261
263
|
}
|
|
262
264
|
jr(t) {
|
|
@@ -265,18 +267,18 @@ export default class ee {
|
|
|
265
267
|
const s = localStorage.getItem(this.mE(t));
|
|
266
268
|
return null != s && (e = JSON.parse(s)), null == e ? null : e.v;
|
|
267
269
|
} catch (t) {
|
|
268
|
-
return E.info("Storage retrieval failure: " +
|
|
270
|
+
return E.info("Storage retrieval failure: " + ai(t)), null;
|
|
269
271
|
}
|
|
270
272
|
}
|
|
271
273
|
remove(t) {
|
|
272
274
|
try {
|
|
273
275
|
localStorage.removeItem(this.mE(t));
|
|
274
276
|
} catch (t) {
|
|
275
|
-
return E.info("Storage removal failure: " +
|
|
277
|
+
return E.info("Storage removal failure: " + ai(t)), !1;
|
|
276
278
|
}
|
|
277
279
|
}
|
|
278
280
|
}),
|
|
279
|
-
(ee.
|
|
281
|
+
(ee.Yc = class {
|
|
280
282
|
constructor() {
|
|
281
283
|
(this.KE = {}), (this.YE = 5242880), (this.bE = 3);
|
|
282
284
|
}
|
|
@@ -318,17 +320,14 @@ export default class ee {
|
|
|
318
320
|
this.KE[t] = null;
|
|
319
321
|
}
|
|
320
322
|
}),
|
|
321
|
-
(ee.
|
|
322
|
-
constructor(t, e) {
|
|
323
|
-
(this.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
(this.DE = this.CE()),
|
|
327
|
-
(this.ME = 576e3),
|
|
328
|
-
(this.GE = !!e);
|
|
323
|
+
(ee.me = class {
|
|
324
|
+
constructor(t, e, s) {
|
|
325
|
+
(this.tu = t), (this.DE = e), (this.tu = t), (this.GE = this.CE());
|
|
326
|
+
const r = "number" == typeof s && s > 0 ? s : 400;
|
|
327
|
+
(this.ME = 24 * r * 60), (this.DE = !!e);
|
|
329
328
|
}
|
|
330
329
|
mE(t) {
|
|
331
|
-
return null != this.
|
|
330
|
+
return null != this.tu ? t + "." + this.tu : t;
|
|
332
331
|
}
|
|
333
332
|
CE() {
|
|
334
333
|
let t = 0,
|
|
@@ -345,12 +344,12 @@ export default class ee {
|
|
|
345
344
|
e
|
|
346
345
|
);
|
|
347
346
|
}
|
|
348
|
-
|
|
347
|
+
pe() {
|
|
349
348
|
const t = new Date();
|
|
350
349
|
return t.setTime(t.getTime() + 60 * this.ME * 1e3), t.getFullYear();
|
|
351
350
|
}
|
|
352
351
|
pE() {
|
|
353
|
-
const t = Pt(STORAGE_KEYS.
|
|
352
|
+
const t = Pt(STORAGE_KEYS.Ou),
|
|
354
353
|
e = document.cookie.split(";");
|
|
355
354
|
for (let s = 0; s < e.length; s++) {
|
|
356
355
|
let r = e[s];
|
|
@@ -363,7 +362,7 @@ export default class ee {
|
|
|
363
362
|
}
|
|
364
363
|
if (o) {
|
|
365
364
|
const t = r.split("=")[0];
|
|
366
|
-
-1 === t.indexOf("." + this.
|
|
365
|
+
-1 === t.indexOf("." + this.tu) && this.vE(t);
|
|
367
366
|
}
|
|
368
367
|
}
|
|
369
368
|
}
|
|
@@ -372,9 +371,9 @@ export default class ee {
|
|
|
372
371
|
const s = new Date();
|
|
373
372
|
s.setTime(s.getTime() + 60 * this.ME * 1e3);
|
|
374
373
|
const r = "expires=" + s.toUTCString(),
|
|
375
|
-
o = "domain=" + this.
|
|
374
|
+
o = "domain=" + this.GE;
|
|
376
375
|
let n;
|
|
377
|
-
n = this.
|
|
376
|
+
n = this.DE ? e : encodeURIComponent(e);
|
|
378
377
|
const a = this.mE(t) + "=" + n + ";" + r + ";" + o + ";path=/";
|
|
379
378
|
return a.length >= 4093
|
|
380
379
|
? (E.info(
|
|
@@ -395,13 +394,13 @@ export default class ee {
|
|
|
395
394
|
if (0 === n.indexOf(s))
|
|
396
395
|
try {
|
|
397
396
|
let t;
|
|
398
|
-
(t = this.
|
|
397
|
+
(t = this.DE
|
|
399
398
|
? n.substring(s.length, n.length)
|
|
400
399
|
: decodeURIComponent(n.substring(s.length, n.length))),
|
|
401
400
|
e.push(t);
|
|
402
401
|
} catch (e) {
|
|
403
402
|
return (
|
|
404
|
-
E.info("Storage retrieval failure: " +
|
|
403
|
+
E.info("Storage retrieval failure: " + ai(e)),
|
|
405
404
|
this.remove(t),
|
|
406
405
|
null
|
|
407
406
|
);
|
|
@@ -415,17 +414,17 @@ export default class ee {
|
|
|
415
414
|
vE(t) {
|
|
416
415
|
const e = t + "=;expires=" + new Date(0).toUTCString();
|
|
417
416
|
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
418
|
-
const s = e + ";domain=" + this.
|
|
417
|
+
const s = e + ";domain=" + this.GE;
|
|
419
418
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
420
419
|
}
|
|
421
420
|
}),
|
|
422
|
-
(ee.
|
|
423
|
-
constructor(t, e, s) {
|
|
424
|
-
(this.
|
|
421
|
+
(ee.Wc = class {
|
|
422
|
+
constructor(t, e, s, r) {
|
|
423
|
+
(this.tu = t),
|
|
425
424
|
(this.UE = []),
|
|
426
|
-
e && this.UE.push(new ee.
|
|
427
|
-
s && this.UE.push(new ee.
|
|
428
|
-
this.UE.push(new ee.
|
|
425
|
+
e && this.UE.push(new ee.me(t, void 0, r)),
|
|
426
|
+
s && this.UE.push(new ee.Xc(t)),
|
|
427
|
+
this.UE.push(new ee.Yc());
|
|
429
428
|
}
|
|
430
429
|
store(t, e) {
|
|
431
430
|
let s = !0;
|
|
@@ -440,7 +439,7 @@ export default class ee {
|
|
|
440
439
|
return null;
|
|
441
440
|
}
|
|
442
441
|
remove(t) {
|
|
443
|
-
new ee.
|
|
442
|
+
new ee.me(this.tu).remove(t);
|
|
444
443
|
for (let e = 0; e < this.UE.length; e++) this.UE[e].remove(t);
|
|
445
444
|
}
|
|
446
445
|
});
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Guid as
|
|
2
|
-
export default class
|
|
1
|
+
import { Guid as P } from "../../shared-lib/index.js";
|
|
2
|
+
export default class m {
|
|
3
3
|
constructor() {
|
|
4
|
-
this.
|
|
4
|
+
this.vn = {};
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
Rt(t) {
|
|
7
7
|
if ("function" != typeof t) return null;
|
|
8
|
-
const i =
|
|
9
|
-
return (this.
|
|
8
|
+
const i = P.se();
|
|
9
|
+
return (this.vn[i] = t), i;
|
|
10
10
|
}
|
|
11
11
|
removeSubscription(t) {
|
|
12
|
-
delete this.
|
|
12
|
+
delete this.vn[t];
|
|
13
13
|
}
|
|
14
14
|
removeAllSubscriptions() {
|
|
15
|
-
this.
|
|
15
|
+
this.vn = {};
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
return Object.keys(this.
|
|
17
|
+
We() {
|
|
18
|
+
return Object.keys(this.vn).length;
|
|
19
19
|
}
|
|
20
20
|
L(t) {
|
|
21
21
|
const i = [];
|
|
22
|
-
for (const s in this.
|
|
23
|
-
const r = this.
|
|
22
|
+
for (const s in this.vn) {
|
|
23
|
+
const r = this.vn[s];
|
|
24
24
|
i.push(r(t));
|
|
25
25
|
}
|
|
26
26
|
return i;
|
package/src/managers/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
zl: "invalid_api_key",
|
|
3
|
+
jl: "blacklisted",
|
|
4
|
+
Ml: "no_device_identifier",
|
|
5
|
+
Bl: "invalid_json_response",
|
|
6
|
+
wl: "empty_response",
|
|
7
7
|
__: "sdk_auth_error",
|
|
8
8
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import { getAlias as
|
|
2
|
+
import { getAlias as qe } from "../managers/utils.js";
|
|
3
3
|
import { isObject as yt } from "../util/code-utils.js";
|
|
4
4
|
import {
|
|
5
|
-
convertMsToSeconds as
|
|
5
|
+
convertMsToSeconds as X,
|
|
6
6
|
timestampOrNow as ts,
|
|
7
7
|
} from "../util/date-utils.js";
|
|
8
|
-
export default class
|
|
8
|
+
export default class De {
|
|
9
9
|
constructor(t, s, i, r, e) {
|
|
10
10
|
(this.userId = t),
|
|
11
11
|
(this.type = s),
|
|
@@ -18,23 +18,23 @@ export default class ue {
|
|
|
18
18
|
(this.sessionId = r),
|
|
19
19
|
(this.data = e);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
Jn() {
|
|
22
22
|
var t;
|
|
23
23
|
const s = {
|
|
24
24
|
name: this.type,
|
|
25
|
-
time:
|
|
25
|
+
time: X(this.time),
|
|
26
26
|
data: this.data || {},
|
|
27
27
|
session_id: this.sessionId,
|
|
28
28
|
};
|
|
29
29
|
null != this.userId && (s.user_id = this.userId);
|
|
30
30
|
const i = (null === (t = r.Sr()) || void 0 === t ? void 0 : t.wh()) || !1;
|
|
31
31
|
if (!s.user_id && !i) {
|
|
32
|
-
const t =
|
|
32
|
+
const t = qe(r.p());
|
|
33
33
|
t && (s.alias = t);
|
|
34
34
|
}
|
|
35
35
|
return s;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
gt() {
|
|
38
38
|
return {
|
|
39
39
|
u: this.userId,
|
|
40
40
|
t: this.type,
|
|
@@ -44,12 +44,12 @@ export default class ue {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
static fromJson(t) {
|
|
47
|
-
return new
|
|
47
|
+
return new De(t.user_id, t.name, t.time, t.session_id, t.data);
|
|
48
48
|
}
|
|
49
49
|
static gE(t) {
|
|
50
50
|
return null != t && yt(t) && null != t.t && "" !== t.t;
|
|
51
51
|
}
|
|
52
|
-
static
|
|
53
|
-
return new
|
|
52
|
+
static _u(t) {
|
|
53
|
+
return new De(t.u, t.t, t.ts, t.s, t.d);
|
|
54
54
|
}
|
|
55
55
|
}
|