@braze/web-sdk 5.9.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +109 -253
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +24 -26
- package/shared-lib/guid.js +2 -2
- package/shared-lib/indexed-db-adapter.js +19 -19
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +21 -22
- package/src/Banner/display/banner-to-html.js +13 -25
- package/src/Banner/display/destroy-banner-html.js +2 -2
- package/src/Banner/display/detect-banner-impressions.js +11 -11
- package/src/Banner/index.js +0 -1
- package/src/Banner/request-banners-refresh.js +8 -8
- package/src/Banner/subscribe-to-banners-updates.js +2 -2
- package/src/Banner/ui/insert-banner.js +7 -7
- package/src/Card/card-manager.js +35 -37
- package/src/Card/display/card-display.js +76 -74
- package/src/Card/index.js +0 -2
- package/src/Card/log-card-dismissal.js +2 -2
- package/src/Card/log-content-card-click.js +9 -2
- package/src/Card/log-content-card-impressions.js +11 -2
- package/src/Card/models/captioned-image.js +20 -20
- package/src/Card/models/card.js +110 -104
- package/src/Card/models/classic-card.js +20 -20
- package/src/Card/models/control-card.js +14 -14
- package/src/Card/models/image-only.js +19 -20
- package/src/Card/util/card-factory.js +57 -78
- package/src/ContentCards/content-cards-provider-factory.js +10 -10
- package/src/ContentCards/content-cards-provider.js +109 -109
- package/src/ContentCards/content-cards.js +21 -13
- 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/hide-content-cards.js +5 -5
- package/src/ContentCards/ui/show-content-cards.js +34 -34
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +7 -7
- package/src/Core/disable-sdk.js +6 -6
- package/src/Core/enable-sdk.js +5 -5
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +7 -7
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/is-initialized.js +1 -1
- package/src/Core/log-custom-event.js +9 -9
- package/src/Core/log-purchase.js +7 -7
- package/src/Core/open-session.js +12 -12
- package/src/Core/request-immediate-data-flush.js +1 -1
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/wipe-data.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +7 -7
- 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 +1 -1
- package/src/FeatureFlags/get-all-feature-flags.js +2 -2
- package/src/FeatureFlags/get-feature-flag.js +2 -2
- package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
- package/src/FeatureFlags/refresh-feature-flags.js +2 -2
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +37 -37
- package/src/InAppMessage/display/in-app-message-to-html.js +139 -133
- package/src/InAppMessage/display/modal-utils.js +39 -41
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +22 -14
- package/src/InAppMessage/in-app-message-manager.js +90 -88
- package/src/InAppMessage/log-in-app-message-button-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-html-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/control-message.js +2 -2
- package/src/InAppMessage/models/full-screen-message.js +40 -34
- package/src/InAppMessage/models/html-message.js +23 -21
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +137 -133
- package/src/InAppMessage/models/modal-message.js +39 -33
- package/src/InAppMessage/models/slide-up-message.js +36 -30
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +56 -62
- package/src/Push/is-push-blocked.js +2 -2
- package/src/Push/is-push-permission-granted.js +2 -2
- package/src/Push/is-push-supported.js +2 -2
- package/src/Push/push-manager-factory.js +8 -8
- package/src/Push/push-manager.js +90 -90
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/utils/push-utils.js +25 -15
- package/src/User/user-manager.js +14 -14
- package/src/User/user.js +55 -55
- package/src/common/content-cards-display.js +211 -0
- package/src/common/event-logger.js +6 -6
- package/src/index.js +0 -1
- package/src/l10n/l10n-manager-factory.js +9 -9
- package/src/l10n/l10n-manager.js +6 -6
- package/src/managers/auth-manager.js +27 -27
- package/src/managers/braze-instance.js +136 -137
- package/src/managers/device-manager.js +22 -22
- package/src/managers/network-manager.js +180 -183
- package/src/managers/server-config-manager.js +63 -63
- package/src/managers/session-manager.js +34 -34
- package/src/managers/storage-manager-factory.js +11 -11
- package/src/managers/storage-manager.js +139 -141
- package/src/managers/subscription-manager.js +3 -3
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +15 -15
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +13 -13
- package/src/models/push-token.js +12 -12
- package/src/models/request-result.js +2 -2
- package/src/models/server-config.js +29 -29
- package/src/request-controller.js +181 -169
- package/src/triggers/models/custom-event-data.js +6 -6
- package/src/triggers/models/custom-event-property-data.js +7 -7
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +45 -45
- package/src/triggers/models/in-app-message-click-data.js +3 -3
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +47 -47
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +15 -15
- package/src/triggers/triggers-provider-factory.js +4 -4
- package/src/triggers/triggers-provider.js +44 -44
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/banner-css.js +1 -1
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +4 -4
- package/src/util/braze-actions.js +8 -14
- package/src/util/browser-detector.js +12 -12
- package/src/util/client-hints-parser.js +3 -3
- package/src/util/component-utils.js +14 -14
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +6 -6
- package/src/util/html-display-utils.js +37 -37
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +17 -17
- package/src/util/user-agent-parser.js +4 -4
- package/src/util/validation-utils.js +20 -20
- package/src/util/window-utils.js +1 -1
- package/src/Card/log-card-click.js +0 -11
- package/src/Card/log-card-impressions.js +0 -13
- package/src/Feed/feed-provider-factory.js +0 -18
- package/src/Feed/feed-provider.js +0 -90
- package/src/Feed/feed.js +0 -20
- package/src/Feed/get-cached-feed.js +0 -5
- package/src/Feed/index.js +0 -8
- package/src/Feed/log-feed-displayed.js +0 -7
- package/src/Feed/request-feed-refresh.js +0 -5
- package/src/Feed/subscribe-to-feed-updates.js +0 -5
- package/src/Feed/types.js +0 -1
- package/src/Feed/ui/hide-feed.js +0 -7
- package/src/Feed/ui/show-feed.js +0 -96
- package/src/Feed/ui/toggle-feed.js +0 -8
- package/src/common/base-feed.js +0 -29
- package/src/common/feed-display.js +0 -211
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ue from "../models/braze-event.js";
|
|
2
2
|
import _t from "../models/identifier.js";
|
|
3
3
|
import {
|
|
4
|
-
isArray as
|
|
4
|
+
isArray as D,
|
|
5
5
|
keys as C,
|
|
6
6
|
validateValueIsFromEnum as ta,
|
|
7
|
-
values as
|
|
7
|
+
values as Pt,
|
|
8
8
|
} from "../util/code-utils.js";
|
|
9
9
|
import { logger as N, EventTypes as d } from "../../shared-lib/index.js";
|
|
10
10
|
import { User } from "../User/index.js";
|
|
@@ -13,73 +13,71 @@ import { getErrorMessage as si } from "../util/error-utils.js";
|
|
|
13
13
|
export const STORAGE_KEYS = {
|
|
14
14
|
iu: {
|
|
15
15
|
su: "ab.storage.userId",
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
Qh: "ab.storage.deviceId",
|
|
17
|
+
Nu: "ab.storage.sessionId",
|
|
18
18
|
},
|
|
19
19
|
gt: {
|
|
20
|
-
|
|
20
|
+
ec: "ab.test",
|
|
21
21
|
tE: "ab.storage.events",
|
|
22
22
|
eE: "ab.storage.attributes",
|
|
23
23
|
sE: "ab.storage.attributes.anonymous_user",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Hu: "ab.storage.globalRateLimitCurrentTokenCount",
|
|
39
|
-
_u: "ab.storage.dynamicRateLimitCurrentTokenCount",
|
|
24
|
+
Za: "ab.storage.device",
|
|
25
|
+
rl: "ab.storage.sdk_metadata",
|
|
26
|
+
ol: "ab.storage.session_id_for_cached_metadata",
|
|
27
|
+
Vn: "ab.storage.pushToken",
|
|
28
|
+
rE: "ab.storage.cardImpressions",
|
|
29
|
+
gu: "ab.storage.serverConfig",
|
|
30
|
+
oE: "ab.storage.triggers",
|
|
31
|
+
nE: "ab.storage.triggers.ts",
|
|
32
|
+
Hu: "ab.storage.messagingSessionStart",
|
|
33
|
+
Xs: "ab.storage.cc",
|
|
34
|
+
Hs: "ab.storage.ccLastFullSync",
|
|
35
|
+
Is: "ab.storage.ccLastCardUpdated",
|
|
36
|
+
Ll: "ab.storage.globalRateLimitCurrentTokenCount",
|
|
37
|
+
Kl: "ab.storage.dynamicRateLimitCurrentTokenCount",
|
|
40
38
|
Kt: "ab.storage.ccClicks",
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
Xt: "ab.storage.ccImpressions",
|
|
40
|
+
Qt: "ab.storage.ccDismissals",
|
|
41
|
+
aE: "ab.storage.lastDisplayedTriggerTimesById",
|
|
42
|
+
iE: "ab.storage.lastDisplayedTriggerTime",
|
|
43
|
+
EE: "ab.storage.triggerFireInstancesById",
|
|
44
|
+
xh: "ab.storage.signature",
|
|
45
|
+
lE: "ab.storage.brazeSyncRetryCount",
|
|
46
|
+
Vs: "ab.storage.sdkVersion",
|
|
49
47
|
Xe: "ab.storage.ff",
|
|
50
48
|
Ge: "ab.storage.ffImpressions",
|
|
51
49
|
Ze: "ab.storage.ffLastRefreshAt",
|
|
52
50
|
Ve: "ab.storage.ff.sessionId",
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
SE: "ab.storage.lastReqToEndpoint",
|
|
52
|
+
_E: "ab.storage.requestAttempts",
|
|
53
|
+
Fr: "ab.storage.deferredIam",
|
|
54
|
+
zl: "ab.storage.lastSdkReq",
|
|
55
|
+
uE: "ab.storage.alias",
|
|
58
56
|
vt: "ab.storage.banners",
|
|
59
57
|
Nt: "ab.storage.banners.impressions",
|
|
60
58
|
yt: "ab.storage.banners.sessionId",
|
|
61
59
|
},
|
|
62
60
|
me: "ab.optOut",
|
|
63
61
|
};
|
|
64
|
-
export default class
|
|
62
|
+
export default class ee {
|
|
65
63
|
constructor(t, e) {
|
|
66
|
-
(this.
|
|
64
|
+
(this.cE = t), (this.TE = e), (this.cE = t), (this.TE = e);
|
|
67
65
|
}
|
|
68
|
-
|
|
66
|
+
Va(t) {
|
|
69
67
|
const e = C(STORAGE_KEYS.iu),
|
|
70
|
-
s = new
|
|
68
|
+
s = new ee.se(t);
|
|
71
69
|
for (const t of e) s.remove(STORAGE_KEYS.iu[t]);
|
|
72
70
|
}
|
|
73
71
|
uu(t, e) {
|
|
74
72
|
let s = null;
|
|
75
|
-
null != e && e instanceof _t && (s = e.bt()), this.
|
|
73
|
+
null != e && e instanceof _t && (s = e.bt()), this.cE.store(t, s);
|
|
76
74
|
}
|
|
77
|
-
|
|
75
|
+
hE(t) {
|
|
78
76
|
const e = this.tu(t);
|
|
79
|
-
null != e && ((e.
|
|
77
|
+
null != e && ((e.qu = new Date().valueOf()), this.uu(t, e));
|
|
80
78
|
}
|
|
81
79
|
tu(t) {
|
|
82
|
-
const e = this.
|
|
80
|
+
const e = this.cE.pr(t),
|
|
83
81
|
s = ((t) => {
|
|
84
82
|
let e;
|
|
85
83
|
try {
|
|
@@ -90,44 +88,44 @@ export default class ne {
|
|
|
90
88
|
return e;
|
|
91
89
|
})(e);
|
|
92
90
|
let r;
|
|
93
|
-
if (s) (r = _t.
|
|
91
|
+
if (s) (r = _t.zn(s) || null), r && this.uu(t, r);
|
|
94
92
|
else {
|
|
95
|
-
const s = _t.
|
|
96
|
-
(r = _t.
|
|
93
|
+
const s = _t.AE(e);
|
|
94
|
+
(r = _t.zn(s) || null), s !== e && r && this.uu(t, r);
|
|
97
95
|
}
|
|
98
96
|
return r;
|
|
99
97
|
}
|
|
100
|
-
|
|
101
|
-
this.
|
|
98
|
+
Ku(t) {
|
|
99
|
+
this.cE.remove(t);
|
|
102
100
|
}
|
|
103
|
-
|
|
101
|
+
Fa() {
|
|
104
102
|
const t = C(STORAGE_KEYS.iu);
|
|
105
103
|
let e;
|
|
106
104
|
for (const s of t)
|
|
107
105
|
(e = this.tu(STORAGE_KEYS.iu[s])),
|
|
108
106
|
null != e && this.uu(STORAGE_KEYS.iu[s], e);
|
|
109
107
|
}
|
|
110
|
-
|
|
108
|
+
Wo(t) {
|
|
111
109
|
let e;
|
|
112
110
|
if (null == t || 0 === t.length) return !1;
|
|
113
|
-
e =
|
|
114
|
-
let s = this.
|
|
115
|
-
(null != s &&
|
|
111
|
+
e = D(t) ? t : [t];
|
|
112
|
+
let s = this.TE.pr(STORAGE_KEYS.gt.tE);
|
|
113
|
+
(null != s && D(s)) || (s = []);
|
|
116
114
|
for (let t = 0; t < e.length; t++) s.push(e[t].bt());
|
|
117
|
-
return this.
|
|
115
|
+
return this.TE.store(STORAGE_KEYS.gt.tE, s);
|
|
118
116
|
}
|
|
119
|
-
|
|
120
|
-
return null != t && this.
|
|
117
|
+
Au(t) {
|
|
118
|
+
return null != t && this.Wo([t]);
|
|
121
119
|
}
|
|
122
|
-
|
|
123
|
-
let t = this.
|
|
124
|
-
this.
|
|
120
|
+
RE() {
|
|
121
|
+
let t = this.TE.pr(STORAGE_KEYS.gt.tE);
|
|
122
|
+
this.TE.remove(STORAGE_KEYS.gt.tE), null == t && (t = []);
|
|
125
123
|
const e = [];
|
|
126
124
|
let s = !1,
|
|
127
125
|
r = null;
|
|
128
|
-
if (
|
|
126
|
+
if (D(t))
|
|
129
127
|
for (let s = 0; s < t.length; s++)
|
|
130
|
-
|
|
128
|
+
ue.gE(t[s]) ? e.push(ue.zn(t[s])) : (r = s);
|
|
131
129
|
else s = !0;
|
|
132
130
|
if (s || null != r) {
|
|
133
131
|
let o = "Stored events could not be deserialized as Events";
|
|
@@ -140,7 +138,7 @@ export default class ne {
|
|
|
140
138
|
typeof t +
|
|
141
139
|
": " +
|
|
142
140
|
JSON.stringify(t)),
|
|
143
|
-
e.push(new
|
|
141
|
+
e.push(new ue(null, d.ul, new Date().valueOf(), null, { e: o }));
|
|
144
142
|
}
|
|
145
143
|
return e;
|
|
146
144
|
}
|
|
@@ -151,7 +149,7 @@ export default class ne {
|
|
|
151
149
|
t,
|
|
152
150
|
"StorageManager cannot store object.",
|
|
153
151
|
"STORAGE_KEYS.OBJECTS",
|
|
154
|
-
) && this.
|
|
152
|
+
) && this.TE.store(t, e)
|
|
155
153
|
);
|
|
156
154
|
}
|
|
157
155
|
ft(t) {
|
|
@@ -161,7 +159,7 @@ export default class ne {
|
|
|
161
159
|
t,
|
|
162
160
|
"StorageManager cannot retrieve object.",
|
|
163
161
|
"STORAGE_KEYS.OBJECTS",
|
|
164
|
-
) && this.
|
|
162
|
+
) && this.TE.pr(t)
|
|
165
163
|
);
|
|
166
164
|
}
|
|
167
165
|
Ut(t) {
|
|
@@ -171,7 +169,7 @@ export default class ne {
|
|
|
171
169
|
t,
|
|
172
170
|
"StorageManager cannot remove object.",
|
|
173
171
|
"STORAGE_KEYS.OBJECTS",
|
|
174
|
-
) && (this.
|
|
172
|
+
) && (this.TE.remove(t), !0)
|
|
175
173
|
);
|
|
176
174
|
}
|
|
177
175
|
clearData() {
|
|
@@ -179,90 +177,90 @@ export default class ne {
|
|
|
179
177
|
e = C(STORAGE_KEYS.gt);
|
|
180
178
|
for (let e = 0; e < t.length; e++) {
|
|
181
179
|
const s = t[e];
|
|
182
|
-
this.
|
|
180
|
+
this.cE.remove(STORAGE_KEYS.iu[s]);
|
|
183
181
|
}
|
|
184
182
|
for (let t = 0; t < e.length; t++) {
|
|
185
183
|
const s = e[t];
|
|
186
|
-
this.
|
|
184
|
+
this.TE.remove(STORAGE_KEYS.gt[s]);
|
|
187
185
|
}
|
|
188
186
|
}
|
|
189
|
-
|
|
187
|
+
OE(t) {
|
|
190
188
|
return t || STORAGE_KEYS.gt.sE;
|
|
191
189
|
}
|
|
192
|
-
|
|
193
|
-
let e = this.
|
|
190
|
+
bl(t) {
|
|
191
|
+
let e = this.TE.pr(STORAGE_KEYS.gt.eE);
|
|
194
192
|
null == e && (e = {});
|
|
195
|
-
const s = this.
|
|
193
|
+
const s = this.OE(t[User.Qn]),
|
|
196
194
|
r = e[s];
|
|
197
195
|
for (const o in t)
|
|
198
|
-
o !== User.
|
|
196
|
+
o !== User.Qn &&
|
|
199
197
|
(null == e[s] || (r && null == r[o])) &&
|
|
200
|
-
this.mu(t[User.
|
|
198
|
+
this.mu(t[User.Qn], o, t[o]);
|
|
201
199
|
}
|
|
202
200
|
mu(t, e, s) {
|
|
203
|
-
let r = this.
|
|
201
|
+
let r = this.TE.pr(STORAGE_KEYS.gt.eE);
|
|
204
202
|
null == r && (r = {});
|
|
205
|
-
const o = this.
|
|
203
|
+
const o = this.OE(t);
|
|
206
204
|
let n = r[o];
|
|
207
205
|
if (
|
|
208
|
-
(null == n && ((n = {}), null != t && (n[User.
|
|
206
|
+
(null == n && ((n = {}), null != t && (n[User.Qn] = t)), e === User.lu)
|
|
209
207
|
) {
|
|
210
208
|
null == n[e] && (n[e] = {});
|
|
211
209
|
for (const t in s) n[e][t] = s[t];
|
|
212
210
|
} else n[e] = s;
|
|
213
|
-
return (r[o] = n), this.
|
|
211
|
+
return (r[o] = n), this.TE.store(STORAGE_KEYS.gt.eE, r);
|
|
214
212
|
}
|
|
215
|
-
|
|
216
|
-
const t = this.
|
|
217
|
-
this.
|
|
213
|
+
IE() {
|
|
214
|
+
const t = this.TE.pr(STORAGE_KEYS.gt.eE);
|
|
215
|
+
this.TE.remove(STORAGE_KEYS.gt.eE);
|
|
218
216
|
const e = [];
|
|
219
217
|
for (const s in t) null != t[s] && e.push(t[s]);
|
|
220
218
|
return e;
|
|
221
219
|
}
|
|
222
220
|
ru(t) {
|
|
223
|
-
const e = this.
|
|
221
|
+
const e = this.TE.pr(STORAGE_KEYS.gt.eE);
|
|
224
222
|
if (null != e) {
|
|
225
|
-
const s = this.
|
|
223
|
+
const s = this.OE(null),
|
|
226
224
|
r = e[s];
|
|
227
225
|
null != r &&
|
|
228
226
|
((e[s] = void 0),
|
|
229
|
-
this.
|
|
230
|
-
(r[User.
|
|
231
|
-
this.
|
|
227
|
+
this.TE.store(STORAGE_KEYS.gt.eE, e),
|
|
228
|
+
(r[User.Qn] = t),
|
|
229
|
+
this.bl(r));
|
|
232
230
|
}
|
|
233
|
-
const s = this.tu(STORAGE_KEYS.iu.
|
|
231
|
+
const s = this.tu(STORAGE_KEYS.iu.Nu);
|
|
234
232
|
let r = null;
|
|
235
233
|
null != s && (r = s.eu);
|
|
236
|
-
const o = this.
|
|
234
|
+
const o = this.RE();
|
|
237
235
|
if (null != o)
|
|
238
236
|
for (let e = 0; e < o.length; e++) {
|
|
239
237
|
const s = o[e];
|
|
240
|
-
null == s.userId && s.sessionId == r && (s.userId = t), this.
|
|
238
|
+
null == s.userId && s.sessionId == r && (s.userId = t), this.Au(s);
|
|
241
239
|
}
|
|
242
240
|
}
|
|
243
|
-
|
|
244
|
-
return this.
|
|
241
|
+
dE() {
|
|
242
|
+
return this.TE.fE;
|
|
245
243
|
}
|
|
246
244
|
}
|
|
247
|
-
(
|
|
245
|
+
(ee.rc = class {
|
|
248
246
|
constructor(t) {
|
|
249
|
-
(this.
|
|
247
|
+
(this.on = t), (this.on = t), (this.fE = ro.bE() ? 3 : 10);
|
|
250
248
|
}
|
|
251
|
-
|
|
252
|
-
return t + "." + this.
|
|
249
|
+
mE(t) {
|
|
250
|
+
return t + "." + this.on;
|
|
253
251
|
}
|
|
254
252
|
store(t, e) {
|
|
255
253
|
const s = { v: e };
|
|
256
254
|
try {
|
|
257
|
-
return localStorage.setItem(this.
|
|
255
|
+
return localStorage.setItem(this.mE(t), JSON.stringify(s)), !0;
|
|
258
256
|
} catch (t) {
|
|
259
257
|
return N.info("Storage failure: " + si(t)), !1;
|
|
260
258
|
}
|
|
261
259
|
}
|
|
262
|
-
|
|
260
|
+
pr(t) {
|
|
263
261
|
try {
|
|
264
262
|
let e = null;
|
|
265
|
-
const s = localStorage.getItem(this.
|
|
263
|
+
const s = localStorage.getItem(this.mE(t));
|
|
266
264
|
return null != s && (e = JSON.parse(s)), null == e ? null : e.v;
|
|
267
265
|
} catch (t) {
|
|
268
266
|
return N.info("Storage retrieval failure: " + si(t)), null;
|
|
@@ -270,30 +268,30 @@ export default class ne {
|
|
|
270
268
|
}
|
|
271
269
|
remove(t) {
|
|
272
270
|
try {
|
|
273
|
-
localStorage.removeItem(this.
|
|
271
|
+
localStorage.removeItem(this.mE(t));
|
|
274
272
|
} catch (t) {
|
|
275
273
|
return N.info("Storage removal failure: " + si(t)), !1;
|
|
276
274
|
}
|
|
277
275
|
}
|
|
278
276
|
}),
|
|
279
|
-
(
|
|
277
|
+
(ee.ac = class {
|
|
280
278
|
constructor() {
|
|
281
|
-
(this.KE = {}), (this.
|
|
279
|
+
(this.KE = {}), (this.YE = 5242880), (this.fE = 3);
|
|
282
280
|
}
|
|
283
281
|
store(t, e) {
|
|
284
282
|
const s = { value: e },
|
|
285
|
-
r = this.
|
|
286
|
-
return r > this.
|
|
283
|
+
r = this.NE(e);
|
|
284
|
+
return r > this.YE
|
|
287
285
|
? (N.info(
|
|
288
286
|
"Storage failure: object is ≈" +
|
|
289
287
|
r +
|
|
290
288
|
" bytes which is greater than the max of " +
|
|
291
|
-
this.
|
|
289
|
+
this.YE,
|
|
292
290
|
),
|
|
293
291
|
!1)
|
|
294
292
|
: ((this.KE[t] = s), !0);
|
|
295
293
|
}
|
|
296
|
-
|
|
294
|
+
NE(t) {
|
|
297
295
|
const e = [],
|
|
298
296
|
s = [t];
|
|
299
297
|
let r = 0;
|
|
@@ -310,7 +308,7 @@ export default class ne {
|
|
|
310
308
|
}
|
|
311
309
|
return r;
|
|
312
310
|
}
|
|
313
|
-
|
|
311
|
+
pr(t) {
|
|
314
312
|
const e = this.KE[t];
|
|
315
313
|
return null == e ? null : e.value;
|
|
316
314
|
}
|
|
@@ -318,17 +316,17 @@ export default class ne {
|
|
|
318
316
|
this.KE[t] = null;
|
|
319
317
|
}
|
|
320
318
|
}),
|
|
321
|
-
(
|
|
319
|
+
(ee.se = class {
|
|
322
320
|
constructor(t, e) {
|
|
323
|
-
(this.
|
|
324
|
-
(this.
|
|
325
|
-
(this.
|
|
326
|
-
(this.
|
|
327
|
-
(this.
|
|
328
|
-
(this.
|
|
321
|
+
(this.on = t),
|
|
322
|
+
(this.GE = e),
|
|
323
|
+
(this.on = t),
|
|
324
|
+
(this.CE = this.DE()),
|
|
325
|
+
(this.ME = 576e3),
|
|
326
|
+
(this.GE = !!e);
|
|
329
327
|
}
|
|
330
|
-
|
|
331
|
-
return null != this.
|
|
328
|
+
mE(t) {
|
|
329
|
+
return null != this.on ? t + "." + this.on : t;
|
|
332
330
|
}
|
|
333
331
|
DE() {
|
|
334
332
|
let t = 0,
|
|
@@ -347,10 +345,10 @@ export default class ne {
|
|
|
347
345
|
}
|
|
348
346
|
le() {
|
|
349
347
|
const t = new Date();
|
|
350
|
-
return t.setTime(t.getTime() + 60 * this.
|
|
348
|
+
return t.setTime(t.getTime() + 60 * this.ME * 1e3), t.getFullYear();
|
|
351
349
|
}
|
|
352
|
-
|
|
353
|
-
const t =
|
|
350
|
+
pE() {
|
|
351
|
+
const t = Pt(STORAGE_KEYS.iu),
|
|
354
352
|
e = document.cookie.split(";");
|
|
355
353
|
for (let s = 0; s < e.length; s++) {
|
|
356
354
|
let r = e[s];
|
|
@@ -363,19 +361,19 @@ export default class ne {
|
|
|
363
361
|
}
|
|
364
362
|
if (o) {
|
|
365
363
|
const t = r.split("=")[0];
|
|
366
|
-
-1 === t.indexOf("." + this.
|
|
364
|
+
-1 === t.indexOf("." + this.on) && this.vE(t);
|
|
367
365
|
}
|
|
368
366
|
}
|
|
369
367
|
}
|
|
370
368
|
store(t, e) {
|
|
371
|
-
this.
|
|
369
|
+
this.pE();
|
|
372
370
|
const s = new Date();
|
|
373
|
-
s.setTime(s.getTime() + 60 * this.
|
|
371
|
+
s.setTime(s.getTime() + 60 * this.ME * 1e3);
|
|
374
372
|
const r = "expires=" + s.toUTCString(),
|
|
375
|
-
o = "domain=" + this.
|
|
373
|
+
o = "domain=" + this.CE;
|
|
376
374
|
let n;
|
|
377
|
-
n = this.
|
|
378
|
-
const a = this.
|
|
375
|
+
n = this.GE ? e : encodeURIComponent(e);
|
|
376
|
+
const a = this.mE(t) + "=" + n + ";" + r + ";" + o + ";path=/";
|
|
379
377
|
return a.length >= 4093
|
|
380
378
|
? (N.info(
|
|
381
379
|
"Storage failure: string is " +
|
|
@@ -385,9 +383,9 @@ export default class ne {
|
|
|
385
383
|
!1)
|
|
386
384
|
: ((document.cookie = a), !0);
|
|
387
385
|
}
|
|
388
|
-
|
|
386
|
+
pr(t) {
|
|
389
387
|
const e = [],
|
|
390
|
-
s = this.
|
|
388
|
+
s = this.mE(t) + "=",
|
|
391
389
|
r = document.cookie.split(";");
|
|
392
390
|
for (let o = 0; o < r.length; o++) {
|
|
393
391
|
let n = r[o];
|
|
@@ -395,7 +393,7 @@ export default class ne {
|
|
|
395
393
|
if (0 === n.indexOf(s))
|
|
396
394
|
try {
|
|
397
395
|
let t;
|
|
398
|
-
(t = this.
|
|
396
|
+
(t = this.GE
|
|
399
397
|
? n.substring(s.length, n.length)
|
|
400
398
|
: decodeURIComponent(n.substring(s.length, n.length))),
|
|
401
399
|
e.push(t);
|
|
@@ -410,37 +408,37 @@ export default class ne {
|
|
|
410
408
|
return e.length > 0 ? e[e.length - 1] : null;
|
|
411
409
|
}
|
|
412
410
|
remove(t) {
|
|
413
|
-
this.
|
|
411
|
+
this.vE(this.mE(t));
|
|
414
412
|
}
|
|
415
|
-
|
|
413
|
+
vE(t) {
|
|
416
414
|
const e = t + "=;expires=" + new Date(0).toUTCString();
|
|
417
415
|
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
418
|
-
const s = e + ";domain=" + this.
|
|
416
|
+
const s = e + ";domain=" + this.CE;
|
|
419
417
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
420
418
|
}
|
|
421
419
|
}),
|
|
422
|
-
(
|
|
420
|
+
(ee.tc = class {
|
|
423
421
|
constructor(t, e, s) {
|
|
424
|
-
(this.
|
|
425
|
-
(this.
|
|
426
|
-
e && this.
|
|
427
|
-
s && this.
|
|
428
|
-
this.
|
|
422
|
+
(this.on = t),
|
|
423
|
+
(this.UE = []),
|
|
424
|
+
e && this.UE.push(new ee.se(t)),
|
|
425
|
+
s && this.UE.push(new ee.rc(t)),
|
|
426
|
+
this.UE.push(new ee.ac());
|
|
429
427
|
}
|
|
430
428
|
store(t, e) {
|
|
431
429
|
let s = !0;
|
|
432
|
-
for (let r = 0; r < this.
|
|
430
|
+
for (let r = 0; r < this.UE.length; r++) s = this.UE[r].store(t, e) && s;
|
|
433
431
|
return s;
|
|
434
432
|
}
|
|
435
|
-
|
|
436
|
-
for (let e = 0; e < this.
|
|
437
|
-
const s = this.
|
|
433
|
+
pr(t) {
|
|
434
|
+
for (let e = 0; e < this.UE.length; e++) {
|
|
435
|
+
const s = this.UE[e].pr(t);
|
|
438
436
|
if (null != s) return s;
|
|
439
437
|
}
|
|
440
438
|
return null;
|
|
441
439
|
}
|
|
442
440
|
remove(t) {
|
|
443
|
-
new
|
|
444
|
-
for (let e = 0; e < this.
|
|
441
|
+
new ee.se(this.on).remove(t);
|
|
442
|
+
for (let e = 0; e < this.UE.length; e++) this.UE[e].remove(t);
|
|
445
443
|
}
|
|
446
444
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Guid as
|
|
1
|
+
import { Guid as O } from "../../shared-lib/index.js";
|
|
2
2
|
export default class u {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.Mi = {};
|
|
5
5
|
}
|
|
6
6
|
Dt(t) {
|
|
7
7
|
if ("function" != typeof t) return null;
|
|
8
|
-
const i =
|
|
8
|
+
const i = O.ce();
|
|
9
9
|
return (this.Mi[i] = t), i;
|
|
10
10
|
}
|
|
11
11
|
removeSubscription(t) {
|
|
@@ -14,7 +14,7 @@ export default class u {
|
|
|
14
14
|
removeAllSubscriptions() {
|
|
15
15
|
this.Mi = {};
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
ic() {
|
|
18
18
|
return Object.keys(this.Mi).length;
|
|
19
19
|
}
|
|
20
20
|
X(t) {
|
package/src/managers/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
dl: "invalid_api_key",
|
|
3
|
+
fl: "blacklisted",
|
|
4
|
+
ml: "no_device_identifier",
|
|
5
|
+
cl: "invalid_json_response",
|
|
6
|
+
hl: "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
|
|
3
|
-
import { isObject as
|
|
2
|
+
import { getAlias as ce } from "../managers/utils.js";
|
|
3
|
+
import { isObject as It } from "../util/code-utils.js";
|
|
4
4
|
import {
|
|
5
|
-
convertMsToSeconds as
|
|
6
|
-
timestampOrNow as
|
|
5
|
+
convertMsToSeconds as X,
|
|
6
|
+
timestampOrNow as ts,
|
|
7
7
|
} from "../util/date-utils.js";
|
|
8
|
-
export default class
|
|
8
|
+
export default class ue {
|
|
9
9
|
constructor(t, s, i, r, e) {
|
|
10
10
|
(this.userId = t),
|
|
11
11
|
(this.type = s),
|
|
@@ -14,22 +14,22 @@ export default class ve {
|
|
|
14
14
|
(this.data = e),
|
|
15
15
|
(this.userId = t),
|
|
16
16
|
(this.type = s),
|
|
17
|
-
(this.time =
|
|
17
|
+
(this.time = ts(i)),
|
|
18
18
|
(this.sessionId = r),
|
|
19
19
|
(this.data = e);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
Tr() {
|
|
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
|
-
const i = (null === (t = r.Sr()) || void 0 === t ? void 0 : t.
|
|
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 = ce(r.j());
|
|
33
33
|
t && (s.alias = t);
|
|
34
34
|
}
|
|
35
35
|
return s;
|
|
@@ -44,12 +44,12 @@ export default class ve {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
static fromJson(t) {
|
|
47
|
-
return new
|
|
47
|
+
return new ue(t.user_id, t.name, t.time, t.session_id, t.data);
|
|
48
48
|
}
|
|
49
|
-
static
|
|
50
|
-
return null != t &&
|
|
49
|
+
static gE(t) {
|
|
50
|
+
return null != t && It(t) && null != t.t && "" !== t.t;
|
|
51
51
|
}
|
|
52
|
-
static
|
|
53
|
-
return new
|
|
52
|
+
static zn(t) {
|
|
53
|
+
return new ue(t.u, t.t, t.ts, t.s, t.d);
|
|
54
54
|
}
|
|
55
55
|
}
|
package/src/models/device.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class Qt {
|
|
2
2
|
constructor(s) {
|
|
3
3
|
(this.id = s), (this.id = s);
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
Tr() {
|
|
6
6
|
const s = {};
|
|
7
7
|
return (
|
|
8
8
|
null != this.browser && (s.browser = this.browser),
|
|
9
|
-
null != this.
|
|
9
|
+
null != this.Ja && (s.browser_version = this.Ja),
|
|
10
10
|
null != this.os && (s.os_version = this.os),
|
|
11
11
|
null != this.resolution && (s.resolution = this.resolution),
|
|
12
12
|
null != this.language && (s.locale = this.language),
|