@usermaven/sdk-js 1.2.4 → 1.2.6
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 +60 -35
- package/dist/npm/usermaven.d.ts +7 -0
- package/dist/npm/usermaven.es.js +60 -35
- package/dist/web/lib.js +1 -1
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/******************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
7
7
|
|
|
8
8
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -56,7 +56,7 @@ function __generator(thisArg, body) {
|
|
|
56
56
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
57
57
|
function step(op) {
|
|
58
58
|
if (f) throw new TypeError("Generator is already executing.");
|
|
59
|
-
while (_) try {
|
|
59
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
60
60
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
61
61
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
62
62
|
switch (op[0]) {
|
|
@@ -86,7 +86,12 @@ function __spreadArray(to, from, pack) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
89
|
-
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
92
|
+
var e = new Error(message);
|
|
93
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
94
|
+
};
|
|
90
95
|
|
|
91
96
|
var LogLevels = {
|
|
92
97
|
DEBUG: { name: "DEBUG", severity: 10 },
|
|
@@ -110,7 +115,7 @@ function getLogger() {
|
|
|
110
115
|
function setRootLogLevel(logLevelName) {
|
|
111
116
|
var logLevel = LogLevels[logLevelName.toLocaleUpperCase()];
|
|
112
117
|
if (!logLevel) {
|
|
113
|
-
console.warn("Can't find log level with name "
|
|
118
|
+
console.warn("Can't find log level with name " + logLevelName.toLocaleUpperCase() + ", defaulting to INFO");
|
|
114
119
|
logLevel = LogLevels.INFO;
|
|
115
120
|
}
|
|
116
121
|
rootLogger = createLogger(logLevel);
|
|
@@ -153,7 +158,7 @@ function createLogger(logLevel) {
|
|
|
153
158
|
if (severity >= minLogLevel.severity && args.length > 0) {
|
|
154
159
|
var message = args[0];
|
|
155
160
|
var msgArgs = args.splice(1);
|
|
156
|
-
var msgFormatted = "[J-"
|
|
161
|
+
var msgFormatted = "[J-" + name + "] " + message;
|
|
157
162
|
if (name === 'DEBUG' || name === 'INFO') {
|
|
158
163
|
console.log.apply(console, __spreadArray([msgFormatted], msgArgs, false));
|
|
159
164
|
}
|
|
@@ -204,21 +209,21 @@ function serializeCookie(name, val, opt) {
|
|
|
204
209
|
if (opt === void 0) { opt = {}; }
|
|
205
210
|
try {
|
|
206
211
|
var maxAge = opt.maxAge, domain = opt.domain, path = opt.path, expires = opt.expires, httpOnly = opt.httpOnly, secure = opt.secure, sameSite = opt.sameSite;
|
|
207
|
-
var new_cookie_val =
|
|
212
|
+
var new_cookie_val = name + "=" + encodeURIComponent(val);
|
|
208
213
|
if (domain) {
|
|
209
|
-
new_cookie_val += "; domain="
|
|
214
|
+
new_cookie_val += "; domain=" + domain;
|
|
210
215
|
}
|
|
211
216
|
if (path) {
|
|
212
|
-
new_cookie_val += "; path="
|
|
217
|
+
new_cookie_val += "; path=" + path;
|
|
213
218
|
}
|
|
214
219
|
else {
|
|
215
220
|
new_cookie_val += "; path=/";
|
|
216
221
|
}
|
|
217
222
|
if (expires) {
|
|
218
|
-
new_cookie_val += "; expires="
|
|
223
|
+
new_cookie_val += "; expires=" + expires.toUTCString();
|
|
219
224
|
}
|
|
220
225
|
if (maxAge) {
|
|
221
|
-
new_cookie_val += "; max-age="
|
|
226
|
+
new_cookie_val += "; max-age=" + maxAge;
|
|
222
227
|
}
|
|
223
228
|
if (httpOnly) {
|
|
224
229
|
new_cookie_val += "; httponly";
|
|
@@ -1387,10 +1392,10 @@ _safewrap_instance_methods(autocapture);
|
|
|
1387
1392
|
|
|
1388
1393
|
var VERSION_INFO = {
|
|
1389
1394
|
env: 'production',
|
|
1390
|
-
date: '2023-
|
|
1391
|
-
version: '1.2.
|
|
1395
|
+
date: '2023-12-12T10:51:57.547Z',
|
|
1396
|
+
version: '1.2.6'
|
|
1392
1397
|
};
|
|
1393
|
-
var USERMAVEN_VERSION =
|
|
1398
|
+
var USERMAVEN_VERSION = VERSION_INFO.version + "/" + VERSION_INFO.env + "@" + VERSION_INFO.date;
|
|
1394
1399
|
var MAX_AGE_TEN_YEARS = 31622400 * 10;
|
|
1395
1400
|
var beaconTransport = function (url, json) {
|
|
1396
1401
|
getLogger().debug("Sending beacon", json);
|
|
@@ -1409,7 +1414,7 @@ function tryFormat(string) {
|
|
|
1409
1414
|
}
|
|
1410
1415
|
}
|
|
1411
1416
|
var echoTransport = function (url, json) {
|
|
1412
|
-
console.debug("Jitsu client tried to send payload to "
|
|
1417
|
+
console.debug("Jitsu client tried to send payload to " + url, tryFormat(json));
|
|
1413
1418
|
return Promise.resolve();
|
|
1414
1419
|
};
|
|
1415
1420
|
// This is a hack to expire all cookies with non-root path left behind by invalid tracking.
|
|
@@ -1442,7 +1447,7 @@ var CookiePersistence = /** @class */ (function () {
|
|
|
1442
1447
|
try {
|
|
1443
1448
|
var parsed = JSON.parse(decodeURIComponent(str));
|
|
1444
1449
|
if (typeof parsed !== "object") {
|
|
1445
|
-
getLogger().warn("Can't restore value of "
|
|
1450
|
+
getLogger().warn("Can't restore value of " + this.cookieName + "@" + this.cookieDomain + ", expected to be object, but found " + (typeof parsed !== "object") + ": " + parsed + ". Ignoring");
|
|
1446
1451
|
return undefined;
|
|
1447
1452
|
}
|
|
1448
1453
|
return parsed;
|
|
@@ -1585,7 +1590,7 @@ function fetchApi(req, res, opts) {
|
|
|
1585
1590
|
page_title: "",
|
|
1586
1591
|
referer: req.headers["referrer"],
|
|
1587
1592
|
screen_resolution: "",
|
|
1588
|
-
url:
|
|
1593
|
+
url: proto + "://" + requestHost + (path || "") + (query || ""),
|
|
1589
1594
|
user_agent: req.headers["user-agent"],
|
|
1590
1595
|
user_language: req.headers["accept-language"] &&
|
|
1591
1596
|
req.headers["accept-language"].split(",")[0],
|
|
@@ -1653,7 +1658,7 @@ function httpApi(req, res, opts) {
|
|
|
1653
1658
|
page_title: "",
|
|
1654
1659
|
referer: header(req, "referrer"),
|
|
1655
1660
|
screen_resolution: "",
|
|
1656
|
-
url:
|
|
1661
|
+
url: proto + "://" + requestHost + (path || "") + (query || ""),
|
|
1657
1662
|
user_agent: req.headers["user-agent"],
|
|
1658
1663
|
user_language: req.headers["accept-language"] &&
|
|
1659
1664
|
req.headers["accept-language"].split(",")[0],
|
|
@@ -1685,15 +1690,15 @@ var xmlHttpTransport = function (url, jsonPayload, additionalHeaders, handler) {
|
|
|
1685
1690
|
var req = new window.XMLHttpRequest();
|
|
1686
1691
|
return new Promise(function (resolve, reject) {
|
|
1687
1692
|
req.onerror = function (e) {
|
|
1688
|
-
getLogger().error("Failed to send payload to "
|
|
1693
|
+
getLogger().error("Failed to send payload to " + url + ": " + ((e === null || e === void 0 ? void 0 : e.message) || "unknown error"), jsonPayload, e);
|
|
1689
1694
|
handler(-1, {});
|
|
1690
1695
|
reject(new Error("Failed to send JSON. See console logs"));
|
|
1691
1696
|
};
|
|
1692
1697
|
req.onload = function () {
|
|
1693
1698
|
if (req.status !== 200) {
|
|
1694
1699
|
handler(req.status, {});
|
|
1695
|
-
getLogger().warn("Failed to send data to "
|
|
1696
|
-
reject(new Error("Failed to send JSON. Error code: "
|
|
1700
|
+
getLogger().warn("Failed to send data to " + url + " (#" + req.status + " - " + req.statusText + ")", jsonPayload);
|
|
1701
|
+
reject(new Error("Failed to send JSON. Error code: " + req.status + ". See logs for details"));
|
|
1697
1702
|
}
|
|
1698
1703
|
else {
|
|
1699
1704
|
handler(req.status, req.responseText);
|
|
@@ -1731,12 +1736,12 @@ var fetchTransport = function (fetch) {
|
|
|
1731
1736
|
return [3 /*break*/, 3];
|
|
1732
1737
|
case 2:
|
|
1733
1738
|
e_1 = _c.sent();
|
|
1734
|
-
getLogger().error("Failed to send data to "
|
|
1739
|
+
getLogger().error("Failed to send data to " + url + ": " + ((e_1 === null || e_1 === void 0 ? void 0 : e_1.message) || "unknown error"), jsonPayload, e_1);
|
|
1735
1740
|
handler(-1, {});
|
|
1736
1741
|
return [2 /*return*/];
|
|
1737
1742
|
case 3:
|
|
1738
1743
|
if (res.status !== 200) {
|
|
1739
|
-
getLogger().warn("Failed to send data to "
|
|
1744
|
+
getLogger().warn("Failed to send data to " + url + " (#" + res.status + " - " + res.statusText + ")", jsonPayload);
|
|
1740
1745
|
handler(res.status, {});
|
|
1741
1746
|
return [2 /*return*/];
|
|
1742
1747
|
}
|
|
@@ -1753,14 +1758,14 @@ var fetchTransport = function (fetch) {
|
|
|
1753
1758
|
return [3 /*break*/, 7];
|
|
1754
1759
|
case 6:
|
|
1755
1760
|
e_2 = _c.sent();
|
|
1756
|
-
getLogger().error("Failed to parse "
|
|
1761
|
+
getLogger().error("Failed to parse " + url + " response. Content-type: " + contentType + " text: " + text, e_2);
|
|
1757
1762
|
return [3 /*break*/, 7];
|
|
1758
1763
|
case 7:
|
|
1759
1764
|
try {
|
|
1760
1765
|
handler(res.status, resJson);
|
|
1761
1766
|
}
|
|
1762
1767
|
catch (e) {
|
|
1763
|
-
getLogger().error("Failed to handle "
|
|
1768
|
+
getLogger().error("Failed to handle " + url + " response. Content-type: " + contentType + " text: " + text, e);
|
|
1764
1769
|
}
|
|
1765
1770
|
return [2 /*return*/];
|
|
1766
1771
|
}
|
|
@@ -1797,6 +1802,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
1797
1802
|
// public persistence?: UserMavenPersistence;
|
|
1798
1803
|
// public sessionManager?: SessionIdManager;
|
|
1799
1804
|
this.__autocapture_enabled = false;
|
|
1805
|
+
this.__auto_pageview_enabled = false;
|
|
1800
1806
|
// private anonymousId: string = '';
|
|
1801
1807
|
// Fallback tracking host
|
|
1802
1808
|
this.trackingHostFallback = "https://events.usermaven.com" ;
|
|
@@ -1910,15 +1916,15 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
1910
1916
|
};
|
|
1911
1917
|
UsermavenClientImpl.prototype.doSendJson = function (json) {
|
|
1912
1918
|
var _this = this;
|
|
1913
|
-
var cookiePolicy = this.cookiePolicy !== "keep" ? "&cookie_policy="
|
|
1914
|
-
var ipPolicy = this.ipPolicy !== "keep" ? "&ip_policy="
|
|
1919
|
+
var cookiePolicy = this.cookiePolicy !== "keep" ? "&cookie_policy=" + this.cookiePolicy : "";
|
|
1920
|
+
var ipPolicy = this.ipPolicy !== "keep" ? "&ip_policy=" + this.ipPolicy : "";
|
|
1915
1921
|
var urlPrefix = isWindowAvailable() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
1916
|
-
var url = ""
|
|
1922
|
+
var url = "" + this.trackingHost + urlPrefix + "?token=" + this.apiKey + cookiePolicy + ipPolicy;
|
|
1917
1923
|
if (this.randomizeUrl) {
|
|
1918
|
-
url =
|
|
1924
|
+
url = this.trackingHost + "/api." + generateRandom() + "?p_" + generateRandom() + "=" + this.apiKey + cookiePolicy + ipPolicy;
|
|
1919
1925
|
}
|
|
1920
1926
|
var jsonString = JSON.stringify(json);
|
|
1921
|
-
getLogger().debug("Sending payload to "
|
|
1927
|
+
getLogger().debug("Sending payload to " + url, jsonString);
|
|
1922
1928
|
return this.transport(url, jsonString, this.customHeaders(), function (code, body) {
|
|
1923
1929
|
return _this.postHandle(code, body);
|
|
1924
1930
|
});
|
|
@@ -1934,7 +1940,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
1934
1940
|
var factor = Math.pow(2, this.attempt++);
|
|
1935
1941
|
timeout = Math.min(this.retryTimeout[0] * random * factor, this.retryTimeout[1]);
|
|
1936
1942
|
}
|
|
1937
|
-
getLogger().debug("Scheduling event queue flush in "
|
|
1943
|
+
getLogger().debug("Scheduling event queue flush in " + timeout + " ms.");
|
|
1938
1944
|
setTimeout(function () { return _this.flush(); }, timeout);
|
|
1939
1945
|
};
|
|
1940
1946
|
UsermavenClientImpl.prototype.flush = function () {
|
|
@@ -1961,18 +1967,18 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
1961
1967
|
case 2:
|
|
1962
1968
|
_b.sent();
|
|
1963
1969
|
this.attempt = 1;
|
|
1964
|
-
getLogger().debug("Successfully flushed "
|
|
1970
|
+
getLogger().debug("Successfully flushed " + queue.length + " events from queue");
|
|
1965
1971
|
return [3 /*break*/, 4];
|
|
1966
1972
|
case 3:
|
|
1967
1973
|
_b.sent();
|
|
1968
1974
|
// In case of failing custom domain (trackingHost), we will replace it with default domain (trackingHostFallback)
|
|
1969
1975
|
if (this.trackingHost !== this.trackingHostFallback) {
|
|
1970
|
-
getLogger().debug("Using fallback tracking host "
|
|
1976
|
+
getLogger().debug("Using fallback tracking host " + this.trackingHostFallback + " instead of " + this.trackingHost + " on " + VERSION_INFO.env);
|
|
1971
1977
|
this.trackingHost = this.trackingHostFallback;
|
|
1972
1978
|
}
|
|
1973
1979
|
queue = queue.map(function (el) { return [el[0], el[1] + 1]; }).filter(function (el) {
|
|
1974
1980
|
if (el[1] >= _this.maxSendAttempts) {
|
|
1975
|
-
getLogger().error("Dropping queued event after "
|
|
1981
|
+
getLogger().error("Dropping queued event after " + el[1] + " attempts since max send attempts " + _this.maxSendAttempts + " reached. See logs for details");
|
|
1976
1982
|
return false;
|
|
1977
1983
|
}
|
|
1978
1984
|
return true;
|
|
@@ -2156,7 +2162,8 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2156
2162
|
this.trackingHost = getHostWithProtocol(options["tracking_host"] || "t.usermaven.com");
|
|
2157
2163
|
this.randomizeUrl = options.randomize_url || false;
|
|
2158
2164
|
this.apiKey = options.key;
|
|
2159
|
-
this.
|
|
2165
|
+
this.__auto_pageview_enabled = options.auto_pageview || false;
|
|
2166
|
+
this.idCookieName = options.cookie_name || "__eventn_id_" + options.key;
|
|
2160
2167
|
if (this.cookiePolicy === "strict") {
|
|
2161
2168
|
this.propsPersistance = new NoPersistence();
|
|
2162
2169
|
}
|
|
@@ -2188,7 +2195,8 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2188
2195
|
autocapture: false,
|
|
2189
2196
|
properties_string_max_length: null,
|
|
2190
2197
|
property_blacklist: [],
|
|
2191
|
-
sanitize_properties: null
|
|
2198
|
+
sanitize_properties: null,
|
|
2199
|
+
auto_pageview: false
|
|
2192
2200
|
};
|
|
2193
2201
|
this.config = _extend({}, defaultConfig, options || {}, this.config || {}, { token: this.apiKey });
|
|
2194
2202
|
getLogger().debug('Default Configuration', this.config);
|
|
@@ -2219,6 +2227,9 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2219
2227
|
}
|
|
2220
2228
|
window.addEventListener("beforeunload", function () { return _this.flush(); });
|
|
2221
2229
|
}
|
|
2230
|
+
if (this.__auto_pageview_enabled) {
|
|
2231
|
+
enableAutoPageviews(this);
|
|
2232
|
+
}
|
|
2222
2233
|
this.retryTimeout = [
|
|
2223
2234
|
(_c = options.min_send_timeout) !== null && _c !== void 0 ? _c : this.retryTimeout[0],
|
|
2224
2235
|
(_d = options.max_send_timeout) !== null && _d !== void 0 ? _d : this.retryTimeout[1],
|
|
@@ -2409,6 +2420,20 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2409
2420
|
};
|
|
2410
2421
|
return UsermavenClientImpl;
|
|
2411
2422
|
}());
|
|
2423
|
+
function enableAutoPageviews(t) {
|
|
2424
|
+
var page = function () { return t.track("pageview"); };
|
|
2425
|
+
// Attach pushState and popState listeners
|
|
2426
|
+
var originalPushState = history.pushState;
|
|
2427
|
+
if (originalPushState) {
|
|
2428
|
+
// eslint-disable-next-line functional/immutable-data
|
|
2429
|
+
history.pushState = function (data, title, url) {
|
|
2430
|
+
originalPushState.apply(this, [data, title, url]);
|
|
2431
|
+
page();
|
|
2432
|
+
};
|
|
2433
|
+
addEventListener('popstate', page);
|
|
2434
|
+
}
|
|
2435
|
+
addEventListener('hashchange', page);
|
|
2436
|
+
}
|
|
2412
2437
|
function interceptSegmentCalls(t) {
|
|
2413
2438
|
var win = window;
|
|
2414
2439
|
if (!win.analytics) {
|
package/dist/npm/usermaven.d.ts
CHANGED
|
@@ -244,6 +244,13 @@ export type UsermavenOptions = {
|
|
|
244
244
|
*/
|
|
245
245
|
autocapture?: boolean,
|
|
246
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Auto pageview is disabled by default
|
|
249
|
+
*
|
|
250
|
+
* @default false
|
|
251
|
+
*/
|
|
252
|
+
auto_pageview?: boolean,
|
|
253
|
+
|
|
247
254
|
/**
|
|
248
255
|
* To control the payload properties character limit. Defaults to null that means there is no limit. i.e 65535
|
|
249
256
|
*
|
package/dist/npm/usermaven.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -52,7 +52,7 @@ function __generator(thisArg, body) {
|
|
|
52
52
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
53
53
|
function step(op) {
|
|
54
54
|
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
-
while (_) try {
|
|
55
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
56
56
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
57
57
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
58
58
|
switch (op[0]) {
|
|
@@ -82,7 +82,12 @@ function __spreadArray(to, from, pack) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
85
|
-
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
88
|
+
var e = new Error(message);
|
|
89
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
90
|
+
};
|
|
86
91
|
|
|
87
92
|
var LogLevels = {
|
|
88
93
|
DEBUG: { name: "DEBUG", severity: 10 },
|
|
@@ -106,7 +111,7 @@ function getLogger() {
|
|
|
106
111
|
function setRootLogLevel(logLevelName) {
|
|
107
112
|
var logLevel = LogLevels[logLevelName.toLocaleUpperCase()];
|
|
108
113
|
if (!logLevel) {
|
|
109
|
-
console.warn("Can't find log level with name "
|
|
114
|
+
console.warn("Can't find log level with name " + logLevelName.toLocaleUpperCase() + ", defaulting to INFO");
|
|
110
115
|
logLevel = LogLevels.INFO;
|
|
111
116
|
}
|
|
112
117
|
rootLogger = createLogger(logLevel);
|
|
@@ -149,7 +154,7 @@ function createLogger(logLevel) {
|
|
|
149
154
|
if (severity >= minLogLevel.severity && args.length > 0) {
|
|
150
155
|
var message = args[0];
|
|
151
156
|
var msgArgs = args.splice(1);
|
|
152
|
-
var msgFormatted = "[J-"
|
|
157
|
+
var msgFormatted = "[J-" + name + "] " + message;
|
|
153
158
|
if (name === 'DEBUG' || name === 'INFO') {
|
|
154
159
|
console.log.apply(console, __spreadArray([msgFormatted], msgArgs, false));
|
|
155
160
|
}
|
|
@@ -200,21 +205,21 @@ function serializeCookie(name, val, opt) {
|
|
|
200
205
|
if (opt === void 0) { opt = {}; }
|
|
201
206
|
try {
|
|
202
207
|
var maxAge = opt.maxAge, domain = opt.domain, path = opt.path, expires = opt.expires, httpOnly = opt.httpOnly, secure = opt.secure, sameSite = opt.sameSite;
|
|
203
|
-
var new_cookie_val =
|
|
208
|
+
var new_cookie_val = name + "=" + encodeURIComponent(val);
|
|
204
209
|
if (domain) {
|
|
205
|
-
new_cookie_val += "; domain="
|
|
210
|
+
new_cookie_val += "; domain=" + domain;
|
|
206
211
|
}
|
|
207
212
|
if (path) {
|
|
208
|
-
new_cookie_val += "; path="
|
|
213
|
+
new_cookie_val += "; path=" + path;
|
|
209
214
|
}
|
|
210
215
|
else {
|
|
211
216
|
new_cookie_val += "; path=/";
|
|
212
217
|
}
|
|
213
218
|
if (expires) {
|
|
214
|
-
new_cookie_val += "; expires="
|
|
219
|
+
new_cookie_val += "; expires=" + expires.toUTCString();
|
|
215
220
|
}
|
|
216
221
|
if (maxAge) {
|
|
217
|
-
new_cookie_val += "; max-age="
|
|
222
|
+
new_cookie_val += "; max-age=" + maxAge;
|
|
218
223
|
}
|
|
219
224
|
if (httpOnly) {
|
|
220
225
|
new_cookie_val += "; httponly";
|
|
@@ -1383,10 +1388,10 @@ _safewrap_instance_methods(autocapture);
|
|
|
1383
1388
|
|
|
1384
1389
|
var VERSION_INFO = {
|
|
1385
1390
|
env: 'production',
|
|
1386
|
-
date: '2023-
|
|
1387
|
-
version: '1.2.
|
|
1391
|
+
date: '2023-12-12T10:51:57.547Z',
|
|
1392
|
+
version: '1.2.6'
|
|
1388
1393
|
};
|
|
1389
|
-
var USERMAVEN_VERSION =
|
|
1394
|
+
var USERMAVEN_VERSION = VERSION_INFO.version + "/" + VERSION_INFO.env + "@" + VERSION_INFO.date;
|
|
1390
1395
|
var MAX_AGE_TEN_YEARS = 31622400 * 10;
|
|
1391
1396
|
var beaconTransport = function (url, json) {
|
|
1392
1397
|
getLogger().debug("Sending beacon", json);
|
|
@@ -1405,7 +1410,7 @@ function tryFormat(string) {
|
|
|
1405
1410
|
}
|
|
1406
1411
|
}
|
|
1407
1412
|
var echoTransport = function (url, json) {
|
|
1408
|
-
console.debug("Jitsu client tried to send payload to "
|
|
1413
|
+
console.debug("Jitsu client tried to send payload to " + url, tryFormat(json));
|
|
1409
1414
|
return Promise.resolve();
|
|
1410
1415
|
};
|
|
1411
1416
|
// This is a hack to expire all cookies with non-root path left behind by invalid tracking.
|
|
@@ -1438,7 +1443,7 @@ var CookiePersistence = /** @class */ (function () {
|
|
|
1438
1443
|
try {
|
|
1439
1444
|
var parsed = JSON.parse(decodeURIComponent(str));
|
|
1440
1445
|
if (typeof parsed !== "object") {
|
|
1441
|
-
getLogger().warn("Can't restore value of "
|
|
1446
|
+
getLogger().warn("Can't restore value of " + this.cookieName + "@" + this.cookieDomain + ", expected to be object, but found " + (typeof parsed !== "object") + ": " + parsed + ". Ignoring");
|
|
1442
1447
|
return undefined;
|
|
1443
1448
|
}
|
|
1444
1449
|
return parsed;
|
|
@@ -1581,7 +1586,7 @@ function fetchApi(req, res, opts) {
|
|
|
1581
1586
|
page_title: "",
|
|
1582
1587
|
referer: req.headers["referrer"],
|
|
1583
1588
|
screen_resolution: "",
|
|
1584
|
-
url:
|
|
1589
|
+
url: proto + "://" + requestHost + (path || "") + (query || ""),
|
|
1585
1590
|
user_agent: req.headers["user-agent"],
|
|
1586
1591
|
user_language: req.headers["accept-language"] &&
|
|
1587
1592
|
req.headers["accept-language"].split(",")[0],
|
|
@@ -1649,7 +1654,7 @@ function httpApi(req, res, opts) {
|
|
|
1649
1654
|
page_title: "",
|
|
1650
1655
|
referer: header(req, "referrer"),
|
|
1651
1656
|
screen_resolution: "",
|
|
1652
|
-
url:
|
|
1657
|
+
url: proto + "://" + requestHost + (path || "") + (query || ""),
|
|
1653
1658
|
user_agent: req.headers["user-agent"],
|
|
1654
1659
|
user_language: req.headers["accept-language"] &&
|
|
1655
1660
|
req.headers["accept-language"].split(",")[0],
|
|
@@ -1681,15 +1686,15 @@ var xmlHttpTransport = function (url, jsonPayload, additionalHeaders, handler) {
|
|
|
1681
1686
|
var req = new window.XMLHttpRequest();
|
|
1682
1687
|
return new Promise(function (resolve, reject) {
|
|
1683
1688
|
req.onerror = function (e) {
|
|
1684
|
-
getLogger().error("Failed to send payload to "
|
|
1689
|
+
getLogger().error("Failed to send payload to " + url + ": " + ((e === null || e === void 0 ? void 0 : e.message) || "unknown error"), jsonPayload, e);
|
|
1685
1690
|
handler(-1, {});
|
|
1686
1691
|
reject(new Error("Failed to send JSON. See console logs"));
|
|
1687
1692
|
};
|
|
1688
1693
|
req.onload = function () {
|
|
1689
1694
|
if (req.status !== 200) {
|
|
1690
1695
|
handler(req.status, {});
|
|
1691
|
-
getLogger().warn("Failed to send data to "
|
|
1692
|
-
reject(new Error("Failed to send JSON. Error code: "
|
|
1696
|
+
getLogger().warn("Failed to send data to " + url + " (#" + req.status + " - " + req.statusText + ")", jsonPayload);
|
|
1697
|
+
reject(new Error("Failed to send JSON. Error code: " + req.status + ". See logs for details"));
|
|
1693
1698
|
}
|
|
1694
1699
|
else {
|
|
1695
1700
|
handler(req.status, req.responseText);
|
|
@@ -1727,12 +1732,12 @@ var fetchTransport = function (fetch) {
|
|
|
1727
1732
|
return [3 /*break*/, 3];
|
|
1728
1733
|
case 2:
|
|
1729
1734
|
e_1 = _c.sent();
|
|
1730
|
-
getLogger().error("Failed to send data to "
|
|
1735
|
+
getLogger().error("Failed to send data to " + url + ": " + ((e_1 === null || e_1 === void 0 ? void 0 : e_1.message) || "unknown error"), jsonPayload, e_1);
|
|
1731
1736
|
handler(-1, {});
|
|
1732
1737
|
return [2 /*return*/];
|
|
1733
1738
|
case 3:
|
|
1734
1739
|
if (res.status !== 200) {
|
|
1735
|
-
getLogger().warn("Failed to send data to "
|
|
1740
|
+
getLogger().warn("Failed to send data to " + url + " (#" + res.status + " - " + res.statusText + ")", jsonPayload);
|
|
1736
1741
|
handler(res.status, {});
|
|
1737
1742
|
return [2 /*return*/];
|
|
1738
1743
|
}
|
|
@@ -1749,14 +1754,14 @@ var fetchTransport = function (fetch) {
|
|
|
1749
1754
|
return [3 /*break*/, 7];
|
|
1750
1755
|
case 6:
|
|
1751
1756
|
e_2 = _c.sent();
|
|
1752
|
-
getLogger().error("Failed to parse "
|
|
1757
|
+
getLogger().error("Failed to parse " + url + " response. Content-type: " + contentType + " text: " + text, e_2);
|
|
1753
1758
|
return [3 /*break*/, 7];
|
|
1754
1759
|
case 7:
|
|
1755
1760
|
try {
|
|
1756
1761
|
handler(res.status, resJson);
|
|
1757
1762
|
}
|
|
1758
1763
|
catch (e) {
|
|
1759
|
-
getLogger().error("Failed to handle "
|
|
1764
|
+
getLogger().error("Failed to handle " + url + " response. Content-type: " + contentType + " text: " + text, e);
|
|
1760
1765
|
}
|
|
1761
1766
|
return [2 /*return*/];
|
|
1762
1767
|
}
|
|
@@ -1793,6 +1798,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
1793
1798
|
// public persistence?: UserMavenPersistence;
|
|
1794
1799
|
// public sessionManager?: SessionIdManager;
|
|
1795
1800
|
this.__autocapture_enabled = false;
|
|
1801
|
+
this.__auto_pageview_enabled = false;
|
|
1796
1802
|
// private anonymousId: string = '';
|
|
1797
1803
|
// Fallback tracking host
|
|
1798
1804
|
this.trackingHostFallback = "https://events.usermaven.com" ;
|
|
@@ -1906,15 +1912,15 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
1906
1912
|
};
|
|
1907
1913
|
UsermavenClientImpl.prototype.doSendJson = function (json) {
|
|
1908
1914
|
var _this = this;
|
|
1909
|
-
var cookiePolicy = this.cookiePolicy !== "keep" ? "&cookie_policy="
|
|
1910
|
-
var ipPolicy = this.ipPolicy !== "keep" ? "&ip_policy="
|
|
1915
|
+
var cookiePolicy = this.cookiePolicy !== "keep" ? "&cookie_policy=" + this.cookiePolicy : "";
|
|
1916
|
+
var ipPolicy = this.ipPolicy !== "keep" ? "&ip_policy=" + this.ipPolicy : "";
|
|
1911
1917
|
var urlPrefix = isWindowAvailable() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
1912
|
-
var url = ""
|
|
1918
|
+
var url = "" + this.trackingHost + urlPrefix + "?token=" + this.apiKey + cookiePolicy + ipPolicy;
|
|
1913
1919
|
if (this.randomizeUrl) {
|
|
1914
|
-
url =
|
|
1920
|
+
url = this.trackingHost + "/api." + generateRandom() + "?p_" + generateRandom() + "=" + this.apiKey + cookiePolicy + ipPolicy;
|
|
1915
1921
|
}
|
|
1916
1922
|
var jsonString = JSON.stringify(json);
|
|
1917
|
-
getLogger().debug("Sending payload to "
|
|
1923
|
+
getLogger().debug("Sending payload to " + url, jsonString);
|
|
1918
1924
|
return this.transport(url, jsonString, this.customHeaders(), function (code, body) {
|
|
1919
1925
|
return _this.postHandle(code, body);
|
|
1920
1926
|
});
|
|
@@ -1930,7 +1936,7 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
1930
1936
|
var factor = Math.pow(2, this.attempt++);
|
|
1931
1937
|
timeout = Math.min(this.retryTimeout[0] * random * factor, this.retryTimeout[1]);
|
|
1932
1938
|
}
|
|
1933
|
-
getLogger().debug("Scheduling event queue flush in "
|
|
1939
|
+
getLogger().debug("Scheduling event queue flush in " + timeout + " ms.");
|
|
1934
1940
|
setTimeout(function () { return _this.flush(); }, timeout);
|
|
1935
1941
|
};
|
|
1936
1942
|
UsermavenClientImpl.prototype.flush = function () {
|
|
@@ -1957,18 +1963,18 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
1957
1963
|
case 2:
|
|
1958
1964
|
_b.sent();
|
|
1959
1965
|
this.attempt = 1;
|
|
1960
|
-
getLogger().debug("Successfully flushed "
|
|
1966
|
+
getLogger().debug("Successfully flushed " + queue.length + " events from queue");
|
|
1961
1967
|
return [3 /*break*/, 4];
|
|
1962
1968
|
case 3:
|
|
1963
1969
|
_b.sent();
|
|
1964
1970
|
// In case of failing custom domain (trackingHost), we will replace it with default domain (trackingHostFallback)
|
|
1965
1971
|
if (this.trackingHost !== this.trackingHostFallback) {
|
|
1966
|
-
getLogger().debug("Using fallback tracking host "
|
|
1972
|
+
getLogger().debug("Using fallback tracking host " + this.trackingHostFallback + " instead of " + this.trackingHost + " on " + VERSION_INFO.env);
|
|
1967
1973
|
this.trackingHost = this.trackingHostFallback;
|
|
1968
1974
|
}
|
|
1969
1975
|
queue = queue.map(function (el) { return [el[0], el[1] + 1]; }).filter(function (el) {
|
|
1970
1976
|
if (el[1] >= _this.maxSendAttempts) {
|
|
1971
|
-
getLogger().error("Dropping queued event after "
|
|
1977
|
+
getLogger().error("Dropping queued event after " + el[1] + " attempts since max send attempts " + _this.maxSendAttempts + " reached. See logs for details");
|
|
1972
1978
|
return false;
|
|
1973
1979
|
}
|
|
1974
1980
|
return true;
|
|
@@ -2152,7 +2158,8 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2152
2158
|
this.trackingHost = getHostWithProtocol(options["tracking_host"] || "t.usermaven.com");
|
|
2153
2159
|
this.randomizeUrl = options.randomize_url || false;
|
|
2154
2160
|
this.apiKey = options.key;
|
|
2155
|
-
this.
|
|
2161
|
+
this.__auto_pageview_enabled = options.auto_pageview || false;
|
|
2162
|
+
this.idCookieName = options.cookie_name || "__eventn_id_" + options.key;
|
|
2156
2163
|
if (this.cookiePolicy === "strict") {
|
|
2157
2164
|
this.propsPersistance = new NoPersistence();
|
|
2158
2165
|
}
|
|
@@ -2184,7 +2191,8 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2184
2191
|
autocapture: false,
|
|
2185
2192
|
properties_string_max_length: null,
|
|
2186
2193
|
property_blacklist: [],
|
|
2187
|
-
sanitize_properties: null
|
|
2194
|
+
sanitize_properties: null,
|
|
2195
|
+
auto_pageview: false
|
|
2188
2196
|
};
|
|
2189
2197
|
this.config = _extend({}, defaultConfig, options || {}, this.config || {}, { token: this.apiKey });
|
|
2190
2198
|
getLogger().debug('Default Configuration', this.config);
|
|
@@ -2215,6 +2223,9 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2215
2223
|
}
|
|
2216
2224
|
window.addEventListener("beforeunload", function () { return _this.flush(); });
|
|
2217
2225
|
}
|
|
2226
|
+
if (this.__auto_pageview_enabled) {
|
|
2227
|
+
enableAutoPageviews(this);
|
|
2228
|
+
}
|
|
2218
2229
|
this.retryTimeout = [
|
|
2219
2230
|
(_c = options.min_send_timeout) !== null && _c !== void 0 ? _c : this.retryTimeout[0],
|
|
2220
2231
|
(_d = options.max_send_timeout) !== null && _d !== void 0 ? _d : this.retryTimeout[1],
|
|
@@ -2405,6 +2416,20 @@ var UsermavenClientImpl = /** @class */ (function () {
|
|
|
2405
2416
|
};
|
|
2406
2417
|
return UsermavenClientImpl;
|
|
2407
2418
|
}());
|
|
2419
|
+
function enableAutoPageviews(t) {
|
|
2420
|
+
var page = function () { return t.track("pageview"); };
|
|
2421
|
+
// Attach pushState and popState listeners
|
|
2422
|
+
var originalPushState = history.pushState;
|
|
2423
|
+
if (originalPushState) {
|
|
2424
|
+
// eslint-disable-next-line functional/immutable-data
|
|
2425
|
+
history.pushState = function (data, title, url) {
|
|
2426
|
+
originalPushState.apply(this, [data, title, url]);
|
|
2427
|
+
page();
|
|
2428
|
+
};
|
|
2429
|
+
addEventListener('popstate', page);
|
|
2430
|
+
}
|
|
2431
|
+
addEventListener('hashchange', page);
|
|
2432
|
+
}
|
|
2408
2433
|
function interceptSegmentCalls(t) {
|
|
2409
2434
|
var win = window;
|
|
2410
2435
|
if (!win.analytics) {
|
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,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[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(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function r(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function i(e){const t=!!globalThis.window&&!!globalThis.window.document&&!!globalThis.window.location;return!t&&e&&c().warn(e),t}function o(e){if(!i())throw new Error(e||"window' is not available. Seems like this code runs outside browser environment. It shouldn't happen");return window}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=i()&&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,i=e.severity;a[t.toLowerCase()]=function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];if(i>=n.severity&&e.length>0){var s=e[0],a=e.splice(1),c="[J-".concat(t,"] ").concat(s);"DEBUG"===t||"INFO"===t?console.log.apply(console,r([c],a,!1)):"WARN"===t?console.warn.apply(console,r([c],a,!1)):console.error.apply(console,r([c],a,!1))}}})),function(e,t){if(i()){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 r=n.maxAge,i=n.domain,o=n.path,s=n.expires,a=n.httpOnly,u=n.secure,l=n.sameSite,p="".concat(e,"=").concat(encodeURIComponent(t));if(i&&(p+="; domain=".concat(i)),p+=o?"; path=".concat(o):"; path=/",s&&(p+="; expires=".concat(s.toUTCString())),r&&(p+="; max-age=".concat(r)),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(i())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("."),r=n.length;return r>2&&(2==n[r-1].length?(t=n[r-2]+"."+n[r-1],2==n[r-2].length&&(t=n[r-3]+"."+t)):t=n[r-2]+"."+n[r-1]),t}(e)),n}(window.location.hostname)};function h(e){if(!e)return{};for(var t={},n=e.split(";"),r=0;r<n.length;r++){var i=n[r],o=i.indexOf("=");o>0&&(t[i.substr(r>0?1:0,r>0?o-1:o)]=i.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,r=e.getElementsByTagName("script");for(n=r.length-1;n>=0;n--){var i=r[n],o=document.createElement("script");f(i,o),i.innerHTML&&(o.innerHTML=i.innerHTML),o.setAttribute("data-usermaven-tag-id",e.id),document.getElementsByTagName("head")[0].appendChild(o),r[n].parentNode.removeChild(r[n])}}var g=function(e){if(!e)return null;try{for(var t=e+"=",n=o().document.cookie.split(";"),r=0;r<n.length;r++){for(var i=n[r];" "==i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return decodeURIComponent(i.substring(t.length,i.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)},w={utm_source:"source",utm_medium:"medium",utm_campaign:"campaign",utm_term:"term",utm_content:"content"},k={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,C=x.hasOwnProperty,A=Array.prototype.forEach,E=Array.isArray,O={},I=E||function(e){return"[object Array]"===N.call(e)};function T(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 r=0,i=e.length;r<i;r++)if(r in e&&t.call(n,e[r],r)===O)return}var j=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 r=0,i=e.length;r<i;r++)if(r in e&&t.call(n,e[r],r)===O)return}else for(var o in e)if(C.call(e,o)&&t.call(n,e[o],o)===O)return}var D=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return T(t,(function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])})),e};function F(e,t){return-1!==e.indexOf(t)}var $=function(e){try{return/^\s*\bfunction\b/.test(e)}catch(e){return!1}},U=function(e){return void 0===e},z=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,r,i,o){if(t)if(t.addEventListener&&!i)t.addEventListener(n,r,!!o);else{var s="on"+n,a=t[s];t[s]=function(t,n,r){return function(i){if(i=i||e(window.event)){var o,s=!0;$(r)&&(o=r(i));var a=n.call(t,i);return!1!==o&&!1!==a||(s=!1),s}}}(t,r,a)}else c().error("No valid element provided to register_event")}}(),L=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)?(r=[],T(e,(function(e){r.push(R(e,t))}))):(r={},H(e,(function(e,n){n!==M&&(r[n]=R(e,t,n))}))),delete e[M],r);var r}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 W(e){var t="";return Z(e)&&!X(e)&&e.childNodes&&e.childNodes.length&&H(e.childNodes,(function(e){K(e)&&e.textContent&&(t+=j(e.textContent).split(/(\s+)/).filter(ee).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))})),j(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(F(n,"ph-sensitive")||F(n,"ph-no-capture"))return!1}if(F(B(e).split(" "),"ph-include"))return!0;var r=e.type||"";if("string"==typeof r)switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=e.name||e.id||"";if("string"==typeof i){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.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||U(e))return!1;if("string"==typeof e){e=j(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 r=this.clicks[this.clicks.length-1];r&&Math.abs(e-r.x)+Math.abs(t-r.y)<30&&n-r.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(),r=t-e;return Math.min(100,Math.floor(n/r*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}(),re={_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 r=e.tagName.toLowerCase(),i={tag_name:r};Y.indexOf(r)>-1&&!n&&(i.$el_text=W(e));var o=B(e);o.length>0&&(i.classes=o.split(" ").filter((function(e){return""!==e}))),H(e.attributes,(function(n){var r;X(e)&&-1===["name","id","class"].indexOf(n.name)||!t&&ee(n.value)&&("string"!=typeof(r=n.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))&&(i["attr__"+n.name]=n.value)}));for(var s=1,a=1,c=e;c=this._previousElementSibling(c);)s++,c.tagName===e.tagName&&a++;return i.nth_child=s,i.nth_of_type=a,i},_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(r){H(r.event_selectors,(function(i){H(document.querySelectorAll(i),(function(i){F(e,i)&&Z(i)&&(n[r.name]=t._extractCustomPropertyValue(r))}))}))})),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 r,i=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===(r=this.rageclicks)||void 0===r||r.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,r=[e],i=!0,o=e;o.parentNode&&!G(o,"body");)if(Q(o.parentNode))r.push(o.parentNode.host),o=o.parentNode.host;else{if(!(i=o.parentNode||!1))break;if(Y.indexOf(i.tagName.toLowerCase())>-1)n=!0;else{var s=window.getComputedStyle(i);s&&"pointer"===s.getPropertyValue("cursor")&&(n=!0)}r.push(i),o=i}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),F(B(e).split(" "),"ph-no-capture")&&(l=!0),u.push(i._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=D(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,r=function(r){r=r||window.event,n._captureEvent(r,e,t)};z(document,"submit",r,!1,!0),z(document,"change",r,!1,!0),z(document,"click",r,!1,!0),z(document,"visibilitychange",r,!1,!0),z(document,"scroll",r,!1,!0),z(window,"popstate",r,!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=U(t)?10:t,n=U(n)?10:n;for(var r=0,i=0;i<e.length;i++)r+=e.charCodeAt(i);return r%t<n},isBrowserSupported:function(){return $(document.querySelectorAll)}};!function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=e[t].bind(e))}(re),function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=L(e[t]))}(re);var ie="production",oe="2023-09-02T18:25:09.785Z",se="".concat("1.2.4","/").concat(ie,"@").concat(oe),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 ".concat(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 ".concat(this.cookieName,"@").concat(this.cookieDomain,", expected to be object, but found ").concat("object"!=typeof t,": ").concat(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;le(t);var r=g(t);if(r)return c().debug("Existing user id",r),r;var i=_();return c().debug("New user id",i),v(t,i,{domain:n,secure:"http:"!==document.location.protocol,maxAge:ae}),i}};var fe={getSourceIp:function(){},describeClient:function(){return{}},getAnonymousId:function(){return""}},me=function(){return he},ge=function(){return fe},ve=function(e,t,n,r){void 0===r&&(r=function(e,t){});var i=new window.XMLHttpRequest;return new Promise((function(o,s){i.onerror=function(n){c().error("Failed to send payload to ".concat(e,": ").concat((null==n?void 0:n.message)||"unknown error"),t,n),r(-1,{}),s(new Error("Failed to send JSON. See console logs"))},i.onload=function(){200!==i.status?(r(i.status,{}),c().warn("Failed to send data to ".concat(e," (#").concat(i.status," - ").concat(i.statusText,")"),t),s(new Error("Failed to send JSON. Error code: ".concat(i.status,". See logs for details")))):r(i.status,i.responseText),o()},i.open("POST",e),i.setRequestHeader("Content-Type","application/json"),Object.entries(n||{}).forEach((function(e){var t=e[0],n=e[1];return i.setRequestHeader(t,n)})),i.send(t),c().debug("sending json",t)}))},ye=function(){function r(){this.userProperties={},this.groupProperties={},this.permanentProperties={globalProps:{},propsPerEvent:{}},this.cookieDomain="",this.trackingHost="",this.idCookieName="",this.randomizeUrl=!1,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.trackingHostFallback="https://events.usermaven.com"}return r.prototype.get_config=function(e){return this.config?this.config[e]:null},r.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",{})},r.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",{})},r.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()},r.prototype.rawTrack=function(e){return this.sendJson(e)},r.prototype.makeEvent=function(t,n,r){var o,s=r.env,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(r,["env"]);s||(s=i()?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)},r.prototype._send3p=function(e,t,n){var r="3rdparty";n&&""!==n&&(r=n);var i=this.makeEvent(r,e,{src_payload:t});return this.sendJson(i)},r.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}))}))},r.prototype.doSendJson=function(e){var t=this,n="keep"!==this.cookiePolicy?"&cookie_policy=".concat(this.cookiePolicy):"",r="keep"!==this.ipPolicy?"&ip_policy=".concat(this.ipPolicy):"",o=i()?"/api/v1/event":"/api/v1/s2s/event",s="".concat(this.trackingHost).concat(o,"?token=").concat(this.apiKey).concat(n).concat(r);this.randomizeUrl&&(s="".concat(this.trackingHost,"/api.").concat(b(),"?p_").concat(b(),"=").concat(this.apiKey).concat(n).concat(r));var a=JSON.stringify(e);return c().debug("Sending payload to ".concat(s),a),this.transport(s,a,this.customHeaders(),(function(e,n){return t.postHandle(e,n)}))},r.prototype.scheduleFlush=function(e){var t=this;if(!this.flushing){if(this.flushing=!0,void 0===e){var n=Math.random()+1,r=Math.pow(2,this.attempt++);e=Math.min(this.retryTimeout[0]*n*r,this.retryTimeout[1])}c().debug("Scheduling event queue flush in ".concat(e," ms.")),setTimeout((function(){return t.flush()}),e)}},r.prototype.flush=function(){return t(this,void 0,Promise,(function(){var e,t,r=this;return n(this,(function(n){switch(n.label){case 0:if(i()&&!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 ".concat(e.length," events from queue")),[3,4];case 3:return n.sent(),this.trackingHost!==this.trackingHostFallback&&(c().debug("Using fallback tracking host ".concat(this.trackingHostFallback," instead of ").concat(this.trackingHost," on ").concat(ie)),this.trackingHost=this.trackingHostFallback),(e=e.map((function(e){return[e[0],e[1]+1]})).filter((function(e){return!(e[1]>=r.maxSendAttempts)||(c().error("Dropping queued event after ".concat(e[1]," attempts since max send attempts ").concat(r.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]}}))}))},r.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 r=(n=JSON.parse(t)).jitsu_sdk_extras;if(r&&r.length>0)if(i())for(var o=0,s=r;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")}}},r.prototype.getCtx=function(t){var n=new Date,r=t.describeClient()||{},i=e({},this.userProperties),o=i.company||{};delete i.company;var s,a,c=e(e({event_id:"",user:e({anonymous_id:"strict"!==this.cookiePolicy?t.getAnonymousId({name:this.idCookieName,domain:this.cookieDomain}):""},i),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()},r),function(e){var t={utm:{},click_id:{}};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n],i=w[n];i?t.utm[i]=r:k[n]&&(t.click_id[n]=r)}return t}(function(e){if(!e)return{};for(var t=e.length>0&&"?"===e.charAt(0)?e.substring(1):e,n={},r=("?"===t[0]?t.substr(1):t).split("&"),i=0;i<r.length;i++){var o=r[i].split("=");n[decodeURIComponent(o[0])]=decodeURIComponent(o[1]||"")}return n}(r.doc_search)));return Object.keys(o).length&&(c.company=o),c},r.prototype._getIds=function(){if(!i())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,r=Object.entries(e);n<r.length;n++){var o=r[n],s=o[0],a=o[1];this._3pCookies[s]&&(t["_"==s.charAt(0)?s.substr(1):s]=a)}return t},r.prototype.pathMatches=function(e,t){return new URL(t).pathname.match(new RegExp("^"+e.trim().replace(/\*\*/g,".*").replace(/([^\.])\*/g,"$1[^\\s/]*")+"/?$"))},r.prototype.track=function(e,t){var n=this,r=t||{};c().debug("track event of type",e,r);var o=i()?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)},r.prototype.init=function(r){var o,l,p,h,f,m,g,v=this;if(i()&&!r.force_use_fetch)r.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(!r.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=(f=r.fetch||globalThis.fetch,function(r,i,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,m;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,f(r,{method:"POST",headers:e({Accept:"application/json","Content-Type":"application/json"},o||{}),body:i})];case 1:return t=n.sent(),[3,3];case 2:return a=n.sent(),c().error("Failed to send data to ".concat(r,": ").concat((null==a?void 0:a.message)||"unknown error"),i,a),s(-1,{}),[2];case 3:if(200!==t.status)return c().warn("Failed to send data to ".concat(r," (#").concat(t.status," - ").concat(t.statusText,")"),i),s(t.status,{}),[2];u={},l="",p=null!==(m=null===(h=t.headers)||void 0===h?void 0:h.get("Content-Type"))&&void 0!==m?m:"",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 ".concat(r," response. Content-type: ").concat(p," text: ").concat(l),d),[3,7];case 7:try{s(t.status,u)}catch(e){c().error("Failed to handle ".concat(r," response. Content-type: ").concat(p," text: ").concat(l),e)}return[2]}}))}))})}if(r.custom_headers&&"function"==typeof r.custom_headers?this.customHeaders=r.custom_headers:r.custom_headers&&(this.customHeaders=function(){return r.custom_headers}),"echo"===r.tracking_host&&(c().warn('jitsuClient is configured with "echo" transport. Outgoing requests will be written to console'),this.transport=ue),r.ip_policy&&(this.ipPolicy=r.ip_policy),r.cookie_policy&&(this.cookiePolicy=r.cookie_policy),"strict"===r.privacy_policy&&(this.ipPolicy="strict",this.cookiePolicy="strict"),r.use_beacon_api&&navigator.sendBeacon&&(this.beaconApi=!0),"comply"===this.cookiePolicy&&this.beaconApi&&(this.cookiePolicy="strict"),r.log_level&&(m=r.log_level,(g=s[m.toLocaleUpperCase()])||(console.warn("Can't find log level with name ".concat(m.toLocaleUpperCase(),", defaulting to INFO")),g=s.INFO),a=u(g)),this.initialOptions=r,c().debug("Initializing Usemaven Tracker tracker",r,se),r.key){if(this.compatMode=void 0!==r.compat_mode&&!!r.compat_mode,this.cookieDomain=r.cookie_domain||d(),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}(r.tracking_host||"t.usermaven.com"),this.randomizeUrl=r.randomize_url||!1,this.apiKey=r.key,this.idCookieName=r.cookie_name||"__eventn_id_".concat(r.key),"strict"===this.cookiePolicy?this.propsPersistance=new de:this.propsPersistance=i()?new pe(this.cookieDomain,this.idCookieName+"_props"):new de,"strict"===this.cookiePolicy?this.userIdPersistence=new de:this.userIdPersistence=i()?new pe(this.cookieDomain,this.idCookieName+"_usr"):new de,this.propsPersistance){var y=this.propsPersistance.restore();y&&(this.permanentProperties=y,this.permanentProperties.globalProps=null!==(o=y.globalProps)&&void 0!==o?o:{},this.permanentProperties.propsPerEvent=null!==(l=y.propsPerEvent)&&void 0!==l?l:{}),c().debug("Restored persistent properties",this.permanentProperties)}this.propertyBlacklist=r.property_blacklist&&r.property_blacklist.length>0?r.property_blacklist:[];this.config=D({},{autocapture:!1,properties_string_max_length:null,property_blacklist:[],sanitize_properties:null},r||{},this.config||{},{token:this.apiKey}),c().debug("Default Configuration",this.config),this.manageAutoCapture(this.config),!1===r.capture_3rd_party_cookies?this._3pCookies={}:(r.capture_3rd_party_cookies||["_ga","_fbp","_ym_uid","ajs_user_id","ajs_anonymous_id"]).forEach((function(e){return v._3pCookies[e]=!0})),r.ga_hook&&c().warn("GA event interceptor isn't supported anymore"),r.segment_hook&&function(e){var t=window;t.analytics||(t.analytics=[]);e.interceptAnalytics(t.analytics)}(this),i()&&(r.disable_event_persistence||(this.queue=new S("jitsu-event-queue"),this.scheduleFlush(0)),window.addEventListener("beforeunload",(function(){return v.flush()}))),this.retryTimeout=[null!==(p=r.min_send_timeout)&&void 0!==p?p:this.retryTimeout[0],null!==(h=r.max_send_timeout)&&void 0!==h?h:this.retryTimeout[1]],r.max_send_attempts&&(this.maxSendAttempts=r.max_send_attempts),this.initialized=!0}else c().error("Can't initialize Usemaven, key property is not set")},r.prototype.interceptAnalytics=function(t){var n=this,r=function(t){var r;try{var i=e({},t.payload);c().debug("Intercepted segment payload",i.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&&(i.obj.userId=s.user().id())}(null===(r=null==i?void 0:i.obj)||void 0===r?void 0:r.timestamp)&&(i.obj.sentAt=i.obj.timestamp);var a=t.payload.type();"track"===a&&(a=t.payload.event()),n._send3p("ajs",i,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(r)):(c().debug("Analytics.js is not initialized, pushing addSourceMiddleware to callstack"),t.push(["addSourceMiddleware",r])),t.__en_intercepted=!0},r.prototype.restoreId=function(){if(this.userIdPersistence){var t=this.userIdPersistence.restore();t&&(this.userProperties=e(e({},t),this.userProperties))}},r.prototype.set=function(t,n){var r,i=null==n?void 0:n.eventType,o=void 0===(null==n?void 0:n.persist)||(null==n?void 0:n.persist);if(void 0!==i){var s=null!==(r=this.permanentProperties.propsPerEvent[i])&&void 0!==r?r:{};this.permanentProperties.propsPerEvent[i]=e(e({},s),t)}else this.permanentProperties.globalProps=e(e({},this.permanentProperties.globalProps),t);this.propsPersistance&&o&&this.propsPersistance.save(this.permanentProperties)},r.prototype.unset=function(e,t){o();var n=null==t?void 0:t.eventType,r=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&&r&&this.propsPersistance.save(this.permanentProperties)},r.prototype.manageAutoCapture=function(e){if(c().debug("Auto Capture Status: ",this.config.autocapture),this.__autocapture_enabled=this.config.autocapture,this.__autocapture_enabled){re.enabledForProject(this.apiKey,100,100)?re.isBrowserSupported()?(c().debug("Autocapture enabled..."),re.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."))}},r.prototype.capture=function(e,t){var n,r;if(void 0===t&&(t={}),this.initialized)if(U(e)||"string"!=typeof e)console.error("No event name provided to usermaven.capture");else{var i={event:e+(t.$event_type?"_"+t.$event_type:""),properties:this._calculate_event_properties(e,t)};(null===(r=null===(n=(i=J(i,this.get_config("properties_string_max_length"))).properties)||void 0===n?void 0:n.autocapture_attributes)||void 0===r?void 0:r.tag_name)&&this.track("$autocapture",i.properties),"$scroll"===e&&this.track(e,i.properties)}else console.error("Trying to capture event before initialization")},r.prototype._calculate_event_properties=function(e,t){var n,r,i=t||{};if("$snapshot"===e||"$scroll"===e)return i;I(this.propertyBlacklist)?H(this.propertyBlacklist,(function(e){delete i[e]})):console.error("Invalid value for property_blacklist config: "+this.propertyBlacklist);var o={},s=i.$elements||[];return s.length&&(o=s[0]),i.autocapture_attributes=o,i.autocapture_attributes.el_text=null!==(n=i.autocapture_attributes.$el_text)&&void 0!==n?n:"",i.autocapture_attributes.event_type=null!==(r=i.$event_type)&&void 0!==r?r:"",["$ce_version","$event_type","$initial_referrer","$initial_referring_domain","$referrer","$referring_domain","$elements"].forEach((function(e){delete i[e]})),delete i.autocapture_attributes.$el_text,delete i.autocapture_attributes.nth_child,delete i.autocapture_attributes.nth_of_type,i},r}();var _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"];var be="data-suppress-interception-warning";function we(e){return"\n ATTENTION! ".concat(e,"-hook set to true along with defer/async attribute! If ").concat(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 ").concat(e," before Usermaven is fully initialized, set ").concat(be,'="true"\n script attribute\n ')}function ke(e,t){c().debug("Processing queue",e);for(var n=0;n<e.length;n+=1){var i=r([],e[n],!0)||[],o=i[0],s=i.slice(1),a=t[o];"function"==typeof a&&a.apply(t,s)}e.length=0}if(window){var Pe=window,Se=function(e){var t=document.currentScript||document.querySelector("script[src*=jsFileName][data-usermaven-api-key]");if(t){var n,r={tracking_host:(n=t.getAttribute("src"),n.replace("/s/lib.js","").replace("/lib.js","")),key:null};_e.forEach((function(e){var n="data-"+e.replace(new RegExp("_","g"),"-");if(void 0!==t.getAttribute(n)&&null!==t.getAttribute(n)){var i=t.getAttribute(n);"true"===i?i=!0:"false"===i&&(i=!1),r[e]=i}})),e.usermavenClient=function(e){var t=new ye;return t.init(e),t}(r),!r.segment_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(be)||c().warn(we("segment")),!r.ga_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(be)||c().warn(we("ga"));var i=function(){var t=e.usermavenQ=e.usermavenQ||[];t.push(arguments),ke(t,e.usermavenClient)};return e.usermaven=i,r.project_id&&i("set",{project_id:r.project_id}),"true"!==t.getAttribute("data-init-only")&&"yes"!==t.getAttribute("data-init-only")&&i("track","pageview"),document.addEventListener("visibilitychange",(function(e){"visibilitychange"===e.type&&"hidden"===document.visibilityState&&i("track","$pageleave")}),!1),e.usermavenClient}c().warn("Usermaven script is not properly initialized. The definition must contain data-usermaven-api-key as a parameter")}(Pe);Se?(c().debug("Usermaven in-browser tracker has been initialized"),Pe.usermaven=function(){var e=Pe.usermavenQ=Pe.usermavenQ||[];e.push(arguments),ke(e,Se)},Pe.usermavenQ&&(c().debug("Initial queue size of ".concat(Pe.usermavenQ.length," will be processed")),ke(Pe.usermavenQ,Se))):c().error("Usermaven tracker has not been initialized (reason unknown)")}else c().warn("Usermaven tracker called outside browser context. It will be ignored")}();
|
|
1
|
+
!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[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(u){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,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function r(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function i(e=void 0){const t=!!globalThis.window&&!!globalThis.window.document&&!!globalThis.window.location;return!t&&e&&u().warn(e),t}function o(e=void 0){if(!i())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 u(){return a||(a=c())}function c(e){var t=i()&&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,i=e.severity;a[t.toLowerCase()]=function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];if(i>=n.severity&&e.length>0){var s=e[0],a=e.splice(1),u="[J-"+t+"] "+s;"DEBUG"===t||"INFO"===t?console.log.apply(console,r([u],a,!1)):"WARN"===t?console.warn.apply(console,r([u],a,!1)):console.error.apply(console,r([u],a,!1))}}})),function(e,t){if(i()){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 r=n.maxAge,i=n.domain,o=n.path,s=n.expires,a=n.httpOnly,c=n.secure,l=n.sameSite,p=e+"="+encodeURIComponent(t);if(i&&(p+="; domain="+i),p+=o?"; path="+o:"; path=/",s&&(p+="; expires="+s.toUTCString()),r&&(p+="; max-age="+r),a&&(p+="; httponly"),c&&(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 c&&(p+="; SameSite=None");return p}catch(e){return u().error("serializeCookie",e),""}}var p,d=function(){if(i())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("."),r=n.length;return r>2&&(2==n[r-1].length?(t=n[r-2]+"."+n[r-1],2==n[r-2].length&&(t=n[r-3]+"."+t)):t=n[r-2]+"."+n[r-1]),t}(e)),n}(window.location.hostname)};function h(e){if(!e)return{};for(var t={},n=e.split(";"),r=0;r<n.length;r++){var i=n[r],o=i.indexOf("=");o>0&&(t[i.substr(r>0?1:0,r>0?o-1:o)]=i.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,r=e.getElementsByTagName("script");for(n=r.length-1;n>=0;n--){var i=r[n],o=document.createElement("script");f(i,o),i.innerHTML&&(o.innerHTML=i.innerHTML),o.setAttribute("data-usermaven-tag-id",e.id),document.getElementsByTagName("head")[0].appendChild(o),r[n].parentNode.removeChild(r[n])}}var g=function(e){if(!e)return null;try{for(var t=e+"=",n=o().document.cookie.split(";"),r=0;r<n.length;r++){for(var i=n[r];" "==i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return decodeURIComponent(i.substring(t.length,i.length))}}catch(e){u().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)},w={utm_source:"source",utm_medium:"medium",utm_campaign:"campaign",utm_term:"term",utm_content:"content"},k={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,C=Array.prototype.forEach,A=Array.isArray,O={},I=A||function(e){return"[object Array]"===N.call(e)};function T(e,t,n){if(Array.isArray(e))if(C&&e.forEach===C)e.forEach(t,n);else if("length"in e&&e.length===+e.length)for(var r=0,i=e.length;r<i;r++)if(r in e&&t.call(n,e[r],r)===O)return}var j=function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};function H(e,t,n){if(null!=e)if(C&&Array.isArray(e)&&e.forEach===C)e.forEach(t,n);else if("length"in e&&e.length===+e.length){for(var r=0,i=e.length;r<i;r++)if(r in e&&t.call(n,e[r],r)===O)return}else for(var o in e)if(E.call(e,o)&&t.call(n,e[o],o)===O)return}var D=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return T(t,(function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])})),e};function F(e,t){return-1!==e.indexOf(t)}var $=function(e){try{return/^\s*\bfunction\b/.test(e)}catch(e){return!1}},L=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,r,i,o){if(t)if(t.addEventListener&&!i)t.addEventListener(n,r,!!o);else{var s="on"+n,a=t[s];t[s]=function(t,n,r){return function(i){if(i=i||e(window.event)){var o,s=!0;$(r)&&(o=r(i));var a=n.call(t,i);return!1!==o&&!1!==a||(s=!1),s}}}(t,r,a)}else u().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){u().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)?(r=[],T(e,(function(e){r.push(R(e,t))}))):(r={},H(e,(function(e,n){n!==M&&(r[n]=R(e,t,n))}))),delete e[M],r);var r}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 W(e){var t="";return Z(e)&&!X(e)&&e.childNodes&&e.childNodes.length&&H(e.childNodes,(function(e){K(e)&&e.textContent&&(t+=j(e.textContent).split(/(\s+)/).filter(ee).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))})),j(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(F(n,"ph-sensitive")||F(n,"ph-no-capture"))return!1}if(F(B(e).split(" "),"ph-include"))return!0;var r=e.type||"";if("string"==typeof r)switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=e.name||e.id||"";if("string"==typeof i){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.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||L(e))return!1;if("string"==typeof e){e=j(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 r=this.clicks[this.clicks.length-1];r&&Math.abs(e-r.x)+Math.abs(t-r.y)<30&&n-r.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(),r=t-e;return Math.min(100,Math.floor(n/r*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}(),re={_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 r=e.tagName.toLowerCase(),i={tag_name:r};Y.indexOf(r)>-1&&!n&&(i.$el_text=W(e));var o=B(e);o.length>0&&(i.classes=o.split(" ").filter((function(e){return""!==e}))),H(e.attributes,(function(n){var r;X(e)&&-1===["name","id","class"].indexOf(n.name)||!t&&ee(n.value)&&("string"!=typeof(r=n.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))&&(i["attr__"+n.name]=n.value)}));for(var s=1,a=1,u=e;u=this._previousElementSibling(u);)s++,u.tagName===e.tagName&&a++;return i.nth_child=s,i.nth_of_type=a,i},_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(r){H(r.event_selectors,(function(i){H(document.querySelectorAll(i),(function(i){F(e,i)&&Z(i)&&(n[r.name]=t._extractCustomPropertyValue(r))}))}))})),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 r,i=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===(r=this.rageclicks)||void 0===r||r.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,r=[e],i=!0,o=e;o.parentNode&&!G(o,"body");)if(Q(o.parentNode))r.push(o.parentNode.host),o=o.parentNode.host;else{if(!(i=o.parentNode||!1))break;if(Y.indexOf(i.tagName.toLowerCase())>-1)n=!0;else{var s=window.getComputedStyle(i);s&&"pointer"===s.getPropertyValue("cursor")&&(n=!0)}r.push(i),o=i}var a=window.getComputedStyle(e);if(a&&"pointer"===a.getPropertyValue("cursor")&&"click"===t.type)return!0;var u=e.tagName.toLowerCase();switch(u){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(u)>-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 u,c=[],l=!1;if(H(s,(function(e){var t=Z(e);"a"===e.tagName.toLowerCase()&&(u=e.getAttribute("href"),u=t&&ee(u)&&u),F(B(e).split(" "),"ph-no-capture")&&(l=!0),c.push(i._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)||(c[0].$el_text=W(o)),u&&(c[0].attr__href=u),l)return!1;var p=D(this._getDefaultProperties(e.type),{$elements:c},this._getCustomProperties(s));return t.capture("$autocapture",p),!0}},_navigate:function(e){window.location.href=e},_addDomEventHandlers:function(e,t){var n=this,r=function(r){r=r||window.event,n._captureEvent(r,e,t)};U(document,"submit",r,!1,!0),U(document,"change",r,!1,!0),U(document,"click",r,!1,!0),U(document,"visibilitychange",r,!1,!0),U(document,"scroll",r,!1,!0),U(window,"popstate",r,!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=L(t)?10:t,n=L(n)?10:n;for(var r=0,i=0;i<e.length;i++)r+=e.charCodeAt(i);return r%t<n},isBrowserSupported:function(){return $(document.querySelectorAll)}};!function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=e[t].bind(e))}(re),function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=z(e[t]))}(re);var ie="production",oe="1.2.6"+"/"+ie+"@"+"2023-12-12T10:51:55.909Z",se=316224e3,ae=function(e,t){u().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 ce(e,t){void 0===t&&(t=void 0),""!=(t=null!=t?t:window.location.pathname)&&"/"!=t&&(y(e,t),ce(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(){ce(this.cookieName);var e=g(this.cookieName);if(e)try{var t=JSON.parse(decodeURIComponent(e));return"object"!=typeof t?void u().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 u().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;ce(t);var r=g(t);if(r)return u().debug("Existing user id",r),r;var i=_();return u().debug("New user id",i),v(t,i,{domain:n,secure:"http:"!==document.location.protocol,maxAge:se}),i}};var he={getSourceIp:function(){},describeClient:function(){return{}},getAnonymousId:function(){return""}},fe=function(){return de},me=function(){return he},ge=function(e,t,n,r){void 0===r&&(r=function(e,t){});var i=new window.XMLHttpRequest;return new Promise((function(o,s){i.onerror=function(n){u().error("Failed to send payload to "+e+": "+((null==n?void 0:n.message)||"unknown error"),t,n),r(-1,{}),s(new Error("Failed to send JSON. See console logs"))},i.onload=function(){200!==i.status?(r(i.status,{}),u().warn("Failed to send data to "+e+" (#"+i.status+" - "+i.statusText+")",t),s(new Error("Failed to send JSON. Error code: "+i.status+". See logs for details"))):r(i.status,i.responseText),o()},i.open("POST",e),i.setRequestHeader("Content-Type","application/json"),Object.entries(n||{}).forEach((function(e){var t=e[0],n=e[1];return i.setRequestHeader(t,n)})),i.send(t),u().debug("sending json",t)}))},ve=function(){function r(){this.userProperties={},this.groupProperties={},this.permanentProperties={globalProps:{},propsPerEvent:{}},this.cookieDomain="",this.trackingHost="",this.idCookieName="",this.randomizeUrl=!1,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 r.prototype.get_config=function(e){return this.config?this.config[e]:null},r.prototype.id=function(t,n){return this.userProperties=e(e({},this.userProperties),t),u().debug("Usermaven user identified",t),this.userIdPersistence?this.userIdPersistence.save(t):u().warn("Id() is called before initialization"),n?Promise.resolve():this.track("user_identify",{})},r.prototype.group=function(t,n){return this.groupProperties=e(e({},this.groupProperties),t),u().debug("Usermaven group identified",t),this.userIdPersistence?this.userIdPersistence.save({company:t}):u().warn("Group() is called before initialization"),n?Promise.resolve():this.track("group",{})},r.prototype.reset=function(e){if(this.userIdPersistence&&this.userIdPersistence.delete(),this.propsPersistance&&this.propsPersistance.delete(),e){var t=g(this.idCookieName);t&&(u().debug("Removing id cookie",t),v(this.idCookieName,"",{domain:this.cookieDomain,expires:new Date(0)}))}return Promise.resolve()},r.prototype.rawTrack=function(e){return this.sendJson(e)},r.prototype.makeEvent=function(t,n,r){var o,s=r.env,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(r,["env"]);s||(s=i()?fe():me()),this.restoreId();var u=this.getCtx(s),c=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({},c),{eventn_ctx:u}),l):e(e(e({},c),u),l)},r.prototype._send3p=function(e,t,n){var r="3rdparty";n&&""!==n&&(r=n);var i=this.makeEvent(r,e,{src_payload:t});return this.sendJson(i)},r.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}))}))},r.prototype.doSendJson=function(e){var t=this,n="keep"!==this.cookiePolicy?"&cookie_policy="+this.cookiePolicy:"",r="keep"!==this.ipPolicy?"&ip_policy="+this.ipPolicy:"",o=i()?"/api/v1/event":"/api/v1/s2s/event",s=""+this.trackingHost+o+"?token="+this.apiKey+n+r;this.randomizeUrl&&(s=this.trackingHost+"/api."+b()+"?p_"+b()+"="+this.apiKey+n+r);var a=JSON.stringify(e);return u().debug("Sending payload to "+s,a),this.transport(s,a,this.customHeaders(),(function(e,n){return t.postHandle(e,n)}))},r.prototype.scheduleFlush=function(e){var t=this;if(!this.flushing){if(this.flushing=!0,void 0===e){var n=Math.random()+1,r=Math.pow(2,this.attempt++);e=Math.min(this.retryTimeout[0]*n*r,this.retryTimeout[1])}u().debug("Scheduling event queue flush in "+e+" ms."),setTimeout((function(){return t.flush()}),e)}},r.prototype.flush=function(){return t(this,void 0,Promise,(function(){var e,t,r=this;return n(this,(function(n){switch(n.label){case 0:if(i()&&!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,u().debug("Successfully flushed "+e.length+" events from queue"),[3,4];case 3:return n.sent(),this.trackingHost!==this.trackingHostFallback&&(u().debug("Using fallback tracking host "+this.trackingHostFallback+" instead of "+this.trackingHost+" on "+ie),this.trackingHost=this.trackingHostFallback),(e=e.map((function(e){return[e[0],e[1]+1]})).filter((function(e){return!(e[1]>=r.maxSendAttempts)||(u().error("Dropping queued event after "+e[1]+" attempts since max send attempts "+r.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]}}))}))},r.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 r=(n=JSON.parse(t)).jitsu_sdk_extras;if(r&&r.length>0)if(i())for(var o=0,s=r;o<s.length;o++){var a=s[o],c=a.type,l=a.id,p=a.value;if("tag"===c){var d=document.createElement("div");d.id=l,m(d,p),d.childElementCount>0&&document.body.appendChild(d)}}else u().error("Tags destination supported only in browser environment")}}},r.prototype.getCtx=function(t){var n=new Date,r=t.describeClient()||{},i=e({},this.userProperties),o=i.company||{};delete i.company;var s,a,u=e(e({event_id:"",user:e({anonymous_id:"strict"!==this.cookiePolicy?t.getAnonymousId({name:this.idCookieName,domain:this.cookieDomain}):""},i),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()},r),function(e){var t={utm:{},click_id:{}};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n],i=w[n];i?t.utm[i]=r:k[n]&&(t.click_id[n]=r)}return t}(function(e){if(!e)return{};for(var t=e.length>0&&"?"===e.charAt(0)?e.substring(1):e,n={},r=("?"===t[0]?t.substr(1):t).split("&"),i=0;i<r.length;i++){var o=r[i].split("=");n[decodeURIComponent(o[0])]=decodeURIComponent(o[1]||"")}return n}(r.doc_search)));return Object.keys(o).length&&(u.company=o),u},r.prototype._getIds=function(){if(!i())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,r=Object.entries(e);n<r.length;n++){var o=r[n],s=o[0],a=o[1];this._3pCookies[s]&&(t["_"==s.charAt(0)?s.substr(1):s]=a)}return t},r.prototype.pathMatches=function(e,t){return new URL(t).pathname.match(new RegExp("^"+e.trim().replace(/\*\*/g,".*").replace(/([^\.])\*/g,"$1[^\\s/]*")+"/?$"))},r.prototype.track=function(e,t){var n=this,r=t||{};u().debug("track event of type",e,r);var o=i()?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 u().debug("Page is excluded from tracking");var a=t||{};"$autocapture"!==e&&"user_identify"!==e&&"pageview"!==e&&"$pageleave"!==e&&(a={event_attributes:t});var c=this.makeEvent(e,this.compatMode?"eventn":"usermaven",a);return this.sendJson(c)},r.prototype.init=function(r){var o,l,p,h,f,m,g,v=this;if(i()&&!r.force_use_fetch)r.fetch&&u().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(!r.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=(f=r.fetch||globalThis.fetch,function(r,i,o,s){return void 0===s&&(s=function(e,t){}),t(void 0,void 0,void 0,(function(){var t,a,c,l,p,d,h,m;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,f(r,{method:"POST",headers:e({Accept:"application/json","Content-Type":"application/json"},o||{}),body:i})];case 1:return t=n.sent(),[3,3];case 2:return a=n.sent(),u().error("Failed to send data to "+r+": "+((null==a?void 0:a.message)||"unknown error"),i,a),s(-1,{}),[2];case 3:if(200!==t.status)return u().warn("Failed to send data to "+r+" (#"+t.status+" - "+t.statusText+")",i),s(t.status,{}),[2];c={},l="",p=null!==(m=null===(h=t.headers)||void 0===h?void 0:h.get("Content-Type"))&&void 0!==m?m:"",n.label=4;case 4:return n.trys.push([4,6,,7]),[4,t.text()];case 5:return l=n.sent(),c=JSON.parse(l),[3,7];case 6:return d=n.sent(),u().error("Failed to parse "+r+" response. Content-type: "+p+" text: "+l,d),[3,7];case 7:try{s(t.status,c)}catch(e){u().error("Failed to handle "+r+" response. Content-type: "+p+" text: "+l,e)}return[2]}}))}))})}if(r.custom_headers&&"function"==typeof r.custom_headers?this.customHeaders=r.custom_headers:r.custom_headers&&(this.customHeaders=function(){return r.custom_headers}),"echo"===r.tracking_host&&(u().warn('jitsuClient is configured with "echo" transport. Outgoing requests will be written to console'),this.transport=ue),r.ip_policy&&(this.ipPolicy=r.ip_policy),r.cookie_policy&&(this.cookiePolicy=r.cookie_policy),"strict"===r.privacy_policy&&(this.ipPolicy="strict",this.cookiePolicy="strict"),r.use_beacon_api&&navigator.sendBeacon&&(this.beaconApi=!0),"comply"===this.cookiePolicy&&this.beaconApi&&(this.cookiePolicy="strict"),r.log_level&&(m=r.log_level,(g=s[m.toLocaleUpperCase()])||(console.warn("Can't find log level with name "+m.toLocaleUpperCase()+", defaulting to INFO"),g=s.INFO),a=c(g)),this.initialOptions=r,u().debug("Initializing Usemaven Tracker tracker",r,oe),r.key){if(this.compatMode=void 0!==r.compat_mode&&!!r.compat_mode,this.cookieDomain=r.cookie_domain||d(),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}(r.tracking_host||"t.usermaven.com"),this.randomizeUrl=r.randomize_url||!1,this.apiKey=r.key,this.__auto_pageview_enabled=r.auto_pageview||!1,this.idCookieName=r.cookie_name||"__eventn_id_"+r.key,"strict"===this.cookiePolicy?this.propsPersistance=new pe:this.propsPersistance=i()?new le(this.cookieDomain,this.idCookieName+"_props"):new pe,"strict"===this.cookiePolicy?this.userIdPersistence=new pe:this.userIdPersistence=i()?new le(this.cookieDomain,this.idCookieName+"_usr"):new pe,this.propsPersistance){var y=this.propsPersistance.restore();y&&(this.permanentProperties=y,this.permanentProperties.globalProps=null!==(o=y.globalProps)&&void 0!==o?o:{},this.permanentProperties.propsPerEvent=null!==(l=y.propsPerEvent)&&void 0!==l?l:{}),u().debug("Restored persistent properties",this.permanentProperties)}this.propertyBlacklist=r.property_blacklist&&r.property_blacklist.length>0?r.property_blacklist:[];this.config=D({},{autocapture:!1,properties_string_max_length:null,property_blacklist:[],sanitize_properties:null,auto_pageview:!1},r||{},this.config||{},{token:this.apiKey}),u().debug("Default Configuration",this.config),this.manageAutoCapture(this.config),!1===r.capture_3rd_party_cookies?this._3pCookies={}:(r.capture_3rd_party_cookies||["_ga","_fbp","_ym_uid","ajs_user_id","ajs_anonymous_id"]).forEach((function(e){return v._3pCookies[e]=!0})),r.ga_hook&&u().warn("GA event interceptor isn't supported anymore"),r.segment_hook&&function(e){var t=window;t.analytics||(t.analytics=[]);e.interceptAnalytics(t.analytics)}(this),i()&&(r.disable_event_persistence||(this.queue=new S("jitsu-event-queue"),this.scheduleFlush(0)),window.addEventListener("beforeunload",(function(){return v.flush()}))),this.__auto_pageview_enabled&&function(e){var t=function(){return e.track("pageview")},n=history.pushState;n&&(history.pushState=function(e,r,i){n.apply(this,[e,r,i]),t()},addEventListener("popstate",t));addEventListener("hashchange",t)}(this),this.retryTimeout=[null!==(p=r.min_send_timeout)&&void 0!==p?p:this.retryTimeout[0],null!==(h=r.max_send_timeout)&&void 0!==h?h:this.retryTimeout[1]],r.max_send_attempts&&(this.maxSendAttempts=r.max_send_attempts),this.initialized=!0}else u().error("Can't initialize Usemaven, key property is not set")},r.prototype.interceptAnalytics=function(t){var n=this,r=function(t){var r;try{var i=e({},t.payload);u().debug("Intercepted segment payload",i.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&&(i.obj.userId=s.user().id())}(null===(r=null==i?void 0:i.obj)||void 0===r?void 0:r.timestamp)&&(i.obj.sentAt=i.obj.timestamp);var a=t.payload.type();"track"===a&&(a=t.payload.event()),n._send3p("ajs",i,a)}catch(e){u().warn("Failed to send an event",e)}t.next(t.payload)};"function"==typeof t.addSourceMiddleware?(u().debug("Analytics.js is initialized, calling addSourceMiddleware"),t.addSourceMiddleware(r)):(u().debug("Analytics.js is not initialized, pushing addSourceMiddleware to callstack"),t.push(["addSourceMiddleware",r])),t.__en_intercepted=!0},r.prototype.restoreId=function(){if(this.userIdPersistence){var t=this.userIdPersistence.restore();t&&(this.userProperties=e(e({},t),this.userProperties))}},r.prototype.set=function(t,n){var r,i=null==n?void 0:n.eventType,o=void 0===(null==n?void 0:n.persist)||(null==n?void 0:n.persist);if(void 0!==i){var s=null!==(r=this.permanentProperties.propsPerEvent[i])&&void 0!==r?r:{};this.permanentProperties.propsPerEvent[i]=e(e({},s),t)}else this.permanentProperties.globalProps=e(e({},this.permanentProperties.globalProps),t);this.propsPersistance&&o&&this.propsPersistance.save(this.permanentProperties)},r.prototype.unset=function(e,t){o();var n=null==t?void 0:t.eventType,r=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&&r&&this.propsPersistance.save(this.permanentProperties)},r.prototype.manageAutoCapture=function(e){if(u().debug("Auto Capture Status: ",this.config.autocapture),this.__autocapture_enabled=this.config.autocapture,this.__autocapture_enabled){re.enabledForProject(this.apiKey,100,100)?re.isBrowserSupported()?(u().debug("Autocapture enabled..."),re.init(this,e)):(this.config.autocapture=!1,this.__autocapture_enabled=!1,u().debug("Disabling Automatic Event Collection because this browser is not supported")):(this.config.autocapture=!1,this.__autocapture_enabled=!1,u().debug("Not in active bucket: disabling Automatic Event Collection."))}},r.prototype.capture=function(e,t){var n,r;if(void 0===t&&(t={}),this.initialized)if(L(e)||"string"!=typeof e)console.error("No event name provided to usermaven.capture");else{var i={event:e+(t.$event_type?"_"+t.$event_type:""),properties:this._calculate_event_properties(e,t)};(null===(r=null===(n=(i=J(i,this.get_config("properties_string_max_length"))).properties)||void 0===n?void 0:n.autocapture_attributes)||void 0===r?void 0:r.tag_name)&&this.track("$autocapture",i.properties),"$scroll"===e&&this.track(e,i.properties)}else console.error("Trying to capture event before initialization")},r.prototype._calculate_event_properties=function(e,t){var n,r,i=t||{};if("$snapshot"===e||"$scroll"===e)return i;I(this.propertyBlacklist)?H(this.propertyBlacklist,(function(e){delete i[e]})):console.error("Invalid value for property_blacklist config: "+this.propertyBlacklist);var o={},s=i.$elements||[];return s.length&&(o=s[0]),i.autocapture_attributes=o,i.autocapture_attributes.el_text=null!==(n=i.autocapture_attributes.$el_text)&&void 0!==n?n:"",i.autocapture_attributes.event_type=null!==(r=i.$event_type)&&void 0!==r?r:"",["$ce_version","$event_type","$initial_referrer","$initial_referring_domain","$referrer","$referring_domain","$elements"].forEach((function(e){delete i[e]})),delete i.autocapture_attributes.$el_text,delete i.autocapture_attributes.nth_child,delete i.autocapture_attributes.nth_of_type,i},r}();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"];var be="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 "+be+'="true"\n script attribute\n '}function ke(e,t){u().debug("Processing queue",e);for(var n=0;n<e.length;n+=1){var i=r([],e[n],!0)||[],o=i[0],s=i.slice(1),a=t[o];"function"==typeof a&&a.apply(t,s)}e.length=0}if(window){var Pe=window,Se=function(e){var t=document.currentScript||document.querySelector("script[src*=jsFileName][data-usermaven-api-key]");if(t){var n,r={tracking_host:(n=t.getAttribute("src"),n.replace("/s/"+ye,"").replace("/"+ye,"")),key:null};_e.forEach((function(e){var n="data-"+e.replace(new RegExp("_","g"),"-");if(void 0!==t.getAttribute(n)&&null!==t.getAttribute(n)){var i=t.getAttribute(n);"true"===i?i=!0:"false"===i&&(i=!1),r[e]=i}})),e.usermavenClient=function(e){var t=new ve;return t.init(e),t}(r),!r.segment_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(be)||u().warn(we("segment")),!r.ga_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(be)||u().warn(we("ga"));var i=function(){var t=e.usermavenQ=e.usermavenQ||[];t.push(arguments),ke(t,e.usermavenClient)};e.usermaven=i,r.project_id&&i("set",{project_id:r.project_id}),"true"!==t.getAttribute("data-init-only")&&"yes"!==t.getAttribute("data-init-only")&&i("track","pageview");var o=void 0===e.onpagehide?"unload":"pagehide";return e.addEventListener(o,(function(){i("track","$pageleave")})),e.usermavenClient}u().warn("Usermaven script is not properly initialized. The definition must contain data-usermaven-api-key as a parameter")}(Pe);Se?(u().debug("Usermaven in-browser tracker has been initialized"),Pe.usermaven=function(){var e=Pe.usermavenQ=Pe.usermavenQ||[];e.push(arguments),ke(e,Se)},Pe.usermavenQ&&(u().debug("Initial queue size of "+Pe.usermavenQ.length+" will be processed"),ke(Pe.usermavenQ,Se))):u().error("Usermaven tracker has not been initialized (reason unknown)")}else u().warn("Usermaven tracker called outside browser context. It will be ignored")}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usermaven/sdk-js",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Usermaven JavaScript SDK.",
|
|
5
5
|
"main": "dist/npm/usermaven.cjs.js",
|
|
6
6
|
"module": "dist/npm/usermaven.es.js",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"rollup-plugin-terser": "^7.0.2",
|
|
48
48
|
"rollup-plugin-typescript": "^1.0.1",
|
|
49
49
|
"ts-jest": "^27.1.2",
|
|
50
|
-
"ts-node": "
|
|
50
|
+
"ts-node": "9.1.1",
|
|
51
51
|
"tslib": "^2.3.1",
|
|
52
|
-
"typescript": "
|
|
52
|
+
"typescript": "4.4.3"
|
|
53
53
|
},
|
|
54
54
|
"resolutions": {
|
|
55
55
|
|