@usermaven/sdk-js 1.3.2 → 1.4.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/dist/npm/usermaven.cjs.js +162 -11
- package/dist/npm/usermaven.d.ts +5 -0
- package/dist/npm/usermaven.es.js +162 -11
- package/dist/web/lib.js +1 -1
- package/package.json +1 -1
|
@@ -783,10 +783,21 @@ function _copyAndTruncateStrings(object, maxStringLength) {
|
|
|
783
783
|
}
|
|
784
784
|
// Function to find the closest link element
|
|
785
785
|
function _findClosestLink(element) {
|
|
786
|
-
while (element && element.tagName
|
|
786
|
+
while (element && element.tagName) {
|
|
787
|
+
if (element.tagName.toLowerCase() == 'a') {
|
|
788
|
+
return element;
|
|
789
|
+
}
|
|
787
790
|
element = element.parentNode;
|
|
788
791
|
}
|
|
789
|
-
return
|
|
792
|
+
return null;
|
|
793
|
+
}
|
|
794
|
+
function _cleanObject(obj) {
|
|
795
|
+
for (var propName in obj) {
|
|
796
|
+
if (obj[propName] === '' || obj[propName] === null || obj[propName] === undefined || (typeof obj[propName] === 'object' && Object.keys(obj[propName]).length === 0)) {
|
|
797
|
+
delete obj[propName];
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
return obj;
|
|
790
801
|
}
|
|
791
802
|
|
|
792
803
|
/*
|
|
@@ -1397,10 +1408,131 @@ var autocapture = {
|
|
|
1397
1408
|
_bind_instance_methods(autocapture);
|
|
1398
1409
|
_safewrap_instance_methods(autocapture);
|
|
1399
1410
|
|
|
1411
|
+
var FormTracking = /** @class */ (function () {
|
|
1412
|
+
function FormTracking(instance, trackingType) {
|
|
1413
|
+
if (trackingType === void 0) { trackingType = 'all'; }
|
|
1414
|
+
this.instance = instance;
|
|
1415
|
+
this.trackingType = trackingType;
|
|
1416
|
+
// Wait for the DOM to be ready
|
|
1417
|
+
if (document.readyState === 'loading') {
|
|
1418
|
+
document.addEventListener('DOMContentLoaded', this.track.bind(this));
|
|
1419
|
+
}
|
|
1420
|
+
else {
|
|
1421
|
+
this.track();
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Track form submit
|
|
1426
|
+
* @description this function will be called on every form submit event to track form submit
|
|
1427
|
+
*/
|
|
1428
|
+
FormTracking.prototype.track = function () {
|
|
1429
|
+
var _this = this;
|
|
1430
|
+
this.formElements = document.querySelectorAll('form');
|
|
1431
|
+
if (this.trackingType === 'tagged') {
|
|
1432
|
+
this.formElements = document.querySelectorAll('form[data-um-form]');
|
|
1433
|
+
}
|
|
1434
|
+
this.formElements.forEach(function (form) {
|
|
1435
|
+
form.addEventListener('submit', function (event) {
|
|
1436
|
+
var form = event.target;
|
|
1437
|
+
var props = _this._getFormDetails(form);
|
|
1438
|
+
_this.instance.capture('$form', _cleanObject(props));
|
|
1439
|
+
});
|
|
1440
|
+
});
|
|
1441
|
+
};
|
|
1442
|
+
FormTracking.getInstance = function (instance, trackingType) {
|
|
1443
|
+
if (trackingType === void 0) { trackingType = 'all'; }
|
|
1444
|
+
if (!FormTracking.instance) {
|
|
1445
|
+
FormTracking.instance = new FormTracking(instance, trackingType);
|
|
1446
|
+
}
|
|
1447
|
+
return FormTracking.instance;
|
|
1448
|
+
};
|
|
1449
|
+
FormTracking.prototype._getFormDetails = function (form) {
|
|
1450
|
+
var _this = this;
|
|
1451
|
+
var formDetails = {
|
|
1452
|
+
form_id: form.id,
|
|
1453
|
+
form_name: form.name || '',
|
|
1454
|
+
form_action: form.action,
|
|
1455
|
+
form_method: form.method,
|
|
1456
|
+
};
|
|
1457
|
+
var formFields = form.querySelectorAll('input, select, textarea');
|
|
1458
|
+
// ignore form fields with class um-no-capture
|
|
1459
|
+
var filteredFormFields = Array.from(formFields).filter(function (field) { return !field.classList.contains('um-no-capture'); });
|
|
1460
|
+
filteredFormFields.forEach(function (field, index) {
|
|
1461
|
+
var fieldProps = _this._getFieldProps(field, index);
|
|
1462
|
+
Object.assign(formDetails, fieldProps);
|
|
1463
|
+
});
|
|
1464
|
+
return formDetails;
|
|
1465
|
+
};
|
|
1466
|
+
FormTracking.prototype._getFieldProps = function (field, index) {
|
|
1467
|
+
var _a;
|
|
1468
|
+
var fieldDataAttributes = Object.keys(field.dataset).length ? JSON.stringify(field.dataset) : undefined;
|
|
1469
|
+
var safeValue = this.getSafeText(field);
|
|
1470
|
+
return _a = {},
|
|
1471
|
+
_a["field_" + (index + 1) + "_tag"] = field.tagName.toLowerCase(),
|
|
1472
|
+
_a["field_" + (index + 1) + "_type"] = field instanceof HTMLInputElement ? field.type : undefined,
|
|
1473
|
+
_a["field_" + (index + 1) + "_data_attributes"] = fieldDataAttributes,
|
|
1474
|
+
_a["field_" + (index + 1) + "_id"] = field.id,
|
|
1475
|
+
_a["field_" + (index + 1) + "_value"] = safeValue,
|
|
1476
|
+
_a["field_" + (index + 1) + "_class"] = field.className,
|
|
1477
|
+
_a["field_" + (index + 1) + "_name"] = field.name,
|
|
1478
|
+
_a;
|
|
1479
|
+
};
|
|
1480
|
+
FormTracking.prototype.getSafeText = function (element) {
|
|
1481
|
+
var safeText = '';
|
|
1482
|
+
if ('value' in element && element.type !== "password") {
|
|
1483
|
+
safeText = element.value;
|
|
1484
|
+
}
|
|
1485
|
+
else if (element.hasChildNodes()) {
|
|
1486
|
+
var textNodes = Array.from(element.childNodes).filter(function (node) { return node.nodeType === Node.TEXT_NODE; });
|
|
1487
|
+
safeText = textNodes.map(function (node) { return node.textContent; }).join('');
|
|
1488
|
+
}
|
|
1489
|
+
else {
|
|
1490
|
+
safeText = element.textContent || '';
|
|
1491
|
+
}
|
|
1492
|
+
return this._scrubPotentiallySensitiveValues(safeText);
|
|
1493
|
+
};
|
|
1494
|
+
FormTracking.prototype._scrubPotentiallySensitiveValues = function (text) {
|
|
1495
|
+
if (!this._shouldCaptureValue(text)) {
|
|
1496
|
+
return '<redacted>';
|
|
1497
|
+
}
|
|
1498
|
+
return text;
|
|
1499
|
+
};
|
|
1500
|
+
FormTracking.prototype._shouldCaptureValue = function (value) {
|
|
1501
|
+
if (this._isNullish(value)) {
|
|
1502
|
+
return false;
|
|
1503
|
+
}
|
|
1504
|
+
if (this._isString(value)) {
|
|
1505
|
+
value = this._trim(value);
|
|
1506
|
+
// check to see if input value looks like a credit card number
|
|
1507
|
+
// see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
|
|
1508
|
+
var ccRegex = /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/;
|
|
1509
|
+
if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
|
|
1510
|
+
return false;
|
|
1511
|
+
}
|
|
1512
|
+
// check to see if input value looks like a social security number
|
|
1513
|
+
var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
|
|
1514
|
+
if (ssnRegex.test(value)) {
|
|
1515
|
+
return false;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
return true;
|
|
1519
|
+
};
|
|
1520
|
+
FormTracking.prototype._isNullish = function (value) {
|
|
1521
|
+
return value === null || value === undefined;
|
|
1522
|
+
};
|
|
1523
|
+
FormTracking.prototype._isString = function (value) {
|
|
1524
|
+
return typeof value === 'string' || value instanceof String;
|
|
1525
|
+
};
|
|
1526
|
+
FormTracking.prototype._trim = function (value) {
|
|
1527
|
+
return value.trim().replace(/^\s+|\s+$/g, '');
|
|
1528
|
+
};
|
|
1529
|
+
return FormTracking;
|
|
1530
|
+
}());
|
|
1531
|
+
|
|
1400
1532
|
var VERSION_INFO = {
|
|
1401
1533
|
env: 'production',
|
|
1402
|
-
date: '2024-
|
|
1403
|
-
version: '1.
|
|
1534
|
+
date: '2024-05-21T10:41:05.452Z',
|
|
1535
|
+
version: '1.4.0'
|
|
1404
1536
|
};
|
|
1405
1537
|
var USERMAVEN_VERSION = VERSION_INFO.version + "/" + VERSION_INFO.env + "@" + VERSION_INFO.date;
|
|
1406
1538
|
var MAX_AGE_TEN_YEARS = 31622400 * 10;
|
|
@@ -1820,6 +1952,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
1820
1952
|
this.randomizeUrl = false;
|
|
1821
1953
|
this.namespace = "usermaven";
|
|
1822
1954
|
this.crossDomainLinking = true;
|
|
1955
|
+
this.formTracking = false;
|
|
1823
1956
|
this.domains = [];
|
|
1824
1957
|
this.apiKey = "";
|
|
1825
1958
|
this.initialized = false;
|
|
@@ -2138,7 +2271,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2138
2271
|
};
|
|
2139
2272
|
UsermavenClientImpl.prototype.init = function (options) {
|
|
2140
2273
|
var _this = this;
|
|
2141
|
-
var _a, _b, _c, _d, _e;
|
|
2274
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2142
2275
|
if (isWindowAvailable() && !options.force_use_fetch) {
|
|
2143
2276
|
if (options.fetch) {
|
|
2144
2277
|
getLogger().warn("Custom fetch implementation is provided to Usermaven. However, it will be ignored since Usermaven runs in browser");
|
|
@@ -2198,6 +2331,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2198
2331
|
this.cookieDomain = options.cookie_domain || getCookieDomain();
|
|
2199
2332
|
this.namespace = options.namespace || "usermaven";
|
|
2200
2333
|
this.crossDomainLinking = (_a = options.cross_domain_linking) !== null && _a !== void 0 ? _a : true;
|
|
2334
|
+
this.formTracking = (_b = options.form_tracking) !== null && _b !== void 0 ? _b : false;
|
|
2201
2335
|
this.domains = options.domains ? (options.domains).split(',').map(function (domain) { return domain.trim(); }) : [];
|
|
2202
2336
|
this.trackingHost = getHostWithProtocol(options["tracking_host"] || "t.usermaven.com");
|
|
2203
2337
|
this.randomizeUrl = options.randomize_url || false;
|
|
@@ -2224,8 +2358,8 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2224
2358
|
var restored = this.propsPersistance.restore();
|
|
2225
2359
|
if (restored) {
|
|
2226
2360
|
this.permanentProperties = restored;
|
|
2227
|
-
this.permanentProperties.globalProps = (
|
|
2228
|
-
this.permanentProperties.propsPerEvent = (
|
|
2361
|
+
this.permanentProperties.globalProps = (_c = restored.globalProps) !== null && _c !== void 0 ? _c : {};
|
|
2362
|
+
this.permanentProperties.propsPerEvent = (_d = restored.propsPerEvent) !== null && _d !== void 0 ? _d : {};
|
|
2229
2363
|
}
|
|
2230
2364
|
getLogger().debug("Restored persistent properties", this.permanentProperties);
|
|
2231
2365
|
}
|
|
@@ -2242,6 +2376,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2242
2376
|
getLogger().debug('Default Configuration', this.config);
|
|
2243
2377
|
// this.manageSession(this.config);
|
|
2244
2378
|
this.manageAutoCapture(this.config);
|
|
2379
|
+
this.manageFormTracking(this.config);
|
|
2245
2380
|
this.manageCrossDomainLinking({
|
|
2246
2381
|
cross_domain_linking: this.crossDomainLinking,
|
|
2247
2382
|
domains: this.domains,
|
|
@@ -2276,8 +2411,8 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2276
2411
|
enableAutoPageviews(this);
|
|
2277
2412
|
}
|
|
2278
2413
|
this.retryTimeout = [
|
|
2279
|
-
(
|
|
2280
|
-
(
|
|
2414
|
+
(_e = options.min_send_timeout) !== null && _e !== void 0 ? _e : this.retryTimeout[0],
|
|
2415
|
+
(_f = options.max_send_timeout) !== null && _f !== void 0 ? _f : this.retryTimeout[1],
|
|
2281
2416
|
];
|
|
2282
2417
|
if (!!options.max_send_attempts) {
|
|
2283
2418
|
this.maxSendAttempts = options.max_send_attempts;
|
|
@@ -2374,7 +2509,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2374
2509
|
var target = _findClosestLink(event.target);
|
|
2375
2510
|
if (target) {
|
|
2376
2511
|
// Check if the link is pointing to a different domain
|
|
2377
|
-
var href = target.getAttribute('href');
|
|
2512
|
+
var href = (target === null || target === void 0 ? void 0 : target.hasAttribute('href')) ? target === null || target === void 0 ? void 0 : target.getAttribute('href') : '';
|
|
2378
2513
|
if (href && href.startsWith('http')) {
|
|
2379
2514
|
var url = new URL(href);
|
|
2380
2515
|
var cookie = getCookie(cookieName);
|
|
@@ -2418,6 +2553,18 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2418
2553
|
autocapture.init(this, options);
|
|
2419
2554
|
}
|
|
2420
2555
|
};
|
|
2556
|
+
/**
|
|
2557
|
+
* Manage form tracking
|
|
2558
|
+
*/
|
|
2559
|
+
UsermavenClientImpl.prototype.manageFormTracking = function (options) {
|
|
2560
|
+
if (!isWindowAvailable() || !this.formTracking || this.formTracking === "none") {
|
|
2561
|
+
return;
|
|
2562
|
+
}
|
|
2563
|
+
getLogger().debug('Form tracking enabled...');
|
|
2564
|
+
// all and true are the same
|
|
2565
|
+
var trackingType = this.formTracking === true ? 'all' : this.formTracking;
|
|
2566
|
+
FormTracking.getInstance(this, trackingType).track();
|
|
2567
|
+
};
|
|
2421
2568
|
/**
|
|
2422
2569
|
* Capture an event. This is the most important and
|
|
2423
2570
|
* frequently used usermaven function.
|
|
@@ -2458,12 +2605,16 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2458
2605
|
if (event_name === '$scroll') {
|
|
2459
2606
|
this.track(event_name, data.properties);
|
|
2460
2607
|
}
|
|
2608
|
+
// send event if the event is $form
|
|
2609
|
+
if (event_name === '$form') {
|
|
2610
|
+
this.track(event_name, data.properties);
|
|
2611
|
+
}
|
|
2461
2612
|
};
|
|
2462
2613
|
UsermavenClientImpl.prototype._calculate_event_properties = function (event_name, event_properties) {
|
|
2463
2614
|
var _a, _b;
|
|
2464
2615
|
// set defaults
|
|
2465
2616
|
var properties = event_properties || {};
|
|
2466
|
-
if (event_name === '$snapshot' || event_name === '$scroll') {
|
|
2617
|
+
if (event_name === '$snapshot' || event_name === '$scroll' || event_name === '$form') {
|
|
2467
2618
|
return properties;
|
|
2468
2619
|
}
|
|
2469
2620
|
if (_isArray(this.propertyBlacklist)) {
|
package/dist/npm/usermaven.d.ts
CHANGED
package/dist/npm/usermaven.es.js
CHANGED
|
@@ -779,10 +779,21 @@ function _copyAndTruncateStrings(object, maxStringLength) {
|
|
|
779
779
|
}
|
|
780
780
|
// Function to find the closest link element
|
|
781
781
|
function _findClosestLink(element) {
|
|
782
|
-
while (element && element.tagName
|
|
782
|
+
while (element && element.tagName) {
|
|
783
|
+
if (element.tagName.toLowerCase() == 'a') {
|
|
784
|
+
return element;
|
|
785
|
+
}
|
|
783
786
|
element = element.parentNode;
|
|
784
787
|
}
|
|
785
|
-
return
|
|
788
|
+
return null;
|
|
789
|
+
}
|
|
790
|
+
function _cleanObject(obj) {
|
|
791
|
+
for (var propName in obj) {
|
|
792
|
+
if (obj[propName] === '' || obj[propName] === null || obj[propName] === undefined || (typeof obj[propName] === 'object' && Object.keys(obj[propName]).length === 0)) {
|
|
793
|
+
delete obj[propName];
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return obj;
|
|
786
797
|
}
|
|
787
798
|
|
|
788
799
|
/*
|
|
@@ -1393,10 +1404,131 @@ var autocapture = {
|
|
|
1393
1404
|
_bind_instance_methods(autocapture);
|
|
1394
1405
|
_safewrap_instance_methods(autocapture);
|
|
1395
1406
|
|
|
1407
|
+
var FormTracking = /** @class */ (function () {
|
|
1408
|
+
function FormTracking(instance, trackingType) {
|
|
1409
|
+
if (trackingType === void 0) { trackingType = 'all'; }
|
|
1410
|
+
this.instance = instance;
|
|
1411
|
+
this.trackingType = trackingType;
|
|
1412
|
+
// Wait for the DOM to be ready
|
|
1413
|
+
if (document.readyState === 'loading') {
|
|
1414
|
+
document.addEventListener('DOMContentLoaded', this.track.bind(this));
|
|
1415
|
+
}
|
|
1416
|
+
else {
|
|
1417
|
+
this.track();
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Track form submit
|
|
1422
|
+
* @description this function will be called on every form submit event to track form submit
|
|
1423
|
+
*/
|
|
1424
|
+
FormTracking.prototype.track = function () {
|
|
1425
|
+
var _this = this;
|
|
1426
|
+
this.formElements = document.querySelectorAll('form');
|
|
1427
|
+
if (this.trackingType === 'tagged') {
|
|
1428
|
+
this.formElements = document.querySelectorAll('form[data-um-form]');
|
|
1429
|
+
}
|
|
1430
|
+
this.formElements.forEach(function (form) {
|
|
1431
|
+
form.addEventListener('submit', function (event) {
|
|
1432
|
+
var form = event.target;
|
|
1433
|
+
var props = _this._getFormDetails(form);
|
|
1434
|
+
_this.instance.capture('$form', _cleanObject(props));
|
|
1435
|
+
});
|
|
1436
|
+
});
|
|
1437
|
+
};
|
|
1438
|
+
FormTracking.getInstance = function (instance, trackingType) {
|
|
1439
|
+
if (trackingType === void 0) { trackingType = 'all'; }
|
|
1440
|
+
if (!FormTracking.instance) {
|
|
1441
|
+
FormTracking.instance = new FormTracking(instance, trackingType);
|
|
1442
|
+
}
|
|
1443
|
+
return FormTracking.instance;
|
|
1444
|
+
};
|
|
1445
|
+
FormTracking.prototype._getFormDetails = function (form) {
|
|
1446
|
+
var _this = this;
|
|
1447
|
+
var formDetails = {
|
|
1448
|
+
form_id: form.id,
|
|
1449
|
+
form_name: form.name || '',
|
|
1450
|
+
form_action: form.action,
|
|
1451
|
+
form_method: form.method,
|
|
1452
|
+
};
|
|
1453
|
+
var formFields = form.querySelectorAll('input, select, textarea');
|
|
1454
|
+
// ignore form fields with class um-no-capture
|
|
1455
|
+
var filteredFormFields = Array.from(formFields).filter(function (field) { return !field.classList.contains('um-no-capture'); });
|
|
1456
|
+
filteredFormFields.forEach(function (field, index) {
|
|
1457
|
+
var fieldProps = _this._getFieldProps(field, index);
|
|
1458
|
+
Object.assign(formDetails, fieldProps);
|
|
1459
|
+
});
|
|
1460
|
+
return formDetails;
|
|
1461
|
+
};
|
|
1462
|
+
FormTracking.prototype._getFieldProps = function (field, index) {
|
|
1463
|
+
var _a;
|
|
1464
|
+
var fieldDataAttributes = Object.keys(field.dataset).length ? JSON.stringify(field.dataset) : undefined;
|
|
1465
|
+
var safeValue = this.getSafeText(field);
|
|
1466
|
+
return _a = {},
|
|
1467
|
+
_a["field_" + (index + 1) + "_tag"] = field.tagName.toLowerCase(),
|
|
1468
|
+
_a["field_" + (index + 1) + "_type"] = field instanceof HTMLInputElement ? field.type : undefined,
|
|
1469
|
+
_a["field_" + (index + 1) + "_data_attributes"] = fieldDataAttributes,
|
|
1470
|
+
_a["field_" + (index + 1) + "_id"] = field.id,
|
|
1471
|
+
_a["field_" + (index + 1) + "_value"] = safeValue,
|
|
1472
|
+
_a["field_" + (index + 1) + "_class"] = field.className,
|
|
1473
|
+
_a["field_" + (index + 1) + "_name"] = field.name,
|
|
1474
|
+
_a;
|
|
1475
|
+
};
|
|
1476
|
+
FormTracking.prototype.getSafeText = function (element) {
|
|
1477
|
+
var safeText = '';
|
|
1478
|
+
if ('value' in element && element.type !== "password") {
|
|
1479
|
+
safeText = element.value;
|
|
1480
|
+
}
|
|
1481
|
+
else if (element.hasChildNodes()) {
|
|
1482
|
+
var textNodes = Array.from(element.childNodes).filter(function (node) { return node.nodeType === Node.TEXT_NODE; });
|
|
1483
|
+
safeText = textNodes.map(function (node) { return node.textContent; }).join('');
|
|
1484
|
+
}
|
|
1485
|
+
else {
|
|
1486
|
+
safeText = element.textContent || '';
|
|
1487
|
+
}
|
|
1488
|
+
return this._scrubPotentiallySensitiveValues(safeText);
|
|
1489
|
+
};
|
|
1490
|
+
FormTracking.prototype._scrubPotentiallySensitiveValues = function (text) {
|
|
1491
|
+
if (!this._shouldCaptureValue(text)) {
|
|
1492
|
+
return '<redacted>';
|
|
1493
|
+
}
|
|
1494
|
+
return text;
|
|
1495
|
+
};
|
|
1496
|
+
FormTracking.prototype._shouldCaptureValue = function (value) {
|
|
1497
|
+
if (this._isNullish(value)) {
|
|
1498
|
+
return false;
|
|
1499
|
+
}
|
|
1500
|
+
if (this._isString(value)) {
|
|
1501
|
+
value = this._trim(value);
|
|
1502
|
+
// check to see if input value looks like a credit card number
|
|
1503
|
+
// see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
|
|
1504
|
+
var ccRegex = /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/;
|
|
1505
|
+
if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
|
|
1506
|
+
return false;
|
|
1507
|
+
}
|
|
1508
|
+
// check to see if input value looks like a social security number
|
|
1509
|
+
var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
|
|
1510
|
+
if (ssnRegex.test(value)) {
|
|
1511
|
+
return false;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
return true;
|
|
1515
|
+
};
|
|
1516
|
+
FormTracking.prototype._isNullish = function (value) {
|
|
1517
|
+
return value === null || value === undefined;
|
|
1518
|
+
};
|
|
1519
|
+
FormTracking.prototype._isString = function (value) {
|
|
1520
|
+
return typeof value === 'string' || value instanceof String;
|
|
1521
|
+
};
|
|
1522
|
+
FormTracking.prototype._trim = function (value) {
|
|
1523
|
+
return value.trim().replace(/^\s+|\s+$/g, '');
|
|
1524
|
+
};
|
|
1525
|
+
return FormTracking;
|
|
1526
|
+
}());
|
|
1527
|
+
|
|
1396
1528
|
var VERSION_INFO = {
|
|
1397
1529
|
env: 'production',
|
|
1398
|
-
date: '2024-
|
|
1399
|
-
version: '1.
|
|
1530
|
+
date: '2024-05-21T10:41:05.452Z',
|
|
1531
|
+
version: '1.4.0'
|
|
1400
1532
|
};
|
|
1401
1533
|
var USERMAVEN_VERSION = VERSION_INFO.version + "/" + VERSION_INFO.env + "@" + VERSION_INFO.date;
|
|
1402
1534
|
var MAX_AGE_TEN_YEARS = 31622400 * 10;
|
|
@@ -1816,6 +1948,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
1816
1948
|
this.randomizeUrl = false;
|
|
1817
1949
|
this.namespace = "usermaven";
|
|
1818
1950
|
this.crossDomainLinking = true;
|
|
1951
|
+
this.formTracking = false;
|
|
1819
1952
|
this.domains = [];
|
|
1820
1953
|
this.apiKey = "";
|
|
1821
1954
|
this.initialized = false;
|
|
@@ -2134,7 +2267,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2134
2267
|
};
|
|
2135
2268
|
UsermavenClientImpl.prototype.init = function (options) {
|
|
2136
2269
|
var _this = this;
|
|
2137
|
-
var _a, _b, _c, _d, _e;
|
|
2270
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2138
2271
|
if (isWindowAvailable() && !options.force_use_fetch) {
|
|
2139
2272
|
if (options.fetch) {
|
|
2140
2273
|
getLogger().warn("Custom fetch implementation is provided to Usermaven. However, it will be ignored since Usermaven runs in browser");
|
|
@@ -2194,6 +2327,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2194
2327
|
this.cookieDomain = options.cookie_domain || getCookieDomain();
|
|
2195
2328
|
this.namespace = options.namespace || "usermaven";
|
|
2196
2329
|
this.crossDomainLinking = (_a = options.cross_domain_linking) !== null && _a !== void 0 ? _a : true;
|
|
2330
|
+
this.formTracking = (_b = options.form_tracking) !== null && _b !== void 0 ? _b : false;
|
|
2197
2331
|
this.domains = options.domains ? (options.domains).split(',').map(function (domain) { return domain.trim(); }) : [];
|
|
2198
2332
|
this.trackingHost = getHostWithProtocol(options["tracking_host"] || "t.usermaven.com");
|
|
2199
2333
|
this.randomizeUrl = options.randomize_url || false;
|
|
@@ -2220,8 +2354,8 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2220
2354
|
var restored = this.propsPersistance.restore();
|
|
2221
2355
|
if (restored) {
|
|
2222
2356
|
this.permanentProperties = restored;
|
|
2223
|
-
this.permanentProperties.globalProps = (
|
|
2224
|
-
this.permanentProperties.propsPerEvent = (
|
|
2357
|
+
this.permanentProperties.globalProps = (_c = restored.globalProps) !== null && _c !== void 0 ? _c : {};
|
|
2358
|
+
this.permanentProperties.propsPerEvent = (_d = restored.propsPerEvent) !== null && _d !== void 0 ? _d : {};
|
|
2225
2359
|
}
|
|
2226
2360
|
getLogger().debug("Restored persistent properties", this.permanentProperties);
|
|
2227
2361
|
}
|
|
@@ -2238,6 +2372,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2238
2372
|
getLogger().debug('Default Configuration', this.config);
|
|
2239
2373
|
// this.manageSession(this.config);
|
|
2240
2374
|
this.manageAutoCapture(this.config);
|
|
2375
|
+
this.manageFormTracking(this.config);
|
|
2241
2376
|
this.manageCrossDomainLinking({
|
|
2242
2377
|
cross_domain_linking: this.crossDomainLinking,
|
|
2243
2378
|
domains: this.domains,
|
|
@@ -2272,8 +2407,8 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2272
2407
|
enableAutoPageviews(this);
|
|
2273
2408
|
}
|
|
2274
2409
|
this.retryTimeout = [
|
|
2275
|
-
(
|
|
2276
|
-
(
|
|
2410
|
+
(_e = options.min_send_timeout) !== null && _e !== void 0 ? _e : this.retryTimeout[0],
|
|
2411
|
+
(_f = options.max_send_timeout) !== null && _f !== void 0 ? _f : this.retryTimeout[1],
|
|
2277
2412
|
];
|
|
2278
2413
|
if (!!options.max_send_attempts) {
|
|
2279
2414
|
this.maxSendAttempts = options.max_send_attempts;
|
|
@@ -2370,7 +2505,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2370
2505
|
var target = _findClosestLink(event.target);
|
|
2371
2506
|
if (target) {
|
|
2372
2507
|
// Check if the link is pointing to a different domain
|
|
2373
|
-
var href = target.getAttribute('href');
|
|
2508
|
+
var href = (target === null || target === void 0 ? void 0 : target.hasAttribute('href')) ? target === null || target === void 0 ? void 0 : target.getAttribute('href') : '';
|
|
2374
2509
|
if (href && href.startsWith('http')) {
|
|
2375
2510
|
var url = new URL(href);
|
|
2376
2511
|
var cookie = getCookie(cookieName);
|
|
@@ -2414,6 +2549,18 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2414
2549
|
autocapture.init(this, options);
|
|
2415
2550
|
}
|
|
2416
2551
|
};
|
|
2552
|
+
/**
|
|
2553
|
+
* Manage form tracking
|
|
2554
|
+
*/
|
|
2555
|
+
UsermavenClientImpl.prototype.manageFormTracking = function (options) {
|
|
2556
|
+
if (!isWindowAvailable() || !this.formTracking || this.formTracking === "none") {
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2559
|
+
getLogger().debug('Form tracking enabled...');
|
|
2560
|
+
// all and true are the same
|
|
2561
|
+
var trackingType = this.formTracking === true ? 'all' : this.formTracking;
|
|
2562
|
+
FormTracking.getInstance(this, trackingType).track();
|
|
2563
|
+
};
|
|
2417
2564
|
/**
|
|
2418
2565
|
* Capture an event. This is the most important and
|
|
2419
2566
|
* frequently used usermaven function.
|
|
@@ -2454,12 +2601,16 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2454
2601
|
if (event_name === '$scroll') {
|
|
2455
2602
|
this.track(event_name, data.properties);
|
|
2456
2603
|
}
|
|
2604
|
+
// send event if the event is $form
|
|
2605
|
+
if (event_name === '$form') {
|
|
2606
|
+
this.track(event_name, data.properties);
|
|
2607
|
+
}
|
|
2457
2608
|
};
|
|
2458
2609
|
UsermavenClientImpl.prototype._calculate_event_properties = function (event_name, event_properties) {
|
|
2459
2610
|
var _a, _b;
|
|
2460
2611
|
// set defaults
|
|
2461
2612
|
var properties = event_properties || {};
|
|
2462
|
-
if (event_name === '$snapshot' || event_name === '$scroll') {
|
|
2613
|
+
if (event_name === '$snapshot' || event_name === '$scroll' || event_name === '$form') {
|
|
2463
2614
|
return properties;
|
|
2464
2615
|
}
|
|
2465
2616
|
if (_isArray(this.propertyBlacklist)) {
|
package/dist/web/lib.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t,n,i){return new(n||(n=Promise))((function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function n(e,t){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],i=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function i(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;r<o;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}function r(e=void 0){const t=!!globalThis.window&&!!globalThis.window.document&&!!globalThis.window.location;return!t&&e&&c().warn(e),t}function o(e=void 0){if(!r())throw new Error(e||"window' is not available. Seems like this code runs outside browser environment. It shouldn't happen");return window}"function"==typeof SuppressedError&&SuppressedError;var s={DEBUG:{name:"DEBUG",severity:10},INFO:{name:"INFO",severity:100},WARN:{name:"WARN",severity:1e3},ERROR:{name:"ERROR",severity:1e4},NONE:{name:"NONE",severity:1e4}},a=null;function c(){return a||(a=u())}function u(e){var t=r()&&window.__eventNLogLevel,n=s.WARN;if(t){var o=s[t.toUpperCase()];o&&o>0&&(n=o)}else e&&(n=e);var a={minLogLevel:n};return Object.values(s).forEach((function(e){var t=e.name,r=e.severity;a[t.toLowerCase()]=function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];if(r>=n.severity&&e.length>0){var s=e[0],a=e.splice(1),c="[J-"+t+"] "+s;"DEBUG"===t||"INFO"===t?console.log.apply(console,i([c],a,!1)):"WARN"===t?console.warn.apply(console,i([c],a,!1)):console.error.apply(console,i([c],a,!1))}}})),function(e,t){if(r()){var n=window;n.__usermavenDebug||(n.__usermavenDebug={}),n.__usermavenDebug[e]=t}}("logger",a),a}function l(e,t,n){void 0===n&&(n={});try{var i=n.maxAge,r=n.domain,o=n.path,s=n.expires,a=n.httpOnly,u=n.secure,l=n.sameSite,p=e+"="+encodeURIComponent(t);if(r&&(p+="; domain="+r),p+=o?"; path="+o:"; path=/",s&&(p+="; expires="+s.toUTCString()),i&&(p+="; max-age="+i),a&&(p+="; httponly"),u&&(p+="; secure"),l)switch("string"==typeof l?l.toLowerCase():l){case!0:p+="; SameSite=Strict";break;case"lax":p+="; SameSite=Lax";break;case"strict":p+="; SameSite=Strict";break;case"none":p+="; SameSite=None"}else u&&(p+="; SameSite=None");return p}catch(e){return c().error("serializeCookie",e),""}}var p,d=function(){if(r())return function(e){var t=e.split(".");if(4===t.length&&t.every((function(e){return!isNaN(e)})))return e;var n=function(e){var t=e.match(/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i);return t?t[0]:""}(e);return n||(n=function(e){var t=function(e){return(e.indexOf("//")>-1?e.split("/")[2]:e.split("/")[0]).split(":")[0].split("?")[0]}(e),n=t.split("."),i=n.length;return i>2&&(2==n[i-1].length?(t=n[i-2]+"."+n[i-1],2==n[i-2].length&&(t=n[i-3]+"."+t)):t=n[i-2]+"."+n[i-1]),t}(e)),n}(window.location.hostname)};function h(e){if(!e)return{};for(var t={},n=e.split(";"),i=0;i<n.length;i++){var r=n[i],o=r.indexOf("=");o>0&&(t[r.substr(i>0?1:0,i>0?o-1:o)]=r.substr(o+1))}return t}function f(e,t){return Array.from(e.attributes).forEach((function(e){t.setAttribute(e.nodeName,e.nodeValue)}))}function m(e,t){e.innerHTML=t;var n,i=e.getElementsByTagName("script");for(n=i.length-1;n>=0;n--){var r=i[n],o=document.createElement("script");f(r,o),r.innerHTML&&(o.innerHTML=r.innerHTML),o.setAttribute("data-usermaven-tag-id",e.id),document.getElementsByTagName("head")[0].appendChild(o),i[n].parentNode.removeChild(i[n])}}var g=function(e){if(!e)return null;try{for(var t=e+"=",n=o().document.cookie.split(";"),i=0;i<n.length;i++){for(var r=n[i];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){c().error("getCookies",e)}return null},v=function(e,t,n){void 0===n&&(n={}),o().document.cookie=l(e,t,n)},y=function(e,t){void 0===t&&(t="/"),document.cookie=e+"= ; SameSite=Strict; expires = Thu, 01 Jan 1970 00:00:00 GMT"+(t?"; path = "+t:"")},_=function(){return Math.random().toString(36).substring(2,12)},b=function(){return Math.random().toString(36).substring(2,7)},k={utm_source:"source",utm_medium:"medium",utm_campaign:"campaign",utm_term:"term",utm_content:"content"},w={gclid:!0,fbclid:!0,dclid:!0};var P=function(){function e(){this.queue=[]}return e.prototype.flush=function(){var e=this.queue;return this.queue=[],e},e.prototype.push=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this.queue).push.apply(e,t)},e}(),S=function(){function e(e){this.key=e}return e.prototype.flush=function(){var e=this.get();return e.length&&this.set([]),e},e.prototype.push=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this.get();n.push.apply(n,e),this.set(n)},e.prototype.set=function(e){localStorage.setItem(this.key,JSON.stringify(e))},e.prototype.get=function(){var e=localStorage.getItem(this.key);return null!==e&&""!==e?JSON.parse(e):[]},e}(),x=Object.prototype,N=x.toString,E=x.hasOwnProperty,A=Array.prototype.forEach,C=Array.isArray,O={},I=C||function(e){return"[object Array]"===N.call(e)};function D(e,t,n){if(Array.isArray(e))if(A&&e.forEach===A)e.forEach(t,n);else if("length"in e&&e.length===+e.length)for(var i=0,r=e.length;i<r;i++)if(i in e&&t.call(n,e[i],i)===O)return}var T=function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};function H(e,t,n){if(null!=e)if(A&&Array.isArray(e)&&e.forEach===A)e.forEach(t,n);else if("length"in e&&e.length===+e.length){for(var i=0,r=e.length;i<r;i++)if(i in e&&t.call(n,e[i],i)===O)return}else for(var o in e)if(E.call(e,o)&&t.call(n,e[o],o)===O)return}var L=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return D(t,(function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])})),e};function j(e,t){return-1!==e.indexOf(t)}var $=function(e){try{return/^\s*\bfunction\b/.test(e)}catch(e){return!1}},F=function(e){return void 0===e},U=function(){function e(t){return t&&(t.preventDefault=e.preventDefault,t.stopPropagation=e.stopPropagation),t}return e.preventDefault=function(){this.returnValue=!1},e.stopPropagation=function(){this.cancelBubble=!0},function(t,n,i,r,o){if(t)if(t.addEventListener&&!r)t.addEventListener(n,i,!!o);else{var s="on"+n,a=t[s];t[s]=function(t,n,i){return function(r){if(r=r||e(window.event)){var o,s=!0;$(i)&&(o=i(r));var a=n.call(t,r);return!1!==o&&!1!==a||(s=!1),s}}}(t,i,a)}else c().error("No valid element provided to register_event")}}(),z=function(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return e.apply(this,t)}catch(e){c().error("Implementation error. Please turn on debug and contact support@usermaven.com.",e)}}},M="undefined"!=typeof Symbol?Symbol("__deepCircularCopyInProgress__"):"__deepCircularCopyInProgress__";function R(e,t,n){return e!==Object(e)?t?t(e,n):e:e[M]?void 0:(e[M]=!0,I(e)?(i=[],D(e,(function(e){i.push(R(e,t))}))):(i={},H(e,(function(e,n){n!==M&&(i[n]=R(e,t,n))}))),delete e[M],i);var i}var J=["$performance_raw"];function q(e,t){return R(e,(function(e,n){return n&&J.indexOf(n)>-1?e:"string"==typeof e&&null!==t?e.slice(0,t):e}))}function B(e){switch(typeof e.className){case"string":return e.className;case"object":return("baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";default:return""}}function W(e){var t="";return Z(e)&&!X(e)&&e.childNodes&&e.childNodes.length&&H(e.childNodes,(function(e){K(e)&&e.textContent&&(t+=T(e.textContent).split(/(\s+)/).filter(ee).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))})),T(t)}function V(e){return!!e&&1===e.nodeType}function G(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function K(e){return!!e&&3===e.nodeType}function Q(e){return!!e&&11===e.nodeType}var Y=["a","button","form","input","select","textarea","label"];function Z(e){for(var t=e;t.parentNode&&!G(t,"body");t=t.parentNode){var n=B(t).split(" ");if(j(n,"ph-sensitive")||j(n,"ph-no-capture"))return!1}if(j(B(e).split(" "),"ph-include"))return!0;var i=e.type||"";if("string"==typeof i)switch(i.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if("string"==typeof r){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function X(e){return!!(G(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||G(e,"select")||G(e,"textarea")||"true"===e.getAttribute("contenteditable"))}function ee(e){if(null===e||F(e))return!1;if("string"==typeof e){e=T(e);if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((e||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(e))return!1}return!0}var te=function(){function e(e,t){void 0===t&&(t=!1),this.clicks=[],this.instance=e,this.enabled=t}return e.prototype.click=function(e,t,n){if(this.enabled){var i=this.clicks[this.clicks.length-1];i&&Math.abs(e-i.x)+Math.abs(t-i.y)<30&&n-i.timestamp<1e3?(this.clicks.push({x:e,y:t,timestamp:n}),3===this.clicks.length&&this.instance.capture("$rageclick")):this.clicks=[{x:e,y:t,timestamp:n}]}},e}(),ne=function(){function e(e){this.instance=e,this.lastScrollDepth=0,this.canSend=!0,this.documentElement=document.documentElement}return e.prototype.track=function(){var e=this.getScrollDepth();e>this.lastScrollDepth&&(this.lastScrollDepth=e,this.canSend=!0)},e.prototype.send=function(e){if(void 0===e&&(e="$scroll"),this.canSend){var t={percent:this.lastScrollDepth,window_height:this.getWindowHeight(),document_height:this.getDocumentHeight(),scroll_distance:this.getScrollDistance()};this.instance.capture(e,t),this.canSend=!1}},e.prototype.getScrollDepth=function(){try{var e=this.getWindowHeight(),t=this.getDocumentHeight(),n=this.getScrollDistance(),i=t-e;return Math.min(100,Math.floor(n/i*100))}catch(e){return 0}},e.prototype.getWindowHeight=function(){try{return window.innerHeight||this.documentElement.clientHeight||document.body.clientHeight||0}catch(e){return 0}},e.prototype.getDocumentHeight=function(){try{return Math.max(document.body.scrollHeight||0,this.documentElement.scrollHeight||0,document.body.offsetHeight||0,this.documentElement.offsetHeight||0,document.body.clientHeight||0,this.documentElement.clientHeight||0)}catch(e){return 0}},e.prototype.getScrollDistance=function(){try{return window.scrollY||window.pageYOffset||document.body.scrollTop||this.documentElement.scrollTop||0}catch(e){return 0}},e}(),ie={_initializedTokens:[],_previousElementSibling:function(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!V(t));return t},_getPropertiesFromElement:function(e,t,n){var i=e.tagName.toLowerCase(),r={tag_name:i};Y.indexOf(i)>-1&&!n&&(r.$el_text=W(e));var o=B(e);o.length>0&&(r.classes=o.split(" ").filter((function(e){return""!==e}))),H(e.attributes,(function(n){var i;X(e)&&-1===["name","id","class"].indexOf(n.name)||!t&&ee(n.value)&&("string"!=typeof(i=n.name)||"_ngcontent"!==i.substring(0,10)&&"_nghost"!==i.substring(0,7))&&(r["attr__"+n.name]=n.value)}));for(var s=1,a=1,c=e;c=this._previousElementSibling(c);)s++,c.tagName===e.tagName&&a++;return r.nth_child=s,r.nth_of_type=a,r},_getDefaultProperties:function(e){return{$event_type:e,$ce_version:1}},_extractCustomPropertyValue:function(e){var t=[];return H(document.querySelectorAll(e.css_selector),(function(e){var n;["input","select"].indexOf(e.tagName.toLowerCase())>-1?n=e.value:e.textContent&&(n=e.textContent),ee(n)&&t.push(n)})),t.join(", ")},_getCustomProperties:function(e){var t=this,n={};return H(this._customProperties,(function(i){H(i.event_selectors,(function(r){H(document.querySelectorAll(r),(function(r){j(e,r)&&Z(r)&&(n[i.name]=t._extractCustomPropertyValue(i))}))}))})),n},_getEventTarget:function(e){var t;return void 0===e.target?e.srcElement||null:(null===(t=e.target)||void 0===t?void 0:t.shadowRoot)?e.composedPath()[0]||null:e.target||null},_captureEvent:function(e,t,n){var i,r=this,o=this._getEventTarget(e);if(K(o)&&(o=o.parentNode||null),"scroll"===e.type)return this.scrollDepth.track(),!0;if("visibilitychange"===e.type&&"hidden"===document.visibilityState||"popstate"===e.type)return this.scrollDepth.send(),!0;if("click"===e.type&&e instanceof MouseEvent&&(null===(i=this.rageclicks)||void 0===i||i.click(e.clientX,e.clientY,(new Date).getTime())),o&&function(e,t){if(!e||G(e,"html")||!V(e))return!1;if(e.classList&&e.classList.contains("um-no-capture"))return!1;for(var n=!1,i=[e],r=!0,o=e;o.parentNode&&!G(o,"body");)if(Q(o.parentNode))i.push(o.parentNode.host),o=o.parentNode.host;else{if(!(r=o.parentNode||!1))break;if(Y.indexOf(r.tagName.toLowerCase())>-1)n=!0;else{var s=window.getComputedStyle(r);s&&"pointer"===s.getPropertyValue("cursor")&&(n=!0)}i.push(r),o=r}var a=window.getComputedStyle(e);if(a&&"pointer"===a.getPropertyValue("cursor")&&"click"===t.type)return!0;var c=e.tagName.toLowerCase();switch(c){case"html":return!1;case"form":return"submit"===t.type;case"input":case"select":case"textarea":return"change"===t.type||"click"===t.type;default:return n?"click"===t.type:"click"===t.type&&(Y.indexOf(c)>-1||"true"===e.getAttribute("contenteditable"))}}(o,e)){for(var s=[o],a=o;a.parentNode&&!G(a,"body");)Q(a.parentNode)?(s.push(a.parentNode.host),a=a.parentNode.host):(s.push(a.parentNode),a=a.parentNode);var c,u=[],l=!1;if(H(s,(function(e){var t=Z(e);"a"===e.tagName.toLowerCase()&&(c=e.getAttribute("href"),c=t&&ee(c)&&c),j(B(e).split(" "),"ph-no-capture")&&(l=!0),u.push(r._getPropertiesFromElement(e,null==n?void 0:n.mask_all_element_attributes,null==n?void 0:n.mask_all_text))})),(null==n?void 0:n.mask_all_text)||(u[0].$el_text=W(o)),c&&(u[0].attr__href=c),l)return!1;var p=L(this._getDefaultProperties(e.type),{$elements:u},this._getCustomProperties(s));return t.capture("$autocapture",p),!0}},_navigate:function(e){window.location.href=e},_addDomEventHandlers:function(e,t){var n=this,i=function(i){i=i||window.event,n._captureEvent(i,e,t)};U(document,"submit",i,!1,!0),U(document,"change",i,!1,!0),U(document,"click",i,!1,!0),U(document,"visibilitychange",i,!1,!0),U(document,"scroll",i,!1,!0),U(window,"popstate",i,!1,!0)},_customProperties:[],rageclicks:null,scrollDepth:null,opts:{},init:function(e,t){var n=this;if(this.rageclicks=new te(e),this.scrollDepth=new ne(e),this.opts=t,!document||!document.body)return console.debug("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((function(){n.readyAutocapture(e,t)}),500);this.readyAutocapture(e,t)},readyAutocapture:function(e,t){this._addDomEventHandlers(e,t)},enabledForProject:function(e,t,n){if(!e)return!0;t=F(t)?10:t,n=F(n)?10:n;for(var i=0,r=0;r<e.length;r++)i+=e.charCodeAt(r);return i%t<n},isBrowserSupported:function(){return $(document.querySelectorAll)}};!function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=e[t].bind(e))}(ie),function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=z(e[t]))}(ie);var re="production",oe="1.3.2"+"/"+re+"@"+"2024-02-20T05:52:37.302Z",se=316224e3,ae=function(e,t){c().debug("Sending beacon",t);var n=new Blob([t],{type:"text/plain"});return navigator.sendBeacon(e,n),Promise.resolve()};var ce=function(e,t){return console.debug("Jitsu client tried to send payload to "+e,function(e){if("string"==typeof e)try{return JSON.stringify(JSON.parse(e),null,2)}catch(t){return e}}(t)),Promise.resolve()};function ue(e,t){void 0===t&&(t=void 0),""!=(t=null!=t?t:window.location.pathname)&&"/"!=t&&(y(e,t),ue(e,t.slice(0,t.lastIndexOf("/"))))}var le=function(){function e(e,t){this.cookieDomain=e,this.cookieName=t}return e.prototype.save=function(e){v(this.cookieName,JSON.stringify(e),{domain:this.cookieDomain,secure:"http:"!==document.location.protocol,maxAge:se})},e.prototype.restore=function(){ue(this.cookieName);var e=g(this.cookieName);if(e)try{var t=JSON.parse(decodeURIComponent(e));return"object"!=typeof t?void c().warn("Can't restore value of "+this.cookieName+"@"+this.cookieDomain+", expected to be object, but found "+("object"!=typeof t)+": "+t+". Ignoring"):t}catch(t){return void c().error("Failed to decode JSON from "+e,t)}},e.prototype.delete=function(){y(this.cookieName)},e}(),pe=function(){function e(){}return e.prototype.save=function(e){},e.prototype.restore=function(){},e.prototype.delete=function(){},e}();var de={getSourceIp:function(){},describeClient:function(){return{referer:document.referrer,url:window.location.href,page_title:document.title,doc_path:document.location.pathname,doc_host:document.location.hostname,doc_search:window.location.search,screen_resolution:screen.width+"x"+screen.height,vp_size:Math.max(document.documentElement.clientWidth||0,window.innerWidth||0)+"x"+Math.max(document.documentElement.clientHeight||0,window.innerHeight||0),user_agent:navigator.userAgent,user_language:navigator.language,doc_encoding:document.characterSet}},getAnonymousId:function(e){var t=e.name,n=e.domain,i=e.crossDomainLinking,r=void 0===i||i;if(ue(t),r){var o=new URLSearchParams(window.location.search).get("_um"),s=window.location.hash.substring(1).split("~"),a=s.length>1?s[1]:void 0,u=o||a;if(u){c().debug("Existing user id from other domain",u);var l=g(t);return l&&l===u||v(t,u,{domain:n,secure:"http:"!==document.location.protocol,maxAge:se}),u}}var p=g(t);if(p)return c().debug("Existing user id",p),p;var d=_();return c().debug("New user id",d),v(t,d,{domain:n,secure:"http:"!==document.location.protocol,maxAge:se}),d}};var he={getSourceIp:function(){},describeClient:function(){return{}},getAnonymousId:function(){return""}},fe=function(){return de},me=function(){return he},ge=function(e,t,n,i){void 0===i&&(i=function(e,t){});var r=new window.XMLHttpRequest;return new Promise((function(o,s){r.onerror=function(n){c().error("Failed to send payload to "+e+": "+((null==n?void 0:n.message)||"unknown error"),t,n),i(-1,{}),s(new Error("Failed to send JSON. See console logs"))},r.onload=function(){200!==r.status?(i(r.status,{}),c().warn("Failed to send data to "+e+" (#"+r.status+" - "+r.statusText+")",t),s(new Error("Failed to send JSON. Error code: "+r.status+". See logs for details"))):i(r.status,r.responseText),o()},r.open("POST",e),r.setRequestHeader("Content-Type","application/json"),Object.entries(n||{}).forEach((function(e){var t=e[0],n=e[1];return r.setRequestHeader(t,n)})),r.send(t),c().debug("sending json",t)}))},ve=function(){function i(){this.userProperties={},this.groupProperties={},this.permanentProperties={globalProps:{},propsPerEvent:{}},this.cookieDomain="",this.trackingHost="",this.idCookieName="",this.randomizeUrl=!1,this.namespace="usermaven",this.crossDomainLinking=!0,this.domains=[],this.apiKey="",this.initialized=!1,this._3pCookies={},this.cookiePolicy="keep",this.ipPolicy="keep",this.beaconApi=!1,this.transport=ge,this.customHeaders=function(){return{}},this.queue=new P,this.maxSendAttempts=4,this.retryTimeout=[500,1e12],this.flushing=!1,this.attempt=1,this.propertyBlacklist=[],this.__autocapture_enabled=!1,this.__auto_pageview_enabled=!1,this.trackingHostFallback="https://events.usermaven.com"}return i.prototype.get_config=function(e){return this.config?this.config[e]:null},i.prototype.id=function(t,n){return this.userProperties=e(e({},this.userProperties),t),c().debug("Usermaven user identified",t),this.userIdPersistence?this.userIdPersistence.save(t):c().warn("Id() is called before initialization"),n?Promise.resolve():this.track("user_identify",{})},i.prototype.group=function(t,n){return this.groupProperties=e(e({},this.groupProperties),t),c().debug("Usermaven group identified",t),this.userIdPersistence?this.userIdPersistence.save({company:t}):c().warn("Group() is called before initialization"),n?Promise.resolve():this.track("group",{})},i.prototype.reset=function(e){if(this.userIdPersistence&&this.userIdPersistence.delete(),this.propsPersistance&&this.propsPersistance.delete(),e){var t=g(this.idCookieName);t&&(c().debug("Removing id cookie",t),v(this.idCookieName,"",{domain:this.cookieDomain,expires:new Date(0)}))}return Promise.resolve()},i.prototype.rawTrack=function(e){return this.sendJson(e)},i.prototype.makeEvent=function(t,n,i){var o,s=i.env,a=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(i,["env"]);s||(s=r()?fe():me()),this.restoreId();var c=this.getCtx(s),u=e(e({},this.permanentProperties.globalProps),null!==(o=this.permanentProperties.propsPerEvent[t])&&void 0!==o?o:{}),l=e({api_key:this.apiKey,src:n,event_type:t},a),p=s.getSourceIp();return p&&(l.source_ip=p),this.compatMode?e(e(e({},u),{eventn_ctx:c}),l):e(e(e({},u),c),l)},i.prototype._send3p=function(e,t,n){var i="3rdparty";n&&""!==n&&(i=n);var r=this.makeEvent(i,e,{src_payload:t});return this.sendJson(r)},i.prototype.sendJson=function(e){return t(this,void 0,Promise,(function(){return n(this,(function(t){switch(t.label){case 0:return n="false","undefined"!=typeof window&&window.localStorage&&(n=localStorage.getItem("um_exclusion")),null!=n&&"false"!==n?[3,3]:this.maxSendAttempts>1?(this.queue.push([e,0]),this.scheduleFlush(0),[3,3]):[3,1];case 1:return[4,this.doSendJson(e)];case 2:t.sent(),t.label=3;case 3:return[2]}var n}))}))},i.prototype.doSendJson=function(e){var t=this,n="keep"!==this.cookiePolicy?"&cookie_policy="+this.cookiePolicy:"",i="keep"!==this.ipPolicy?"&ip_policy="+this.ipPolicy:"",o=r()?"/api/v1/event":"/api/v1/s2s/event",s=""+this.trackingHost+o+"?token="+this.apiKey+n+i;this.randomizeUrl&&(s=this.trackingHost+"/api."+b()+"?p_"+b()+"="+this.apiKey+n+i);var a=JSON.stringify(e);return c().debug("Sending payload to "+s,e.length),this.transport(s,a,this.customHeaders(),(function(e,n){return t.postHandle(e,n)}))},i.prototype.scheduleFlush=function(e){var t=this;if(!this.flushing){if(this.flushing=!0,void 0===e){var n=Math.random()+1,i=Math.pow(2,this.attempt++);e=Math.min(this.retryTimeout[0]*n*i,this.retryTimeout[1])}c().debug("Scheduling event queue flush in "+e+" ms."),setTimeout((function(){return t.flush()}),e)}},i.prototype.flush=function(){return t(this,void 0,Promise,(function(){var e,t,i=this;return n(this,(function(n){switch(n.label){case 0:if(r()&&!window.navigator.onLine&&(this.flushing=!1,this.scheduleFlush()),e=this.queue.flush(),this.flushing=!1,0===e.length)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.doSendJson(e.map((function(e){return e[0]})))];case 2:return n.sent(),this.attempt=1,c().debug("Successfully flushed "+e.length+" events from queue"),[3,4];case 3:return n.sent(),this.trackingHost!==this.trackingHostFallback&&(c().debug("Using fallback tracking host "+this.trackingHostFallback+" instead of "+this.trackingHost+" on "+re),this.trackingHost=this.trackingHostFallback),(e=e.map((function(e){return[e[0],e[1]+1]})).filter((function(e){return!(e[1]>=i.maxSendAttempts)||(c().error("Dropping queued event after "+e[1]+" attempts since max send attempts "+i.maxSendAttempts+" reached. See logs for details"),!1)}))).length>0?((t=this.queue).push.apply(t,e),this.scheduleFlush()):this.attempt=1,[3,4];case 4:return[2]}}))}))},i.prototype.postHandle=function(e,t){if("strict"===this.cookiePolicy||"comply"===this.cookiePolicy){if(200===e){var n=t;if("string"==typeof t&&(n=JSON.parse(t)),!n.delete_cookie)return}this.userIdPersistence.delete(),this.propsPersistance.delete(),y(this.idCookieName)}if(200===e){n=t;if("string"==typeof t&&t.length>0){var i=(n=JSON.parse(t)).jitsu_sdk_extras;if(i&&i.length>0)if(r())for(var o=0,s=i;o<s.length;o++){var a=s[o],u=a.type,l=a.id,p=a.value;if("tag"===u){var d=document.createElement("div");d.id=l,m(d,p),d.childElementCount>0&&document.body.appendChild(d)}}else c().error("Tags destination supported only in browser environment")}}},i.prototype.getCtx=function(t){var n=new Date,i=t.describeClient()||{},r=e({},this.userProperties),o=r.company||{};delete r.company;var s,a,c=e(e({event_id:"",user:e({anonymous_id:"strict"!==this.cookiePolicy?t.getAnonymousId({name:this.idCookieName,domain:this.cookieDomain,crossDomainLinking:this.crossDomainLinking}):""},r),ids:this._getIds(),utc_time:(s=n.toISOString(),a=s.split(".")[1],a?a.length>=7?s:s.slice(0,-1)+"0".repeat(7-a.length)+"Z":s),local_tz_offset:n.getTimezoneOffset()},i),function(e){var t={utm:{},click_id:{}};for(var n in e)if(e.hasOwnProperty(n)){var i=e[n],r=k[n];r?t.utm[r]=i:w[n]&&(t.click_id[n]=i)}return t}(function(e){if(!e)return{};for(var t=e.length>0&&"?"===e.charAt(0)?e.substring(1):e,n={},i=("?"===t[0]?t.substr(1):t).split("&"),r=0;r<i.length;r++){var o=i[r].split("=");n[decodeURIComponent(o[0])]=decodeURIComponent(o[1]||"")}return n}(i.doc_search)));return Object.keys(o).length&&(c.company=o),c},i.prototype._getIds=function(){if(!r())return{};for(var e=function(e){if(void 0===e&&(e=!1),e&&p)return p;var t=h(document.cookie);return p=t,t}(!1),t={},n=0,i=Object.entries(e);n<i.length;n++){var o=i[n],s=o[0],a=o[1];this._3pCookies[s]&&(t["_"==s.charAt(0)?s.substr(1):s]=a)}return t},i.prototype.pathMatches=function(e,t){return new URL(t).pathname.match(new RegExp("^"+e.trim().replace(/\*\*/g,".*").replace(/([^\.])\*/g,"$1[^\\s/]*")+"/?$"))},i.prototype.track=function(e,t){var n=this,i=t||{};c().debug("track event of type",e,i);var o=r()?fe():me(),s=this.getCtx(o);if(this.config&&this.config.exclude&&this.config.exclude.length>1&&(null==s?void 0:s.url)&&this.config.exclude.split(",").some((function(e){return n.pathMatches(e.trim(),null==s?void 0:s.url)})))return void c().debug("Page is excluded from tracking");var a=t||{};"$autocapture"!==e&&"user_identify"!==e&&"pageview"!==e&&"$pageleave"!==e&&(a={event_attributes:t});var u=this.makeEvent(e,this.compatMode?"eventn":"usermaven",a);return this.sendJson(u)},i.prototype.init=function(i){var o,l,p,h,f,m,g,v,y=this;if(r()&&!i.force_use_fetch)i.fetch&&c().warn("Custom fetch implementation is provided to Usermaven. However, it will be ignored since Usermaven runs in browser"),this.transport=this.beaconApi?ae:ge;else{if(!i.fetch&&!globalThis.fetch)throw new Error("Usermaven runs in Node environment. However, neither UsermavenOptions.fetch is provided, nor global fetch function is defined. \nPlease, provide custom fetch implementation. You can get it via node-fetch package");this.transport=(m=i.fetch||globalThis.fetch,function(i,r,o,s){return void 0===s&&(s=function(e,t){}),t(void 0,void 0,void 0,(function(){var t,a,u,l,p,d,h,f;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,m(i,{method:"POST",headers:e({Accept:"application/json","Content-Type":"application/json"},o||{}),body:r})];case 1:return t=n.sent(),[3,3];case 2:return a=n.sent(),c().error("Failed to send data to "+i+": "+((null==a?void 0:a.message)||"unknown error"),r,a),s(-1,{}),[2];case 3:if(200!==t.status)return c().warn("Failed to send data to "+i+" (#"+t.status+" - "+t.statusText+")",r),s(t.status,{}),[2];u={},l="",p=null!==(f=null===(h=t.headers)||void 0===h?void 0:h.get("Content-Type"))&&void 0!==f?f:"",n.label=4;case 4:return n.trys.push([4,6,,7]),[4,t.text()];case 5:return l=n.sent(),u=JSON.parse(l),[3,7];case 6:return d=n.sent(),c().error("Failed to parse "+i+" response. Content-type: "+p+" text: "+l,d),[3,7];case 7:try{s(t.status,u)}catch(e){c().error("Failed to handle "+i+" response. Content-type: "+p+" text: "+l,e)}return[2]}}))}))})}if(i.custom_headers&&"function"==typeof i.custom_headers?this.customHeaders=i.custom_headers:i.custom_headers&&(this.customHeaders=function(){return i.custom_headers}),"echo"===i.tracking_host&&(c().warn('jitsuClient is configured with "echo" transport. Outgoing requests will be written to console'),this.transport=ce),i.ip_policy&&(this.ipPolicy=i.ip_policy),i.cookie_policy&&(this.cookiePolicy=i.cookie_policy),"strict"===i.privacy_policy&&(this.ipPolicy="strict",this.cookiePolicy="strict"),i.use_beacon_api&&navigator.sendBeacon&&(this.beaconApi=!0),"comply"===this.cookiePolicy&&this.beaconApi&&(this.cookiePolicy="strict"),i.log_level&&(g=i.log_level,(v=s[g.toLocaleUpperCase()])||(console.warn("Can't find log level with name "+g.toLocaleUpperCase()+", defaulting to INFO"),v=s.INFO),a=u(v)),this.initialOptions=i,c().debug("Initializing Usemaven Tracker tracker",i,oe),i.key){if(this.compatMode=void 0!==i.compat_mode&&!!i.compat_mode,this.cookieDomain=i.cookie_domain||d(),this.namespace=i.namespace||"usermaven",this.crossDomainLinking=null===(o=i.cross_domain_linking)||void 0===o||o,this.domains=i.domains?i.domains.split(",").map((function(e){return e.trim()})):[],this.trackingHost=function(e){for(;n="/",-1!==(t=e).indexOf(n,t.length-n.length);)e=e.substr(0,e.length-1);var t,n;return 0===e.indexOf("https://")||0===e.indexOf("http://")?e:"https://"+e}(i.tracking_host||"t.usermaven.com"),this.randomizeUrl=i.randomize_url||!1,this.apiKey=i.key,this.__auto_pageview_enabled=i.auto_pageview||!1,this.idCookieName=i.cookie_name||"__eventn_id_"+i.key,"strict"===this.cookiePolicy?this.propsPersistance=new pe:this.propsPersistance=r()?new le(this.cookieDomain,this.idCookieName+"_props"):new pe,"strict"===this.cookiePolicy?this.userIdPersistence=new pe:this.userIdPersistence=r()?new le(this.cookieDomain,this.idCookieName+"_usr"):new pe,this.propsPersistance){var _=this.propsPersistance.restore();_&&(this.permanentProperties=_,this.permanentProperties.globalProps=null!==(l=_.globalProps)&&void 0!==l?l:{},this.permanentProperties.propsPerEvent=null!==(p=_.propsPerEvent)&&void 0!==p?p:{}),c().debug("Restored persistent properties",this.permanentProperties)}this.propertyBlacklist=i.property_blacklist&&i.property_blacklist.length>0?i.property_blacklist:[];this.config=L({},{autocapture:!1,properties_string_max_length:null,property_blacklist:[],sanitize_properties:null,auto_pageview:!1},i||{},this.config||{},{token:this.apiKey}),c().debug("Default Configuration",this.config),this.manageAutoCapture(this.config),this.manageCrossDomainLinking({cross_domain_linking:this.crossDomainLinking,domains:this.domains,cookiePolicy:this.cookiePolicy}),!1===i.capture_3rd_party_cookies?this._3pCookies={}:(i.capture_3rd_party_cookies||["_ga","_fbp","_ym_uid","ajs_user_id","ajs_anonymous_id"]).forEach((function(e){return y._3pCookies[e]=!0})),i.ga_hook&&c().warn("GA event interceptor isn't supported anymore"),i.segment_hook&&function(e){var t=window;t.analytics||(t.analytics=[]);e.interceptAnalytics(t.analytics)}(this),r()&&(i.disable_event_persistence||(this.queue=new S(this.namespace+"-event-queue"),this.scheduleFlush(0)),window.addEventListener("beforeunload",(function(){return y.flush()}))),this.__auto_pageview_enabled&&function(e){var t=function(){return e.track("pageview")},n=history.pushState;n&&(history.pushState=function(e,i,r){n.apply(this,[e,i,r]),t()},addEventListener("popstate",t));addEventListener("hashchange",t)}(this),this.retryTimeout=[null!==(h=i.min_send_timeout)&&void 0!==h?h:this.retryTimeout[0],null!==(f=i.max_send_timeout)&&void 0!==f?f:this.retryTimeout[1]],i.max_send_attempts&&(this.maxSendAttempts=i.max_send_attempts),this.initialized=!0}else c().error("Can't initialize Usemaven, key property is not set")},i.prototype.interceptAnalytics=function(t){var n=this,i=function(t){var i;try{var r=e({},t.payload);c().debug("Intercepted segment payload",r.obj);var o=t.integrations["Segment.io"];if(o&&o.analytics){var s=o.analytics;"function"==typeof s.user&&s.user()&&"function"==typeof s.user().id&&(r.obj.userId=s.user().id())}(null===(i=null==r?void 0:r.obj)||void 0===i?void 0:i.timestamp)&&(r.obj.sentAt=r.obj.timestamp);var a=t.payload.type();"track"===a&&(a=t.payload.event()),n._send3p("ajs",r,a)}catch(e){c().warn("Failed to send an event",e)}t.next(t.payload)};"function"==typeof t.addSourceMiddleware?(c().debug("Analytics.js is initialized, calling addSourceMiddleware"),t.addSourceMiddleware(i)):(c().debug("Analytics.js is not initialized, pushing addSourceMiddleware to callstack"),t.push(["addSourceMiddleware",i])),t.__en_intercepted=!0},i.prototype.restoreId=function(){if(this.userIdPersistence){var t=this.userIdPersistence.restore();t&&(this.userProperties=e(e({},t),this.userProperties))}},i.prototype.set=function(t,n){var i,r=null==n?void 0:n.eventType,o=void 0===(null==n?void 0:n.persist)||(null==n?void 0:n.persist);if(void 0!==r){var s=null!==(i=this.permanentProperties.propsPerEvent[r])&&void 0!==i?i:{};this.permanentProperties.propsPerEvent[r]=e(e({},s),t)}else this.permanentProperties.globalProps=e(e({},this.permanentProperties.globalProps),t);this.propsPersistance&&o&&this.propsPersistance.save(this.permanentProperties)},i.prototype.unset=function(e,t){o();var n=null==t?void 0:t.eventType,i=void 0===(null==t?void 0:t.persist)||(null==t?void 0:t.persist);n?this.permanentProperties.propsPerEvent[n]&&delete this.permanentProperties.propsPerEvent[n][e]:delete this.permanentProperties.globalProps[e],this.propsPersistance&&i&&this.propsPersistance.save(this.permanentProperties)},i.prototype.manageCrossDomainLinking=function(e){if(!r()||!e.cross_domain_linking||0===e.domains.length||"strict"===e.cookiePolicy)return!1;var t=this.idCookieName,n=e.domains||[];document.addEventListener("click",(function(e){var i=function(e){for(;e&&e.tagName&&"a"!==e.tagName.toLowerCase();)e=e.parentNode;return e}(e.target);if(i){var r=i.getAttribute("href");if(r&&r.startsWith("http")){var o=new URL(r),s=g(t);if(o.hostname===window.location.hostname)return;n.includes(o.hostname)&&s&&(o.searchParams.append("_um",s),i.setAttribute("href",o.toString()))}}}),!1)},i.prototype.manageAutoCapture=function(e){if(c().debug("Auto Capture Status: ",this.config.autocapture),this.__autocapture_enabled=this.config.autocapture&&r(),this.__autocapture_enabled){ie.enabledForProject(this.apiKey,100,100)?ie.isBrowserSupported()?(c().debug("Autocapture enabled..."),ie.init(this,e)):(this.config.autocapture=!1,this.__autocapture_enabled=!1,c().debug("Disabling Automatic Event Collection because this browser is not supported")):(this.config.autocapture=!1,this.__autocapture_enabled=!1,c().debug("Not in active bucket: disabling Automatic Event Collection."))}},i.prototype.capture=function(e,t){var n,i;if(void 0===t&&(t={}),this.initialized)if(F(e)||"string"!=typeof e)console.error("No event name provided to usermaven.capture");else{var r={event:e+(t.$event_type?"_"+t.$event_type:""),properties:this._calculate_event_properties(e,t)};(null===(i=null===(n=(r=q(r,this.get_config("properties_string_max_length"))).properties)||void 0===n?void 0:n.autocapture_attributes)||void 0===i?void 0:i.tag_name)&&this.track("$autocapture",r.properties),"$scroll"===e&&this.track(e,r.properties)}else console.error("Trying to capture event before initialization")},i.prototype._calculate_event_properties=function(e,t){var n,i,r=t||{};if("$snapshot"===e||"$scroll"===e)return r;I(this.propertyBlacklist)?H(this.propertyBlacklist,(function(e){delete r[e]})):console.error("Invalid value for property_blacklist config: "+this.propertyBlacklist);var o={},s=r.$elements||[];return s.length&&(o=s[0]),r.autocapture_attributes=o,r.autocapture_attributes.el_text=null!==(n=r.autocapture_attributes.$el_text)&&void 0!==n?n:"",r.autocapture_attributes.event_type=null!==(i=r.$event_type)&&void 0!==i?i:"",["$ce_version","$event_type","$initial_referrer","$initial_referring_domain","$referrer","$referring_domain","$elements"].forEach((function(e){delete r[e]})),delete r.autocapture_attributes.$el_text,delete r.autocapture_attributes.nth_child,delete r.autocapture_attributes.nth_of_type,r},i}();var ye="lib.js",_e=["use_beacon_api","cookie_domain","tracking_host","cookie_name","key","ga_hook","segment_hook","randomize_url","capture_3rd_party_cookies","id_method","log_level","compat_mode","privacy_policy","cookie_policy","ip_policy","custom_headers","force_use_fetch","min_send_timeout","max_send_timeout","max_send_attempts","disable_event_persistence","project_id","autocapture","properties_string_max_length","property_blacklist","exclude","auto_pageview","namespace","cross_domain_linking","domains"];var be="data-suppress-interception-warning";function ke(e){return"\n ATTENTION! "+e+"-hook set to true along with defer/async attribute! If "+e+" code is inserted right after Usermaven tag,\n first tracking call might not be intercepted! Consider one of the following:\n - Inject usermaven tracking code without defer/async attribute\n - If you're sure that events won't be sent to "+e+" before Usermaven is fully initialized, set "+be+'="true"\n script attribute\n '}function we(e){var t=document.currentScript;if(t){var n,i={tracking_host:(n=t.getAttribute("src"),n.replace("/s/"+ye,"").replace("/"+ye,"")),key:null},r=t.getAttribute("data-namespace")||"usermaven";_e.forEach((function(e){var n="data-"+e.replace(new RegExp("_","g"),"-");if(void 0!==t.getAttribute(n)&&null!==t.getAttribute(n)){var r=t.getAttribute(n);"true"===r?r=!0:"false"===r&&(r=!1),i[e]=r}}));var o=r+"Client";e[o]=function(e){var t=new ve;return t.init(e),t}(i),!i.segment_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(be)||c().warn(ke("segment")),!i.ga_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(be)||c().warn(ke("ga")),!function(t,n,i){e[t]=function(){var i=e[t+"Q"]=e[t+"Q"]||[];i.push(arguments),Pe(i,e[n])}}(r,o),i.project_id&&e[r]("set",{project_id:i.project_id}),"true"!==t.getAttribute("data-init-only")&&"yes"!==t.getAttribute("data-init-only")&&e[r]("track","pageview");var s=void 0===e.onpagehide?"unload":"pagehide";return e.addEventListener(s,(function(){e[r]("track","$pageleave")})),e[o]}c().warn("Usermaven script is not properly initialized. The definition must contain data-usermaven-api-key as a parameter")}function Pe(e,t){c().debug("Processing queue",e);for(var n=0;n<e.length;n+=1){var r=i([],e[n],!0)||[],o=r[0],s=r.slice(1),a=t[o];"function"==typeof a&&a.apply(t,s)}e.length=0}!function(e){if(window){var t=window,n=e,i=we(t);i?(c().debug("Usermaven in-browser tracker has been initialized",n),t[n]=function(){var e=t[n+"Q"]=t[n+"Q"]||[];e.push(arguments),Pe(e,i)},t[n+"Q"]&&(c().debug("Initial queue size of "+t[n+"Q"].length+" will be processed"),Pe(t[n+"Q"],i))):c().error("Usermaven tracker has not been initialized (reason unknown)")}else c().warn("Usermaven tracker called outside browser context. It will be ignored")}(document.currentScript.getAttribute("data-namespace")||"usermaven")}();
|
|
1
|
+
!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t,n,i){return new(n||(n=Promise))((function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function n(e,t){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],i=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function i(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;r<o;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}function r(e=void 0){const t=!!globalThis.window&&!!globalThis.window.document&&!!globalThis.window.location;return!t&&e&&c().warn(e),t}function o(e=void 0){if(!r())throw new Error(e||"window' is not available. Seems like this code runs outside browser environment. It shouldn't happen");return window}"function"==typeof SuppressedError&&SuppressedError;var s={DEBUG:{name:"DEBUG",severity:10},INFO:{name:"INFO",severity:100},WARN:{name:"WARN",severity:1e3},ERROR:{name:"ERROR",severity:1e4},NONE:{name:"NONE",severity:1e4}},a=null;function c(){return a||(a=u())}function u(e){var t=r()&&window.__eventNLogLevel,n=s.WARN;if(t){var o=s[t.toUpperCase()];o&&o>0&&(n=o)}else e&&(n=e);var a={minLogLevel:n};return Object.values(s).forEach((function(e){var t=e.name,r=e.severity;a[t.toLowerCase()]=function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];if(r>=n.severity&&e.length>0){var s=e[0],a=e.splice(1),c="[J-"+t+"] "+s;"DEBUG"===t||"INFO"===t?console.log.apply(console,i([c],a,!1)):"WARN"===t?console.warn.apply(console,i([c],a,!1)):console.error.apply(console,i([c],a,!1))}}})),function(e,t){if(r()){var n=window;n.__usermavenDebug||(n.__usermavenDebug={}),n.__usermavenDebug[e]=t}}("logger",a),a}function l(e,t,n){void 0===n&&(n={});try{var i=n.maxAge,r=n.domain,o=n.path,s=n.expires,a=n.httpOnly,u=n.secure,l=n.sameSite,p=e+"="+encodeURIComponent(t);if(r&&(p+="; domain="+r),p+=o?"; path="+o:"; path=/",s&&(p+="; expires="+s.toUTCString()),i&&(p+="; max-age="+i),a&&(p+="; httponly"),u&&(p+="; secure"),l)switch("string"==typeof l?l.toLowerCase():l){case!0:p+="; SameSite=Strict";break;case"lax":p+="; SameSite=Lax";break;case"strict":p+="; SameSite=Strict";break;case"none":p+="; SameSite=None"}else u&&(p+="; SameSite=None");return p}catch(e){return c().error("serializeCookie",e),""}}var p,d=function(){if(r())return function(e){var t=e.split(".");if(4===t.length&&t.every((function(e){return!isNaN(e)})))return e;var n=function(e){var t=e.match(/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i);return t?t[0]:""}(e);return n||(n=function(e){var t=function(e){return(e.indexOf("//")>-1?e.split("/")[2]:e.split("/")[0]).split(":")[0].split("?")[0]}(e),n=t.split("."),i=n.length;return i>2&&(2==n[i-1].length?(t=n[i-2]+"."+n[i-1],2==n[i-2].length&&(t=n[i-3]+"."+t)):t=n[i-2]+"."+n[i-1]),t}(e)),n}(window.location.hostname)};function h(e){if(!e)return{};for(var t={},n=e.split(";"),i=0;i<n.length;i++){var r=n[i],o=r.indexOf("=");o>0&&(t[r.substr(i>0?1:0,i>0?o-1:o)]=r.substr(o+1))}return t}function f(e,t){return Array.from(e.attributes).forEach((function(e){t.setAttribute(e.nodeName,e.nodeValue)}))}function m(e,t){e.innerHTML=t;var n,i=e.getElementsByTagName("script");for(n=i.length-1;n>=0;n--){var r=i[n],o=document.createElement("script");f(r,o),r.innerHTML&&(o.innerHTML=r.innerHTML),o.setAttribute("data-usermaven-tag-id",e.id),document.getElementsByTagName("head")[0].appendChild(o),i[n].parentNode.removeChild(i[n])}}var g=function(e){if(!e)return null;try{for(var t=e+"=",n=o().document.cookie.split(";"),i=0;i<n.length;i++){for(var r=n[i];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){c().error("getCookies",e)}return null},v=function(e,t,n){void 0===n&&(n={}),o().document.cookie=l(e,t,n)},y=function(e,t){void 0===t&&(t="/"),document.cookie=e+"= ; SameSite=Strict; expires = Thu, 01 Jan 1970 00:00:00 GMT"+(t?"; path = "+t:"")},_=function(){return Math.random().toString(36).substring(2,12)},b=function(){return Math.random().toString(36).substring(2,7)},k={utm_source:"source",utm_medium:"medium",utm_campaign:"campaign",utm_term:"term",utm_content:"content"},w={gclid:!0,fbclid:!0,dclid:!0};var P=function(){function e(){this.queue=[]}return e.prototype.flush=function(){var e=this.queue;return this.queue=[],e},e.prototype.push=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this.queue).push.apply(e,t)},e}(),S=function(){function e(e){this.key=e}return e.prototype.flush=function(){var e=this.get();return e.length&&this.set([]),e},e.prototype.push=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this.get();n.push.apply(n,e),this.set(n)},e.prototype.set=function(e){localStorage.setItem(this.key,JSON.stringify(e))},e.prototype.get=function(){var e=localStorage.getItem(this.key);return null!==e&&""!==e?JSON.parse(e):[]},e}(),x=Object.prototype,N=x.toString,E=x.hasOwnProperty,A=Array.prototype.forEach,C=Array.isArray,O={},T=C||function(e){return"[object Array]"===N.call(e)};function D(e,t,n){if(Array.isArray(e))if(A&&e.forEach===A)e.forEach(t,n);else if("length"in e&&e.length===+e.length)for(var i=0,r=e.length;i<r;i++)if(i in e&&t.call(n,e[i],i)===O)return}var I=function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};function L(e,t,n){if(null!=e)if(A&&Array.isArray(e)&&e.forEach===A)e.forEach(t,n);else if("length"in e&&e.length===+e.length){for(var i=0,r=e.length;i<r;i++)if(i in e&&t.call(n,e[i],i)===O)return}else for(var o in e)if(E.call(e,o)&&t.call(n,e[o],o)===O)return}var j=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return D(t,(function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])})),e};function H(e,t){return-1!==e.indexOf(t)}var F=function(e){try{return/^\s*\bfunction\b/.test(e)}catch(e){return!1}},$=function(e){return void 0===e},U=function(){function e(t){return t&&(t.preventDefault=e.preventDefault,t.stopPropagation=e.stopPropagation),t}return e.preventDefault=function(){this.returnValue=!1},e.stopPropagation=function(){this.cancelBubble=!0},function(t,n,i,r,o){if(t)if(t.addEventListener&&!r)t.addEventListener(n,i,!!o);else{var s="on"+n,a=t[s];t[s]=function(t,n,i){return function(r){if(r=r||e(window.event)){var o,s=!0;F(i)&&(o=i(r));var a=n.call(t,r);return!1!==o&&!1!==a||(s=!1),s}}}(t,i,a)}else c().error("No valid element provided to register_event")}}(),M=function(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return e.apply(this,t)}catch(e){c().error("Implementation error. Please turn on debug and contact support@usermaven.com.",e)}}},z="undefined"!=typeof Symbol?Symbol("__deepCircularCopyInProgress__"):"__deepCircularCopyInProgress__";function R(e,t,n){return e!==Object(e)?t?t(e,n):e:e[z]?void 0:(e[z]=!0,T(e)?(i=[],D(e,(function(e){i.push(R(e,t))}))):(i={},L(e,(function(e,n){n!==z&&(i[n]=R(e,t,n))}))),delete e[z],i);var i}var q=["$performance_raw"];function J(e,t){return R(e,(function(e,n){return n&&q.indexOf(n)>-1?e:"string"==typeof e&&null!==t?e.slice(0,t):e}))}function B(e){switch(typeof e.className){case"string":return e.className;case"object":return("baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";default:return""}}function V(e){var t="";return X(e)&&!Z(e)&&e.childNodes&&e.childNodes.length&&L(e.childNodes,(function(e){K(e)&&e.textContent&&(t+=I(e.textContent).split(/(\s+)/).filter(ee).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))})),I(t)}function W(e){return!!e&&1===e.nodeType}function G(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function K(e){return!!e&&3===e.nodeType}function Q(e){return!!e&&11===e.nodeType}var Y=["a","button","form","input","select","textarea","label"];function X(e){for(var t=e;t.parentNode&&!G(t,"body");t=t.parentNode){var n=B(t).split(" ");if(H(n,"ph-sensitive")||H(n,"ph-no-capture"))return!1}if(H(B(e).split(" "),"ph-include"))return!0;var i=e.type||"";if("string"==typeof i)switch(i.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if("string"==typeof r){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function Z(e){return!!(G(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||G(e,"select")||G(e,"textarea")||"true"===e.getAttribute("contenteditable"))}function ee(e){if(null===e||$(e))return!1;if("string"==typeof e){e=I(e);if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((e||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(e))return!1}return!0}var te=function(){function e(e,t){void 0===t&&(t=!1),this.clicks=[],this.instance=e,this.enabled=t}return e.prototype.click=function(e,t,n){if(this.enabled){var i=this.clicks[this.clicks.length-1];i&&Math.abs(e-i.x)+Math.abs(t-i.y)<30&&n-i.timestamp<1e3?(this.clicks.push({x:e,y:t,timestamp:n}),3===this.clicks.length&&this.instance.capture("$rageclick")):this.clicks=[{x:e,y:t,timestamp:n}]}},e}(),ne=function(){function e(e){this.instance=e,this.lastScrollDepth=0,this.canSend=!0,this.documentElement=document.documentElement}return e.prototype.track=function(){var e=this.getScrollDepth();e>this.lastScrollDepth&&(this.lastScrollDepth=e,this.canSend=!0)},e.prototype.send=function(e){if(void 0===e&&(e="$scroll"),this.canSend){var t={percent:this.lastScrollDepth,window_height:this.getWindowHeight(),document_height:this.getDocumentHeight(),scroll_distance:this.getScrollDistance()};this.instance.capture(e,t),this.canSend=!1}},e.prototype.getScrollDepth=function(){try{var e=this.getWindowHeight(),t=this.getDocumentHeight(),n=this.getScrollDistance(),i=t-e;return Math.min(100,Math.floor(n/i*100))}catch(e){return 0}},e.prototype.getWindowHeight=function(){try{return window.innerHeight||this.documentElement.clientHeight||document.body.clientHeight||0}catch(e){return 0}},e.prototype.getDocumentHeight=function(){try{return Math.max(document.body.scrollHeight||0,this.documentElement.scrollHeight||0,document.body.offsetHeight||0,this.documentElement.offsetHeight||0,document.body.clientHeight||0,this.documentElement.clientHeight||0)}catch(e){return 0}},e.prototype.getScrollDistance=function(){try{return window.scrollY||window.pageYOffset||document.body.scrollTop||this.documentElement.scrollTop||0}catch(e){return 0}},e}(),ie={_initializedTokens:[],_previousElementSibling:function(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!W(t));return t},_getPropertiesFromElement:function(e,t,n){var i=e.tagName.toLowerCase(),r={tag_name:i};Y.indexOf(i)>-1&&!n&&(r.$el_text=V(e));var o=B(e);o.length>0&&(r.classes=o.split(" ").filter((function(e){return""!==e}))),L(e.attributes,(function(n){var i;Z(e)&&-1===["name","id","class"].indexOf(n.name)||!t&&ee(n.value)&&("string"!=typeof(i=n.name)||"_ngcontent"!==i.substring(0,10)&&"_nghost"!==i.substring(0,7))&&(r["attr__"+n.name]=n.value)}));for(var s=1,a=1,c=e;c=this._previousElementSibling(c);)s++,c.tagName===e.tagName&&a++;return r.nth_child=s,r.nth_of_type=a,r},_getDefaultProperties:function(e){return{$event_type:e,$ce_version:1}},_extractCustomPropertyValue:function(e){var t=[];return L(document.querySelectorAll(e.css_selector),(function(e){var n;["input","select"].indexOf(e.tagName.toLowerCase())>-1?n=e.value:e.textContent&&(n=e.textContent),ee(n)&&t.push(n)})),t.join(", ")},_getCustomProperties:function(e){var t=this,n={};return L(this._customProperties,(function(i){L(i.event_selectors,(function(r){L(document.querySelectorAll(r),(function(r){H(e,r)&&X(r)&&(n[i.name]=t._extractCustomPropertyValue(i))}))}))})),n},_getEventTarget:function(e){var t;return void 0===e.target?e.srcElement||null:(null===(t=e.target)||void 0===t?void 0:t.shadowRoot)?e.composedPath()[0]||null:e.target||null},_captureEvent:function(e,t,n){var i,r=this,o=this._getEventTarget(e);if(K(o)&&(o=o.parentNode||null),"scroll"===e.type)return this.scrollDepth.track(),!0;if("visibilitychange"===e.type&&"hidden"===document.visibilityState||"popstate"===e.type)return this.scrollDepth.send(),!0;if("click"===e.type&&e instanceof MouseEvent&&(null===(i=this.rageclicks)||void 0===i||i.click(e.clientX,e.clientY,(new Date).getTime())),o&&function(e,t){if(!e||G(e,"html")||!W(e))return!1;if(e.classList&&e.classList.contains("um-no-capture"))return!1;for(var n=!1,i=[e],r=!0,o=e;o.parentNode&&!G(o,"body");)if(Q(o.parentNode))i.push(o.parentNode.host),o=o.parentNode.host;else{if(!(r=o.parentNode||!1))break;if(Y.indexOf(r.tagName.toLowerCase())>-1)n=!0;else{var s=window.getComputedStyle(r);s&&"pointer"===s.getPropertyValue("cursor")&&(n=!0)}i.push(r),o=r}var a=window.getComputedStyle(e);if(a&&"pointer"===a.getPropertyValue("cursor")&&"click"===t.type)return!0;var c=e.tagName.toLowerCase();switch(c){case"html":return!1;case"form":return"submit"===t.type;case"input":case"select":case"textarea":return"change"===t.type||"click"===t.type;default:return n?"click"===t.type:"click"===t.type&&(Y.indexOf(c)>-1||"true"===e.getAttribute("contenteditable"))}}(o,e)){for(var s=[o],a=o;a.parentNode&&!G(a,"body");)Q(a.parentNode)?(s.push(a.parentNode.host),a=a.parentNode.host):(s.push(a.parentNode),a=a.parentNode);var c,u=[],l=!1;if(L(s,(function(e){var t=X(e);"a"===e.tagName.toLowerCase()&&(c=e.getAttribute("href"),c=t&&ee(c)&&c),H(B(e).split(" "),"ph-no-capture")&&(l=!0),u.push(r._getPropertiesFromElement(e,null==n?void 0:n.mask_all_element_attributes,null==n?void 0:n.mask_all_text))})),(null==n?void 0:n.mask_all_text)||(u[0].$el_text=V(o)),c&&(u[0].attr__href=c),l)return!1;var p=j(this._getDefaultProperties(e.type),{$elements:u},this._getCustomProperties(s));return t.capture("$autocapture",p),!0}},_navigate:function(e){window.location.href=e},_addDomEventHandlers:function(e,t){var n=this,i=function(i){i=i||window.event,n._captureEvent(i,e,t)};U(document,"submit",i,!1,!0),U(document,"change",i,!1,!0),U(document,"click",i,!1,!0),U(document,"visibilitychange",i,!1,!0),U(document,"scroll",i,!1,!0),U(window,"popstate",i,!1,!0)},_customProperties:[],rageclicks:null,scrollDepth:null,opts:{},init:function(e,t){var n=this;if(this.rageclicks=new te(e),this.scrollDepth=new ne(e),this.opts=t,!document||!document.body)return console.debug("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((function(){n.readyAutocapture(e,t)}),500);this.readyAutocapture(e,t)},readyAutocapture:function(e,t){this._addDomEventHandlers(e,t)},enabledForProject:function(e,t,n){if(!e)return!0;t=$(t)?10:t,n=$(n)?10:n;for(var i=0,r=0;r<e.length;r++)i+=e.charCodeAt(r);return i%t<n},isBrowserSupported:function(){return F(document.querySelectorAll)}};!function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=e[t].bind(e))}(ie),function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=M(e[t]))}(ie);var re=function(){function e(e,t){void 0===t&&(t="all"),this.instance=e,this.trackingType=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",this.track.bind(this)):this.track()}return e.prototype.track=function(){var e=this;this.formElements=document.querySelectorAll("form"),"tagged"===this.trackingType&&(this.formElements=document.querySelectorAll("form[data-um-form]")),this.formElements.forEach((function(t){t.addEventListener("submit",(function(t){var n=t.target,i=e._getFormDetails(n);e.instance.capture("$form",function(e){for(var t in e)(""===e[t]||null===e[t]||void 0===e[t]||"object"==typeof e[t]&&0===Object.keys(e[t]).length)&&delete e[t];return e}(i))}))}))},e.getInstance=function(t,n){return void 0===n&&(n="all"),e.instance||(e.instance=new e(t,n)),e.instance},e.prototype._getFormDetails=function(e){var t=this,n={form_id:e.id,form_name:e.name||"",form_action:e.action,form_method:e.method},i=e.querySelectorAll("input, select, textarea");return Array.from(i).filter((function(e){return!e.classList.contains("um-no-capture")})).forEach((function(e,i){var r=t._getFieldProps(e,i);Object.assign(n,r)})),n},e.prototype._getFieldProps=function(e,t){var n,i=Object.keys(e.dataset).length?JSON.stringify(e.dataset):void 0,r=this.getSafeText(e);return(n={})["field_"+(t+1)+"_tag"]=e.tagName.toLowerCase(),n["field_"+(t+1)+"_type"]=e instanceof HTMLInputElement?e.type:void 0,n["field_"+(t+1)+"_data_attributes"]=i,n["field_"+(t+1)+"_id"]=e.id,n["field_"+(t+1)+"_value"]=r,n["field_"+(t+1)+"_class"]=e.className,n["field_"+(t+1)+"_name"]=e.name,n},e.prototype.getSafeText=function(e){var t="";if("value"in e&&"password"!==e.type)t=e.value;else if(e.hasChildNodes()){t=Array.from(e.childNodes).filter((function(e){return e.nodeType===Node.TEXT_NODE})).map((function(e){return e.textContent})).join("")}else t=e.textContent||"";return this._scrubPotentiallySensitiveValues(t)},e.prototype._scrubPotentiallySensitiveValues=function(e){return this._shouldCaptureValue(e)?e:"<redacted>"},e.prototype._shouldCaptureValue=function(e){if(this._isNullish(e))return!1;if(this._isString(e)){e=this._trim(e);if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((e||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(e))return!1}return!0},e.prototype._isNullish=function(e){return null==e},e.prototype._isString=function(e){return"string"==typeof e||e instanceof String},e.prototype._trim=function(e){return e.trim().replace(/^\s+|\s+$/g,"")},e}(),oe="production",se="1.4.0"+"/"+oe+"@"+"2024-05-21T10:41:03.987Z",ae=316224e3,ce=function(e,t){c().debug("Sending beacon",t);var n=new Blob([t],{type:"text/plain"});return navigator.sendBeacon(e,n),Promise.resolve()};var ue=function(e,t){return console.debug("Jitsu client tried to send payload to "+e,function(e){if("string"==typeof e)try{return JSON.stringify(JSON.parse(e),null,2)}catch(t){return e}}(t)),Promise.resolve()};function le(e,t){void 0===t&&(t=void 0),""!=(t=null!=t?t:window.location.pathname)&&"/"!=t&&(y(e,t),le(e,t.slice(0,t.lastIndexOf("/"))))}var pe=function(){function e(e,t){this.cookieDomain=e,this.cookieName=t}return e.prototype.save=function(e){v(this.cookieName,JSON.stringify(e),{domain:this.cookieDomain,secure:"http:"!==document.location.protocol,maxAge:ae})},e.prototype.restore=function(){le(this.cookieName);var e=g(this.cookieName);if(e)try{var t=JSON.parse(decodeURIComponent(e));return"object"!=typeof t?void c().warn("Can't restore value of "+this.cookieName+"@"+this.cookieDomain+", expected to be object, but found "+("object"!=typeof t)+": "+t+". Ignoring"):t}catch(t){return void c().error("Failed to decode JSON from "+e,t)}},e.prototype.delete=function(){y(this.cookieName)},e}(),de=function(){function e(){}return e.prototype.save=function(e){},e.prototype.restore=function(){},e.prototype.delete=function(){},e}();var he={getSourceIp:function(){},describeClient:function(){return{referer:document.referrer,url:window.location.href,page_title:document.title,doc_path:document.location.pathname,doc_host:document.location.hostname,doc_search:window.location.search,screen_resolution:screen.width+"x"+screen.height,vp_size:Math.max(document.documentElement.clientWidth||0,window.innerWidth||0)+"x"+Math.max(document.documentElement.clientHeight||0,window.innerHeight||0),user_agent:navigator.userAgent,user_language:navigator.language,doc_encoding:document.characterSet}},getAnonymousId:function(e){var t=e.name,n=e.domain,i=e.crossDomainLinking,r=void 0===i||i;if(le(t),r){var o=new URLSearchParams(window.location.search).get("_um"),s=window.location.hash.substring(1).split("~"),a=s.length>1?s[1]:void 0,u=o||a;if(u){c().debug("Existing user id from other domain",u);var l=g(t);return l&&l===u||v(t,u,{domain:n,secure:"http:"!==document.location.protocol,maxAge:ae}),u}}var p=g(t);if(p)return c().debug("Existing user id",p),p;var d=_();return c().debug("New user id",d),v(t,d,{domain:n,secure:"http:"!==document.location.protocol,maxAge:ae}),d}};var fe={getSourceIp:function(){},describeClient:function(){return{}},getAnonymousId:function(){return""}},me=function(){return he},ge=function(){return fe},ve=function(e,t,n,i){void 0===i&&(i=function(e,t){});var r=new window.XMLHttpRequest;return new Promise((function(o,s){r.onerror=function(n){c().error("Failed to send payload to "+e+": "+((null==n?void 0:n.message)||"unknown error"),t,n),i(-1,{}),s(new Error("Failed to send JSON. See console logs"))},r.onload=function(){200!==r.status?(i(r.status,{}),c().warn("Failed to send data to "+e+" (#"+r.status+" - "+r.statusText+")",t),s(new Error("Failed to send JSON. Error code: "+r.status+". See logs for details"))):i(r.status,r.responseText),o()},r.open("POST",e),r.setRequestHeader("Content-Type","application/json"),Object.entries(n||{}).forEach((function(e){var t=e[0],n=e[1];return r.setRequestHeader(t,n)})),r.send(t),c().debug("sending json",t)}))},ye=function(){function i(){this.userProperties={},this.groupProperties={},this.permanentProperties={globalProps:{},propsPerEvent:{}},this.cookieDomain="",this.trackingHost="",this.idCookieName="",this.randomizeUrl=!1,this.namespace="usermaven",this.crossDomainLinking=!0,this.formTracking=!1,this.domains=[],this.apiKey="",this.initialized=!1,this._3pCookies={},this.cookiePolicy="keep",this.ipPolicy="keep",this.beaconApi=!1,this.transport=ve,this.customHeaders=function(){return{}},this.queue=new P,this.maxSendAttempts=4,this.retryTimeout=[500,1e12],this.flushing=!1,this.attempt=1,this.propertyBlacklist=[],this.__autocapture_enabled=!1,this.__auto_pageview_enabled=!1,this.trackingHostFallback="https://events.usermaven.com"}return i.prototype.get_config=function(e){return this.config?this.config[e]:null},i.prototype.id=function(t,n){return this.userProperties=e(e({},this.userProperties),t),c().debug("Usermaven user identified",t),this.userIdPersistence?this.userIdPersistence.save(t):c().warn("Id() is called before initialization"),n?Promise.resolve():this.track("user_identify",{})},i.prototype.group=function(t,n){return this.groupProperties=e(e({},this.groupProperties),t),c().debug("Usermaven group identified",t),this.userIdPersistence?this.userIdPersistence.save({company:t}):c().warn("Group() is called before initialization"),n?Promise.resolve():this.track("group",{})},i.prototype.reset=function(e){if(this.userIdPersistence&&this.userIdPersistence.delete(),this.propsPersistance&&this.propsPersistance.delete(),e){var t=g(this.idCookieName);t&&(c().debug("Removing id cookie",t),v(this.idCookieName,"",{domain:this.cookieDomain,expires:new Date(0)}))}return Promise.resolve()},i.prototype.rawTrack=function(e){return this.sendJson(e)},i.prototype.makeEvent=function(t,n,i){var o,s=i.env,a=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(i,["env"]);s||(s=r()?me():ge()),this.restoreId();var c=this.getCtx(s),u=e(e({},this.permanentProperties.globalProps),null!==(o=this.permanentProperties.propsPerEvent[t])&&void 0!==o?o:{}),l=e({api_key:this.apiKey,src:n,event_type:t},a),p=s.getSourceIp();return p&&(l.source_ip=p),this.compatMode?e(e(e({},u),{eventn_ctx:c}),l):e(e(e({},u),c),l)},i.prototype._send3p=function(e,t,n){var i="3rdparty";n&&""!==n&&(i=n);var r=this.makeEvent(i,e,{src_payload:t});return this.sendJson(r)},i.prototype.sendJson=function(e){return t(this,void 0,Promise,(function(){return n(this,(function(t){switch(t.label){case 0:return n="false","undefined"!=typeof window&&window.localStorage&&(n=localStorage.getItem("um_exclusion")),null!=n&&"false"!==n?[3,3]:this.maxSendAttempts>1?(this.queue.push([e,0]),this.scheduleFlush(0),[3,3]):[3,1];case 1:return[4,this.doSendJson(e)];case 2:t.sent(),t.label=3;case 3:return[2]}var n}))}))},i.prototype.doSendJson=function(e){var t=this,n="keep"!==this.cookiePolicy?"&cookie_policy="+this.cookiePolicy:"",i="keep"!==this.ipPolicy?"&ip_policy="+this.ipPolicy:"",o=r()?"/api/v1/event":"/api/v1/s2s/event",s=""+this.trackingHost+o+"?token="+this.apiKey+n+i;this.randomizeUrl&&(s=this.trackingHost+"/api."+b()+"?p_"+b()+"="+this.apiKey+n+i);var a=JSON.stringify(e);return c().debug("Sending payload to "+s,e.length),this.transport(s,a,this.customHeaders(),(function(e,n){return t.postHandle(e,n)}))},i.prototype.scheduleFlush=function(e){var t=this;if(!this.flushing){if(this.flushing=!0,void 0===e){var n=Math.random()+1,i=Math.pow(2,this.attempt++);e=Math.min(this.retryTimeout[0]*n*i,this.retryTimeout[1])}c().debug("Scheduling event queue flush in "+e+" ms."),setTimeout((function(){return t.flush()}),e)}},i.prototype.flush=function(){return t(this,void 0,Promise,(function(){var e,t,i=this;return n(this,(function(n){switch(n.label){case 0:if(r()&&!window.navigator.onLine&&(this.flushing=!1,this.scheduleFlush()),e=this.queue.flush(),this.flushing=!1,0===e.length)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.doSendJson(e.map((function(e){return e[0]})))];case 2:return n.sent(),this.attempt=1,c().debug("Successfully flushed "+e.length+" events from queue"),[3,4];case 3:return n.sent(),this.trackingHost!==this.trackingHostFallback&&(c().debug("Using fallback tracking host "+this.trackingHostFallback+" instead of "+this.trackingHost+" on "+oe),this.trackingHost=this.trackingHostFallback),(e=e.map((function(e){return[e[0],e[1]+1]})).filter((function(e){return!(e[1]>=i.maxSendAttempts)||(c().error("Dropping queued event after "+e[1]+" attempts since max send attempts "+i.maxSendAttempts+" reached. See logs for details"),!1)}))).length>0?((t=this.queue).push.apply(t,e),this.scheduleFlush()):this.attempt=1,[3,4];case 4:return[2]}}))}))},i.prototype.postHandle=function(e,t){if("strict"===this.cookiePolicy||"comply"===this.cookiePolicy){if(200===e){var n=t;if("string"==typeof t&&(n=JSON.parse(t)),!n.delete_cookie)return}this.userIdPersistence.delete(),this.propsPersistance.delete(),y(this.idCookieName)}if(200===e){n=t;if("string"==typeof t&&t.length>0){var i=(n=JSON.parse(t)).jitsu_sdk_extras;if(i&&i.length>0)if(r())for(var o=0,s=i;o<s.length;o++){var a=s[o],u=a.type,l=a.id,p=a.value;if("tag"===u){var d=document.createElement("div");d.id=l,m(d,p),d.childElementCount>0&&document.body.appendChild(d)}}else c().error("Tags destination supported only in browser environment")}}},i.prototype.getCtx=function(t){var n=new Date,i=t.describeClient()||{},r=e({},this.userProperties),o=r.company||{};delete r.company;var s,a,c=e(e({event_id:"",user:e({anonymous_id:"strict"!==this.cookiePolicy?t.getAnonymousId({name:this.idCookieName,domain:this.cookieDomain,crossDomainLinking:this.crossDomainLinking}):""},r),ids:this._getIds(),utc_time:(s=n.toISOString(),a=s.split(".")[1],a?a.length>=7?s:s.slice(0,-1)+"0".repeat(7-a.length)+"Z":s),local_tz_offset:n.getTimezoneOffset()},i),function(e){var t={utm:{},click_id:{}};for(var n in e)if(e.hasOwnProperty(n)){var i=e[n],r=k[n];r?t.utm[r]=i:w[n]&&(t.click_id[n]=i)}return t}(function(e){if(!e)return{};for(var t=e.length>0&&"?"===e.charAt(0)?e.substring(1):e,n={},i=("?"===t[0]?t.substr(1):t).split("&"),r=0;r<i.length;r++){var o=i[r].split("=");n[decodeURIComponent(o[0])]=decodeURIComponent(o[1]||"")}return n}(i.doc_search)));return Object.keys(o).length&&(c.company=o),c},i.prototype._getIds=function(){if(!r())return{};for(var e=function(e){if(void 0===e&&(e=!1),e&&p)return p;var t=h(document.cookie);return p=t,t}(!1),t={},n=0,i=Object.entries(e);n<i.length;n++){var o=i[n],s=o[0],a=o[1];this._3pCookies[s]&&(t["_"==s.charAt(0)?s.substr(1):s]=a)}return t},i.prototype.pathMatches=function(e,t){return new URL(t).pathname.match(new RegExp("^"+e.trim().replace(/\*\*/g,".*").replace(/([^\.])\*/g,"$1[^\\s/]*")+"/?$"))},i.prototype.track=function(e,t){var n=this,i=t||{};c().debug("track event of type",e,i);var o=r()?me():ge(),s=this.getCtx(o);if(this.config&&this.config.exclude&&this.config.exclude.length>1&&(null==s?void 0:s.url)&&this.config.exclude.split(",").some((function(e){return n.pathMatches(e.trim(),null==s?void 0:s.url)})))return void c().debug("Page is excluded from tracking");var a=t||{};"$autocapture"!==e&&"user_identify"!==e&&"pageview"!==e&&"$pageleave"!==e&&(a={event_attributes:t});var u=this.makeEvent(e,this.compatMode?"eventn":"usermaven",a);return this.sendJson(u)},i.prototype.init=function(i){var o,l,p,h,f,m,g,v,y,_=this;if(r()&&!i.force_use_fetch)i.fetch&&c().warn("Custom fetch implementation is provided to Usermaven. However, it will be ignored since Usermaven runs in browser"),this.transport=this.beaconApi?ce:ve;else{if(!i.fetch&&!globalThis.fetch)throw new Error("Usermaven runs in Node environment. However, neither UsermavenOptions.fetch is provided, nor global fetch function is defined. \nPlease, provide custom fetch implementation. You can get it via node-fetch package");this.transport=(g=i.fetch||globalThis.fetch,function(i,r,o,s){return void 0===s&&(s=function(e,t){}),t(void 0,void 0,void 0,(function(){var t,a,u,l,p,d,h,f;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,g(i,{method:"POST",headers:e({Accept:"application/json","Content-Type":"application/json"},o||{}),body:r})];case 1:return t=n.sent(),[3,3];case 2:return a=n.sent(),c().error("Failed to send data to "+i+": "+((null==a?void 0:a.message)||"unknown error"),r,a),s(-1,{}),[2];case 3:if(200!==t.status)return c().warn("Failed to send data to "+i+" (#"+t.status+" - "+t.statusText+")",r),s(t.status,{}),[2];u={},l="",p=null!==(f=null===(h=t.headers)||void 0===h?void 0:h.get("Content-Type"))&&void 0!==f?f:"",n.label=4;case 4:return n.trys.push([4,6,,7]),[4,t.text()];case 5:return l=n.sent(),u=JSON.parse(l),[3,7];case 6:return d=n.sent(),c().error("Failed to parse "+i+" response. Content-type: "+p+" text: "+l,d),[3,7];case 7:try{s(t.status,u)}catch(e){c().error("Failed to handle "+i+" response. Content-type: "+p+" text: "+l,e)}return[2]}}))}))})}if(i.custom_headers&&"function"==typeof i.custom_headers?this.customHeaders=i.custom_headers:i.custom_headers&&(this.customHeaders=function(){return i.custom_headers}),"echo"===i.tracking_host&&(c().warn('jitsuClient is configured with "echo" transport. Outgoing requests will be written to console'),this.transport=ue),i.ip_policy&&(this.ipPolicy=i.ip_policy),i.cookie_policy&&(this.cookiePolicy=i.cookie_policy),"strict"===i.privacy_policy&&(this.ipPolicy="strict",this.cookiePolicy="strict"),i.use_beacon_api&&navigator.sendBeacon&&(this.beaconApi=!0),"comply"===this.cookiePolicy&&this.beaconApi&&(this.cookiePolicy="strict"),i.log_level&&(v=i.log_level,(y=s[v.toLocaleUpperCase()])||(console.warn("Can't find log level with name "+v.toLocaleUpperCase()+", defaulting to INFO"),y=s.INFO),a=u(y)),this.initialOptions=i,c().debug("Initializing Usemaven Tracker tracker",i,se),i.key){if(this.compatMode=void 0!==i.compat_mode&&!!i.compat_mode,this.cookieDomain=i.cookie_domain||d(),this.namespace=i.namespace||"usermaven",this.crossDomainLinking=null===(o=i.cross_domain_linking)||void 0===o||o,this.formTracking=null!==(l=i.form_tracking)&&void 0!==l&&l,this.domains=i.domains?i.domains.split(",").map((function(e){return e.trim()})):[],this.trackingHost=function(e){for(;n="/",-1!==(t=e).indexOf(n,t.length-n.length);)e=e.substr(0,e.length-1);var t,n;return 0===e.indexOf("https://")||0===e.indexOf("http://")?e:"https://"+e}(i.tracking_host||"t.usermaven.com"),this.randomizeUrl=i.randomize_url||!1,this.apiKey=i.key,this.__auto_pageview_enabled=i.auto_pageview||!1,this.idCookieName=i.cookie_name||"__eventn_id_"+i.key,"strict"===this.cookiePolicy?this.propsPersistance=new de:this.propsPersistance=r()?new pe(this.cookieDomain,this.idCookieName+"_props"):new de,"strict"===this.cookiePolicy?this.userIdPersistence=new de:this.userIdPersistence=r()?new pe(this.cookieDomain,this.idCookieName+"_usr"):new de,this.propsPersistance){var b=this.propsPersistance.restore();b&&(this.permanentProperties=b,this.permanentProperties.globalProps=null!==(p=b.globalProps)&&void 0!==p?p:{},this.permanentProperties.propsPerEvent=null!==(h=b.propsPerEvent)&&void 0!==h?h:{}),c().debug("Restored persistent properties",this.permanentProperties)}this.propertyBlacklist=i.property_blacklist&&i.property_blacklist.length>0?i.property_blacklist:[];this.config=j({},{autocapture:!1,properties_string_max_length:null,property_blacklist:[],sanitize_properties:null,auto_pageview:!1},i||{},this.config||{},{token:this.apiKey}),c().debug("Default Configuration",this.config),this.manageAutoCapture(this.config),this.manageFormTracking(this.config),this.manageCrossDomainLinking({cross_domain_linking:this.crossDomainLinking,domains:this.domains,cookiePolicy:this.cookiePolicy}),!1===i.capture_3rd_party_cookies?this._3pCookies={}:(i.capture_3rd_party_cookies||["_ga","_fbp","_ym_uid","ajs_user_id","ajs_anonymous_id"]).forEach((function(e){return _._3pCookies[e]=!0})),i.ga_hook&&c().warn("GA event interceptor isn't supported anymore"),i.segment_hook&&function(e){var t=window;t.analytics||(t.analytics=[]);e.interceptAnalytics(t.analytics)}(this),r()&&(i.disable_event_persistence||(this.queue=new S(this.namespace+"-event-queue"),this.scheduleFlush(0)),window.addEventListener("beforeunload",(function(){return _.flush()}))),this.__auto_pageview_enabled&&function(e){var t=function(){return e.track("pageview")},n=history.pushState;n&&(history.pushState=function(e,i,r){n.apply(this,[e,i,r]),t()},addEventListener("popstate",t));addEventListener("hashchange",t)}(this),this.retryTimeout=[null!==(f=i.min_send_timeout)&&void 0!==f?f:this.retryTimeout[0],null!==(m=i.max_send_timeout)&&void 0!==m?m:this.retryTimeout[1]],i.max_send_attempts&&(this.maxSendAttempts=i.max_send_attempts),this.initialized=!0}else c().error("Can't initialize Usemaven, key property is not set")},i.prototype.interceptAnalytics=function(t){var n=this,i=function(t){var i;try{var r=e({},t.payload);c().debug("Intercepted segment payload",r.obj);var o=t.integrations["Segment.io"];if(o&&o.analytics){var s=o.analytics;"function"==typeof s.user&&s.user()&&"function"==typeof s.user().id&&(r.obj.userId=s.user().id())}(null===(i=null==r?void 0:r.obj)||void 0===i?void 0:i.timestamp)&&(r.obj.sentAt=r.obj.timestamp);var a=t.payload.type();"track"===a&&(a=t.payload.event()),n._send3p("ajs",r,a)}catch(e){c().warn("Failed to send an event",e)}t.next(t.payload)};"function"==typeof t.addSourceMiddleware?(c().debug("Analytics.js is initialized, calling addSourceMiddleware"),t.addSourceMiddleware(i)):(c().debug("Analytics.js is not initialized, pushing addSourceMiddleware to callstack"),t.push(["addSourceMiddleware",i])),t.__en_intercepted=!0},i.prototype.restoreId=function(){if(this.userIdPersistence){var t=this.userIdPersistence.restore();t&&(this.userProperties=e(e({},t),this.userProperties))}},i.prototype.set=function(t,n){var i,r=null==n?void 0:n.eventType,o=void 0===(null==n?void 0:n.persist)||(null==n?void 0:n.persist);if(void 0!==r){var s=null!==(i=this.permanentProperties.propsPerEvent[r])&&void 0!==i?i:{};this.permanentProperties.propsPerEvent[r]=e(e({},s),t)}else this.permanentProperties.globalProps=e(e({},this.permanentProperties.globalProps),t);this.propsPersistance&&o&&this.propsPersistance.save(this.permanentProperties)},i.prototype.unset=function(e,t){o();var n=null==t?void 0:t.eventType,i=void 0===(null==t?void 0:t.persist)||(null==t?void 0:t.persist);n?this.permanentProperties.propsPerEvent[n]&&delete this.permanentProperties.propsPerEvent[n][e]:delete this.permanentProperties.globalProps[e],this.propsPersistance&&i&&this.propsPersistance.save(this.permanentProperties)},i.prototype.manageCrossDomainLinking=function(e){if(!r()||!e.cross_domain_linking||0===e.domains.length||"strict"===e.cookiePolicy)return!1;var t=this.idCookieName,n=e.domains||[];document.addEventListener("click",(function(e){var i=function(e){for(;e&&e.tagName;){if("a"==e.tagName.toLowerCase())return e;e=e.parentNode}return null}(e.target);if(i){var r=(null==i?void 0:i.hasAttribute("href"))?null==i?void 0:i.getAttribute("href"):"";if(r&&r.startsWith("http")){var o=new URL(r),s=g(t);if(o.hostname===window.location.hostname)return;n.includes(o.hostname)&&s&&(o.searchParams.append("_um",s),i.setAttribute("href",o.toString()))}}}),!1)},i.prototype.manageAutoCapture=function(e){if(c().debug("Auto Capture Status: ",this.config.autocapture),this.__autocapture_enabled=this.config.autocapture&&r(),this.__autocapture_enabled){ie.enabledForProject(this.apiKey,100,100)?ie.isBrowserSupported()?(c().debug("Autocapture enabled..."),ie.init(this,e)):(this.config.autocapture=!1,this.__autocapture_enabled=!1,c().debug("Disabling Automatic Event Collection because this browser is not supported")):(this.config.autocapture=!1,this.__autocapture_enabled=!1,c().debug("Not in active bucket: disabling Automatic Event Collection."))}},i.prototype.manageFormTracking=function(e){if(r()&&this.formTracking&&"none"!==this.formTracking){c().debug("Form tracking enabled...");var t=!0===this.formTracking?"all":this.formTracking;re.getInstance(this,t).track()}},i.prototype.capture=function(e,t){var n,i;if(void 0===t&&(t={}),this.initialized)if($(e)||"string"!=typeof e)console.error("No event name provided to usermaven.capture");else{var r={event:e+(t.$event_type?"_"+t.$event_type:""),properties:this._calculate_event_properties(e,t)};(null===(i=null===(n=(r=J(r,this.get_config("properties_string_max_length"))).properties)||void 0===n?void 0:n.autocapture_attributes)||void 0===i?void 0:i.tag_name)&&this.track("$autocapture",r.properties),"$scroll"===e&&this.track(e,r.properties),"$form"===e&&this.track(e,r.properties)}else console.error("Trying to capture event before initialization")},i.prototype._calculate_event_properties=function(e,t){var n,i,r=t||{};if("$snapshot"===e||"$scroll"===e||"$form"===e)return r;T(this.propertyBlacklist)?L(this.propertyBlacklist,(function(e){delete r[e]})):console.error("Invalid value for property_blacklist config: "+this.propertyBlacklist);var o={},s=r.$elements||[];return s.length&&(o=s[0]),r.autocapture_attributes=o,r.autocapture_attributes.el_text=null!==(n=r.autocapture_attributes.$el_text)&&void 0!==n?n:"",r.autocapture_attributes.event_type=null!==(i=r.$event_type)&&void 0!==i?i:"",["$ce_version","$event_type","$initial_referrer","$initial_referring_domain","$referrer","$referring_domain","$elements"].forEach((function(e){delete r[e]})),delete r.autocapture_attributes.$el_text,delete r.autocapture_attributes.nth_child,delete r.autocapture_attributes.nth_of_type,r},i}();var _e="lib.js",be=["use_beacon_api","cookie_domain","tracking_host","cookie_name","key","ga_hook","segment_hook","randomize_url","capture_3rd_party_cookies","id_method","log_level","compat_mode","privacy_policy","cookie_policy","ip_policy","custom_headers","force_use_fetch","min_send_timeout","max_send_timeout","max_send_attempts","disable_event_persistence","project_id","autocapture","properties_string_max_length","property_blacklist","exclude","auto_pageview","namespace","cross_domain_linking","domains","form_tracking"];var ke="data-suppress-interception-warning";function we(e){return"\n ATTENTION! "+e+"-hook set to true along with defer/async attribute! If "+e+" code is inserted right after Usermaven tag,\n first tracking call might not be intercepted! Consider one of the following:\n - Inject usermaven tracking code without defer/async attribute\n - If you're sure that events won't be sent to "+e+" before Usermaven is fully initialized, set "+ke+'="true"\n script attribute\n '}function Pe(e){var t=document.currentScript;if(t){var n,i={tracking_host:(n=t.getAttribute("src"),n.replace("/s/"+_e,"").replace("/"+_e,"")),key:null},r=t.getAttribute("data-namespace")||"usermaven";be.forEach((function(e){var n="data-"+e.replace(new RegExp("_","g"),"-");if(void 0!==t.getAttribute(n)&&null!==t.getAttribute(n)){var r=t.getAttribute(n);"true"===r?r=!0:"false"===r&&(r=!1),i[e]=r}}));var o=r+"Client";e[o]=function(e){var t=new ye;return t.init(e),t}(i),!i.segment_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(ke)||c().warn(we("segment")),!i.ga_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(ke)||c().warn(we("ga")),!function(t,n,i){e[t]=function(){var i=e[t+"Q"]=e[t+"Q"]||[];i.push(arguments),Se(i,e[n])}}(r,o),i.project_id&&e[r]("set",{project_id:i.project_id}),"true"!==t.getAttribute("data-init-only")&&"yes"!==t.getAttribute("data-init-only")&&e[r]("track","pageview");var s="beforeunload";return(navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPhone/i))&&(s="pagehide"),e.addEventListener(s,(function(){e[r]("track","$pageleave")})),e[o]}c().warn("Usermaven script is not properly initialized. The definition must contain data-usermaven-api-key as a parameter")}function Se(e,t){c().debug("Processing queue",e);for(var n=0;n<e.length;n+=1){var r=i([],e[n],!0)||[],o=r[0],s=r.slice(1),a=t[o];"function"==typeof a&&a.apply(t,s)}e.length=0}!function(e){if(window){var t=window,n=e,i=Pe(t);i?(c().debug("Usermaven in-browser tracker has been initialized",n),t[n]=function(){var e=t[n+"Q"]=t[n+"Q"]||[];e.push(arguments),Se(e,i)},t[n+"Q"]&&(c().debug("Initial queue size of "+t[n+"Q"].length+" will be processed"),Se(t[n+"Q"],i))):c().error("Usermaven tracker has not been initialized (reason unknown)")}else c().warn("Usermaven tracker called outside browser context. It will be ignored")}(document.currentScript.getAttribute("data-namespace")||"usermaven")}();
|