@usermaven/sdk-js 1.5.10-rc.110 → 1.5.10-rc.111
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/dist/index.d.ts +1 -1
- package/dist/usermaven.es.js +199 -60
- package/package.json +2 -3
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import { UsermavenClient } from './core/client';
|
|
|
2
2
|
import { Config, UserProps, EventPayload, ClientProperties } from './core/types';
|
|
3
3
|
import { LogLevel } from './utils/logger';
|
|
4
4
|
declare function usermavenClient(config: Partial<Config>): UsermavenClient;
|
|
5
|
-
export { usermavenClient, UsermavenClient, Config as UsermavenOptions, UserProps, EventPayload, LogLevel, ClientProperties };
|
|
5
|
+
export { usermavenClient, UsermavenClient, Config as UsermavenOptions, UserProps, EventPayload, LogLevel, ClientProperties, };
|
package/dist/usermaven.es.js
CHANGED
|
@@ -32,7 +32,13 @@ const Z = {
|
|
|
32
32
|
gaHook: !1,
|
|
33
33
|
segmentHook: !1,
|
|
34
34
|
randomizeUrl: !1,
|
|
35
|
-
capture3rdPartyCookies: [
|
|
35
|
+
capture3rdPartyCookies: [
|
|
36
|
+
"_ga",
|
|
37
|
+
"_fbp",
|
|
38
|
+
"_ym_uid",
|
|
39
|
+
"ajs_user_id",
|
|
40
|
+
"ajs_anonymous_id"
|
|
41
|
+
],
|
|
36
42
|
idMethod: "cookie",
|
|
37
43
|
ipPolicy: "keep",
|
|
38
44
|
cookiePolicy: "keep",
|
|
@@ -179,7 +185,10 @@ const he = function(n) {
|
|
|
179
185
|
try {
|
|
180
186
|
return n.apply(this, e);
|
|
181
187
|
} catch (t) {
|
|
182
|
-
f().error(
|
|
188
|
+
f().error(
|
|
189
|
+
"Implementation error. Please turn on debug and contact support@usermaven.com.",
|
|
190
|
+
t
|
|
191
|
+
);
|
|
183
192
|
}
|
|
184
193
|
};
|
|
185
194
|
}, Y = function(n) {
|
|
@@ -209,10 +218,13 @@ function ge(n) {
|
|
|
209
218
|
);
|
|
210
219
|
}
|
|
211
220
|
function z(n) {
|
|
212
|
-
return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(z) : Object.keys(n).reduce(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
221
|
+
return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(z) : Object.keys(n).reduce(
|
|
222
|
+
(e, t) => {
|
|
223
|
+
const i = ge(t);
|
|
224
|
+
return e[i] = z(n[t]), e;
|
|
225
|
+
},
|
|
226
|
+
{}
|
|
227
|
+
);
|
|
216
228
|
}
|
|
217
229
|
function x(n) {
|
|
218
230
|
switch (typeof n.className) {
|
|
@@ -242,7 +254,15 @@ function j(n) {
|
|
|
242
254
|
function M(n) {
|
|
243
255
|
return !!n && n.nodeType === 11;
|
|
244
256
|
}
|
|
245
|
-
const C = [
|
|
257
|
+
const C = [
|
|
258
|
+
"a",
|
|
259
|
+
"button",
|
|
260
|
+
"form",
|
|
261
|
+
"input",
|
|
262
|
+
"select",
|
|
263
|
+
"textarea",
|
|
264
|
+
"label"
|
|
265
|
+
];
|
|
246
266
|
function pe(n, e) {
|
|
247
267
|
if (!n || y(n, "html") || !G(n))
|
|
248
268
|
return !1;
|
|
@@ -400,7 +420,9 @@ class _e {
|
|
|
400
420
|
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
401
421
|
}
|
|
402
422
|
checkMilestones(e) {
|
|
403
|
-
this.milestones.filter(
|
|
423
|
+
this.milestones.filter(
|
|
424
|
+
(i) => e >= i
|
|
425
|
+
).forEach((i) => {
|
|
404
426
|
this.send(), this.milestones = this.milestones.filter((s) => s !== i);
|
|
405
427
|
});
|
|
406
428
|
}
|
|
@@ -425,7 +447,9 @@ const I = class I {
|
|
|
425
447
|
return;
|
|
426
448
|
}
|
|
427
449
|
if (!(document && document.body)) {
|
|
428
|
-
this.logger.debug(
|
|
450
|
+
this.logger.debug(
|
|
451
|
+
"Document not ready yet, trying again in 500 milliseconds..."
|
|
452
|
+
), setTimeout(() => this.init(), 500);
|
|
429
453
|
return;
|
|
430
454
|
}
|
|
431
455
|
this.addDomEventHandlers(), this.domHandlersAttached = !0;
|
|
@@ -499,10 +523,13 @@ const I = class I {
|
|
|
499
523
|
}
|
|
500
524
|
extractCustomPropertyValue(e) {
|
|
501
525
|
const t = [];
|
|
502
|
-
return w(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
526
|
+
return w(
|
|
527
|
+
document.querySelectorAll(e.css_selector),
|
|
528
|
+
function(i) {
|
|
529
|
+
let s;
|
|
530
|
+
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), T(s) && t.push(s);
|
|
531
|
+
}
|
|
532
|
+
), t.join(", ");
|
|
506
533
|
}
|
|
507
534
|
getEventTarget(e) {
|
|
508
535
|
var t;
|
|
@@ -589,9 +616,13 @@ class Ee {
|
|
|
589
616
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
590
617
|
}
|
|
591
618
|
async send(e) {
|
|
592
|
-
const t = this.config.key, i = this.constructUrl(t), s = new Blob([JSON.stringify(e)], {
|
|
619
|
+
const t = this.config.key, i = this.constructUrl(t), s = new Blob([JSON.stringify(e)], {
|
|
620
|
+
type: "application/json"
|
|
621
|
+
});
|
|
593
622
|
if (navigator.sendBeacon(i, s))
|
|
594
|
-
this.logger.debug(
|
|
623
|
+
this.logger.debug(
|
|
624
|
+
`Successfully queued ${e.length} event(s) via Beacon API`
|
|
625
|
+
);
|
|
595
626
|
else
|
|
596
627
|
throw new Error("Failed to queue events via Beacon API");
|
|
597
628
|
}
|
|
@@ -721,7 +752,9 @@ class Ae {
|
|
|
721
752
|
class K {
|
|
722
753
|
// Default to true for server-side
|
|
723
754
|
constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = f(), a = "default") {
|
|
724
|
-
this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = s, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new te(
|
|
755
|
+
this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = s, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new te(
|
|
756
|
+
`offline_queue_${a}`
|
|
757
|
+
), h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
725
758
|
}
|
|
726
759
|
add(e) {
|
|
727
760
|
const t = { payload: e, retries: 0, timestamp: Date.now() };
|
|
@@ -735,14 +768,19 @@ class K {
|
|
|
735
768
|
}));
|
|
736
769
|
}
|
|
737
770
|
scheduleBatch() {
|
|
738
|
-
h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
|
|
771
|
+
h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
|
|
772
|
+
() => this.processBatch(),
|
|
773
|
+
this.batchInterval
|
|
774
|
+
));
|
|
739
775
|
}
|
|
740
776
|
async processBatch() {
|
|
741
777
|
if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
742
778
|
this.processing = !0;
|
|
743
779
|
const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
|
|
744
780
|
try {
|
|
745
|
-
await this.transport.send(t), this.logger.debug(
|
|
781
|
+
await this.transport.send(t), this.logger.debug(
|
|
782
|
+
`Successfully sent batch of ${e.length} payloads`
|
|
783
|
+
), h() && this.saveQueueToStorage();
|
|
746
784
|
} catch (i) {
|
|
747
785
|
this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
|
|
748
786
|
}
|
|
@@ -752,7 +790,10 @@ class K {
|
|
|
752
790
|
}
|
|
753
791
|
async handleBatchFailure(e) {
|
|
754
792
|
for (const t of e)
|
|
755
|
-
t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error(
|
|
793
|
+
t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error(
|
|
794
|
+
"Max retries reached, discarding payload",
|
|
795
|
+
t.payload
|
|
796
|
+
);
|
|
756
797
|
h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
|
|
757
798
|
}
|
|
758
799
|
loadQueueFromStorage() {
|
|
@@ -781,14 +822,18 @@ class Se {
|
|
|
781
822
|
}
|
|
782
823
|
click(e, t, i) {
|
|
783
824
|
const s = { x: e, y: t, timestamp: i };
|
|
784
|
-
this.clicks.push(s), this.clicks = this.clicks.filter(
|
|
825
|
+
this.clicks.push(s), this.clicks = this.clicks.filter(
|
|
826
|
+
(r) => i - r.timestamp < this.timeWindow
|
|
827
|
+
), this.clicks.length >= this.threshold && this.checkRageClick();
|
|
785
828
|
}
|
|
786
829
|
checkRageClick() {
|
|
787
830
|
const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
788
831
|
this.clicks.every((r, o) => {
|
|
789
832
|
if (o === 0) return !0;
|
|
790
833
|
const a = this.clicks[o - 1];
|
|
791
|
-
return Math.sqrt(
|
|
834
|
+
return Math.sqrt(
|
|
835
|
+
Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)
|
|
836
|
+
) < this.distanceThreshold;
|
|
792
837
|
}) && this.sendRageClickEvent(i);
|
|
793
838
|
}
|
|
794
839
|
sendRageClickEvent(e) {
|
|
@@ -855,12 +900,17 @@ class A {
|
|
|
855
900
|
trackFieldChanges(e) {
|
|
856
901
|
e.querySelectorAll("input, select, textarea").forEach((i) => {
|
|
857
902
|
i.addEventListener("change", (s) => {
|
|
858
|
-
const r = this._getFieldProps(
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
903
|
+
const r = this._getFieldProps(
|
|
904
|
+
s.target
|
|
905
|
+
);
|
|
906
|
+
this.instance.track(
|
|
907
|
+
"$form_field_change",
|
|
908
|
+
V({
|
|
909
|
+
form_id: e.id,
|
|
910
|
+
form_name: e.name || "",
|
|
911
|
+
field: r
|
|
912
|
+
})
|
|
913
|
+
);
|
|
864
914
|
});
|
|
865
915
|
});
|
|
866
916
|
}
|
|
@@ -876,11 +926,17 @@ class A {
|
|
|
876
926
|
form_class: e.className,
|
|
877
927
|
form_attributes: this._getElementAttributes(e),
|
|
878
928
|
fields: []
|
|
879
|
-
}, i = e.querySelectorAll(
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
929
|
+
}, i = e.querySelectorAll(
|
|
930
|
+
"input, select, textarea"
|
|
931
|
+
);
|
|
932
|
+
return Array.from(i).filter(
|
|
933
|
+
(r) => !r.classList.contains("um-no-capture")
|
|
934
|
+
).forEach(
|
|
935
|
+
(r) => {
|
|
936
|
+
const o = this._getFieldProps(r);
|
|
937
|
+
t.fields.push(o);
|
|
938
|
+
}
|
|
939
|
+
), t;
|
|
884
940
|
}
|
|
885
941
|
_getFieldProps(e) {
|
|
886
942
|
const t = Object.keys(e.dataset).length ? this._convertDOMStringMapToObject(e.dataset) : void 0, i = this.getSafeText(e);
|
|
@@ -971,14 +1027,20 @@ class N {
|
|
|
971
1027
|
// Reduced interval to .2 second
|
|
972
1028
|
this.logger,
|
|
973
1029
|
this.namespace
|
|
974
|
-
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1030
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1031
|
+
`Usermaven client initialized for namespace: ${this.namespace}`
|
|
1032
|
+
);
|
|
975
1033
|
}
|
|
976
1034
|
initializeBrowserFeatures() {
|
|
977
1035
|
if (this.cookieManager = new se(this.config.cookieDomain), this.config.autocapture && H.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new H(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
|
|
978
1036
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
979
|
-
this.formTracking = A.getInstance(
|
|
980
|
-
|
|
981
|
-
|
|
1037
|
+
this.formTracking = A.getInstance(
|
|
1038
|
+
this,
|
|
1039
|
+
e || "none",
|
|
1040
|
+
{
|
|
1041
|
+
trackFieldChanges: !1
|
|
1042
|
+
}
|
|
1043
|
+
);
|
|
982
1044
|
}
|
|
983
1045
|
this.config.autoPageview && (this.pageviewTracking = new be(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Se(this)), this.setupPageLeaveTracking();
|
|
984
1046
|
}
|
|
@@ -1004,7 +1066,9 @@ class N {
|
|
|
1004
1066
|
// Reduced interval to .25 second
|
|
1005
1067
|
this.logger,
|
|
1006
1068
|
this.namespace
|
|
1007
|
-
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1069
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1070
|
+
`Usermaven client reinitialized for namespace: ${this.namespace}`
|
|
1071
|
+
);
|
|
1008
1072
|
}
|
|
1009
1073
|
manageCrossDomainLinking() {
|
|
1010
1074
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
@@ -1034,17 +1098,36 @@ class N {
|
|
|
1034
1098
|
return new Ce(e.trackingHost || t, e);
|
|
1035
1099
|
const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1036
1100
|
if (e.useBeaconApi && r)
|
|
1037
|
-
return new Ee(
|
|
1101
|
+
return new Ee(
|
|
1102
|
+
e.trackingHost || t,
|
|
1103
|
+
e,
|
|
1104
|
+
this.logger
|
|
1105
|
+
);
|
|
1038
1106
|
if (e.forceUseFetch && s)
|
|
1039
|
-
return new W(
|
|
1107
|
+
return new W(
|
|
1108
|
+
e.trackingHost || t,
|
|
1109
|
+
e,
|
|
1110
|
+
this.logger
|
|
1111
|
+
);
|
|
1040
1112
|
if (i)
|
|
1041
|
-
return new Pe(
|
|
1113
|
+
return new Pe(
|
|
1114
|
+
e.trackingHost || t,
|
|
1115
|
+
e,
|
|
1116
|
+
this.logger
|
|
1117
|
+
);
|
|
1042
1118
|
if (s)
|
|
1043
|
-
return new W(
|
|
1119
|
+
return new W(
|
|
1120
|
+
e.trackingHost || t,
|
|
1121
|
+
e,
|
|
1122
|
+
this.logger
|
|
1123
|
+
);
|
|
1044
1124
|
throw new Error("No suitable transport method available");
|
|
1045
1125
|
}
|
|
1046
1126
|
initializePersistence() {
|
|
1047
|
-
return this.config.disableEventPersistence || !h() ? new Ae() : new te(
|
|
1127
|
+
return this.config.disableEventPersistence || !h() ? new Ae() : new te(
|
|
1128
|
+
`${this.namespace}_${this.config.key}`,
|
|
1129
|
+
this.logger
|
|
1130
|
+
);
|
|
1048
1131
|
}
|
|
1049
1132
|
getOrCreateAnonymousId() {
|
|
1050
1133
|
var i, s;
|
|
@@ -1061,7 +1144,13 @@ class N {
|
|
|
1061
1144
|
}
|
|
1062
1145
|
t || (t = R());
|
|
1063
1146
|
const r = 365 * 10;
|
|
1064
|
-
(s = this.cookieManager) == null || s.set(
|
|
1147
|
+
(s = this.cookieManager) == null || s.set(
|
|
1148
|
+
e,
|
|
1149
|
+
t,
|
|
1150
|
+
r,
|
|
1151
|
+
document.location.protocol !== "http:",
|
|
1152
|
+
!1
|
|
1153
|
+
);
|
|
1065
1154
|
}
|
|
1066
1155
|
return t;
|
|
1067
1156
|
}
|
|
@@ -1087,7 +1176,9 @@ class N {
|
|
|
1087
1176
|
}
|
|
1088
1177
|
lead(e, t = !1) {
|
|
1089
1178
|
if (!P(e))
|
|
1090
|
-
throw new Error(
|
|
1179
|
+
throw new Error(
|
|
1180
|
+
"Lead payload must be a non-null object and not an array"
|
|
1181
|
+
);
|
|
1091
1182
|
const i = e.email;
|
|
1092
1183
|
if (!L(i)) {
|
|
1093
1184
|
this.logger.error("Lead event requires a valid email attribute");
|
|
@@ -1108,7 +1199,9 @@ class N {
|
|
|
1108
1199
|
if (!L(e))
|
|
1109
1200
|
throw new Error("Event name must be a string");
|
|
1110
1201
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1111
|
-
throw new Error(
|
|
1202
|
+
throw new Error(
|
|
1203
|
+
"Event payload must be a non-null object and not an array"
|
|
1204
|
+
);
|
|
1112
1205
|
const r = this.createEventPayload(e, t);
|
|
1113
1206
|
try {
|
|
1114
1207
|
if (i) {
|
|
@@ -1129,7 +1222,9 @@ class N {
|
|
|
1129
1222
|
if (!P(e))
|
|
1130
1223
|
throw new Error("Company properties must be an object");
|
|
1131
1224
|
if (!e.id || !e.name || !e.created_at)
|
|
1132
|
-
throw new Error(
|
|
1225
|
+
throw new Error(
|
|
1226
|
+
"Company properties must include id, name, and created_at"
|
|
1227
|
+
);
|
|
1133
1228
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1134
1229
|
}
|
|
1135
1230
|
createEventPayload(e, t) {
|
|
@@ -1154,7 +1249,9 @@ class N {
|
|
|
1154
1249
|
...a
|
|
1155
1250
|
};
|
|
1156
1251
|
if (e === "$autocapture") {
|
|
1157
|
-
const d = this.processAutocaptureAttributes(
|
|
1252
|
+
const d = this.processAutocaptureAttributes(
|
|
1253
|
+
t || {}
|
|
1254
|
+
);
|
|
1158
1255
|
c.autocapture_attributes = d;
|
|
1159
1256
|
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
|
|
1160
1257
|
delete l[d];
|
|
@@ -1164,7 +1261,15 @@ class N {
|
|
|
1164
1261
|
processAutocaptureAttributes(e) {
|
|
1165
1262
|
let t = {};
|
|
1166
1263
|
const i = e.$elements || [];
|
|
1167
|
-
return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
|
|
1264
|
+
return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
|
|
1265
|
+
"$ce_version",
|
|
1266
|
+
"$event_type",
|
|
1267
|
+
"$initial_referrer",
|
|
1268
|
+
"$initial_referring_domain",
|
|
1269
|
+
"$referrer",
|
|
1270
|
+
"$referring_domain",
|
|
1271
|
+
"$elements"
|
|
1272
|
+
].forEach((s) => {
|
|
1168
1273
|
delete t[s];
|
|
1169
1274
|
}), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
|
|
1170
1275
|
}
|
|
@@ -1182,16 +1287,28 @@ class N {
|
|
|
1182
1287
|
}
|
|
1183
1288
|
getUtmParams() {
|
|
1184
1289
|
const e = {}, t = we(window.location.search);
|
|
1185
|
-
return [
|
|
1290
|
+
return [
|
|
1291
|
+
"utm_source",
|
|
1292
|
+
"utm_medium",
|
|
1293
|
+
"utm_campaign",
|
|
1294
|
+
"utm_term",
|
|
1295
|
+
"utm_content"
|
|
1296
|
+
].forEach((s) => {
|
|
1186
1297
|
t[s] && (e[s.replace("utm_", "")] = t[s]);
|
|
1187
1298
|
}), e;
|
|
1188
1299
|
}
|
|
1189
1300
|
pageview() {
|
|
1190
|
-
h() ? this.track(
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1301
|
+
h() ? this.track(
|
|
1302
|
+
"pageview",
|
|
1303
|
+
{
|
|
1304
|
+
url: window.location.href,
|
|
1305
|
+
referrer: document.referrer,
|
|
1306
|
+
title: document.title
|
|
1307
|
+
},
|
|
1308
|
+
!0
|
|
1309
|
+
) : this.logger.warn(
|
|
1310
|
+
"Pageview tracking is not available in server-side environments"
|
|
1311
|
+
);
|
|
1195
1312
|
}
|
|
1196
1313
|
setupPageLeaveTracking() {
|
|
1197
1314
|
if (!h()) return;
|
|
@@ -1226,7 +1343,10 @@ class N {
|
|
|
1226
1343
|
const t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1227
1344
|
this.cookieManager.delete(t), this.anonymousId = this.getOrCreateAnonymousId();
|
|
1228
1345
|
}
|
|
1229
|
-
this.logger.info("core state reset", {
|
|
1346
|
+
this.logger.info("core state reset", {
|
|
1347
|
+
resetAnonId: e,
|
|
1348
|
+
namespace: this.namespace
|
|
1349
|
+
});
|
|
1230
1350
|
}
|
|
1231
1351
|
set(e, t) {
|
|
1232
1352
|
if (!P(e))
|
|
@@ -1259,7 +1379,10 @@ class N {
|
|
|
1259
1379
|
let r = this.persistence.get("global_props") || {};
|
|
1260
1380
|
delete r[e], this.persistence.set("global_props", r);
|
|
1261
1381
|
}
|
|
1262
|
-
s && this.persistence.save(), this.logger.debug(
|
|
1382
|
+
s && this.persistence.save(), this.logger.debug(
|
|
1383
|
+
`Property unset: ${e}`,
|
|
1384
|
+
`Event type: ${i || "global"}`
|
|
1385
|
+
);
|
|
1263
1386
|
}
|
|
1264
1387
|
}
|
|
1265
1388
|
function ie() {
|
|
@@ -1270,13 +1393,18 @@ function Te() {
|
|
|
1270
1393
|
}
|
|
1271
1394
|
const $e = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
|
|
1272
1395
|
function O(n) {
|
|
1273
|
-
const e = JSON.parse(JSON.stringify(n)), t = z(e), i = {
|
|
1396
|
+
const e = JSON.parse(JSON.stringify(n)), t = z(e), i = {
|
|
1397
|
+
...Z,
|
|
1398
|
+
...t
|
|
1399
|
+
};
|
|
1274
1400
|
if (!i.key)
|
|
1275
1401
|
throw new Error("API key is required!");
|
|
1276
1402
|
if (!i.trackingHost)
|
|
1277
1403
|
throw new Error("Tracking host is required!");
|
|
1278
1404
|
const s = i.key || "", r = `${$e}${s}`;
|
|
1279
|
-
return h() && i.autocapture && window[r] && (console.warn(
|
|
1405
|
+
return h() && i.autocapture && window[r] && (console.warn(
|
|
1406
|
+
"Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
|
|
1407
|
+
), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new N(i);
|
|
1280
1408
|
}
|
|
1281
1409
|
function xe(n) {
|
|
1282
1410
|
var s;
|
|
@@ -1300,7 +1428,10 @@ function xe(n) {
|
|
|
1300
1428
|
minSendTimeout: parseInt(n.getAttribute("data-min-send-timeout") || "", 10) || void 0,
|
|
1301
1429
|
maxSendTimeout: parseInt(n.getAttribute("data-max-send-timeout") || "", 10) || void 0,
|
|
1302
1430
|
maxSendAttempts: parseInt(n.getAttribute("data-max-send-attempts") || "", 10) || void 0,
|
|
1303
|
-
propertiesStringMaxLength: parseInt(
|
|
1431
|
+
propertiesStringMaxLength: parseInt(
|
|
1432
|
+
n.getAttribute("data-properties-string-max-length") || "",
|
|
1433
|
+
10
|
|
1434
|
+
) || null,
|
|
1304
1435
|
propertyBlacklist: ((s = n.getAttribute("data-property-blacklist")) == null ? void 0 : s.split(",")) || void 0,
|
|
1305
1436
|
exclude: n.getAttribute("data-exclude") || void 0,
|
|
1306
1437
|
namespace: n.getAttribute("data-namespace") || void 0,
|
|
@@ -1355,7 +1486,15 @@ function He(n, e) {
|
|
|
1355
1486
|
return e[g].apply(e, u.slice(1));
|
|
1356
1487
|
console.error(`Method ${g} not found on UsermavenClient`);
|
|
1357
1488
|
}
|
|
1358
|
-
const l = ["id", "group", "reset"], c = [
|
|
1489
|
+
const l = ["id", "group", "reset"], c = [
|
|
1490
|
+
"track",
|
|
1491
|
+
"lead",
|
|
1492
|
+
"pageview",
|
|
1493
|
+
"set",
|
|
1494
|
+
"unset",
|
|
1495
|
+
"rawTrack",
|
|
1496
|
+
"setUserId"
|
|
1497
|
+
];
|
|
1359
1498
|
[...l, ...c].forEach((u) => {
|
|
1360
1499
|
a[u] = function(...g) {
|
|
1361
1500
|
if (!t) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usermaven/sdk-js",
|
|
3
|
-
"version": "1.5.10-rc.
|
|
3
|
+
"version": "1.5.10-rc.111",
|
|
4
4
|
"description": "Usermaven JavaScript SDK",
|
|
5
5
|
"main": "dist/lib.js",
|
|
6
6
|
"module": "dist/usermaven.es.js",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"jsdom": "^25.0.1",
|
|
38
38
|
"morgan": "^1.10.0",
|
|
39
39
|
"playwright": "^1.40.0",
|
|
40
|
-
"prettier": "^2.8.7",
|
|
41
40
|
"typescript": "^5.0.3",
|
|
42
41
|
"vite": "^5.4.8",
|
|
43
42
|
"vite-plugin-dts": "^4.2.3",
|
|
@@ -57,7 +56,7 @@
|
|
|
57
56
|
"test:e2e:ui": "npm run build && playwright test --ui --config=./playwright.local.config.ts",
|
|
58
57
|
"test:browserstack": "npx browserstack-node-sdk playwright test --config=./playwright.config.ts",
|
|
59
58
|
"lint": "eslint . --ext .ts",
|
|
60
|
-
"format": "
|
|
59
|
+
"format": "biome format --write .",
|
|
61
60
|
"mock": "wait-on dist/lib.js && node server/mockServer.js",
|
|
62
61
|
"example:build": "tsc examples/test.ts --outDir examples",
|
|
63
62
|
"example:serve": "wait-on dist/lib.js && vite --config vite.config.ts",
|