@braze/web-sdk 4.3.0 → 4.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/index.d.ts +68 -6
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +8 -1
- package/shared-lib/encoding-utils.js +12 -1
- package/shared-lib/event-types.js +32 -1
- package/shared-lib/guid.js +10 -1
- package/shared-lib/indexed-db-adapter.js +315 -1
- package/shared-lib/logger.js +38 -1
- package/shared-lib/supported-options.js +26 -1
- package/src/Card/card-manager-factory.js +14 -1
- package/src/Card/card-manager.js +72 -1
- package/src/Card/display/card-display.js +134 -1
- package/src/Card/index.js +5 -1
- package/src/Card/log-card-click.js +11 -1
- package/src/Card/log-card-dismissal.js +11 -1
- package/src/Card/log-card-impressions.js +13 -1
- package/src/Card/log-content-card-impressions.js +4 -1
- package/src/Card/models/banner.js +30 -1
- package/src/Card/models/captioned-image.js +32 -1
- package/src/Card/models/card.js +175 -1
- package/src/Card/models/classic-card.js +32 -1
- package/src/Card/models/control-card.js +39 -1
- package/src/Card/models/index.js +5 -1
- package/src/Card/util/card-factory.js +104 -1
- package/src/ContentCards/content-cards-provider-factory.js +20 -1
- package/src/ContentCards/content-cards-provider.js +283 -1
- package/src/ContentCards/content-cards.js +24 -1
- package/src/ContentCards/get-cached-content-cards.js +5 -1
- package/src/ContentCards/index.js +8 -1
- package/src/ContentCards/log-content-cards-displayed.js +5 -1
- package/src/ContentCards/request-content-cards-refresh.js +5 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +14 -1
- package/src/ContentCards/ui/hide-content-cards.js +8 -1
- package/src/ContentCards/ui/show-content-cards.js +72 -1
- package/src/ContentCards/ui/toggle-content-cards.js +8 -1
- package/src/Core/add-sdk-metadata.js +27 -1
- package/src/Core/braze-sdk-metadata.js +10 -1
- package/src/Core/change-user.js +19 -1
- package/src/Core/destroy.js +5 -1
- package/src/Core/device-properties.js +9 -1
- package/src/Core/disable-sdk.js +10 -1
- package/src/Core/enable-sdk.js +8 -1
- package/src/Core/get-device-id.js +10 -1
- package/src/Core/get-user.js +4 -1
- package/src/Core/handle-braze-action.js +64 -1
- package/src/Core/index.js +23 -1
- package/src/Core/initialize.js +4 -1
- package/src/Core/is-disabled.js +4 -1
- package/src/Core/log-custom-event.js +36 -1
- package/src/Core/log-purchase.js +245 -1
- package/src/Core/open-session.js +23 -1
- package/src/Core/remove-all-subscriptions.js +4 -1
- package/src/Core/remove-subscription.js +4 -1
- package/src/Core/request-immediate-data-flush.js +4 -1
- package/src/Core/set-logger.js +4 -1
- package/src/Core/set-sdk-authentication-signature.js +9 -1
- package/src/Core/subscribe-to-sdk-authentication-failures.js +4 -1
- package/src/Core/toggle-logging.js +4 -1
- package/src/Core/wipe-data.js +15 -1
- package/src/FeatureFlags/feature-flag-factory.js +14 -0
- package/src/FeatureFlags/feature-flag.js +16 -0
- package/src/FeatureFlags/feature-flags-provider-factory.js +19 -0
- package/src/FeatureFlags/feature-flags-provider.js +94 -0
- package/src/FeatureFlags/get-all-feature-flags.js +12 -0
- package/src/FeatureFlags/get-feature-flag.js +12 -0
- package/src/FeatureFlags/index.js +4 -0
- package/src/FeatureFlags/refresh-feature-flags.js +9 -0
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +6 -0
- package/src/Feed/feed-provider-factory.js +18 -1
- package/src/Feed/feed-provider.js +79 -1
- package/src/Feed/feed.js +20 -1
- package/src/Feed/get-cached-feed.js +5 -1
- package/src/Feed/index.js +8 -1
- package/src/Feed/log-feed-displayed.js +5 -1
- package/src/Feed/request-feed-refresh.js +5 -1
- package/src/Feed/subscribe-to-feed-updates.js +5 -1
- package/src/Feed/ui/hide-feed.js +7 -1
- package/src/Feed/ui/show-feed.js +89 -1
- package/src/Feed/ui/toggle-feed.js +8 -1
- package/src/InAppMessage/display/get-animation-effect.js +19 -1
- package/src/InAppMessage/display/html-message-to-html.js +223 -1
- package/src/InAppMessage/display/in-app-message-to-html.js +152 -1
- package/src/InAppMessage/display/modal-utils.js +68 -1
- package/src/InAppMessage/in-app-message-factory.js +145 -1
- package/src/InAppMessage/in-app-message-manager-factory.js +16 -1
- package/src/InAppMessage/in-app-message-manager.js +189 -1
- package/src/InAppMessage/index.js +14 -1
- package/src/InAppMessage/log-in-app-message-button-click.js +19 -1
- package/src/InAppMessage/log-in-app-message-click.js +19 -1
- package/src/InAppMessage/log-in-app-message-html-click.js +23 -1
- package/src/InAppMessage/log-in-app-message-impression.js +13 -1
- package/src/InAppMessage/models/control-message.js +8 -1
- package/src/InAppMessage/models/full-screen-message.js +71 -1
- package/src/InAppMessage/models/html-message.js +54 -1
- package/src/InAppMessage/models/in-app-message-button.js +40 -1
- package/src/InAppMessage/models/in-app-message.js +271 -1
- package/src/InAppMessage/models/modal-message.js +68 -1
- package/src/InAppMessage/models/slide-up-message.js +58 -1
- package/src/InAppMessage/models/templated-in-app-message.js +14 -1
- package/src/InAppMessage/subscribe-to-in-app-message.js +10 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +15 -1
- package/src/InAppMessage/ui/show-in-app-message.js +170 -1
- package/src/Push/index.js +5 -1
- package/src/Push/is-push-blocked.js +5 -1
- package/src/Push/is-push-permission-granted.js +5 -1
- package/src/Push/is-push-supported.js +5 -1
- package/src/Push/push-manager-factory.js +30 -1
- package/src/Push/push-manager.js +360 -1
- package/src/Push/request-push-permission.js +8 -1
- package/src/Push/unregister-push.js +5 -1
- package/src/Push/utils/push-utils.js +34 -1
- package/src/User/index.js +1 -1
- package/src/User/user-manager.js +70 -1
- package/src/User/user.js +278 -1
- package/src/common/base-feed.js +25 -1
- package/src/common/base-provider.js +6 -1
- package/src/common/constants.js +5 -1
- package/src/common/event-logger.js +24 -1
- package/src/common/feed-display.js +200 -1
- package/src/common/translations.js +148 -1
- package/src/index.js +9 -1
- package/src/l10n/l10n-manager-factory.js +22 -1
- package/src/l10n/l10n-manager.js +21 -1
- package/src/managers/auth-manager.js +48 -1
- package/src/managers/braze-instance.js +307 -1
- package/src/managers/device-manager.js +80 -1
- package/src/managers/network-manager.js +219 -1
- package/src/managers/server-config-manager.js +88 -1
- package/src/managers/session-manager.js +68 -1
- package/src/managers/storage-manager-factory.js +35 -1
- package/src/managers/storage-manager.js +394 -1
- package/src/managers/subscription-manager.js +25 -1
- package/src/models/backend-errors.js +8 -1
- package/src/models/braze-event.js +41 -1
- package/src/models/braze-sdk-metadata.js +10 -1
- package/src/models/device.js +26 -1
- package/src/models/identifier.js +20 -1
- package/src/models/push-token.js +22 -1
- package/src/models/request-result.js +8 -1
- package/src/models/server-config.js +32 -1
- package/src/request-controller.js +288 -1
- package/src/triggers/models/custom-event-data.js +14 -1
- package/src/triggers/models/custom-event-property-data.js +21 -1
- package/src/triggers/models/filter-set.js +55 -1
- package/src/triggers/models/filter.js +98 -1
- package/src/triggers/models/in-app-message-click-data.js +25 -1
- package/src/triggers/models/purchase-data.js +14 -1
- package/src/triggers/models/purchase-property-data.js +21 -1
- package/src/triggers/models/push-click-data.js +15 -1
- package/src/triggers/models/trigger-condition.js +109 -1
- package/src/triggers/models/trigger-events.js +8 -1
- package/src/triggers/models/trigger.js +110 -1
- package/src/triggers/triggers-provider-factory.js +30 -1
- package/src/triggers/triggers-provider.js +307 -1
- package/src/ui/js/attach-css.js +12 -1
- package/src/ui/js/feed-css.js +12 -1
- package/src/ui/js/iam-css.js +12 -1
- package/src/ui/js/index.js +3 -1
- package/src/ui/js/load-font-awesome.js +13 -1
- package/src/util/base-device-parser.js +14 -1
- package/src/util/braze-actions.js +79 -1
- package/src/util/browser-detector.js +85 -1
- package/src/util/client-hints-parser.js +60 -1
- package/src/util/code-utils.js +92 -1
- package/src/util/color-utils.js +23 -1
- package/src/util/component-utils.js +26 -1
- package/src/util/date-utils.js +27 -1
- package/src/util/deprecation-utils.js +5 -1
- package/src/util/device-constants.js +14 -1
- package/src/util/dom-utils.js +87 -1
- package/src/util/key-codes.js +1 -1
- package/src/util/math.js +5 -1
- package/src/util/net.js +75 -1
- package/src/util/string-utils.js +22 -1
- package/src/util/url-utils.js +23 -1
- package/src/util/user-agent-parser.js +85 -1
- package/src/util/validation-utils.js +136 -1
- package/src/util/window-utils.js +35 -1
|
@@ -1 +1,394 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ot from "../util/browser-detector.js";
|
|
2
|
+
import ue from "../models/braze-event.js";
|
|
3
|
+
import _t from "../models/identifier.js";
|
|
4
|
+
import {
|
|
5
|
+
isArray as p,
|
|
6
|
+
keys as rr,
|
|
7
|
+
validateValueIsFromEnum as F,
|
|
8
|
+
values as At
|
|
9
|
+
} from "../util/code-utils.js";
|
|
10
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
11
|
+
import { User } from "../User/index.js";
|
|
12
|
+
export const STORAGE_KEYS = {
|
|
13
|
+
eu: {
|
|
14
|
+
su: "ab.storage.userId",
|
|
15
|
+
Jo: "ab.storage.deviceId",
|
|
16
|
+
ph: "ab.storage.sessionId"
|
|
17
|
+
},
|
|
18
|
+
q: {
|
|
19
|
+
Sa: "ab.test",
|
|
20
|
+
Ta: "ab.storage.events",
|
|
21
|
+
Ia: "ab.storage.attributes",
|
|
22
|
+
Ka: "ab.storage.attributes.anonymous_user",
|
|
23
|
+
Yo: "ab.storage.device",
|
|
24
|
+
ua: "ab.storage.sdk_metadata",
|
|
25
|
+
ha: "ab.storage.session_id_for_cached_metadata",
|
|
26
|
+
Pn: "ab.storage.pushToken",
|
|
27
|
+
ei: "ab.storage.newsFeed",
|
|
28
|
+
hi: "ab.storage.lastNewsFeedRefresh",
|
|
29
|
+
P: "ab.storage.cardImpressions",
|
|
30
|
+
ol: "ab.storage.serverConfig",
|
|
31
|
+
Ya: "ab.storage.triggers",
|
|
32
|
+
Da: "ab.storage.triggers.ts",
|
|
33
|
+
wh: "ab.storage.messagingSessionStart",
|
|
34
|
+
Yt: "ab.storage.cc",
|
|
35
|
+
vs: "ab.storage.ccLastFullSync",
|
|
36
|
+
ys: "ab.storage.ccLastCardUpdated",
|
|
37
|
+
$: "ab.storage.ccClicks",
|
|
38
|
+
O: "ab.storage.ccImpressions",
|
|
39
|
+
K: "ab.storage.ccDismissals",
|
|
40
|
+
Ga: "ab.storage.lastDisplayedTriggerTimesById",
|
|
41
|
+
Na: "ab.storage.lastDisplayedTriggerTime",
|
|
42
|
+
va: "ab.storage.triggerFireInstancesById",
|
|
43
|
+
Mn: "ab.storage.signature",
|
|
44
|
+
As: "ab.storage.brazeSyncRetryCount",
|
|
45
|
+
_s: "ab.storage.sdkVersion",
|
|
46
|
+
ze: "ab.storage.ff",
|
|
47
|
+
qe: "ab.storage.ffLastRefreshAt"
|
|
48
|
+
},
|
|
49
|
+
ae: "ab.optOut"
|
|
50
|
+
};
|
|
51
|
+
export default class G {
|
|
52
|
+
constructor(t, e) {
|
|
53
|
+
(this.Ma = t), (this.Ca = e);
|
|
54
|
+
}
|
|
55
|
+
ru(t, e) {
|
|
56
|
+
let s = e;
|
|
57
|
+
null != e && e instanceof _t && (s = e.ss()), this.Ma.store(t, s);
|
|
58
|
+
}
|
|
59
|
+
ya(t) {
|
|
60
|
+
const e = this.tu(t);
|
|
61
|
+
null != e && ((e.bh = new Date().valueOf()), this.ru(t, e));
|
|
62
|
+
}
|
|
63
|
+
tu(t) {
|
|
64
|
+
return _t.Sn(this.Ma.lr(t));
|
|
65
|
+
}
|
|
66
|
+
Nh(t) {
|
|
67
|
+
this.Ma.remove(t);
|
|
68
|
+
}
|
|
69
|
+
bo(t) {
|
|
70
|
+
if (null == t || 0 === t.length) return !1;
|
|
71
|
+
p(t) || (t = [t]);
|
|
72
|
+
let e = this.Ca.lr(STORAGE_KEYS.q.Ta);
|
|
73
|
+
(null != e && p(e)) || (e = []);
|
|
74
|
+
for (let s = 0; s < t.length; s++) e.push(t[s].ss());
|
|
75
|
+
return this.Ca.store(STORAGE_KEYS.q.Ta, e);
|
|
76
|
+
}
|
|
77
|
+
Dh(t) {
|
|
78
|
+
return null != t && this.bo([t]);
|
|
79
|
+
}
|
|
80
|
+
Ua() {
|
|
81
|
+
let t = this.Ca.lr(STORAGE_KEYS.q.Ta);
|
|
82
|
+
this.Ca.remove(STORAGE_KEYS.q.Ta), null == t && (t = []);
|
|
83
|
+
const e = [];
|
|
84
|
+
let s = !1,
|
|
85
|
+
o = null;
|
|
86
|
+
if (p(t))
|
|
87
|
+
for (let s = 0; s < t.length; s++)
|
|
88
|
+
ue.Fa(t[s]) ? e.push(ue.Sn(t[s])) : (o = s);
|
|
89
|
+
else s = !0;
|
|
90
|
+
if (s || null != o) {
|
|
91
|
+
let n = "Stored events could not be deserialized as Events";
|
|
92
|
+
s &&
|
|
93
|
+
(n += ", was " + Object.prototype.toString.call(t) + " not an array"),
|
|
94
|
+
null != o &&
|
|
95
|
+
(n += ", value at index " + o + " does not look like an event"),
|
|
96
|
+
(n +=
|
|
97
|
+
", serialized values were of type " +
|
|
98
|
+
typeof t +
|
|
99
|
+
": " +
|
|
100
|
+
JSON.stringify(t)),
|
|
101
|
+
e.push(new ue(null, r.A.qs, new Date().valueOf(), null, { e: n }));
|
|
102
|
+
}
|
|
103
|
+
return e;
|
|
104
|
+
}
|
|
105
|
+
B(t, e) {
|
|
106
|
+
return (
|
|
107
|
+
!!F(
|
|
108
|
+
STORAGE_KEYS.q,
|
|
109
|
+
t,
|
|
110
|
+
"StorageManager cannot store object.",
|
|
111
|
+
"STORAGE_KEYS.OBJECTS"
|
|
112
|
+
) && this.Ca.store(t, e)
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
I(t) {
|
|
116
|
+
return (
|
|
117
|
+
!!F(
|
|
118
|
+
STORAGE_KEYS.q,
|
|
119
|
+
t,
|
|
120
|
+
"StorageManager cannot retrieve object.",
|
|
121
|
+
"STORAGE_KEYS.OBJECTS"
|
|
122
|
+
) && this.Ca.lr(t)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
Xs(t) {
|
|
126
|
+
return (
|
|
127
|
+
!!F(
|
|
128
|
+
STORAGE_KEYS.q,
|
|
129
|
+
t,
|
|
130
|
+
"StorageManager cannot remove object.",
|
|
131
|
+
"STORAGE_KEYS.OBJECTS"
|
|
132
|
+
) && (this.Ca.remove(t), !0)
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
clearData() {
|
|
136
|
+
const t = rr(STORAGE_KEYS.eu),
|
|
137
|
+
e = rr(STORAGE_KEYS.q);
|
|
138
|
+
for (let e = 0; e < t.length; e++) {
|
|
139
|
+
const s = t[e];
|
|
140
|
+
this.Ma.remove(STORAGE_KEYS.eu[s]);
|
|
141
|
+
}
|
|
142
|
+
for (let t = 0; t < e.length; t++) {
|
|
143
|
+
const s = e[t];
|
|
144
|
+
this.Ca.remove(STORAGE_KEYS.q[s]);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
La(t) {
|
|
148
|
+
return t || STORAGE_KEYS.q.Ka;
|
|
149
|
+
}
|
|
150
|
+
Aa(t) {
|
|
151
|
+
let e = this.Ca.lr(STORAGE_KEYS.q.Ia);
|
|
152
|
+
null == e && (e = {});
|
|
153
|
+
const s = this.La(t[User.Rn]);
|
|
154
|
+
for (let r in t)
|
|
155
|
+
r === User.Rn ||
|
|
156
|
+
(null != e[s] && null != e[s][r]) ||
|
|
157
|
+
this.mu(t[User.Rn], r, t[r]);
|
|
158
|
+
}
|
|
159
|
+
mu(t, e, s) {
|
|
160
|
+
let r = this.Ca.lr(STORAGE_KEYS.q.Ia);
|
|
161
|
+
null == r && (r = {});
|
|
162
|
+
const o = this.La(t);
|
|
163
|
+
let n = r[o];
|
|
164
|
+
if (
|
|
165
|
+
(null == n && ((n = {}), null != t && (n[User.Rn] = t)), e === User.lu)
|
|
166
|
+
) {
|
|
167
|
+
null == n[e] && (n[e] = {});
|
|
168
|
+
for (let t in s) n[e][t] = s[t];
|
|
169
|
+
} else n[e] = s;
|
|
170
|
+
return (r[o] = n), this.Ca.store(STORAGE_KEYS.q.Ia, r);
|
|
171
|
+
}
|
|
172
|
+
Ba() {
|
|
173
|
+
const t = this.Ca.lr(STORAGE_KEYS.q.Ia);
|
|
174
|
+
this.Ca.remove(STORAGE_KEYS.q.Ia);
|
|
175
|
+
const e = [];
|
|
176
|
+
for (let s in t) null != t[s] && e.push(t[s]);
|
|
177
|
+
return e;
|
|
178
|
+
}
|
|
179
|
+
ou(t) {
|
|
180
|
+
const e = this.Ca.lr(STORAGE_KEYS.q.Ia);
|
|
181
|
+
if (null != e) {
|
|
182
|
+
const s = this.La(null),
|
|
183
|
+
r = e[s];
|
|
184
|
+
null != r &&
|
|
185
|
+
((e[s] = void 0),
|
|
186
|
+
this.Ca.store(STORAGE_KEYS.q.Ia, e),
|
|
187
|
+
(r[User.Rn] = t),
|
|
188
|
+
this.Aa(r));
|
|
189
|
+
}
|
|
190
|
+
const s = this.tu(STORAGE_KEYS.eu.ph);
|
|
191
|
+
let r = null;
|
|
192
|
+
null != s && (r = s.iu);
|
|
193
|
+
const o = this.Ua();
|
|
194
|
+
if (null != o)
|
|
195
|
+
for (let e = 0; e < o.length; e++) {
|
|
196
|
+
const s = o[e];
|
|
197
|
+
null == s.userId && s.sessionId == r && (s.userId = t), this.Dh(s);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
Pa() {
|
|
201
|
+
return this.Ca.xa;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
G._a = class {
|
|
205
|
+
constructor(t) {
|
|
206
|
+
(this._r = t), (this.xa = ot.Ja() ? 3 : 10);
|
|
207
|
+
}
|
|
208
|
+
ka(t) {
|
|
209
|
+
return t + "." + this._r;
|
|
210
|
+
}
|
|
211
|
+
store(t, e) {
|
|
212
|
+
const s = { v: e };
|
|
213
|
+
try {
|
|
214
|
+
return localStorage.setItem(this.ka(t), JSON.stringify(s)), !0;
|
|
215
|
+
} catch (t) {
|
|
216
|
+
return r.D.info("Storage failure: " + t.message), !1;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
lr(t) {
|
|
220
|
+
try {
|
|
221
|
+
const e = JSON.parse(localStorage.getItem(this.ka(t)));
|
|
222
|
+
return null == e ? null : e.v;
|
|
223
|
+
} catch (t) {
|
|
224
|
+
return r.D.info("Storage retrieval failure: " + t.message), null;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
remove(t) {
|
|
228
|
+
try {
|
|
229
|
+
localStorage.removeItem(this.ka(t));
|
|
230
|
+
} catch (t) {
|
|
231
|
+
return r.D.info("Storage removal failure: " + t.message), !1;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
G.ne = class {
|
|
236
|
+
constructor(t, e) {
|
|
237
|
+
(this._r = t), (this.Va = this.Qa()), (this.Ha = 576e3), (this.Wa = !!e);
|
|
238
|
+
}
|
|
239
|
+
ka(t) {
|
|
240
|
+
return null != this._r ? t + "." + this._r : t;
|
|
241
|
+
}
|
|
242
|
+
Qa() {
|
|
243
|
+
let t = 0,
|
|
244
|
+
e = document.location.hostname;
|
|
245
|
+
const s = e.split("."),
|
|
246
|
+
r = "ab._gd";
|
|
247
|
+
for (; t < s.length - 1 && -1 === document.cookie.indexOf(r + "=" + r); )
|
|
248
|
+
t++,
|
|
249
|
+
(e = "." + s.slice(-1 - t).join(".")),
|
|
250
|
+
(document.cookie = r + "=" + r + ";domain=" + e + ";");
|
|
251
|
+
return (
|
|
252
|
+
(document.cookie =
|
|
253
|
+
r + "=;expires=" + new Date(0).toGMTString() + ";domain=" + e + ";"),
|
|
254
|
+
e
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
ie() {
|
|
258
|
+
const t = new Date();
|
|
259
|
+
return t.setTime(t.getTime() + 60 * this.Ha * 1e3), t.getFullYear();
|
|
260
|
+
}
|
|
261
|
+
Xa() {
|
|
262
|
+
const t = At(STORAGE_KEYS.eu),
|
|
263
|
+
e = document.cookie.split(";");
|
|
264
|
+
for (let s = 0; s < e.length; s++) {
|
|
265
|
+
let r = e[s];
|
|
266
|
+
for (; " " === r.charAt(0); ) r = r.substring(1);
|
|
267
|
+
let o = !1;
|
|
268
|
+
for (let e = 0; e < t.length; e++)
|
|
269
|
+
if (0 === r.indexOf(t[e])) {
|
|
270
|
+
o = !0;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
if (o) {
|
|
274
|
+
const t = r.split("=")[0];
|
|
275
|
+
-1 === t.indexOf("." + this._r) && this.Za(t);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
store(t, e) {
|
|
280
|
+
this.Xa();
|
|
281
|
+
const s = new Date();
|
|
282
|
+
s.setTime(s.getTime() + 60 * this.Ha * 1e3);
|
|
283
|
+
const o = "expires=" + s.toUTCString(),
|
|
284
|
+
n = "domain=" + this.Va;
|
|
285
|
+
let i;
|
|
286
|
+
i = this.Wa ? e : encodeURIComponent(JSON.stringify(e));
|
|
287
|
+
const a = this.ka(t) + "=" + i + ";" + o + ";" + n + ";path=/";
|
|
288
|
+
return a.length >= 4093
|
|
289
|
+
? (r.D.info(
|
|
290
|
+
"Storage failure: string is " +
|
|
291
|
+
a.length +
|
|
292
|
+
" chars which is too large to store as a cookie."
|
|
293
|
+
),
|
|
294
|
+
!1)
|
|
295
|
+
: ((document.cookie = a), !0);
|
|
296
|
+
}
|
|
297
|
+
lr(t) {
|
|
298
|
+
const e = [],
|
|
299
|
+
s = this.ka(t) + "=",
|
|
300
|
+
o = document.cookie.split(";");
|
|
301
|
+
for (let n = 0; n < o.length; n++) {
|
|
302
|
+
let i = o[n];
|
|
303
|
+
for (; " " === i.charAt(0); ) i = i.substring(1);
|
|
304
|
+
if (0 === i.indexOf(s))
|
|
305
|
+
try {
|
|
306
|
+
let t;
|
|
307
|
+
(t = this.Wa
|
|
308
|
+
? i.substring(s.length, i.length)
|
|
309
|
+
: JSON.parse(decodeURIComponent(i.substring(s.length, i.length)))),
|
|
310
|
+
e.push(t);
|
|
311
|
+
} catch (e) {
|
|
312
|
+
return (
|
|
313
|
+
r.D.info("Storage retrieval failure: " + e.message),
|
|
314
|
+
this.remove(t),
|
|
315
|
+
null
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return e.length > 0 ? e[e.length - 1] : null;
|
|
320
|
+
}
|
|
321
|
+
remove(t) {
|
|
322
|
+
this.Za(this.ka(t));
|
|
323
|
+
}
|
|
324
|
+
Za(t) {
|
|
325
|
+
const e = t + "=;expires=" + new Date(0).toGMTString();
|
|
326
|
+
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
327
|
+
const s = e + ";domain=" + this.Va;
|
|
328
|
+
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
G.Oa = class {
|
|
332
|
+
constructor() {
|
|
333
|
+
(this.$a = {}), (this.El = 5242880), (this.xa = 3);
|
|
334
|
+
}
|
|
335
|
+
store(t, e) {
|
|
336
|
+
const s = { value: e },
|
|
337
|
+
o = this.Sl(e);
|
|
338
|
+
return o > this.El
|
|
339
|
+
? (r.D.info(
|
|
340
|
+
"Storage failure: object is ≈" +
|
|
341
|
+
o +
|
|
342
|
+
" bytes which is greater than the max of " +
|
|
343
|
+
this.El
|
|
344
|
+
),
|
|
345
|
+
!1)
|
|
346
|
+
: ((this.$a[t] = s), !0);
|
|
347
|
+
}
|
|
348
|
+
Sl(t) {
|
|
349
|
+
const e = [],
|
|
350
|
+
s = [t];
|
|
351
|
+
let r = 0;
|
|
352
|
+
for (; s.length; ) {
|
|
353
|
+
const t = s.pop();
|
|
354
|
+
if ("boolean" == typeof t) r += 4;
|
|
355
|
+
else if ("string" == typeof t) r += 2 * t.length;
|
|
356
|
+
else if ("number" == typeof t) r += 8;
|
|
357
|
+
else if ("object" == typeof t && -1 === e.indexOf(t)) {
|
|
358
|
+
e.push(t);
|
|
359
|
+
for (let e in t) s.push(t[e]);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return r;
|
|
363
|
+
}
|
|
364
|
+
lr(t) {
|
|
365
|
+
const e = this.$a[t];
|
|
366
|
+
return null == e ? null : e.value;
|
|
367
|
+
}
|
|
368
|
+
remove(t) {
|
|
369
|
+
this.$a[t] = null;
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
G.wa = class {
|
|
373
|
+
constructor(t, e, s) {
|
|
374
|
+
(this._l = []),
|
|
375
|
+
e && this._l.push(new G.ne(t)),
|
|
376
|
+
s && this._l.push(new G._a(t)),
|
|
377
|
+
this._l.push(new G.Oa(t));
|
|
378
|
+
}
|
|
379
|
+
store(t, e) {
|
|
380
|
+
let s = !0;
|
|
381
|
+
for (let r = 0; r < this._l.length; r++) s = this._l[r].store(t, e) && s;
|
|
382
|
+
return s;
|
|
383
|
+
}
|
|
384
|
+
lr(t) {
|
|
385
|
+
for (let e = 0; e < this._l.length; e++) {
|
|
386
|
+
const s = this._l[e].lr(t);
|
|
387
|
+
if (null != s) return s;
|
|
388
|
+
}
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
remove(t) {
|
|
392
|
+
for (let e = 0; e < this._l.length; e++) this._l[e].remove(t);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
@@ -1 +1,25 @@
|
|
|
1
|
-
import r from"../../shared-lib/braze-shared-lib.js";
|
|
1
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
|
+
export default class u {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.Pe = {};
|
|
5
|
+
}
|
|
6
|
+
ut(t) {
|
|
7
|
+
if ("function" != typeof t) return null;
|
|
8
|
+
const i = r.it.nt();
|
|
9
|
+
return (this.Pe[i] = t), i;
|
|
10
|
+
}
|
|
11
|
+
removeSubscription(t) {
|
|
12
|
+
delete this.Pe[t];
|
|
13
|
+
}
|
|
14
|
+
removeAllSubscriptions() {
|
|
15
|
+
this.Pe = {};
|
|
16
|
+
}
|
|
17
|
+
bu() {
|
|
18
|
+
return Object.keys(this.Pe).length;
|
|
19
|
+
}
|
|
20
|
+
St(t) {
|
|
21
|
+
const i = [];
|
|
22
|
+
for (let r in this.Pe) i.push(this.Pe[r](t));
|
|
23
|
+
return i;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export default{
|
|
1
|
+
export default {
|
|
2
|
+
pa: "invalid_api_key",
|
|
3
|
+
Ra: "blacklisted",
|
|
4
|
+
ba: "no_device_identifier",
|
|
5
|
+
ma: "invalid_json_response",
|
|
6
|
+
fa: "empty_response",
|
|
7
|
+
__: "sdk_auth_error"
|
|
8
|
+
};
|
|
@@ -1 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isObject as Jt } from "../util/code-utils.js";
|
|
2
|
+
import {
|
|
3
|
+
convertMsToSeconds as l,
|
|
4
|
+
timestampOrNow as Vt
|
|
5
|
+
} from "../util/date-utils.js";
|
|
6
|
+
export default class ue {
|
|
7
|
+
constructor(t, i, s, r, e) {
|
|
8
|
+
(this.userId = t),
|
|
9
|
+
(this.type = i),
|
|
10
|
+
(this.time = Vt(s)),
|
|
11
|
+
(this.sessionId = r),
|
|
12
|
+
(this.data = e);
|
|
13
|
+
}
|
|
14
|
+
Mi() {
|
|
15
|
+
const t = {
|
|
16
|
+
name: this.type,
|
|
17
|
+
time: l(this.time),
|
|
18
|
+
data: this.data || {},
|
|
19
|
+
session_id: this.sessionId
|
|
20
|
+
};
|
|
21
|
+
return null != this.userId && (t.user_id = this.userId), t;
|
|
22
|
+
}
|
|
23
|
+
ss() {
|
|
24
|
+
return {
|
|
25
|
+
u: this.userId,
|
|
26
|
+
t: this.type,
|
|
27
|
+
ts: this.time,
|
|
28
|
+
s: this.sessionId,
|
|
29
|
+
d: this.data
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
static fromJson(t) {
|
|
33
|
+
return new ue(t.user_id, t.name, t.time, t.session_id, t.data);
|
|
34
|
+
}
|
|
35
|
+
static Fa(t) {
|
|
36
|
+
return null != t && Jt(t) && null != t.t && "" !== t.t;
|
|
37
|
+
}
|
|
38
|
+
static Sn(t) {
|
|
39
|
+
return new ue(t.u, t.t, t.ts, t.s, t.d);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
export default{
|
|
1
|
+
export default {
|
|
2
|
+
GOOGLE_TAG_MANAGER: "gg",
|
|
3
|
+
MPARTICLE: "mp",
|
|
4
|
+
SEGMENT: "sg",
|
|
5
|
+
TEALIUM: "tl",
|
|
6
|
+
MANUAL: "manu",
|
|
7
|
+
NPM: "npm",
|
|
8
|
+
CDN: "wcd",
|
|
9
|
+
SHOPIFY: "shp"
|
|
10
|
+
};
|
package/src/models/device.js
CHANGED
|
@@ -1 +1,26 @@
|
|
|
1
|
-
import DeviceProperties from"../Core/device-properties.js";
|
|
1
|
+
import DeviceProperties from "../Core/device-properties.js";
|
|
2
|
+
export default class Ie {
|
|
3
|
+
constructor(s) {
|
|
4
|
+
this.id = s;
|
|
5
|
+
}
|
|
6
|
+
Mi() {
|
|
7
|
+
const s = {};
|
|
8
|
+
return (
|
|
9
|
+
null != this[DeviceProperties.BROWSER] &&
|
|
10
|
+
(s.browser = this[DeviceProperties.BROWSER]),
|
|
11
|
+
null != this[DeviceProperties.BROWSER_VERSION] &&
|
|
12
|
+
(s.browser_version = this[DeviceProperties.BROWSER_VERSION]),
|
|
13
|
+
null != this[DeviceProperties.OS] &&
|
|
14
|
+
(s.os_version = this[DeviceProperties.OS]),
|
|
15
|
+
null != this[DeviceProperties.RESOLUTION] &&
|
|
16
|
+
(s.resolution = this[DeviceProperties.RESOLUTION]),
|
|
17
|
+
null != this[DeviceProperties.LANGUAGE] &&
|
|
18
|
+
(s.locale = this[DeviceProperties.LANGUAGE]),
|
|
19
|
+
null != this[DeviceProperties.TIME_ZONE] &&
|
|
20
|
+
(s.time_zone = this[DeviceProperties.TIME_ZONE]),
|
|
21
|
+
null != this[DeviceProperties.USER_AGENT] &&
|
|
22
|
+
(s.user_agent = this[DeviceProperties.USER_AGENT]),
|
|
23
|
+
s
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/models/identifier.js
CHANGED
|
@@ -1 +1,20 @@
|
|
|
1
|
-
import r from"../../shared-lib/braze-shared-lib.js";
|
|
1
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
|
+
export default class _t {
|
|
3
|
+
constructor(t, e, s) {
|
|
4
|
+
null == t && (t = r.it.nt()),
|
|
5
|
+
(s = parseInt(s)),
|
|
6
|
+
(isNaN(s) || 0 === s) && (s = new Date().valueOf()),
|
|
7
|
+
(this.iu = t),
|
|
8
|
+
(this.fh = s),
|
|
9
|
+
(this.bh = new Date().valueOf()),
|
|
10
|
+
(this.jh = e);
|
|
11
|
+
}
|
|
12
|
+
ss() {
|
|
13
|
+
return { g: this.iu, e: this.jh, c: this.fh, l: this.bh };
|
|
14
|
+
}
|
|
15
|
+
static Sn(t) {
|
|
16
|
+
if (null == t || null == t.g) return null;
|
|
17
|
+
const e = new _t(t.g, t.e, t.c);
|
|
18
|
+
return (e.bh = t.l), e;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/models/push-token.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
import{rehydrateDateAfterJsonization as w}from"../util/date-utils.js";
|
|
1
|
+
import { rehydrateDateAfterJsonization as w } from "../util/date-utils.js";
|
|
2
|
+
export default class ei {
|
|
3
|
+
constructor(t, i, l, s, u) {
|
|
4
|
+
(this.endpoint = t || null),
|
|
5
|
+
(this.Dn = i || null),
|
|
6
|
+
(this.publicKey = l || null),
|
|
7
|
+
(this.zl = s || null),
|
|
8
|
+
(this.gl = u || null);
|
|
9
|
+
}
|
|
10
|
+
ss() {
|
|
11
|
+
return {
|
|
12
|
+
e: this.endpoint,
|
|
13
|
+
c: this.Dn,
|
|
14
|
+
p: this.publicKey,
|
|
15
|
+
u: this.zl,
|
|
16
|
+
v: this.gl
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static Sn(t) {
|
|
20
|
+
return new ei(t.e, w(t.c), t.p, t.u, t.v);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export default class t{
|
|
1
|
+
export default class t {
|
|
2
|
+
constructor(t, s) {
|
|
3
|
+
(this.S = !!t), (this.ve = s || []);
|
|
4
|
+
}
|
|
5
|
+
V(t) {
|
|
6
|
+
(this.S = this.S && t.S), this.ve.push(...t.ve);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
export default class Ft
|
|
1
|
+
export default class Ft {
|
|
2
|
+
constructor(t, s, i, h, l, e, r, u) {
|
|
3
|
+
(this.ul = t || 0),
|
|
4
|
+
(this.bl = s || []),
|
|
5
|
+
(this.dl = i || []),
|
|
6
|
+
(this.vl = h || []),
|
|
7
|
+
(this.Cl = l),
|
|
8
|
+
(null != l && "" !== l) || (this.Cl = null),
|
|
9
|
+
(this.gl = e || null),
|
|
10
|
+
(this.ml = r || {}),
|
|
11
|
+
(this.cl = u || {});
|
|
12
|
+
}
|
|
13
|
+
ss() {
|
|
14
|
+
return {
|
|
15
|
+
s: "4.5.0",
|
|
16
|
+
l: this.ul,
|
|
17
|
+
e: this.bl,
|
|
18
|
+
a: this.dl,
|
|
19
|
+
p: this.vl,
|
|
20
|
+
m: this.Cl,
|
|
21
|
+
v: this.gl,
|
|
22
|
+
c: this.ml,
|
|
23
|
+
f: this.cl
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
static Sn(t) {
|
|
27
|
+
let s = t.l;
|
|
28
|
+
return (
|
|
29
|
+
"4.5.0" !== t.s && (s = 0), new Ft(s, t.e, t.a, t.p, t.m, t.v, t.c, t.f)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|