@braze/web-sdk 6.12.1 → 6.13.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 +240 -3
- package/package.json +1 -1
- package/shared-lib/event-types.js +18 -18
- package/shared-lib/indexed-db-adapter.js +58 -58
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +25 -24
- package/src/ConversationalChat/automatically-manage-chat.js +5 -0
- package/src/ConversationalChat/chat-message-factory.js +25 -0
- package/src/ConversationalChat/chat-message.js +33 -0
- package/src/ConversationalChat/constants.js +1 -0
- package/src/ConversationalChat/conversational-chat-provider-factory.js +26 -0
- package/src/ConversationalChat/conversational-chat-provider.js +372 -0
- package/src/ConversationalChat/display/chat-widget-manager.js +113 -0
- package/src/ConversationalChat/display/chat-widget-to-html.js +58 -0
- package/src/ConversationalChat/get-chat-messages.js +7 -0
- package/src/ConversationalChat/index.js +12 -0
- package/src/ConversationalChat/is-chat-conversation-ended.js +7 -0
- package/src/ConversationalChat/is-chat-turn-errored.js +7 -0
- package/src/ConversationalChat/is-chat-turn-in-progress.js +7 -0
- package/src/ConversationalChat/register-chat-action-handler.js +10 -0
- package/src/ConversationalChat/reset-chat-conversation.js +5 -0
- package/src/ConversationalChat/retrieve-chat-config.js +7 -0
- package/src/ConversationalChat/send-chat-message.js +17 -0
- package/src/ConversationalChat/subscribe-to-chat-action.js +5 -0
- package/src/ConversationalChat/subscribe-to-chat-conversation-updated.js +5 -0
- package/src/ConversationalChat/subscribe-to-chat-message-received.js +5 -0
- package/src/ConversationalChat/trigger-chat-action.js +11 -0
- package/src/ConversationalChat/types.js +1 -0
- package/src/Core/add-sdk-metadata.js +5 -5
- package/src/Core/change-user.js +6 -6
- package/src/Core/disable-sdk.js +6 -6
- package/src/Core/enable-sdk.js +3 -3
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/handle-braze-action.js +20 -13
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/is-initialized.js +1 -1
- package/src/Core/log-custom-event.js +9 -9
- package/src/Core/log-ecommerce-event.js +4 -4
- package/src/Core/log-purchase.js +14 -14
- package/src/Core/open-session.js +8 -8
- package/src/Core/set-sdk-authentication-signature.js +3 -3
- package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
- package/src/Core/wipe-data.js +1 -1
- package/src/DUST/dust-config-store.js +35 -35
- package/src/DUST/dust-message-dedup.js +3 -3
- package/src/DUST/dust-provider-factory.js +10 -10
- package/src/DUST/dust-provider.js +234 -234
- package/src/DUST/subscribe-to-dust.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +2 -2
- package/src/FeatureFlags/feature-flag.js +4 -4
- package/src/FeatureFlags/feature-flags-provider-factory.js +11 -11
- package/src/FeatureFlags/feature-flags-provider.js +38 -38
- 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 +4 -4
- package/src/FeatureFlags/refresh-feature-flags.js +5 -5
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +3 -3
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-display-utils.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +13 -13
- package/src/InAppMessage/display/in-app-message-to-html.js +20 -20
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/in-app-message-factory.js +6 -6
- package/src/InAppMessage/in-app-message-manager.js +92 -92
- package/src/InAppMessage/log-in-app-message-button-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-click.js +7 -7
- package/src/InAppMessage/log-in-app-message-html-click.js +6 -6
- package/src/InAppMessage/log-in-app-message-impression.js +3 -3
- package/src/InAppMessage/models/full-screen-message.js +39 -39
- package/src/InAppMessage/models/html-message.js +20 -20
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +102 -102
- package/src/InAppMessage/models/modal-message.js +38 -38
- package/src/InAppMessage/models/slide-up-message.js +34 -34
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/remove-all-visible-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +23 -23
- 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 +13 -13
- package/src/Push/register-push.js +2 -2
- package/src/Push/request-push-permission.js +2 -2
- package/src/Push/unregister-push-token-on-server.js +3 -3
- package/src/Push/unregister-push.js +3 -3
- package/src/Push/utils/push-utils.js +15 -15
- package/src/User/user-manager.js +9 -9
- package/src/User/user.js +50 -50
- package/src/common/constants.js +1 -1
- package/src/common/content-cards-display.js +22 -22
- package/src/common/event-logger.js +3 -3
- package/src/index.js +2 -9
- package/src/l10n/l10n-manager-factory.js +4 -4
- package/src/l10n/l10n-manager.js +6 -6
- package/src/managers/auth-manager.js +28 -28
- package/src/managers/braze-action-manager.js +14 -0
- package/src/managers/braze-instance.js +159 -151
- package/src/managers/device-manager.js +26 -26
- package/src/managers/network-manager.js +120 -120
- package/src/managers/server-config-manager.js +95 -86
- package/src/managers/session-manager.js +25 -25
- package/src/managers/storage-manager-factory.js +12 -12
- package/src/managers/storage-manager.js +129 -124
- package/src/managers/subscription-manager.js +8 -8
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +5 -5
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +8 -8
- package/src/models/push-token.js +6 -6
- package/src/models/request-result.js +2 -2
- package/src/models/server-config.js +27 -27
- package/src/request-controller.js +117 -117
- package/src/standard-index.js +9 -0
- package/src/triggers/models/custom-event-data.js +4 -4
- package/src/triggers/models/custom-event-property-data.js +5 -5
- package/src/triggers/models/filter-set.js +5 -5
- package/src/triggers/models/filter.js +31 -31
- package/src/triggers/models/in-app-message-click-data.js +9 -9
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +5 -5
- package/src/triggers/models/push-click-data.js +4 -4
- package/src/triggers/models/trigger-condition.js +35 -35
- 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 +128 -128
- package/src/types.js +2 -2
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/chat-widget-css.js +11 -0
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +7 -7
- package/src/util/braze-actions.js +5 -5
- package/src/util/browser-detector.js +41 -41
- package/src/util/client-hints-parser.js +10 -10
- package/src/util/component-utils.js +1 -1
- package/src/util/date-utils.js +2 -2
- package/src/util/device-constants.js +5 -5
- package/src/util/dom-utils.js +8 -8
- package/src/util/ecommerce-event-validation.js +13 -13
- package/src/util/html-display-utils.js +6 -6
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +82 -44
- package/src/util/request-header-utils.js +26 -24
- package/src/util/user-agent-parser.js +21 -21
- package/src/util/validation-utils.js +29 -21
- package/src/util/window-utils.js +3 -3
|
@@ -1,91 +1,96 @@
|
|
|
1
1
|
import ve from "../models/braze-event.js";
|
|
2
|
-
import
|
|
2
|
+
import Ut from "../models/identifier.js";
|
|
3
3
|
import {
|
|
4
4
|
isArray as g,
|
|
5
5
|
keys as C,
|
|
6
|
-
validateValueIsFromEnum as
|
|
7
|
-
values as
|
|
6
|
+
validateValueIsFromEnum as ra,
|
|
7
|
+
values as fi,
|
|
8
8
|
} from "../util/code-utils.js";
|
|
9
9
|
import { logger as b, EventTypes as p } from "../../shared-lib/index.js";
|
|
10
10
|
import { User } from "../User/index.js";
|
|
11
|
-
import
|
|
11
|
+
import eo from "../util/browser-detector.js";
|
|
12
12
|
import { getErrorMessage as ci } from "../util/error-utils.js";
|
|
13
13
|
export const STORAGE_KEYS = {
|
|
14
14
|
Ou: {
|
|
15
15
|
Cu: "ab.storage.userId",
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
Nl: "ab.storage.deviceId",
|
|
17
|
+
am: "ab.storage.sessionId",
|
|
18
18
|
},
|
|
19
19
|
It: {
|
|
20
|
-
|
|
20
|
+
ag: "ab.test",
|
|
21
21
|
tS: "ab.storage.events",
|
|
22
22
|
eS: "ab.storage.attributes",
|
|
23
23
|
sS: "ab.storage.attributes.anonymous_user",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
Mc: "ab.storage.device",
|
|
25
|
+
Hl: "ab.storage.sdk_metadata",
|
|
26
|
+
Yl: "ab.storage.session_id_for_cached_metadata",
|
|
27
27
|
xu: "ab.storage.pushToken",
|
|
28
28
|
rS: "ab.storage.cardImpressions",
|
|
29
|
-
|
|
29
|
+
Rd: "ab.storage.serverConfig",
|
|
30
30
|
oS: "ab.storage.triggers",
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
aS: "ab.storage.triggers.ts",
|
|
32
|
+
fm: "ab.storage.messagingSessionStart",
|
|
33
33
|
bi: "ab.storage.cc",
|
|
34
34
|
ji: "ab.storage.ccLastFullSync",
|
|
35
35
|
yi: "ab.storage.ccLastCardUpdated",
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
_c: "ab.storage.globalRateLimitCurrentTokenCount",
|
|
37
|
+
Jc: "ab.storage.dynamicRateLimitCurrentTokenCount",
|
|
38
38
|
Zt: "ab.storage.ccClicks",
|
|
39
39
|
ps: "ab.storage.ccImpressions",
|
|
40
40
|
fs: "ab.storage.ccDismissals",
|
|
41
|
-
|
|
41
|
+
nS: "ab.storage.lastDisplayedTriggerTimesById",
|
|
42
42
|
iS: "ab.storage.lastDisplayedTriggerTime",
|
|
43
43
|
SS: "ab.storage.triggerFireInstancesById",
|
|
44
|
-
|
|
44
|
+
oc: "ab.storage.signature",
|
|
45
45
|
ES: "ab.storage.brazeSyncRetryCount",
|
|
46
46
|
zi: "ab.storage.sdkVersion",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
ho: "ab.storage.ff",
|
|
48
|
+
do: "ab.storage.ffImpressions",
|
|
49
|
+
To: "ab.storage.ffLastRefreshAt",
|
|
50
|
+
bo: "ab.storage.ff.sessionId",
|
|
51
51
|
lS: "ab.storage.lastReqToEndpoint",
|
|
52
52
|
_S: "ab.storage.requestAttempts",
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
Pa: "ab.storage.deferredIam",
|
|
54
|
+
Uc: "ab.storage.lastSdkReq",
|
|
55
55
|
uS: "ab.storage.alias",
|
|
56
56
|
Tt: "ab.storage.banners",
|
|
57
57
|
At: "ab.storage.banners.impressions",
|
|
58
58
|
Xt: "ab.storage.banners.dismissals",
|
|
59
59
|
kt: "ab.storage.banners.sessionId",
|
|
60
60
|
Ht: "ab.storage.banners.lastRequestedTime",
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
Re: "ab.storage.dust.mite",
|
|
62
|
+
_e: "ab.storage.dust.host",
|
|
63
|
+
Fe: "ab.storage.dust.auth",
|
|
64
|
+
Me: "ab.storage.dust.expiration",
|
|
65
|
+
We: "ab.storage.dust.refreshLock",
|
|
66
66
|
_r: "ab.storage.dust.msgClaims",
|
|
67
|
+
fn: "ab.storage.chat.sessionId",
|
|
68
|
+
mn: "ab.storage.chat.messages",
|
|
69
|
+
wn: "ab.storage.chat.status",
|
|
70
|
+
bn: "ab.storage.chat.error",
|
|
71
|
+
hn: "ab.storage.chat.brazeSessionId",
|
|
67
72
|
},
|
|
68
|
-
|
|
73
|
+
Se: "ab.optOut",
|
|
69
74
|
};
|
|
70
75
|
export default class ne {
|
|
71
76
|
constructor(t, e) {
|
|
72
|
-
(this.
|
|
77
|
+
(this.TS = t), (this.cS = e), (this.TS = t), (this.cS = e);
|
|
73
78
|
}
|
|
74
|
-
|
|
79
|
+
Vl(t) {
|
|
75
80
|
const e = C(STORAGE_KEYS.Ou),
|
|
76
|
-
s = new ne.
|
|
81
|
+
s = new ne.De(t);
|
|
77
82
|
for (const t of e) s.remove(STORAGE_KEYS.Ou[t]);
|
|
78
83
|
}
|
|
79
84
|
Ju(t, e) {
|
|
80
85
|
let s = null;
|
|
81
|
-
null != e && e instanceof
|
|
86
|
+
null != e && e instanceof Ut && (s = e.qt()), this.TS.store(t, s);
|
|
82
87
|
}
|
|
83
88
|
hS(t) {
|
|
84
89
|
const e = this.$u(t);
|
|
85
|
-
null != e && ((e.
|
|
90
|
+
null != e && ((e.gm = new Date().valueOf()), this.Ju(t, e));
|
|
86
91
|
}
|
|
87
92
|
$u(t) {
|
|
88
|
-
const e = this.
|
|
93
|
+
const e = this.TS.wr(t),
|
|
89
94
|
s = ((t) => {
|
|
90
95
|
let e;
|
|
91
96
|
try {
|
|
@@ -96,44 +101,44 @@ export default class ne {
|
|
|
96
101
|
return e;
|
|
97
102
|
})(e);
|
|
98
103
|
let r;
|
|
99
|
-
if (s) (r =
|
|
104
|
+
if (s) (r = Ut._u(s) || null), r && this.Ju(t, r);
|
|
100
105
|
else {
|
|
101
|
-
const s =
|
|
102
|
-
(r =
|
|
106
|
+
const s = Ut.AS(e);
|
|
107
|
+
(r = Ut._u(s) || null), s !== e && r && this.Ju(t, r);
|
|
103
108
|
}
|
|
104
109
|
return r;
|
|
105
110
|
}
|
|
106
|
-
|
|
107
|
-
this.
|
|
111
|
+
xm(t) {
|
|
112
|
+
this.TS.remove(t);
|
|
108
113
|
}
|
|
109
|
-
|
|
114
|
+
Wl() {
|
|
110
115
|
const t = C(STORAGE_KEYS.Ou);
|
|
111
116
|
let e;
|
|
112
117
|
for (const s of t)
|
|
113
118
|
(e = this.$u(STORAGE_KEYS.Ou[s])),
|
|
114
119
|
null != e && this.Ju(STORAGE_KEYS.Ou[s], e);
|
|
115
120
|
}
|
|
116
|
-
|
|
121
|
+
ll(t) {
|
|
117
122
|
let e;
|
|
118
123
|
if (null == t || 0 === t.length) return !1;
|
|
119
124
|
e = g(t) ? t : [t];
|
|
120
|
-
let s = this.
|
|
125
|
+
let s = this.cS.wr(STORAGE_KEYS.It.tS);
|
|
121
126
|
(null != s && g(s)) || (s = []);
|
|
122
127
|
for (let t = 0; t < e.length; t++) s.push(e[t].qt());
|
|
123
|
-
return this.
|
|
128
|
+
return this.cS.store(STORAGE_KEYS.It.tS, s);
|
|
124
129
|
}
|
|
125
|
-
|
|
126
|
-
return null != t && this.
|
|
130
|
+
wm(t) {
|
|
131
|
+
return null != t && this.ll([t]);
|
|
127
132
|
}
|
|
128
|
-
|
|
129
|
-
let t = this.
|
|
130
|
-
this.
|
|
133
|
+
RS() {
|
|
134
|
+
let t = this.cS.wr(STORAGE_KEYS.It.tS);
|
|
135
|
+
this.cS.remove(STORAGE_KEYS.It.tS), null == t && (t = []);
|
|
131
136
|
const e = [];
|
|
132
137
|
let s = !1,
|
|
133
138
|
r = null;
|
|
134
139
|
if (g(t))
|
|
135
140
|
for (let s = 0; s < t.length; s++)
|
|
136
|
-
ve.
|
|
141
|
+
ve.gS(t[s]) ? e.push(ve._u(t[s])) : (r = s);
|
|
137
142
|
else s = !0;
|
|
138
143
|
if (s || null != r) {
|
|
139
144
|
let o = "Stored events could not be deserialized as Events";
|
|
@@ -146,38 +151,38 @@ export default class ne {
|
|
|
146
151
|
typeof t +
|
|
147
152
|
": " +
|
|
148
153
|
JSON.stringify(t)),
|
|
149
|
-
e.push(new ve(null, p.
|
|
154
|
+
e.push(new ve(null, p.Zl, new Date().valueOf(), null, { e: o }));
|
|
150
155
|
}
|
|
151
156
|
return e;
|
|
152
157
|
}
|
|
153
158
|
Pt(t, e) {
|
|
154
159
|
return (
|
|
155
|
-
!!
|
|
160
|
+
!!ra(
|
|
156
161
|
STORAGE_KEYS.It,
|
|
157
162
|
t,
|
|
158
163
|
"StorageManager cannot store object.",
|
|
159
164
|
"STORAGE_KEYS.OBJECTS",
|
|
160
|
-
) && this.
|
|
165
|
+
) && this.cS.store(t, e)
|
|
161
166
|
);
|
|
162
167
|
}
|
|
163
168
|
St(t) {
|
|
164
169
|
return (
|
|
165
|
-
!!
|
|
170
|
+
!!ra(
|
|
166
171
|
STORAGE_KEYS.It,
|
|
167
172
|
t,
|
|
168
173
|
"StorageManager cannot retrieve object.",
|
|
169
174
|
"STORAGE_KEYS.OBJECTS",
|
|
170
|
-
) && this.
|
|
175
|
+
) && this.cS.wr(t)
|
|
171
176
|
);
|
|
172
177
|
}
|
|
173
178
|
Vt(t) {
|
|
174
179
|
return (
|
|
175
|
-
!!
|
|
180
|
+
!!ra(
|
|
176
181
|
STORAGE_KEYS.It,
|
|
177
182
|
t,
|
|
178
183
|
"StorageManager cannot remove object.",
|
|
179
184
|
"STORAGE_KEYS.OBJECTS",
|
|
180
|
-
) && (this.
|
|
185
|
+
) && (this.cS.remove(t), !0)
|
|
181
186
|
);
|
|
182
187
|
}
|
|
183
188
|
clearData() {
|
|
@@ -185,82 +190,82 @@ export default class ne {
|
|
|
185
190
|
e = C(STORAGE_KEYS.It);
|
|
186
191
|
for (let e = 0; e < t.length; e++) {
|
|
187
192
|
const s = t[e];
|
|
188
|
-
this.
|
|
193
|
+
this.TS.remove(STORAGE_KEYS.Ou[s]);
|
|
189
194
|
}
|
|
190
195
|
for (let t = 0; t < e.length; t++) {
|
|
191
196
|
const s = e[t];
|
|
192
|
-
this.
|
|
197
|
+
this.cS.remove(STORAGE_KEYS.It[s]);
|
|
193
198
|
}
|
|
194
199
|
}
|
|
195
|
-
|
|
200
|
+
IS(t) {
|
|
196
201
|
return t || STORAGE_KEYS.It.sS;
|
|
197
202
|
}
|
|
198
|
-
|
|
199
|
-
let e = this.
|
|
203
|
+
Nc(t) {
|
|
204
|
+
let e = this.cS.wr(STORAGE_KEYS.It.eS);
|
|
200
205
|
null == e && (e = {});
|
|
201
|
-
const s = this.
|
|
206
|
+
const s = this.IS(t[User.rl]),
|
|
202
207
|
r = e[s];
|
|
203
208
|
for (const o in t)
|
|
204
|
-
o !== User.
|
|
209
|
+
o !== User.rl &&
|
|
205
210
|
(null == e[s] || (r && null == r[o])) &&
|
|
206
|
-
this.Fu(t[User.
|
|
211
|
+
this.Fu(t[User.rl], o, t[o]);
|
|
207
212
|
}
|
|
208
213
|
Fu(t, e, s) {
|
|
209
|
-
let r = this.
|
|
214
|
+
let r = this.cS.wr(STORAGE_KEYS.It.eS);
|
|
210
215
|
null == r && (r = {});
|
|
211
|
-
const o = this.
|
|
212
|
-
let
|
|
216
|
+
const o = this.IS(t);
|
|
217
|
+
let a = r[o];
|
|
213
218
|
if (
|
|
214
|
-
(null ==
|
|
219
|
+
(null == a && ((a = {}), null != t && (a[User.rl] = t)), e === User.Eu)
|
|
215
220
|
) {
|
|
216
|
-
null ==
|
|
217
|
-
for (const t in s)
|
|
218
|
-
} else
|
|
219
|
-
return (r[o] =
|
|
221
|
+
null == a[e] && (a[e] = {});
|
|
222
|
+
for (const t in s) a[e][t] = s[t];
|
|
223
|
+
} else a[e] = s;
|
|
224
|
+
return (r[o] = a), this.cS.store(STORAGE_KEYS.It.eS, r);
|
|
220
225
|
}
|
|
221
|
-
|
|
222
|
-
const t = this.
|
|
223
|
-
this.
|
|
226
|
+
bS() {
|
|
227
|
+
const t = this.cS.wr(STORAGE_KEYS.It.eS);
|
|
228
|
+
this.cS.remove(STORAGE_KEYS.It.eS);
|
|
224
229
|
const e = [];
|
|
225
230
|
for (const s in t) null != t[s] && e.push(t[s]);
|
|
226
231
|
return e;
|
|
227
232
|
}
|
|
228
233
|
qu(t) {
|
|
229
|
-
const e = this.
|
|
234
|
+
const e = this.cS.wr(STORAGE_KEYS.It.eS);
|
|
230
235
|
if (null != e) {
|
|
231
|
-
const s = this.
|
|
236
|
+
const s = this.IS(null),
|
|
232
237
|
r = e[s];
|
|
233
238
|
null != r &&
|
|
234
239
|
((e[s] = void 0),
|
|
235
|
-
this.
|
|
236
|
-
(r[User.
|
|
237
|
-
this.
|
|
240
|
+
this.cS.store(STORAGE_KEYS.It.eS, e),
|
|
241
|
+
(r[User.rl] = t),
|
|
242
|
+
this.Nc(r));
|
|
238
243
|
}
|
|
239
|
-
const s = this.$u(STORAGE_KEYS.Ou.
|
|
244
|
+
const s = this.$u(STORAGE_KEYS.Ou.am);
|
|
240
245
|
let r = null;
|
|
241
246
|
null != s && (r = s.Iu);
|
|
242
|
-
const o = this.
|
|
247
|
+
const o = this.RS();
|
|
243
248
|
if (null != o)
|
|
244
249
|
for (let e = 0; e < o.length; e++) {
|
|
245
250
|
const s = o[e];
|
|
246
|
-
null == s.userId && s.sessionId == r && (s.userId = t), this.
|
|
251
|
+
null == s.userId && s.sessionId == r && (s.userId = t), this.wm(s);
|
|
247
252
|
}
|
|
248
253
|
}
|
|
249
|
-
|
|
250
|
-
return this.
|
|
254
|
+
dS() {
|
|
255
|
+
return this.cS.fS;
|
|
251
256
|
}
|
|
252
257
|
}
|
|
253
|
-
(ne.
|
|
258
|
+
(ne.eg = class {
|
|
254
259
|
constructor(t) {
|
|
255
|
-
(this.eu = t), (this.eu = t), (this.fS =
|
|
260
|
+
(this.eu = t), (this.eu = t), (this.fS = eo.NS() ? 3 : 10);
|
|
256
261
|
}
|
|
257
|
-
|
|
262
|
+
mS(t) {
|
|
258
263
|
return t + "." + this.eu;
|
|
259
264
|
}
|
|
260
265
|
store(t, e) {
|
|
261
266
|
const s = { v: e };
|
|
262
267
|
try {
|
|
263
|
-
return localStorage.setItem(this.
|
|
268
|
+
return localStorage.setItem(this.mS(t), JSON.stringify(s)), !0;
|
|
264
269
|
} catch (t) {
|
|
265
270
|
return b.info("Storage failure: " + ci(t)), !1;
|
|
266
271
|
}
|
|
@@ -268,7 +273,7 @@ export default class ne {
|
|
|
268
273
|
wr(t) {
|
|
269
274
|
try {
|
|
270
275
|
let e = null;
|
|
271
|
-
const s = localStorage.getItem(this.
|
|
276
|
+
const s = localStorage.getItem(this.mS(t));
|
|
272
277
|
return null != s && (e = JSON.parse(s)), null == e ? null : e.v;
|
|
273
278
|
} catch (t) {
|
|
274
279
|
return b.info("Storage retrieval failure: " + ci(t)), null;
|
|
@@ -276,19 +281,19 @@ export default class ne {
|
|
|
276
281
|
}
|
|
277
282
|
remove(t) {
|
|
278
283
|
try {
|
|
279
|
-
localStorage.removeItem(this.
|
|
284
|
+
localStorage.removeItem(this.mS(t));
|
|
280
285
|
} catch (t) {
|
|
281
286
|
return b.info("Storage removal failure: " + ci(t)), !1;
|
|
282
287
|
}
|
|
283
288
|
}
|
|
284
289
|
}),
|
|
285
|
-
(ne.
|
|
290
|
+
(ne.rg = class {
|
|
286
291
|
constructor() {
|
|
287
|
-
(this.
|
|
292
|
+
(this.KS = {}), (this.YS = 5242880), (this.fS = 3);
|
|
288
293
|
}
|
|
289
294
|
store(t, e) {
|
|
290
295
|
const s = { value: e },
|
|
291
|
-
r = this.
|
|
296
|
+
r = this.CS(e);
|
|
292
297
|
return r > this.YS
|
|
293
298
|
? (b.info(
|
|
294
299
|
"Storage failure: object is ≈" +
|
|
@@ -297,9 +302,9 @@ export default class ne {
|
|
|
297
302
|
this.YS,
|
|
298
303
|
),
|
|
299
304
|
!1)
|
|
300
|
-
: ((this.
|
|
305
|
+
: ((this.KS[t] = s), !0);
|
|
301
306
|
}
|
|
302
|
-
|
|
307
|
+
CS(t) {
|
|
303
308
|
const e = [],
|
|
304
309
|
s = [t];
|
|
305
310
|
let r = 0;
|
|
@@ -317,20 +322,20 @@ export default class ne {
|
|
|
317
322
|
return r;
|
|
318
323
|
}
|
|
319
324
|
wr(t) {
|
|
320
|
-
const e = this.
|
|
325
|
+
const e = this.KS[t];
|
|
321
326
|
return null == e ? null : e.value;
|
|
322
327
|
}
|
|
323
328
|
remove(t) {
|
|
324
|
-
this.
|
|
329
|
+
this.KS[t] = null;
|
|
325
330
|
}
|
|
326
331
|
}),
|
|
327
|
-
(ne.
|
|
332
|
+
(ne.De = class {
|
|
328
333
|
constructor(t, e, s) {
|
|
329
|
-
(this.eu = t), (this.
|
|
334
|
+
(this.eu = t), (this.DS = e), (this.eu = t), (this.GS = this.MS());
|
|
330
335
|
const r = "number" == typeof s && s > 0 ? s : 400;
|
|
331
|
-
(this.US = 24 * r * 60), (this.pS = {}), (this.
|
|
336
|
+
(this.US = 24 * r * 60), (this.pS = {}), (this.DS = !!e);
|
|
332
337
|
}
|
|
333
|
-
|
|
338
|
+
mS(t) {
|
|
334
339
|
return null != this.eu ? t + "." + this.eu : t;
|
|
335
340
|
}
|
|
336
341
|
MS() {
|
|
@@ -348,12 +353,12 @@ export default class ne {
|
|
|
348
353
|
e
|
|
349
354
|
);
|
|
350
355
|
}
|
|
351
|
-
|
|
356
|
+
Ke() {
|
|
352
357
|
const t = new Date();
|
|
353
358
|
return t.setTime(t.getTime() + 60 * this.US * 1e3), t.getFullYear();
|
|
354
359
|
}
|
|
355
360
|
vS() {
|
|
356
|
-
const t =
|
|
361
|
+
const t = fi(STORAGE_KEYS.Ou),
|
|
357
362
|
e = document.cookie.split(";");
|
|
358
363
|
for (let s = 0; s < e.length; s++) {
|
|
359
364
|
let r = e[s];
|
|
@@ -372,14 +377,14 @@ export default class ne {
|
|
|
372
377
|
}
|
|
373
378
|
store(t, e) {
|
|
374
379
|
this.vS();
|
|
375
|
-
const s = this.
|
|
380
|
+
const s = this.mS(t),
|
|
376
381
|
r = new Date();
|
|
377
382
|
r.setTime(r.getTime() + 60 * this.US * 1e3);
|
|
378
383
|
const o = "expires=" + r.toUTCString(),
|
|
379
|
-
|
|
380
|
-
let
|
|
381
|
-
|
|
382
|
-
const i = s + "=" +
|
|
384
|
+
a = "domain=" + this.GS;
|
|
385
|
+
let n;
|
|
386
|
+
n = this.DS ? e : encodeURIComponent(e);
|
|
387
|
+
const i = s + "=" + n + ";" + o + ";" + a + ";path=/";
|
|
383
388
|
if (i.length >= 4093)
|
|
384
389
|
return (
|
|
385
390
|
b.info(
|
|
@@ -396,7 +401,7 @@ export default class ne {
|
|
|
396
401
|
} catch (t) {
|
|
397
402
|
return b.info("Storage failure: " + ci(t)), (this.pS[s] = !0), !1;
|
|
398
403
|
}
|
|
399
|
-
const S = this.
|
|
404
|
+
const S = this.DS ? String(n) : decodeURIComponent(n);
|
|
400
405
|
return this.LS(s) !== S
|
|
401
406
|
? (b.info(
|
|
402
407
|
`Storage failure: unable to verify cookie write for "${s}". Falling back to other storage.`,
|
|
@@ -407,7 +412,7 @@ export default class ne {
|
|
|
407
412
|
: (delete this.pS[s], !0);
|
|
408
413
|
}
|
|
409
414
|
wr(t) {
|
|
410
|
-
const e = this.
|
|
415
|
+
const e = this.mS(t);
|
|
411
416
|
return this.pS[e] ? null : this.LS(e);
|
|
412
417
|
}
|
|
413
418
|
LS(t) {
|
|
@@ -415,14 +420,14 @@ export default class ne {
|
|
|
415
420
|
s = t + "=",
|
|
416
421
|
r = document.cookie.split(";");
|
|
417
422
|
for (let o = 0; o < r.length; o++) {
|
|
418
|
-
let
|
|
419
|
-
for (; " " ===
|
|
420
|
-
if (0 ===
|
|
423
|
+
let a = r[o];
|
|
424
|
+
for (; " " === a.charAt(0); ) a = a.substring(1);
|
|
425
|
+
if (0 === a.indexOf(s))
|
|
421
426
|
try {
|
|
422
427
|
let t;
|
|
423
|
-
(t = this.
|
|
424
|
-
?
|
|
425
|
-
: decodeURIComponent(
|
|
428
|
+
(t = this.DS
|
|
429
|
+
? a.substring(s.length, a.length)
|
|
430
|
+
: decodeURIComponent(a.substring(s.length, a.length))),
|
|
426
431
|
e.push(t);
|
|
427
432
|
} catch (e) {
|
|
428
433
|
return (
|
|
@@ -433,7 +438,7 @@ export default class ne {
|
|
|
433
438
|
return e.length > 0 ? e[e.length - 1] : null;
|
|
434
439
|
}
|
|
435
440
|
remove(t) {
|
|
436
|
-
this.yS(this.
|
|
441
|
+
this.yS(this.mS(t));
|
|
437
442
|
}
|
|
438
443
|
yS(t) {
|
|
439
444
|
const e = t + "=;expires=" + new Date(0).toUTCString();
|
|
@@ -442,13 +447,13 @@ export default class ne {
|
|
|
442
447
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
443
448
|
}
|
|
444
449
|
}),
|
|
445
|
-
(ne.
|
|
450
|
+
(ne.tg = class {
|
|
446
451
|
constructor(t, e, s, r) {
|
|
447
452
|
(this.eu = t),
|
|
448
453
|
(this.BS = []),
|
|
449
|
-
e && this.BS.push(new ne.
|
|
450
|
-
s && this.BS.push(new ne.
|
|
451
|
-
this.BS.push(new ne.
|
|
454
|
+
e && this.BS.push(new ne.De(t, void 0, r)),
|
|
455
|
+
s && this.BS.push(new ne.eg(t)),
|
|
456
|
+
this.BS.push(new ne.rg());
|
|
452
457
|
}
|
|
453
458
|
store(t, e) {
|
|
454
459
|
let s = !0;
|
|
@@ -463,7 +468,7 @@ export default class ne {
|
|
|
463
468
|
return null;
|
|
464
469
|
}
|
|
465
470
|
remove(t) {
|
|
466
|
-
new ne.
|
|
471
|
+
new ne.De(this.eu).remove(t);
|
|
467
472
|
for (let e = 0; e < this.BS.length; e++) this.BS[e].remove(t);
|
|
468
473
|
}
|
|
469
474
|
});
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { Guid as V } from "../../shared-lib/index.js";
|
|
2
2
|
export default class f {
|
|
3
3
|
constructor() {
|
|
4
|
-
this.
|
|
4
|
+
this.So = {};
|
|
5
5
|
}
|
|
6
6
|
Ut(t) {
|
|
7
7
|
if ("function" != typeof t) return null;
|
|
8
8
|
const i = V.de();
|
|
9
|
-
return (this.
|
|
9
|
+
return (this.So[i] = t), i;
|
|
10
10
|
}
|
|
11
11
|
removeSubscription(t) {
|
|
12
|
-
delete this.
|
|
12
|
+
delete this.So[t];
|
|
13
13
|
}
|
|
14
14
|
removeAllSubscriptions() {
|
|
15
|
-
this.
|
|
15
|
+
this.So = {};
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
return Object.keys(this.
|
|
17
|
+
$h() {
|
|
18
|
+
return Object.keys(this.So).length;
|
|
19
19
|
}
|
|
20
20
|
A(t) {
|
|
21
21
|
const i = [];
|
|
22
|
-
for (const s in this.
|
|
23
|
-
const r = this.
|
|
22
|
+
for (const s in this.So) {
|
|
23
|
+
const r = this.So[s];
|
|
24
24
|
i.push(r(t));
|
|
25
25
|
}
|
|
26
26
|
return i;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Rc: "invalid_api_key",
|
|
3
|
+
qc: "blacklisted",
|
|
4
|
+
Ac: "no_device_identifier",
|
|
5
|
+
vc: "invalid_json_response",
|
|
6
|
+
Ql: "empty_response",
|
|
7
7
|
__: "sdk_auth_error",
|
|
8
8
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
2
|
import { getAlias as Te } from "../managers/utils.js";
|
|
3
|
-
import { isObject as
|
|
3
|
+
import { isObject as Yt } from "../util/code-utils.js";
|
|
4
4
|
import {
|
|
5
5
|
convertMsToSeconds as X,
|
|
6
6
|
timestampOrNow as is,
|
|
@@ -18,7 +18,7 @@ export default class ve {
|
|
|
18
18
|
(this.sessionId = r),
|
|
19
19
|
(this.data = e);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
wa() {
|
|
22
22
|
var t;
|
|
23
23
|
const s = {
|
|
24
24
|
name: this.type,
|
|
@@ -27,7 +27,7 @@ export default class ve {
|
|
|
27
27
|
session_id: this.sessionId,
|
|
28
28
|
};
|
|
29
29
|
null != this.userId && (s.user_id = this.userId);
|
|
30
|
-
const i = (null === (t = r.
|
|
30
|
+
const i = (null === (t = r.Gr()) || void 0 === t ? void 0 : t.hc()) || !1;
|
|
31
31
|
if (!s.user_id && !i) {
|
|
32
32
|
const t = Te(r.p());
|
|
33
33
|
t && (s.alias = t);
|
|
@@ -46,8 +46,8 @@ export default class ve {
|
|
|
46
46
|
static fromJson(t) {
|
|
47
47
|
return new ve(t.user_id, t.name, t.time, t.session_id, t.data);
|
|
48
48
|
}
|
|
49
|
-
static
|
|
50
|
-
return null != t &&
|
|
49
|
+
static gS(t) {
|
|
50
|
+
return null != t && Yt(t) && null != t.t && "" !== t.t;
|
|
51
51
|
}
|
|
52
52
|
static _u(t) {
|
|
53
53
|
return new ve(t.u, t.t, t.ts, t.s, t.d);
|
package/src/models/device.js
CHANGED
|
@@ -2,11 +2,11 @@ export default class ke {
|
|
|
2
2
|
constructor(s) {
|
|
3
3
|
(this.id = s), (this.id = s);
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
wa() {
|
|
6
6
|
const s = {};
|
|
7
7
|
return (
|
|
8
8
|
null != this.browser && (s.browser = this.browser),
|
|
9
|
-
null != this.
|
|
9
|
+
null != this.dc && (s.browser_version = this.dc),
|
|
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),
|
package/src/models/identifier.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Guid as V, logger as b } from "../../shared-lib/index.js";
|
|
2
2
|
import { isArray as g } from "../util/code-utils.js";
|
|
3
3
|
import { getErrorMessage as ci } from "../util/error-utils.js";
|
|
4
|
-
export default class
|
|
4
|
+
export default class Ut {
|
|
5
5
|
constructor(t, e, i) {
|
|
6
6
|
(this.Iu = t),
|
|
7
7
|
null == t && (t = V.de()),
|
|
8
8
|
!i || isNaN(i) ? (this.lm = new Date().valueOf()) : (this.lm = i),
|
|
9
9
|
(this.Iu = t),
|
|
10
|
-
(this.
|
|
11
|
-
(this.
|
|
10
|
+
(this.gm = new Date().valueOf()),
|
|
11
|
+
(this.pm = e);
|
|
12
12
|
}
|
|
13
13
|
qt() {
|
|
14
|
-
return `g:${encodeURIComponent(this.Iu)}|e:${this.
|
|
15
|
-
this.
|
|
14
|
+
return `g:${encodeURIComponent(this.Iu)}|e:${this.pm}|c:${this.lm}|l:${
|
|
15
|
+
this.gm
|
|
16
16
|
}`;
|
|
17
17
|
}
|
|
18
18
|
static AS(t) {
|
|
@@ -37,8 +37,8 @@ export default class _t {
|
|
|
37
37
|
const e = parseInt(r(t));
|
|
38
38
|
if (!isNaN(e)) return e;
|
|
39
39
|
};
|
|
40
|
-
(e = new
|
|
41
|
-
(e.
|
|
40
|
+
(e = new Ut(decodeURIComponent(r(i[0])), n(i[1]), n(i[2]))),
|
|
41
|
+
(e.gm = n(i[3]));
|
|
42
42
|
} catch (e) {
|
|
43
43
|
b.info(
|
|
44
44
|
`Unable to parse cookie string ${t}, failed with error: ${ci(e)}`,
|
|
@@ -46,7 +46,7 @@ export default class _t {
|
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
if (null == t || null == t.g) return null;
|
|
49
|
-
(e = new
|
|
49
|
+
(e = new Ut(t.g, t.e, t.c)), (e.gm = t.l);
|
|
50
50
|
}
|
|
51
51
|
return e;
|
|
52
52
|
}
|