@braze/web-sdk 4.7.1 → 4.8.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 +27 -24
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +5 -5
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +24 -24
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +17 -17
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +18 -18
- package/src/Card/card-manager-factory.js +2 -2
- package/src/Card/card-manager.js +47 -41
- package/src/Card/display/card-display.js +70 -67
- package/src/Card/log-card-click.js +1 -1
- package/src/Card/log-card-dismissal.js +1 -1
- package/src/Card/log-card-impressions.js +3 -3
- package/src/Card/models/banner.js +3 -2
- package/src/Card/models/captioned-image.js +6 -5
- package/src/Card/models/card.js +107 -87
- package/src/Card/models/classic-card.js +5 -5
- package/src/Card/models/control-card.js +5 -21
- package/src/Card/types.js +1 -0
- package/src/Card/util/card-factory.js +32 -32
- package/src/ContentCards/content-cards-provider-factory.js +3 -3
- package/src/ContentCards/content-cards-provider.js +283 -175
- package/src/ContentCards/content-cards.js +2 -2
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/log-content-cards-displayed.js +2 -2
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +9 -6
- package/src/ContentCards/types.js +1 -0
- package/src/ContentCards/ui/hide-content-cards.js +2 -2
- package/src/ContentCards/ui/show-content-cards.js +35 -33
- package/src/Core/add-sdk-metadata.js +17 -18
- package/src/Core/change-user.js +12 -14
- package/src/Core/destroy.js +1 -1
- package/src/Core/disable-sdk.js +7 -6
- package/src/Core/enable-sdk.js +4 -4
- package/src/Core/get-device-id.js +7 -6
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +57 -40
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/log-custom-event.js +22 -15
- package/src/Core/log-purchase.js +33 -33
- package/src/Core/open-session.js +17 -15
- package/src/Core/request-immediate-data-flush.js +4 -2
- package/src/Core/set-logger.js +1 -1
- package/src/Core/set-sdk-authentication-signature.js +5 -6
- package/src/Core/subscribe-to-sdk-authentication-failures.js +3 -1
- package/src/Core/toggle-logging.js +1 -1
- package/src/Core/types.js +1 -0
- package/src/Core/wipe-data.js +11 -10
- package/src/FeatureFlags/feature-flag-factory.js +6 -6
- package/src/FeatureFlags/feature-flag.js +17 -17
- package/src/FeatureFlags/feature-flags-provider-factory.js +2 -2
- package/src/FeatureFlags/feature-flags-provider.js +67 -65
- package/src/FeatureFlags/get-all-feature-flags.js +3 -3
- package/src/FeatureFlags/get-feature-flag.js +4 -4
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -1
- package/src/Feed/feed-provider-factory.js +8 -8
- package/src/Feed/feed-provider.js +57 -46
- package/src/Feed/feed.js +1 -1
- package/src/Feed/get-cached-feed.js +2 -2
- package/src/Feed/log-feed-displayed.js +3 -1
- package/src/Feed/request-feed-refresh.js +2 -2
- package/src/Feed/subscribe-to-feed-updates.js +2 -2
- package/src/Feed/types.js +1 -0
- package/src/Feed/ui/hide-feed.js +2 -2
- package/src/Feed/ui/show-feed.js +40 -36
- package/src/InAppMessage/display/html-message-to-html.js +125 -119
- package/src/InAppMessage/display/in-app-message-to-html.js +72 -69
- package/src/InAppMessage/display/modal-utils.js +18 -13
- package/src/InAppMessage/in-app-message-factory.js +9 -8
- package/src/InAppMessage/in-app-message-manager-factory.js +7 -7
- package/src/InAppMessage/in-app-message-manager.js +122 -108
- package/src/InAppMessage/log-in-app-message-button-click.js +10 -10
- package/src/InAppMessage/log-in-app-message-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-html-click.js +10 -10
- package/src/InAppMessage/log-in-app-message-impression.js +5 -5
- package/src/InAppMessage/models/control-message.js +4 -1
- package/src/InAppMessage/models/full-screen-message.js +35 -37
- package/src/InAppMessage/models/html-message.js +34 -33
- package/src/InAppMessage/models/in-app-message-button.js +23 -16
- package/src/InAppMessage/models/in-app-message.js +147 -105
- package/src/InAppMessage/models/modal-message.js +34 -36
- package/src/InAppMessage/models/slide-up-message.js +25 -27
- package/src/InAppMessage/models/templated-in-app-message.js +12 -7
- package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
- package/src/InAppMessage/types.js +1 -0
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
- package/src/InAppMessage/ui/show-in-app-message.js +95 -89
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -0
- 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 +20 -20
- package/src/Push/push-manager.js +192 -174
- package/src/Push/request-push-permission.js +4 -3
- package/src/Push/types.js +1 -0
- package/src/Push/unregister-push.js +2 -2
- package/src/Push/utils/push-utils.js +10 -10
- package/src/User/types.js +1 -0
- package/src/User/user-manager.js +24 -24
- package/src/User/user.js +117 -105
- package/src/common/base-feed.js +7 -7
- package/src/common/base-provider.js +2 -2
- package/src/common/constants.js +6 -0
- package/src/common/event-logger.js +6 -6
- package/src/common/feed-display.js +18 -18
- package/src/common/types.js +1 -0
- package/src/l10n/l10n-manager-factory.js +5 -5
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +204 -202
- package/src/managers/device-manager.js +23 -23
- package/src/managers/network-manager.js +96 -82
- package/src/managers/server-config-manager.js +60 -42
- package/src/managers/session-manager.js +41 -41
- package/src/managers/storage-manager-factory.js +15 -15
- package/src/managers/storage-manager.js +165 -155
- package/src/managers/subscription-manager.js +11 -11
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +7 -7
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +7 -7
- package/src/models/push-token.js +7 -7
- package/src/models/request-result.js +3 -3
- package/src/models/server-config.js +20 -20
- package/src/request-controller.js +176 -174
- package/src/triggers/models/custom-event-data.js +6 -6
- package/src/triggers/models/custom-event-property-data.js +9 -9
- package/src/triggers/models/filter-set.js +9 -9
- package/src/triggers/models/filter.js +64 -64
- package/src/triggers/models/in-app-message-click-data.js +12 -12
- package/src/triggers/models/purchase-data.js +3 -3
- package/src/triggers/models/purchase-property-data.js +9 -9
- package/src/triggers/models/push-click-data.js +5 -5
- package/src/triggers/models/trigger-condition.js +52 -52
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +42 -42
- package/src/triggers/triggers-provider-factory.js +8 -8
- package/src/triggers/triggers-provider.js +171 -168
- package/src/types.js +1 -0
- 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 +1 -1
- package/src/util/braze-actions.js +20 -20
- package/src/util/browser-detector.js +22 -22
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/code-utils.js +1 -1
- package/src/util/color-utils.js +2 -2
- package/src/util/component-utils.js +2 -2
- package/src/util/deprecation-utils.js +1 -1
- package/src/util/device-constants.js +5 -5
- package/src/util/dom-utils.js +2 -2
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +11 -11
- package/src/util/request-header-utils.js +23 -0
- package/src/util/string-utils.js +1 -1
- package/src/util/user-agent-parser.js +20 -20
- package/src/util/validation-utils.js +44 -44
- package/src/util/window-utils.js +3 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import V from "../util/browser-detector.js";
|
|
2
2
|
import ue from "../models/braze-event.js";
|
|
3
3
|
import _t from "../models/identifier.js";
|
|
4
4
|
import {
|
|
5
5
|
isArray as p,
|
|
6
|
-
keys as
|
|
7
|
-
validateValueIsFromEnum as
|
|
6
|
+
keys as oo,
|
|
7
|
+
validateValueIsFromEnum as H,
|
|
8
8
|
values as Lt
|
|
9
9
|
} from "../util/code-utils.js";
|
|
10
10
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
@@ -12,80 +12,83 @@ import { User } from "../User/index.js";
|
|
|
12
12
|
export const STORAGE_KEYS = {
|
|
13
13
|
eu: {
|
|
14
14
|
su: "ab.storage.userId",
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
oa: "ab.storage.deviceId",
|
|
16
|
+
Wh: "ab.storage.sessionId"
|
|
17
17
|
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
k: {
|
|
19
|
+
_a: "ab.test",
|
|
20
|
+
Ia: "ab.storage.events",
|
|
21
|
+
Ka: "ab.storage.attributes",
|
|
22
|
+
Ya: "ab.storage.attributes.anonymous_user",
|
|
23
|
+
ma: "ab.storage.device",
|
|
24
|
+
ga: "ab.storage.sdk_metadata",
|
|
25
|
+
qa: "ab.storage.session_id_for_cached_metadata",
|
|
26
|
+
xn: "ab.storage.pushToken",
|
|
27
|
+
ki: "ab.storage.newsFeed",
|
|
28
|
+
Ai: "ab.storage.lastNewsFeedRefresh",
|
|
29
|
+
L: "ab.storage.cardImpressions",
|
|
30
|
+
ll: "ab.storage.serverConfig",
|
|
31
|
+
Na: "ab.storage.triggers",
|
|
32
|
+
Ga: "ab.storage.triggers.ts",
|
|
33
|
+
qh: "ab.storage.messagingSessionStart",
|
|
34
|
+
Zt: "ab.storage.cc",
|
|
35
35
|
vs: "ab.storage.ccLastFullSync",
|
|
36
36
|
ys: "ab.storage.ccLastCardUpdated",
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
Ws: "ab.storage.ccLastClientRequest",
|
|
38
|
+
ui: "ab.storage.ccRateLimitCurrentTokenCount",
|
|
39
|
+
C: "ab.storage.ccClicks",
|
|
40
|
+
K: "ab.storage.ccImpressions",
|
|
41
|
+
G: "ab.storage.ccDismissals",
|
|
42
|
+
Ua: "ab.storage.lastDisplayedTriggerTimesById",
|
|
43
|
+
La: "ab.storage.lastDisplayedTriggerTime",
|
|
44
|
+
Fa: "ab.storage.triggerFireInstancesById",
|
|
45
|
+
bu: "ab.storage.signature",
|
|
46
|
+
Fs: "ab.storage.brazeSyncRetryCount",
|
|
47
|
+
Ss: "ab.storage.sdkVersion",
|
|
48
|
+
Di: "ab.storage.ff",
|
|
49
|
+
$i: "ab.storage.ffLastRefreshAt",
|
|
50
|
+
Pa: "ab.storage.lastReqToEndpoint"
|
|
48
51
|
},
|
|
49
|
-
|
|
52
|
+
re: "ab.optOut"
|
|
50
53
|
};
|
|
51
|
-
export default class
|
|
54
|
+
export default class O {
|
|
52
55
|
constructor(t, e) {
|
|
53
|
-
(this.
|
|
56
|
+
(this.Ja = t), (this.Va = e);
|
|
54
57
|
}
|
|
55
58
|
uu(t, e) {
|
|
56
59
|
let s = e;
|
|
57
|
-
null != e && e instanceof _t && (s = e.ss()), this.
|
|
60
|
+
null != e && e instanceof _t && (s = e.ss()), this.Ja.store(t, s);
|
|
58
61
|
}
|
|
59
|
-
|
|
62
|
+
Ha(t) {
|
|
60
63
|
const e = this.tu(t);
|
|
61
|
-
null != e && ((e.
|
|
64
|
+
null != e && ((e.Jh = new Date().valueOf()), this.uu(t, e));
|
|
62
65
|
}
|
|
63
66
|
tu(t) {
|
|
64
|
-
return _t.
|
|
67
|
+
return _t.Tn(this.Ja.wr(t));
|
|
65
68
|
}
|
|
66
|
-
|
|
67
|
-
this.
|
|
69
|
+
Yh(t) {
|
|
70
|
+
this.Ja.remove(t);
|
|
68
71
|
}
|
|
69
|
-
|
|
72
|
+
co(t) {
|
|
70
73
|
if (null == t || 0 === t.length) return !1;
|
|
71
74
|
p(t) || (t = [t]);
|
|
72
|
-
let e = this.
|
|
75
|
+
let e = this.Va.wr(STORAGE_KEYS.k.Ia);
|
|
73
76
|
(null != e && p(e)) || (e = []);
|
|
74
77
|
for (let s = 0; s < t.length; s++) e.push(t[s].ss());
|
|
75
|
-
return this.
|
|
78
|
+
return this.Va.store(STORAGE_KEYS.k.Ia, e);
|
|
76
79
|
}
|
|
77
|
-
|
|
78
|
-
return null != t && this.
|
|
80
|
+
Qh(t) {
|
|
81
|
+
return null != t && this.co([t]);
|
|
79
82
|
}
|
|
80
|
-
|
|
81
|
-
let t = this.
|
|
82
|
-
this.
|
|
83
|
+
Wa() {
|
|
84
|
+
let t = this.Va.wr(STORAGE_KEYS.k.Ia);
|
|
85
|
+
this.Va.remove(STORAGE_KEYS.k.Ia), null == t && (t = []);
|
|
83
86
|
const e = [];
|
|
84
87
|
let s = !1,
|
|
85
88
|
o = null;
|
|
86
89
|
if (p(t))
|
|
87
90
|
for (let s = 0; s < t.length; s++)
|
|
88
|
-
ue.
|
|
91
|
+
ue.Za(t[s]) ? e.push(ue.Tn(t[s])) : (o = s);
|
|
89
92
|
else s = !0;
|
|
90
93
|
if (s || null != o) {
|
|
91
94
|
let n = "Stored events could not be deserialized as Events";
|
|
@@ -98,148 +101,153 @@ export default class G {
|
|
|
98
101
|
typeof t +
|
|
99
102
|
": " +
|
|
100
103
|
JSON.stringify(t)),
|
|
101
|
-
e.push(new ue(null, r.
|
|
104
|
+
e.push(new ue(null, r.q.Is, new Date().valueOf(), null, { e: n }));
|
|
102
105
|
}
|
|
103
106
|
return e;
|
|
104
107
|
}
|
|
105
|
-
|
|
108
|
+
D(t, e) {
|
|
106
109
|
return (
|
|
107
|
-
!!
|
|
108
|
-
STORAGE_KEYS.
|
|
110
|
+
!!H(
|
|
111
|
+
STORAGE_KEYS.k,
|
|
109
112
|
t,
|
|
110
113
|
"StorageManager cannot store object.",
|
|
111
114
|
"STORAGE_KEYS.OBJECTS"
|
|
112
|
-
) && this.
|
|
115
|
+
) && this.Va.store(t, e)
|
|
113
116
|
);
|
|
114
117
|
}
|
|
115
|
-
|
|
118
|
+
v(t) {
|
|
116
119
|
return (
|
|
117
|
-
!!
|
|
118
|
-
STORAGE_KEYS.
|
|
120
|
+
!!H(
|
|
121
|
+
STORAGE_KEYS.k,
|
|
119
122
|
t,
|
|
120
123
|
"StorageManager cannot retrieve object.",
|
|
121
124
|
"STORAGE_KEYS.OBJECTS"
|
|
122
|
-
) && this.
|
|
125
|
+
) && this.Va.wr(t)
|
|
123
126
|
);
|
|
124
127
|
}
|
|
125
|
-
|
|
128
|
+
ri(t) {
|
|
126
129
|
return (
|
|
127
|
-
!!
|
|
128
|
-
STORAGE_KEYS.
|
|
130
|
+
!!H(
|
|
131
|
+
STORAGE_KEYS.k,
|
|
129
132
|
t,
|
|
130
133
|
"StorageManager cannot remove object.",
|
|
131
134
|
"STORAGE_KEYS.OBJECTS"
|
|
132
|
-
) && (this.
|
|
135
|
+
) && (this.Va.remove(t), !0)
|
|
133
136
|
);
|
|
134
137
|
}
|
|
138
|
+
xo(t) {
|
|
139
|
+
const e = oo(STORAGE_KEYS.eu),
|
|
140
|
+
s = new O.ee(t);
|
|
141
|
+
for (const t of e) s.remove(STORAGE_KEYS.eu[t]);
|
|
142
|
+
}
|
|
135
143
|
clearData() {
|
|
136
|
-
const t =
|
|
137
|
-
e =
|
|
144
|
+
const t = oo(STORAGE_KEYS.eu),
|
|
145
|
+
e = oo(STORAGE_KEYS.k);
|
|
138
146
|
for (let e = 0; e < t.length; e++) {
|
|
139
147
|
const s = t[e];
|
|
140
|
-
this.
|
|
148
|
+
this.Ja.remove(STORAGE_KEYS.eu[s]);
|
|
141
149
|
}
|
|
142
150
|
for (let t = 0; t < e.length; t++) {
|
|
143
151
|
const s = e[t];
|
|
144
|
-
this.
|
|
152
|
+
this.Va.remove(STORAGE_KEYS.k[s]);
|
|
145
153
|
}
|
|
146
154
|
}
|
|
147
|
-
|
|
148
|
-
return t || STORAGE_KEYS.
|
|
155
|
+
$a(t) {
|
|
156
|
+
return t || STORAGE_KEYS.k.Ya;
|
|
149
157
|
}
|
|
150
|
-
|
|
151
|
-
let e = this.
|
|
158
|
+
wa(t) {
|
|
159
|
+
let e = this.Va.wr(STORAGE_KEYS.k.Ka);
|
|
152
160
|
null == e && (e = {});
|
|
153
|
-
const s = this
|
|
161
|
+
const s = this.$a(t[User.Hn]);
|
|
154
162
|
for (let r in t)
|
|
155
|
-
r === User.
|
|
163
|
+
r === User.Hn ||
|
|
156
164
|
(null != e[s] && null != e[s][r]) ||
|
|
157
|
-
this.mu(t[User.
|
|
165
|
+
this.mu(t[User.Hn], r, t[r]);
|
|
158
166
|
}
|
|
159
167
|
mu(t, e, s) {
|
|
160
|
-
let r = this.
|
|
168
|
+
let r = this.Va.wr(STORAGE_KEYS.k.Ka);
|
|
161
169
|
null == r && (r = {});
|
|
162
|
-
const o = this
|
|
170
|
+
const o = this.$a(t);
|
|
163
171
|
let n = r[o];
|
|
164
172
|
if (
|
|
165
|
-
(null == n && ((n = {}), null != t && (n[User.
|
|
173
|
+
(null == n && ((n = {}), null != t && (n[User.Hn] = t)), e === User.lu)
|
|
166
174
|
) {
|
|
167
175
|
null == n[e] && (n[e] = {});
|
|
168
176
|
for (let t in s) n[e][t] = s[t];
|
|
169
177
|
} else n[e] = s;
|
|
170
|
-
return (r[o] = n), this.
|
|
178
|
+
return (r[o] = n), this.Va.store(STORAGE_KEYS.k.Ka, r);
|
|
171
179
|
}
|
|
172
|
-
|
|
173
|
-
const t = this.
|
|
174
|
-
this.
|
|
180
|
+
tE() {
|
|
181
|
+
const t = this.Va.wr(STORAGE_KEYS.k.Ka);
|
|
182
|
+
this.Va.remove(STORAGE_KEYS.k.Ka);
|
|
175
183
|
const e = [];
|
|
176
184
|
for (let s in t) null != t[s] && e.push(t[s]);
|
|
177
185
|
return e;
|
|
178
186
|
}
|
|
179
187
|
ou(t) {
|
|
180
|
-
const e = this.
|
|
188
|
+
const e = this.Va.wr(STORAGE_KEYS.k.Ka);
|
|
181
189
|
if (null != e) {
|
|
182
|
-
const s = this
|
|
190
|
+
const s = this.$a(null),
|
|
183
191
|
r = e[s];
|
|
184
192
|
null != r &&
|
|
185
193
|
((e[s] = void 0),
|
|
186
|
-
this.
|
|
187
|
-
(r[User.
|
|
188
|
-
this.
|
|
194
|
+
this.Va.store(STORAGE_KEYS.k.Ka, e),
|
|
195
|
+
(r[User.Hn] = t),
|
|
196
|
+
this.wa(r));
|
|
189
197
|
}
|
|
190
|
-
const s = this.tu(STORAGE_KEYS.eu.
|
|
198
|
+
const s = this.tu(STORAGE_KEYS.eu.Wh);
|
|
191
199
|
let r = null;
|
|
192
200
|
null != s && (r = s.iu);
|
|
193
|
-
const o = this.
|
|
201
|
+
const o = this.Wa();
|
|
194
202
|
if (null != o)
|
|
195
203
|
for (let e = 0; e < o.length; e++) {
|
|
196
204
|
const s = o[e];
|
|
197
|
-
null == s.userId && s.sessionId == r && (s.userId = t), this.
|
|
205
|
+
null == s.userId && s.sessionId == r && (s.userId = t), this.Qh(s);
|
|
198
206
|
}
|
|
199
207
|
}
|
|
200
|
-
|
|
201
|
-
return this.
|
|
208
|
+
eE() {
|
|
209
|
+
return this.Va.sE;
|
|
202
210
|
}
|
|
203
211
|
}
|
|
204
|
-
|
|
212
|
+
O.Ma = class {
|
|
205
213
|
constructor(t) {
|
|
206
|
-
(this.
|
|
214
|
+
(this.Ko = t), (this.sE = V.rE() ? 3 : 10);
|
|
207
215
|
}
|
|
208
|
-
|
|
209
|
-
return t + "." + this.
|
|
216
|
+
oE(t) {
|
|
217
|
+
return t + "." + this.Ko;
|
|
210
218
|
}
|
|
211
219
|
store(t, e) {
|
|
212
220
|
const s = { v: e };
|
|
213
221
|
try {
|
|
214
|
-
return localStorage.setItem(this.
|
|
222
|
+
return localStorage.setItem(this.oE(t), JSON.stringify(s)), !0;
|
|
215
223
|
} catch (t) {
|
|
216
|
-
return r.
|
|
224
|
+
return r.j.info("Storage failure: " + t.message), !1;
|
|
217
225
|
}
|
|
218
226
|
}
|
|
219
|
-
|
|
227
|
+
wr(t) {
|
|
220
228
|
try {
|
|
221
|
-
const e = JSON.parse(localStorage.getItem(this.
|
|
229
|
+
const e = JSON.parse(localStorage.getItem(this.oE(t)));
|
|
222
230
|
return null == e ? null : e.v;
|
|
223
231
|
} catch (t) {
|
|
224
|
-
return r.
|
|
232
|
+
return r.j.info("Storage retrieval failure: " + t.message), null;
|
|
225
233
|
}
|
|
226
234
|
}
|
|
227
235
|
remove(t) {
|
|
228
236
|
try {
|
|
229
|
-
localStorage.removeItem(this.
|
|
237
|
+
localStorage.removeItem(this.oE(t));
|
|
230
238
|
} catch (t) {
|
|
231
|
-
return r.
|
|
239
|
+
return r.j.info("Storage removal failure: " + t.message), !1;
|
|
232
240
|
}
|
|
233
241
|
}
|
|
234
242
|
};
|
|
235
|
-
|
|
243
|
+
O.ee = class {
|
|
236
244
|
constructor(t, e) {
|
|
237
|
-
(this.
|
|
245
|
+
(this.Ko = t), (this.nE = this.aE()), (this.iE = 576e3), (this.EE = !!e);
|
|
238
246
|
}
|
|
239
|
-
|
|
240
|
-
return null != this.
|
|
247
|
+
oE(t) {
|
|
248
|
+
return null != this.Ko ? t + "." + this.Ko : t;
|
|
241
249
|
}
|
|
242
|
-
|
|
250
|
+
aE() {
|
|
243
251
|
let t = 0,
|
|
244
252
|
e = document.location.hostname;
|
|
245
253
|
const s = e.split("."),
|
|
@@ -254,11 +262,11 @@ G.ne = class {
|
|
|
254
262
|
e
|
|
255
263
|
);
|
|
256
264
|
}
|
|
257
|
-
|
|
265
|
+
ne() {
|
|
258
266
|
const t = new Date();
|
|
259
|
-
return t.setTime(t.getTime() + 60 * this.
|
|
267
|
+
return t.setTime(t.getTime() + 60 * this.iE * 1e3), t.getFullYear();
|
|
260
268
|
}
|
|
261
|
-
|
|
269
|
+
lE() {
|
|
262
270
|
const t = Lt(STORAGE_KEYS.eu),
|
|
263
271
|
e = document.cookie.split(";");
|
|
264
272
|
for (let s = 0; s < e.length; s++) {
|
|
@@ -272,45 +280,45 @@ G.ne = class {
|
|
|
272
280
|
}
|
|
273
281
|
if (o) {
|
|
274
282
|
const t = r.split("=")[0];
|
|
275
|
-
-1 === t.indexOf("." + this.
|
|
283
|
+
-1 === t.indexOf("." + this.Ko) && this.SE(t);
|
|
276
284
|
}
|
|
277
285
|
}
|
|
278
286
|
}
|
|
279
287
|
store(t, e) {
|
|
280
|
-
this.
|
|
288
|
+
this.lE();
|
|
281
289
|
const s = new Date();
|
|
282
|
-
s.setTime(s.getTime() + 60 * this.
|
|
290
|
+
s.setTime(s.getTime() + 60 * this.iE * 1e3);
|
|
283
291
|
const o = "expires=" + s.toUTCString(),
|
|
284
|
-
n = "domain=" + this.
|
|
285
|
-
let
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
return
|
|
289
|
-
? (r.
|
|
292
|
+
n = "domain=" + this.nE;
|
|
293
|
+
let a;
|
|
294
|
+
a = this.EE ? e : encodeURIComponent(JSON.stringify(e));
|
|
295
|
+
const i = this.oE(t) + "=" + a + ";" + o + ";" + n + ";path=/";
|
|
296
|
+
return i.length >= 4093
|
|
297
|
+
? (r.j.info(
|
|
290
298
|
"Storage failure: string is " +
|
|
291
|
-
|
|
299
|
+
i.length +
|
|
292
300
|
" chars which is too large to store as a cookie."
|
|
293
301
|
),
|
|
294
302
|
!1)
|
|
295
|
-
: ((document.cookie =
|
|
303
|
+
: ((document.cookie = i), !0);
|
|
296
304
|
}
|
|
297
|
-
|
|
305
|
+
wr(t) {
|
|
298
306
|
const e = [],
|
|
299
|
-
s = this.
|
|
307
|
+
s = this.oE(t) + "=",
|
|
300
308
|
o = document.cookie.split(";");
|
|
301
309
|
for (let n = 0; n < o.length; n++) {
|
|
302
|
-
let
|
|
303
|
-
for (; " " ===
|
|
304
|
-
if (0 ===
|
|
310
|
+
let a = o[n];
|
|
311
|
+
for (; " " === a.charAt(0); ) a = a.substring(1);
|
|
312
|
+
if (0 === a.indexOf(s))
|
|
305
313
|
try {
|
|
306
314
|
let t;
|
|
307
|
-
(t = this.
|
|
308
|
-
?
|
|
309
|
-
: JSON.parse(decodeURIComponent(
|
|
315
|
+
(t = this.EE
|
|
316
|
+
? a.substring(s.length, a.length)
|
|
317
|
+
: JSON.parse(decodeURIComponent(a.substring(s.length, a.length)))),
|
|
310
318
|
e.push(t);
|
|
311
319
|
} catch (e) {
|
|
312
320
|
return (
|
|
313
|
-
r.
|
|
321
|
+
r.j.info("Storage retrieval failure: " + e.message),
|
|
314
322
|
this.remove(t),
|
|
315
323
|
null
|
|
316
324
|
);
|
|
@@ -319,33 +327,33 @@ G.ne = class {
|
|
|
319
327
|
return e.length > 0 ? e[e.length - 1] : null;
|
|
320
328
|
}
|
|
321
329
|
remove(t) {
|
|
322
|
-
this.
|
|
330
|
+
this.SE(this.oE(t));
|
|
323
331
|
}
|
|
324
|
-
|
|
332
|
+
SE(t) {
|
|
325
333
|
const e = t + "=;expires=" + new Date(0).toGMTString();
|
|
326
334
|
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
327
|
-
const s = e + ";domain=" + this.
|
|
335
|
+
const s = e + ";domain=" + this.nE;
|
|
328
336
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
329
337
|
}
|
|
330
338
|
};
|
|
331
|
-
|
|
339
|
+
O.Qa = class {
|
|
332
340
|
constructor() {
|
|
333
|
-
(this.
|
|
341
|
+
(this._E = {}), (this.uE = 5242880), (this.sE = 3);
|
|
334
342
|
}
|
|
335
343
|
store(t, e) {
|
|
336
344
|
const s = { value: e },
|
|
337
|
-
o = this
|
|
338
|
-
return o > this.
|
|
339
|
-
? (r.
|
|
345
|
+
o = this.cE(e);
|
|
346
|
+
return o > this.uE
|
|
347
|
+
? (r.j.info(
|
|
340
348
|
"Storage failure: object is ≈" +
|
|
341
349
|
o +
|
|
342
350
|
" bytes which is greater than the max of " +
|
|
343
|
-
this.
|
|
351
|
+
this.uE
|
|
344
352
|
),
|
|
345
353
|
!1)
|
|
346
|
-
: ((this.
|
|
354
|
+
: ((this._E[t] = s), !0);
|
|
347
355
|
}
|
|
348
|
-
|
|
356
|
+
cE(t) {
|
|
349
357
|
const e = [],
|
|
350
358
|
s = [t];
|
|
351
359
|
let r = 0;
|
|
@@ -361,34 +369,36 @@ G.Oa = class {
|
|
|
361
369
|
}
|
|
362
370
|
return r;
|
|
363
371
|
}
|
|
364
|
-
|
|
365
|
-
const e = this.
|
|
372
|
+
wr(t) {
|
|
373
|
+
const e = this._E[t];
|
|
366
374
|
return null == e ? null : e.value;
|
|
367
375
|
}
|
|
368
376
|
remove(t) {
|
|
369
|
-
this.
|
|
377
|
+
this._E[t] = null;
|
|
370
378
|
}
|
|
371
379
|
};
|
|
372
|
-
|
|
380
|
+
O.xa = class {
|
|
373
381
|
constructor(t, e, s) {
|
|
374
|
-
(this.
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
this.
|
|
382
|
+
(this.Ko = t),
|
|
383
|
+
(this.TE = []),
|
|
384
|
+
e && this.TE.push(new O.ee(t)),
|
|
385
|
+
s && this.TE.push(new O.Ma(t)),
|
|
386
|
+
this.TE.push(new O.Qa(t));
|
|
378
387
|
}
|
|
379
388
|
store(t, e) {
|
|
380
389
|
let s = !0;
|
|
381
|
-
for (let r = 0; r < this.
|
|
390
|
+
for (let r = 0; r < this.TE.length; r++) s = this.TE[r].store(t, e) && s;
|
|
382
391
|
return s;
|
|
383
392
|
}
|
|
384
|
-
|
|
385
|
-
for (let e = 0; e < this.
|
|
386
|
-
const s = this.
|
|
393
|
+
wr(t) {
|
|
394
|
+
for (let e = 0; e < this.TE.length; e++) {
|
|
395
|
+
const s = this.TE[e].wr(t);
|
|
387
396
|
if (null != s) return s;
|
|
388
397
|
}
|
|
389
398
|
return null;
|
|
390
399
|
}
|
|
391
400
|
remove(t) {
|
|
392
|
-
|
|
401
|
+
new O.ee(this.Ko).remove(t);
|
|
402
|
+
for (let e = 0; e < this.TE.length; e++) this.TE[e].remove(t);
|
|
393
403
|
}
|
|
394
404
|
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
|
-
export default class
|
|
2
|
+
export default class E {
|
|
3
3
|
constructor() {
|
|
4
|
-
this.
|
|
4
|
+
this.zo = {};
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
lt(t) {
|
|
7
7
|
if ("function" != typeof t) return null;
|
|
8
|
-
const i = r.
|
|
9
|
-
return (this.
|
|
8
|
+
const i = r.Z.Y();
|
|
9
|
+
return (this.zo[i] = t), i;
|
|
10
10
|
}
|
|
11
11
|
removeSubscription(t) {
|
|
12
|
-
delete this.
|
|
12
|
+
delete this.zo[t];
|
|
13
13
|
}
|
|
14
14
|
removeAllSubscriptions() {
|
|
15
|
-
this.
|
|
15
|
+
this.zo = {};
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
return Object.keys(this.
|
|
17
|
+
fu() {
|
|
18
|
+
return Object.keys(this.zo).length;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
Et(t) {
|
|
21
21
|
const i = [];
|
|
22
|
-
for (let r in this.
|
|
22
|
+
for (let r in this.zo) i.push(this.zo[r](t));
|
|
23
23
|
return i;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Da: "invalid_api_key",
|
|
3
|
+
Sa: "blacklisted",
|
|
4
|
+
va: "no_device_identifier",
|
|
5
|
+
Ba: "invalid_json_response",
|
|
6
|
+
za: "empty_response",
|
|
7
7
|
__: "sdk_auth_error"
|
|
8
8
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isObject as
|
|
1
|
+
import { isObject as Ct } from "../util/code-utils.js";
|
|
2
2
|
import {
|
|
3
|
-
convertMsToSeconds as
|
|
3
|
+
convertMsToSeconds as h,
|
|
4
4
|
timestampOrNow as Jt
|
|
5
5
|
} from "../util/date-utils.js";
|
|
6
6
|
export default class ue {
|
|
@@ -11,10 +11,10 @@ export default class ue {
|
|
|
11
11
|
(this.sessionId = r),
|
|
12
12
|
(this.data = e);
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
Wi() {
|
|
15
15
|
const t = {
|
|
16
16
|
name: this.type,
|
|
17
|
-
time:
|
|
17
|
+
time: h(this.time),
|
|
18
18
|
data: this.data || {},
|
|
19
19
|
session_id: this.sessionId
|
|
20
20
|
};
|
|
@@ -32,10 +32,10 @@ export default class ue {
|
|
|
32
32
|
static fromJson(t) {
|
|
33
33
|
return new ue(t.user_id, t.name, t.time, t.session_id, t.data);
|
|
34
34
|
}
|
|
35
|
-
static
|
|
36
|
-
return null != t &&
|
|
35
|
+
static Za(t) {
|
|
36
|
+
return null != t && Ct(t) && null != t.t && "" !== t.t;
|
|
37
37
|
}
|
|
38
|
-
static
|
|
38
|
+
static Tn(t) {
|
|
39
39
|
return new ue(t.u, t.t, t.ts, t.s, t.d);
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/models/device.js
CHANGED
package/src/models/identifier.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
2
|
export default class _t {
|
|
3
3
|
constructor(t, e, s) {
|
|
4
|
-
null == t && (t = r.
|
|
4
|
+
null == t && (t = r.Z.Y()),
|
|
5
5
|
(s = parseInt(s)),
|
|
6
6
|
(isNaN(s) || 0 === s) && (s = new Date().valueOf()),
|
|
7
7
|
(this.iu = t),
|
|
8
|
-
(this.
|
|
9
|
-
(this.
|
|
10
|
-
(this.
|
|
8
|
+
(this.Hh = s),
|
|
9
|
+
(this.Jh = new Date().valueOf()),
|
|
10
|
+
(this.Bh = e);
|
|
11
11
|
}
|
|
12
12
|
ss() {
|
|
13
|
-
return { g: this.iu, e: this.
|
|
13
|
+
return { g: this.iu, e: this.Bh, c: this.Hh, l: this.Jh };
|
|
14
14
|
}
|
|
15
|
-
static
|
|
15
|
+
static Tn(t) {
|
|
16
16
|
if (null == t || null == t.g) return null;
|
|
17
17
|
const e = new _t(t.g, t.e, t.c);
|
|
18
|
-
return (e.
|
|
18
|
+
return (e.Jh = t.l), e;
|
|
19
19
|
}
|
|
20
20
|
}
|