@braze/web-sdk 4.7.2 → 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 +202 -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 +163 -160
- 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 +36 -36
- package/src/triggers/triggers-provider-factory.js +8 -8
- package/src/triggers/triggers-provider.js +165 -162
- 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,153 +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
|
}
|
|
135
|
-
|
|
136
|
-
const e =
|
|
137
|
-
s = new
|
|
138
|
+
xo(t) {
|
|
139
|
+
const e = oo(STORAGE_KEYS.eu),
|
|
140
|
+
s = new O.ee(t);
|
|
138
141
|
for (const t of e) s.remove(STORAGE_KEYS.eu[t]);
|
|
139
142
|
}
|
|
140
143
|
clearData() {
|
|
141
|
-
const t =
|
|
142
|
-
e =
|
|
144
|
+
const t = oo(STORAGE_KEYS.eu),
|
|
145
|
+
e = oo(STORAGE_KEYS.k);
|
|
143
146
|
for (let e = 0; e < t.length; e++) {
|
|
144
147
|
const s = t[e];
|
|
145
|
-
this.
|
|
148
|
+
this.Ja.remove(STORAGE_KEYS.eu[s]);
|
|
146
149
|
}
|
|
147
150
|
for (let t = 0; t < e.length; t++) {
|
|
148
151
|
const s = e[t];
|
|
149
|
-
this.
|
|
152
|
+
this.Va.remove(STORAGE_KEYS.k[s]);
|
|
150
153
|
}
|
|
151
154
|
}
|
|
152
|
-
|
|
153
|
-
return t || STORAGE_KEYS.
|
|
155
|
+
$a(t) {
|
|
156
|
+
return t || STORAGE_KEYS.k.Ya;
|
|
154
157
|
}
|
|
155
|
-
|
|
156
|
-
let e = this.
|
|
158
|
+
wa(t) {
|
|
159
|
+
let e = this.Va.wr(STORAGE_KEYS.k.Ka);
|
|
157
160
|
null == e && (e = {});
|
|
158
|
-
const s = this
|
|
161
|
+
const s = this.$a(t[User.Hn]);
|
|
159
162
|
for (let r in t)
|
|
160
|
-
r === User.
|
|
163
|
+
r === User.Hn ||
|
|
161
164
|
(null != e[s] && null != e[s][r]) ||
|
|
162
|
-
this.mu(t[User.
|
|
165
|
+
this.mu(t[User.Hn], r, t[r]);
|
|
163
166
|
}
|
|
164
167
|
mu(t, e, s) {
|
|
165
|
-
let r = this.
|
|
168
|
+
let r = this.Va.wr(STORAGE_KEYS.k.Ka);
|
|
166
169
|
null == r && (r = {});
|
|
167
|
-
const o = this
|
|
170
|
+
const o = this.$a(t);
|
|
168
171
|
let n = r[o];
|
|
169
172
|
if (
|
|
170
|
-
(null == n && ((n = {}), null != t && (n[User.
|
|
173
|
+
(null == n && ((n = {}), null != t && (n[User.Hn] = t)), e === User.lu)
|
|
171
174
|
) {
|
|
172
175
|
null == n[e] && (n[e] = {});
|
|
173
176
|
for (let t in s) n[e][t] = s[t];
|
|
174
177
|
} else n[e] = s;
|
|
175
|
-
return (r[o] = n), this.
|
|
178
|
+
return (r[o] = n), this.Va.store(STORAGE_KEYS.k.Ka, r);
|
|
176
179
|
}
|
|
177
|
-
|
|
178
|
-
const t = this.
|
|
179
|
-
this.
|
|
180
|
+
tE() {
|
|
181
|
+
const t = this.Va.wr(STORAGE_KEYS.k.Ka);
|
|
182
|
+
this.Va.remove(STORAGE_KEYS.k.Ka);
|
|
180
183
|
const e = [];
|
|
181
184
|
for (let s in t) null != t[s] && e.push(t[s]);
|
|
182
185
|
return e;
|
|
183
186
|
}
|
|
184
187
|
ou(t) {
|
|
185
|
-
const e = this.
|
|
188
|
+
const e = this.Va.wr(STORAGE_KEYS.k.Ka);
|
|
186
189
|
if (null != e) {
|
|
187
|
-
const s = this
|
|
190
|
+
const s = this.$a(null),
|
|
188
191
|
r = e[s];
|
|
189
192
|
null != r &&
|
|
190
193
|
((e[s] = void 0),
|
|
191
|
-
this.
|
|
192
|
-
(r[User.
|
|
193
|
-
this.
|
|
194
|
+
this.Va.store(STORAGE_KEYS.k.Ka, e),
|
|
195
|
+
(r[User.Hn] = t),
|
|
196
|
+
this.wa(r));
|
|
194
197
|
}
|
|
195
|
-
const s = this.tu(STORAGE_KEYS.eu.
|
|
198
|
+
const s = this.tu(STORAGE_KEYS.eu.Wh);
|
|
196
199
|
let r = null;
|
|
197
200
|
null != s && (r = s.iu);
|
|
198
|
-
const o = this.
|
|
201
|
+
const o = this.Wa();
|
|
199
202
|
if (null != o)
|
|
200
203
|
for (let e = 0; e < o.length; e++) {
|
|
201
204
|
const s = o[e];
|
|
202
|
-
null == s.userId && s.sessionId == r && (s.userId = t), this.
|
|
205
|
+
null == s.userId && s.sessionId == r && (s.userId = t), this.Qh(s);
|
|
203
206
|
}
|
|
204
207
|
}
|
|
205
|
-
|
|
206
|
-
return this.
|
|
208
|
+
eE() {
|
|
209
|
+
return this.Va.sE;
|
|
207
210
|
}
|
|
208
211
|
}
|
|
209
|
-
|
|
212
|
+
O.Ma = class {
|
|
210
213
|
constructor(t) {
|
|
211
|
-
(this.
|
|
214
|
+
(this.Ko = t), (this.sE = V.rE() ? 3 : 10);
|
|
212
215
|
}
|
|
213
|
-
|
|
214
|
-
return t + "." + this.
|
|
216
|
+
oE(t) {
|
|
217
|
+
return t + "." + this.Ko;
|
|
215
218
|
}
|
|
216
219
|
store(t, e) {
|
|
217
220
|
const s = { v: e };
|
|
218
221
|
try {
|
|
219
|
-
return localStorage.setItem(this.
|
|
222
|
+
return localStorage.setItem(this.oE(t), JSON.stringify(s)), !0;
|
|
220
223
|
} catch (t) {
|
|
221
|
-
return r.
|
|
224
|
+
return r.j.info("Storage failure: " + t.message), !1;
|
|
222
225
|
}
|
|
223
226
|
}
|
|
224
|
-
|
|
227
|
+
wr(t) {
|
|
225
228
|
try {
|
|
226
|
-
const e = JSON.parse(localStorage.getItem(this.
|
|
229
|
+
const e = JSON.parse(localStorage.getItem(this.oE(t)));
|
|
227
230
|
return null == e ? null : e.v;
|
|
228
231
|
} catch (t) {
|
|
229
|
-
return r.
|
|
232
|
+
return r.j.info("Storage retrieval failure: " + t.message), null;
|
|
230
233
|
}
|
|
231
234
|
}
|
|
232
235
|
remove(t) {
|
|
233
236
|
try {
|
|
234
|
-
localStorage.removeItem(this.
|
|
237
|
+
localStorage.removeItem(this.oE(t));
|
|
235
238
|
} catch (t) {
|
|
236
|
-
return r.
|
|
239
|
+
return r.j.info("Storage removal failure: " + t.message), !1;
|
|
237
240
|
}
|
|
238
241
|
}
|
|
239
242
|
};
|
|
240
|
-
|
|
243
|
+
O.ee = class {
|
|
241
244
|
constructor(t, e) {
|
|
242
|
-
(this.
|
|
245
|
+
(this.Ko = t), (this.nE = this.aE()), (this.iE = 576e3), (this.EE = !!e);
|
|
243
246
|
}
|
|
244
|
-
|
|
245
|
-
return null != this.
|
|
247
|
+
oE(t) {
|
|
248
|
+
return null != this.Ko ? t + "." + this.Ko : t;
|
|
246
249
|
}
|
|
247
|
-
|
|
250
|
+
aE() {
|
|
248
251
|
let t = 0,
|
|
249
252
|
e = document.location.hostname;
|
|
250
253
|
const s = e.split("."),
|
|
@@ -259,11 +262,11 @@ G.ne = class {
|
|
|
259
262
|
e
|
|
260
263
|
);
|
|
261
264
|
}
|
|
262
|
-
|
|
265
|
+
ne() {
|
|
263
266
|
const t = new Date();
|
|
264
|
-
return t.setTime(t.getTime() + 60 * this.
|
|
267
|
+
return t.setTime(t.getTime() + 60 * this.iE * 1e3), t.getFullYear();
|
|
265
268
|
}
|
|
266
|
-
|
|
269
|
+
lE() {
|
|
267
270
|
const t = Lt(STORAGE_KEYS.eu),
|
|
268
271
|
e = document.cookie.split(";");
|
|
269
272
|
for (let s = 0; s < e.length; s++) {
|
|
@@ -277,45 +280,45 @@ G.ne = class {
|
|
|
277
280
|
}
|
|
278
281
|
if (o) {
|
|
279
282
|
const t = r.split("=")[0];
|
|
280
|
-
-1 === t.indexOf("." + this.
|
|
283
|
+
-1 === t.indexOf("." + this.Ko) && this.SE(t);
|
|
281
284
|
}
|
|
282
285
|
}
|
|
283
286
|
}
|
|
284
287
|
store(t, e) {
|
|
285
|
-
this.
|
|
288
|
+
this.lE();
|
|
286
289
|
const s = new Date();
|
|
287
|
-
s.setTime(s.getTime() + 60 * this.
|
|
290
|
+
s.setTime(s.getTime() + 60 * this.iE * 1e3);
|
|
288
291
|
const o = "expires=" + s.toUTCString(),
|
|
289
|
-
n = "domain=" + this.
|
|
290
|
-
let
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
return
|
|
294
|
-
? (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(
|
|
295
298
|
"Storage failure: string is " +
|
|
296
|
-
|
|
299
|
+
i.length +
|
|
297
300
|
" chars which is too large to store as a cookie."
|
|
298
301
|
),
|
|
299
302
|
!1)
|
|
300
|
-
: ((document.cookie =
|
|
303
|
+
: ((document.cookie = i), !0);
|
|
301
304
|
}
|
|
302
|
-
|
|
305
|
+
wr(t) {
|
|
303
306
|
const e = [],
|
|
304
|
-
s = this.
|
|
307
|
+
s = this.oE(t) + "=",
|
|
305
308
|
o = document.cookie.split(";");
|
|
306
309
|
for (let n = 0; n < o.length; n++) {
|
|
307
|
-
let
|
|
308
|
-
for (; " " ===
|
|
309
|
-
if (0 ===
|
|
310
|
+
let a = o[n];
|
|
311
|
+
for (; " " === a.charAt(0); ) a = a.substring(1);
|
|
312
|
+
if (0 === a.indexOf(s))
|
|
310
313
|
try {
|
|
311
314
|
let t;
|
|
312
|
-
(t = this.
|
|
313
|
-
?
|
|
314
|
-
: JSON.parse(decodeURIComponent(
|
|
315
|
+
(t = this.EE
|
|
316
|
+
? a.substring(s.length, a.length)
|
|
317
|
+
: JSON.parse(decodeURIComponent(a.substring(s.length, a.length)))),
|
|
315
318
|
e.push(t);
|
|
316
319
|
} catch (e) {
|
|
317
320
|
return (
|
|
318
|
-
r.
|
|
321
|
+
r.j.info("Storage retrieval failure: " + e.message),
|
|
319
322
|
this.remove(t),
|
|
320
323
|
null
|
|
321
324
|
);
|
|
@@ -324,33 +327,33 @@ G.ne = class {
|
|
|
324
327
|
return e.length > 0 ? e[e.length - 1] : null;
|
|
325
328
|
}
|
|
326
329
|
remove(t) {
|
|
327
|
-
this.
|
|
330
|
+
this.SE(this.oE(t));
|
|
328
331
|
}
|
|
329
|
-
|
|
332
|
+
SE(t) {
|
|
330
333
|
const e = t + "=;expires=" + new Date(0).toGMTString();
|
|
331
334
|
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
332
|
-
const s = e + ";domain=" + this.
|
|
335
|
+
const s = e + ";domain=" + this.nE;
|
|
333
336
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
334
337
|
}
|
|
335
338
|
};
|
|
336
|
-
|
|
339
|
+
O.Qa = class {
|
|
337
340
|
constructor() {
|
|
338
|
-
(this.
|
|
341
|
+
(this._E = {}), (this.uE = 5242880), (this.sE = 3);
|
|
339
342
|
}
|
|
340
343
|
store(t, e) {
|
|
341
344
|
const s = { value: e },
|
|
342
|
-
o = this.
|
|
343
|
-
return o > this
|
|
344
|
-
? (r.
|
|
345
|
+
o = this.cE(e);
|
|
346
|
+
return o > this.uE
|
|
347
|
+
? (r.j.info(
|
|
345
348
|
"Storage failure: object is ≈" +
|
|
346
349
|
o +
|
|
347
350
|
" bytes which is greater than the max of " +
|
|
348
|
-
this
|
|
351
|
+
this.uE
|
|
349
352
|
),
|
|
350
353
|
!1)
|
|
351
|
-
: ((this.
|
|
354
|
+
: ((this._E[t] = s), !0);
|
|
352
355
|
}
|
|
353
|
-
|
|
356
|
+
cE(t) {
|
|
354
357
|
const e = [],
|
|
355
358
|
s = [t];
|
|
356
359
|
let r = 0;
|
|
@@ -366,36 +369,36 @@ G.Oa = class {
|
|
|
366
369
|
}
|
|
367
370
|
return r;
|
|
368
371
|
}
|
|
369
|
-
|
|
370
|
-
const e = this.
|
|
372
|
+
wr(t) {
|
|
373
|
+
const e = this._E[t];
|
|
371
374
|
return null == e ? null : e.value;
|
|
372
375
|
}
|
|
373
376
|
remove(t) {
|
|
374
|
-
this.
|
|
377
|
+
this._E[t] = null;
|
|
375
378
|
}
|
|
376
379
|
};
|
|
377
|
-
|
|
380
|
+
O.xa = class {
|
|
378
381
|
constructor(t, e, s) {
|
|
379
|
-
(this.
|
|
380
|
-
(this.
|
|
381
|
-
e && this.
|
|
382
|
-
s && this.
|
|
383
|
-
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));
|
|
384
387
|
}
|
|
385
388
|
store(t, e) {
|
|
386
389
|
let s = !0;
|
|
387
|
-
for (let r = 0; r < this.
|
|
390
|
+
for (let r = 0; r < this.TE.length; r++) s = this.TE[r].store(t, e) && s;
|
|
388
391
|
return s;
|
|
389
392
|
}
|
|
390
|
-
|
|
391
|
-
for (let e = 0; e < this.
|
|
392
|
-
const s = this.
|
|
393
|
+
wr(t) {
|
|
394
|
+
for (let e = 0; e < this.TE.length; e++) {
|
|
395
|
+
const s = this.TE[e].wr(t);
|
|
393
396
|
if (null != s) return s;
|
|
394
397
|
}
|
|
395
398
|
return null;
|
|
396
399
|
}
|
|
397
400
|
remove(t) {
|
|
398
|
-
new
|
|
399
|
-
for (let e = 0; e < this.
|
|
401
|
+
new O.ee(this.Ko).remove(t);
|
|
402
|
+
for (let e = 0; e < this.TE.length; e++) this.TE[e].remove(t);
|
|
400
403
|
}
|
|
401
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
|
}
|