@braze/web-sdk 6.3.1 → 6.5.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 +38 -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 +1 -1
- package/shared-lib/indexed-db-adapter.js +60 -60
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +24 -23
- 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 +3 -3
- package/src/Banner/display/destroy-banner-html.js +3 -3
- package/src/Banner/display/detect-banner-impressions.js +16 -16
- package/src/Banner/get-all-banners.js +4 -4
- package/src/Banner/get-banner.js +5 -4
- package/src/Banner/index.js +2 -0
- 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 +6 -6
- package/src/Card/card-manager.js +28 -28
- package/src/Card/constants.js +1 -0
- package/src/Card/display/card-display.js +7 -7
- package/src/Card/log-card-dismissal.js +3 -3
- package/src/Card/log-content-card-click.js +3 -3
- package/src/Card/log-content-card-impressions.js +6 -6
- package/src/Card/models/captioned-image.js +3 -3
- package/src/Card/models/card.js +9 -9
- 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/ContentCards/content-cards-provider-factory.js +6 -2
- package/src/ContentCards/content-cards-provider.js +101 -87
- package/src/ContentCards/content-cards.js +4 -4
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +4 -4
- 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 +1 -1
- package/src/Core/disable-sdk.js +5 -5
- package/src/Core/enable-sdk.js +3 -3
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +3 -3
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +7 -7
- package/src/Core/log-purchase.js +4 -4
- package/src/Core/open-session.js +6 -6
- package/src/Core/wipe-data.js +3 -3
- package/src/DUST/dust-connection-core.js +23 -0
- package/src/DUST/dust-provider-factory.js +22 -0
- package/src/DUST/dust-provider.js +520 -0
- 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 +13 -0
- package/src/DUST/subscribe-to-dust.js +24 -0
- package/src/DUST/types.js +1 -0
- 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 +5 -5
- 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 +34 -34
- package/src/InAppMessage/display/modal-utils.js +14 -14
- 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 +98 -98
- package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
- package/src/InAppMessage/log-in-app-message-click.js +11 -11
- package/src/InAppMessage/log-in-app-message-html-click.js +9 -9
- 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 +21 -21
- package/src/InAppMessage/models/html-message.js +18 -18
- package/src/InAppMessage/models/in-app-message-button.js +7 -7
- package/src/InAppMessage/models/in-app-message.js +145 -145
- package/src/InAppMessage/models/modal-message.js +21 -21
- package/src/InAppMessage/models/slide-up-message.js +27 -27
- 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 +18 -0
- package/src/InAppMessage/ui/show-in-app-message.js +36 -36
- 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 +15 -15
- package/src/Push/push-manager.js +97 -97
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/unregister-push.js +1 -1
- package/src/Push/utils/push-utils.js +17 -17
- package/src/User/user-manager.js +24 -24
- package/src/User/user.js +55 -55
- package/src/common/constants.js +8 -10
- package/src/common/content-cards-display.js +40 -40
- package/src/common/event-logger.js +8 -8
- 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 +30 -30
- package/src/managers/braze-instance.js +170 -162
- package/src/managers/device-manager.js +24 -24
- package/src/managers/network-manager.js +149 -149
- package/src/managers/server-config-manager.js +140 -95
- package/src/managers/session-manager.js +39 -39
- package/src/managers/storage-manager-factory.js +10 -10
- package/src/managers/storage-manager.js +145 -141
- package/src/managers/subscription-manager.js +11 -11
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +11 -11
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +16 -16
- package/src/models/push-token.js +13 -13
- package/src/models/request-result.js +3 -3
- package/src/models/server-config.js +45 -37
- package/src/request-controller.js +163 -158
- 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 +10 -10
- package/src/triggers/models/filter.js +27 -27
- 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 +3 -3
- package/src/triggers/models/trigger.js +36 -36
- package/src/triggers/triggers-provider-factory.js +5 -5
- package/src/triggers/triggers-provider.js +63 -63
- 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 +9 -9
- package/src/util/braze-actions.js +5 -5
- package/src/util/browser-detector.js +37 -37
- package/src/util/client-hints-parser.js +11 -11
- 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 +5 -5
- package/src/util/request-header-utils.js +27 -27
- package/src/util/user-agent-parser.js +21 -21
- package/src/util/validation-utils.js +17 -17
- package/src/util/window-utils.js +3 -3
|
@@ -1,83 +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
|
+
tl: "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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
ac: "ab.storage.device",
|
|
25
|
+
Dl: "ab.storage.sdk_metadata",
|
|
26
|
+
Tl: "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
|
+
uc: "ab.storage.globalRateLimitCurrentTokenCount",
|
|
37
|
+
fc: "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
|
-
|
|
45
|
-
|
|
44
|
+
xh: "ab.storage.signature",
|
|
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
|
+
Wn: "ab.storage.deferredIam",
|
|
54
|
+
Jl: "ab.storage.lastSdkReq",
|
|
55
55
|
uE: "ab.storage.alias",
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
vt: "ab.storage.banners",
|
|
57
|
+
Dt: "ab.storage.banners.impressions",
|
|
58
|
+
Bt: "ab.storage.banners.sessionId",
|
|
59
|
+
Ue: "ab.storage.dust.mite",
|
|
60
|
+
Ne: "ab.storage.dust.host",
|
|
61
|
+
Te: "ab.storage.dust.auth",
|
|
62
|
+
ze: "ab.storage.dust.expiration",
|
|
59
63
|
},
|
|
60
|
-
|
|
64
|
+
pe: "ab.optOut",
|
|
61
65
|
};
|
|
62
66
|
export default class ee {
|
|
63
67
|
constructor(t, e) {
|
|
64
|
-
(this.
|
|
68
|
+
(this.TE = t), (this.cE = e), (this.TE = t), (this.cE = e);
|
|
65
69
|
}
|
|
66
|
-
|
|
67
|
-
const e = C(STORAGE_KEYS.
|
|
68
|
-
s = new ee.
|
|
69
|
-
for (const t of e) s.remove(STORAGE_KEYS.
|
|
70
|
+
Sl(t) {
|
|
71
|
+
const e = C(STORAGE_KEYS.Ou),
|
|
72
|
+
s = new ee.le(t);
|
|
73
|
+
for (const t of e) s.remove(STORAGE_KEYS.Ou[t]);
|
|
70
74
|
}
|
|
71
|
-
|
|
75
|
+
Iu(t, e) {
|
|
72
76
|
let s = null;
|
|
73
|
-
null != e && e instanceof _t && (s = e.
|
|
77
|
+
null != e && e instanceof _t && (s = e.gt()), this.TE.store(t, s);
|
|
74
78
|
}
|
|
75
79
|
hE(t) {
|
|
76
|
-
const e = this
|
|
77
|
-
null != e && ((e.
|
|
80
|
+
const e = this.$u(t);
|
|
81
|
+
null != e && ((e.gm = new Date().valueOf()), this.Iu(t, e));
|
|
78
82
|
}
|
|
79
|
-
|
|
80
|
-
const e = this.
|
|
83
|
+
$u(t) {
|
|
84
|
+
const e = this.TE.jr(t),
|
|
81
85
|
s = ((t) => {
|
|
82
86
|
let e;
|
|
83
87
|
try {
|
|
@@ -88,44 +92,44 @@ export default class ee {
|
|
|
88
92
|
return e;
|
|
89
93
|
})(e);
|
|
90
94
|
let r;
|
|
91
|
-
if (s) (r = _t.
|
|
95
|
+
if (s) (r = _t._u(s) || null), r && this.Iu(t, r);
|
|
92
96
|
else {
|
|
93
97
|
const s = _t.AE(e);
|
|
94
|
-
(r = _t.
|
|
98
|
+
(r = _t._u(s) || null), s !== e && r && this.Iu(t, r);
|
|
95
99
|
}
|
|
96
100
|
return r;
|
|
97
101
|
}
|
|
98
|
-
|
|
99
|
-
this.
|
|
102
|
+
xm(t) {
|
|
103
|
+
this.TE.remove(t);
|
|
100
104
|
}
|
|
101
|
-
|
|
102
|
-
const t = C(STORAGE_KEYS.
|
|
105
|
+
Al() {
|
|
106
|
+
const t = C(STORAGE_KEYS.Ou);
|
|
103
107
|
let e;
|
|
104
108
|
for (const s of t)
|
|
105
|
-
(e = this
|
|
106
|
-
null != e && this.
|
|
109
|
+
(e = this.$u(STORAGE_KEYS.Ou[s])),
|
|
110
|
+
null != e && this.Iu(STORAGE_KEYS.Ou[s], e);
|
|
107
111
|
}
|
|
108
|
-
|
|
112
|
+
ol(t) {
|
|
109
113
|
let e;
|
|
110
114
|
if (null == t || 0 === t.length) return !1;
|
|
111
|
-
e =
|
|
112
|
-
let s = this.
|
|
113
|
-
(null != s &&
|
|
114
|
-
for (let t = 0; t < e.length; t++) s.push(e[t].
|
|
115
|
-
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);
|
|
116
120
|
}
|
|
117
|
-
|
|
118
|
-
return null != t && this.
|
|
121
|
+
wm(t) {
|
|
122
|
+
return null != t && this.ol([t]);
|
|
119
123
|
}
|
|
120
124
|
RE() {
|
|
121
|
-
let t = this.
|
|
122
|
-
this.
|
|
125
|
+
let t = this.cE.jr(STORAGE_KEYS.ft.tE);
|
|
126
|
+
this.cE.remove(STORAGE_KEYS.ft.tE), null == t && (t = []);
|
|
123
127
|
const e = [];
|
|
124
128
|
let s = !1,
|
|
125
129
|
r = null;
|
|
126
|
-
if (
|
|
130
|
+
if (R(t))
|
|
127
131
|
for (let s = 0; s < t.length; s++)
|
|
128
|
-
|
|
132
|
+
De.gE(t[s]) ? e.push(De._u(t[s])) : (r = s);
|
|
129
133
|
else s = !0;
|
|
130
134
|
if (s || null != r) {
|
|
131
135
|
let o = "Stored events could not be deserialized as Events";
|
|
@@ -138,145 +142,145 @@ export default class ee {
|
|
|
138
142
|
typeof t +
|
|
139
143
|
": " +
|
|
140
144
|
JSON.stringify(t)),
|
|
141
|
-
e.push(new
|
|
145
|
+
e.push(new De(null, f.wl, new Date().valueOf(), null, { e: o }));
|
|
142
146
|
}
|
|
143
147
|
return e;
|
|
144
148
|
}
|
|
145
|
-
|
|
149
|
+
bt(t, e) {
|
|
146
150
|
return (
|
|
147
151
|
!!ta(
|
|
148
|
-
STORAGE_KEYS.
|
|
152
|
+
STORAGE_KEYS.ft,
|
|
149
153
|
t,
|
|
150
154
|
"StorageManager cannot store object.",
|
|
151
155
|
"STORAGE_KEYS.OBJECTS",
|
|
152
|
-
) && this.
|
|
156
|
+
) && this.cE.store(t, e)
|
|
153
157
|
);
|
|
154
158
|
}
|
|
155
|
-
|
|
159
|
+
dt(t) {
|
|
156
160
|
return (
|
|
157
161
|
!!ta(
|
|
158
|
-
STORAGE_KEYS.
|
|
162
|
+
STORAGE_KEYS.ft,
|
|
159
163
|
t,
|
|
160
164
|
"StorageManager cannot retrieve object.",
|
|
161
165
|
"STORAGE_KEYS.OBJECTS",
|
|
162
|
-
) && this.
|
|
166
|
+
) && this.cE.jr(t)
|
|
163
167
|
);
|
|
164
168
|
}
|
|
165
|
-
|
|
169
|
+
zt(t) {
|
|
166
170
|
return (
|
|
167
171
|
!!ta(
|
|
168
|
-
STORAGE_KEYS.
|
|
172
|
+
STORAGE_KEYS.ft,
|
|
169
173
|
t,
|
|
170
174
|
"StorageManager cannot remove object.",
|
|
171
175
|
"STORAGE_KEYS.OBJECTS",
|
|
172
|
-
) && (this.
|
|
176
|
+
) && (this.cE.remove(t), !0)
|
|
173
177
|
);
|
|
174
178
|
}
|
|
175
179
|
clearData() {
|
|
176
|
-
const t = C(STORAGE_KEYS.
|
|
177
|
-
e = C(STORAGE_KEYS.
|
|
180
|
+
const t = C(STORAGE_KEYS.Ou),
|
|
181
|
+
e = C(STORAGE_KEYS.ft);
|
|
178
182
|
for (let e = 0; e < t.length; e++) {
|
|
179
183
|
const s = t[e];
|
|
180
|
-
this.
|
|
184
|
+
this.TE.remove(STORAGE_KEYS.Ou[s]);
|
|
181
185
|
}
|
|
182
186
|
for (let t = 0; t < e.length; t++) {
|
|
183
187
|
const s = e[t];
|
|
184
|
-
this.
|
|
188
|
+
this.cE.remove(STORAGE_KEYS.ft[s]);
|
|
185
189
|
}
|
|
186
190
|
}
|
|
187
191
|
OE(t) {
|
|
188
|
-
return t || STORAGE_KEYS.
|
|
192
|
+
return t || STORAGE_KEYS.ft.sE;
|
|
189
193
|
}
|
|
190
|
-
|
|
191
|
-
let e = this.
|
|
194
|
+
Xl(t) {
|
|
195
|
+
let e = this.cE.jr(STORAGE_KEYS.ft.eE);
|
|
192
196
|
null == e && (e = {});
|
|
193
|
-
const s = this.OE(t[User.
|
|
197
|
+
const s = this.OE(t[User.Va]),
|
|
194
198
|
r = e[s];
|
|
195
199
|
for (const o in t)
|
|
196
|
-
o !== User.
|
|
200
|
+
o !== User.Va &&
|
|
197
201
|
(null == e[s] || (r && null == r[o])) &&
|
|
198
|
-
this.
|
|
202
|
+
this.Eu(t[User.Va], o, t[o]);
|
|
199
203
|
}
|
|
200
|
-
|
|
201
|
-
let r = this.
|
|
204
|
+
Eu(t, e, s) {
|
|
205
|
+
let r = this.cE.jr(STORAGE_KEYS.ft.eE);
|
|
202
206
|
null == r && (r = {});
|
|
203
207
|
const o = this.OE(t);
|
|
204
208
|
let n = r[o];
|
|
205
209
|
if (
|
|
206
|
-
(null == n && ((n = {}), null != t && (n[User.
|
|
210
|
+
(null == n && ((n = {}), null != t && (n[User.Va] = t)), e === User.Bu)
|
|
207
211
|
) {
|
|
208
212
|
null == n[e] && (n[e] = {});
|
|
209
213
|
for (const t in s) n[e][t] = s[t];
|
|
210
214
|
} else n[e] = s;
|
|
211
|
-
return (r[o] = n), this.
|
|
215
|
+
return (r[o] = n), this.cE.store(STORAGE_KEYS.ft.eE, r);
|
|
212
216
|
}
|
|
213
217
|
IE() {
|
|
214
|
-
const t = this.
|
|
215
|
-
this.
|
|
218
|
+
const t = this.cE.jr(STORAGE_KEYS.ft.eE);
|
|
219
|
+
this.cE.remove(STORAGE_KEYS.ft.eE);
|
|
216
220
|
const e = [];
|
|
217
221
|
for (const s in t) null != t[s] && e.push(t[s]);
|
|
218
222
|
return e;
|
|
219
223
|
}
|
|
220
|
-
|
|
221
|
-
const e = this.
|
|
224
|
+
Lu(t) {
|
|
225
|
+
const e = this.cE.jr(STORAGE_KEYS.ft.eE);
|
|
222
226
|
if (null != e) {
|
|
223
227
|
const s = this.OE(null),
|
|
224
228
|
r = e[s];
|
|
225
229
|
null != r &&
|
|
226
230
|
((e[s] = void 0),
|
|
227
|
-
this.
|
|
228
|
-
(r[User.
|
|
229
|
-
this.
|
|
231
|
+
this.cE.store(STORAGE_KEYS.ft.eE, e),
|
|
232
|
+
(r[User.Va] = t),
|
|
233
|
+
this.Xl(r));
|
|
230
234
|
}
|
|
231
|
-
const s = this
|
|
235
|
+
const s = this.$u(STORAGE_KEYS.Ou.um);
|
|
232
236
|
let r = null;
|
|
233
|
-
null != s && (r = s.
|
|
237
|
+
null != s && (r = s.Tu);
|
|
234
238
|
const o = this.RE();
|
|
235
239
|
if (null != o)
|
|
236
240
|
for (let e = 0; e < o.length; e++) {
|
|
237
241
|
const s = o[e];
|
|
238
|
-
null == s.userId && s.sessionId == r && (s.userId = t), this.
|
|
242
|
+
null == s.userId && s.sessionId == r && (s.userId = t), this.wm(s);
|
|
239
243
|
}
|
|
240
244
|
}
|
|
241
245
|
dE() {
|
|
242
|
-
return this.
|
|
246
|
+
return this.cE.bE;
|
|
243
247
|
}
|
|
244
248
|
}
|
|
245
|
-
(ee.
|
|
249
|
+
(ee.Wc = class {
|
|
246
250
|
constructor(t) {
|
|
247
|
-
(this.
|
|
251
|
+
(this.tu = t), (this.tu = t), (this.bE = ro.fE() ? 3 : 10);
|
|
248
252
|
}
|
|
249
253
|
mE(t) {
|
|
250
|
-
return t + "." + this.
|
|
254
|
+
return t + "." + this.tu;
|
|
251
255
|
}
|
|
252
256
|
store(t, e) {
|
|
253
257
|
const s = { v: e };
|
|
254
258
|
try {
|
|
255
259
|
return localStorage.setItem(this.mE(t), JSON.stringify(s)), !0;
|
|
256
260
|
} catch (t) {
|
|
257
|
-
return E.info("Storage failure: " +
|
|
261
|
+
return E.info("Storage failure: " + ai(t)), !1;
|
|
258
262
|
}
|
|
259
263
|
}
|
|
260
|
-
|
|
264
|
+
jr(t) {
|
|
261
265
|
try {
|
|
262
266
|
let e = null;
|
|
263
267
|
const s = localStorage.getItem(this.mE(t));
|
|
264
268
|
return null != s && (e = JSON.parse(s)), null == e ? null : e.v;
|
|
265
269
|
} catch (t) {
|
|
266
|
-
return E.info("Storage retrieval failure: " +
|
|
270
|
+
return E.info("Storage retrieval failure: " + ai(t)), null;
|
|
267
271
|
}
|
|
268
272
|
}
|
|
269
273
|
remove(t) {
|
|
270
274
|
try {
|
|
271
275
|
localStorage.removeItem(this.mE(t));
|
|
272
276
|
} catch (t) {
|
|
273
|
-
return E.info("Storage removal failure: " +
|
|
277
|
+
return E.info("Storage removal failure: " + ai(t)), !1;
|
|
274
278
|
}
|
|
275
279
|
}
|
|
276
280
|
}),
|
|
277
|
-
(ee.
|
|
281
|
+
(ee.Xc = class {
|
|
278
282
|
constructor() {
|
|
279
|
-
(this.KE = {}), (this.YE = 5242880), (this.
|
|
283
|
+
(this.KE = {}), (this.YE = 5242880), (this.bE = 3);
|
|
280
284
|
}
|
|
281
285
|
store(t, e) {
|
|
282
286
|
const s = { value: e },
|
|
@@ -308,7 +312,7 @@ export default class ee {
|
|
|
308
312
|
}
|
|
309
313
|
return r;
|
|
310
314
|
}
|
|
311
|
-
|
|
315
|
+
jr(t) {
|
|
312
316
|
const e = this.KE[t];
|
|
313
317
|
return null == e ? null : e.value;
|
|
314
318
|
}
|
|
@@ -316,19 +320,19 @@ export default class ee {
|
|
|
316
320
|
this.KE[t] = null;
|
|
317
321
|
}
|
|
318
322
|
}),
|
|
319
|
-
(ee.
|
|
323
|
+
(ee.le = class {
|
|
320
324
|
constructor(t, e) {
|
|
321
|
-
(this.
|
|
322
|
-
(this.
|
|
323
|
-
(this.
|
|
324
|
-
(this.
|
|
325
|
+
(this.tu = t),
|
|
326
|
+
(this.DE = e),
|
|
327
|
+
(this.tu = t),
|
|
328
|
+
(this.GE = this.CE()),
|
|
325
329
|
(this.ME = 576e3),
|
|
326
|
-
(this.
|
|
330
|
+
(this.DE = !!e);
|
|
327
331
|
}
|
|
328
332
|
mE(t) {
|
|
329
|
-
return null != this.
|
|
333
|
+
return null != this.tu ? t + "." + this.tu : t;
|
|
330
334
|
}
|
|
331
|
-
|
|
335
|
+
CE() {
|
|
332
336
|
let t = 0,
|
|
333
337
|
e = document.location.hostname;
|
|
334
338
|
const s = e.split("."),
|
|
@@ -343,12 +347,12 @@ export default class ee {
|
|
|
343
347
|
e
|
|
344
348
|
);
|
|
345
349
|
}
|
|
346
|
-
|
|
350
|
+
me() {
|
|
347
351
|
const t = new Date();
|
|
348
352
|
return t.setTime(t.getTime() + 60 * this.ME * 1e3), t.getFullYear();
|
|
349
353
|
}
|
|
350
354
|
pE() {
|
|
351
|
-
const t = Pt(STORAGE_KEYS.
|
|
355
|
+
const t = Pt(STORAGE_KEYS.Ou),
|
|
352
356
|
e = document.cookie.split(";");
|
|
353
357
|
for (let s = 0; s < e.length; s++) {
|
|
354
358
|
let r = e[s];
|
|
@@ -361,7 +365,7 @@ export default class ee {
|
|
|
361
365
|
}
|
|
362
366
|
if (o) {
|
|
363
367
|
const t = r.split("=")[0];
|
|
364
|
-
-1 === t.indexOf("." + this.
|
|
368
|
+
-1 === t.indexOf("." + this.tu) && this.UE(t);
|
|
365
369
|
}
|
|
366
370
|
}
|
|
367
371
|
}
|
|
@@ -370,9 +374,9 @@ export default class ee {
|
|
|
370
374
|
const s = new Date();
|
|
371
375
|
s.setTime(s.getTime() + 60 * this.ME * 1e3);
|
|
372
376
|
const r = "expires=" + s.toUTCString(),
|
|
373
|
-
o = "domain=" + this.
|
|
377
|
+
o = "domain=" + this.GE;
|
|
374
378
|
let n;
|
|
375
|
-
n = this.
|
|
379
|
+
n = this.DE ? e : encodeURIComponent(e);
|
|
376
380
|
const a = this.mE(t) + "=" + n + ";" + r + ";" + o + ";path=/";
|
|
377
381
|
return a.length >= 4093
|
|
378
382
|
? (E.info(
|
|
@@ -383,7 +387,7 @@ export default class ee {
|
|
|
383
387
|
!1)
|
|
384
388
|
: ((document.cookie = a), !0);
|
|
385
389
|
}
|
|
386
|
-
|
|
390
|
+
jr(t) {
|
|
387
391
|
const e = [],
|
|
388
392
|
s = this.mE(t) + "=",
|
|
389
393
|
r = document.cookie.split(";");
|
|
@@ -393,13 +397,13 @@ export default class ee {
|
|
|
393
397
|
if (0 === n.indexOf(s))
|
|
394
398
|
try {
|
|
395
399
|
let t;
|
|
396
|
-
(t = this.
|
|
400
|
+
(t = this.DE
|
|
397
401
|
? n.substring(s.length, n.length)
|
|
398
402
|
: decodeURIComponent(n.substring(s.length, n.length))),
|
|
399
403
|
e.push(t);
|
|
400
404
|
} catch (e) {
|
|
401
405
|
return (
|
|
402
|
-
E.info("Storage retrieval failure: " +
|
|
406
|
+
E.info("Storage retrieval failure: " + ai(e)),
|
|
403
407
|
this.remove(t),
|
|
404
408
|
null
|
|
405
409
|
);
|
|
@@ -408,37 +412,37 @@ export default class ee {
|
|
|
408
412
|
return e.length > 0 ? e[e.length - 1] : null;
|
|
409
413
|
}
|
|
410
414
|
remove(t) {
|
|
411
|
-
this.
|
|
415
|
+
this.UE(this.mE(t));
|
|
412
416
|
}
|
|
413
|
-
|
|
417
|
+
UE(t) {
|
|
414
418
|
const e = t + "=;expires=" + new Date(0).toUTCString();
|
|
415
419
|
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
416
|
-
const s = e + ";domain=" + this.
|
|
420
|
+
const s = e + ";domain=" + this.GE;
|
|
417
421
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
418
422
|
}
|
|
419
423
|
}),
|
|
420
|
-
(ee.
|
|
424
|
+
(ee.Jc = class {
|
|
421
425
|
constructor(t, e, s) {
|
|
422
|
-
(this.
|
|
423
|
-
(this.
|
|
424
|
-
e && this.
|
|
425
|
-
s && this.
|
|
426
|
-
this.
|
|
426
|
+
(this.tu = t),
|
|
427
|
+
(this.vE = []),
|
|
428
|
+
e && this.vE.push(new ee.le(t)),
|
|
429
|
+
s && this.vE.push(new ee.Wc(t)),
|
|
430
|
+
this.vE.push(new ee.Xc());
|
|
427
431
|
}
|
|
428
432
|
store(t, e) {
|
|
429
433
|
let s = !0;
|
|
430
|
-
for (let r = 0; r < this.
|
|
434
|
+
for (let r = 0; r < this.vE.length; r++) s = this.vE[r].store(t, e) && s;
|
|
431
435
|
return s;
|
|
432
436
|
}
|
|
433
|
-
|
|
434
|
-
for (let e = 0; e < this.
|
|
435
|
-
const s = this.
|
|
437
|
+
jr(t) {
|
|
438
|
+
for (let e = 0; e < this.vE.length; e++) {
|
|
439
|
+
const s = this.vE[e].jr(t);
|
|
436
440
|
if (null != s) return s;
|
|
437
441
|
}
|
|
438
442
|
return null;
|
|
439
443
|
}
|
|
440
444
|
remove(t) {
|
|
441
|
-
new ee.
|
|
442
|
-
for (let e = 0; e < this.
|
|
445
|
+
new ee.le(this.tu).remove(t);
|
|
446
|
+
for (let e = 0; e < this.vE.length; e++) this.vE[e].remove(t);
|
|
443
447
|
}
|
|
444
448
|
});
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { Guid as P } from "../../shared-lib/index.js";
|
|
2
|
-
export default class
|
|
2
|
+
export default class m {
|
|
3
3
|
constructor() {
|
|
4
|
-
this.
|
|
4
|
+
this.jn = {};
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
Rt(t) {
|
|
7
7
|
if ("function" != typeof t) return null;
|
|
8
|
-
const i = P.
|
|
9
|
-
return (this.
|
|
8
|
+
const i = P.se();
|
|
9
|
+
return (this.jn[i] = t), i;
|
|
10
10
|
}
|
|
11
11
|
removeSubscription(t) {
|
|
12
|
-
delete this.
|
|
12
|
+
delete this.jn[t];
|
|
13
13
|
}
|
|
14
14
|
removeAllSubscriptions() {
|
|
15
|
-
this.
|
|
15
|
+
this.jn = {};
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
return Object.keys(this.
|
|
17
|
+
De() {
|
|
18
|
+
return Object.keys(this.jn).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.jn) {
|
|
23
|
+
const r = this.jn[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
|
+
Bl: "invalid_api_key",
|
|
3
|
+
zl: "blacklisted",
|
|
4
|
+
jl: "no_device_identifier",
|
|
5
|
+
Cl: "invalid_json_response",
|
|
6
|
+
yl: "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 qe } from "../managers/utils.js";
|
|
3
|
+
import { isObject as yt } from "../util/code-utils.js";
|
|
4
4
|
import {
|
|
5
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,7 +18,7 @@ export default class ue {
|
|
|
18
18
|
(this.sessionId = r),
|
|
19
19
|
(this.data = e);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
Hn() {
|
|
22
22
|
var t;
|
|
23
23
|
const s = {
|
|
24
24
|
name: this.type,
|
|
@@ -27,14 +27,14 @@ export default class ue {
|
|
|
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 = 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
|
-
return null != t &&
|
|
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
|
}
|
package/src/models/device.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class Jt {
|
|
2
2
|
constructor(s) {
|
|
3
3
|
(this.id = s), (this.id = s);
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
Hn() {
|
|
6
6
|
const s = {};
|
|
7
7
|
return (
|
|
8
8
|
null != this.browser && (s.browser = this.browser),
|
|
9
|
-
null != this.
|
|
9
|
+
null != this.ec && (s.browser_version = this.ec),
|
|
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),
|