@usermaven/sdk-js 1.0.8 → 1.0.9

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/README.md CHANGED
@@ -19,6 +19,7 @@ This section is indented only for package maintainers.
19
19
  * The server listens to all changes to src and rebuilds npm and `lib.js` automatically. Open test cases HTML files to see
20
20
  usermaven in action
21
21
  * http://localhost:8081/test-case/embed.html - embedded Usermaven
22
+ - * <http://localhost:8081/test-case/embed_strict_mode.html> - embedded strict mode for Usermaven
22
23
  * http://localhost:8081/test-case/autocapture.html - embedded Usermaven with autocapturing events
23
24
  * `yarn test` runs [Playwright](https://playwright.dev/) test
24
25
  * `yarn build` builds both npm package and `lib.js` browser bundle
@@ -415,6 +415,58 @@ var getHostWithProtocol = function (host) {
415
415
  }
416
416
  };
417
417
 
418
+ var MemoryQueue = /** @class */ (function () {
419
+ function MemoryQueue() {
420
+ this.queue = [];
421
+ }
422
+ MemoryQueue.prototype.flush = function () {
423
+ var queue = this.queue;
424
+ this.queue = [];
425
+ return queue;
426
+ };
427
+ MemoryQueue.prototype.push = function () {
428
+ var _a;
429
+ var values = [];
430
+ for (var _i = 0; _i < arguments.length; _i++) {
431
+ values[_i] = arguments[_i];
432
+ }
433
+ (_a = this.queue).push.apply(_a, values);
434
+ };
435
+ return MemoryQueue;
436
+ }());
437
+ var LocalStorageQueue = /** @class */ (function () {
438
+ function LocalStorageQueue(key) {
439
+ this.key = key;
440
+ }
441
+ LocalStorageQueue.prototype.flush = function () {
442
+ var queue = this.get();
443
+ if (queue.length) {
444
+ this.set([]);
445
+ }
446
+ return queue;
447
+ };
448
+ LocalStorageQueue.prototype.push = function () {
449
+ var values = [];
450
+ for (var _i = 0; _i < arguments.length; _i++) {
451
+ values[_i] = arguments[_i];
452
+ }
453
+ var queue = this.get();
454
+ queue.push.apply(queue, values);
455
+ this.set(queue);
456
+ };
457
+ LocalStorageQueue.prototype.set = function (queue) {
458
+ localStorage.setItem(this.key, JSON.stringify(queue));
459
+ };
460
+ LocalStorageQueue.prototype.get = function () {
461
+ var data = localStorage.getItem(this.key);
462
+ if (data !== null && data !== "") {
463
+ return JSON.parse(data);
464
+ }
465
+ return [];
466
+ };
467
+ return LocalStorageQueue;
468
+ }());
469
+
418
470
  var Config$1 = {
419
471
  DEBUG: false,
420
472
  LIB_VERSION: '1.0.0',
@@ -2469,8 +2521,8 @@ _.safewrap_instance_methods(autocapture);
2469
2521
 
2470
2522
  var VERSION_INFO = {
2471
2523
  env: 'production',
2472
- date: '2022-04-09T09:14:05.991Z',
2473
- version: '1.0.8'
2524
+ date: '2022-06-16T10:42:52.204Z',
2525
+ version: '1.0.9'
2474
2526
  };
2475
2527
  var USERMAVEN_VERSION = "".concat(VERSION_INFO.version, "/").concat(VERSION_INFO.env, "@").concat(VERSION_INFO.date);
2476
2528
  var MAX_AGE_TEN_YEARS = 31622400 * 10;
@@ -2845,6 +2897,11 @@ var UsermavenClientImpl = /** @class */ (function () {
2845
2897
  this.beaconApi = false;
2846
2898
  this.transport = xmlHttpTransport;
2847
2899
  this.customHeaders = function () { return ({}); };
2900
+ this.queue = new MemoryQueue();
2901
+ this.maxSendAttempts = 4;
2902
+ this.retryTimeout = [500, 1e12];
2903
+ this.flushing = false;
2904
+ this.attempt = 1;
2848
2905
  this.__autocapture_enabled = false;
2849
2906
  }
2850
2907
  // private anonymousId: string = '';
@@ -2899,6 +2956,24 @@ var UsermavenClientImpl = /** @class */ (function () {
2899
2956
  return this.sendJson(e);
2900
2957
  };
2901
2958
  UsermavenClientImpl.prototype.sendJson = function (json) {
2959
+ return __awaiter(this, void 0, Promise, function () {
2960
+ return __generator(this, function (_a) {
2961
+ switch (_a.label) {
2962
+ case 0:
2963
+ if (!(this.maxSendAttempts > 1)) return [3 /*break*/, 1];
2964
+ this.queue.push([json, 0]);
2965
+ this.scheduleFlush(0);
2966
+ return [3 /*break*/, 3];
2967
+ case 1: return [4 /*yield*/, this.doSendJson(json)];
2968
+ case 2:
2969
+ _a.sent();
2970
+ _a.label = 3;
2971
+ case 3: return [2 /*return*/];
2972
+ }
2973
+ });
2974
+ });
2975
+ };
2976
+ UsermavenClientImpl.prototype.doSendJson = function (json) {
2902
2977
  var _this = this;
2903
2978
  var cookiePolicy = this.cookiePolicy !== "keep" ? "&cookie_policy=".concat(this.cookiePolicy) : "";
2904
2979
  var ipPolicy = this.ipPolicy !== "keep" ? "&ip_policy=".concat(this.ipPolicy) : "";
@@ -2913,6 +2988,68 @@ var UsermavenClientImpl = /** @class */ (function () {
2913
2988
  return _this.postHandle(code, body);
2914
2989
  });
2915
2990
  };
2991
+ UsermavenClientImpl.prototype.scheduleFlush = function (timeout) {
2992
+ var _this = this;
2993
+ if (this.flushing) {
2994
+ return;
2995
+ }
2996
+ this.flushing = true;
2997
+ if (typeof timeout === "undefined") {
2998
+ var random = Math.random() + 1;
2999
+ var factor = Math.pow(2, this.attempt++);
3000
+ timeout = Math.min(this.retryTimeout[0] * random * factor, this.retryTimeout[1]);
3001
+ }
3002
+ getLogger().debug("Scheduling event queue flush in ".concat(timeout, " ms."));
3003
+ setTimeout(function () { return _this.flush(); }, timeout);
3004
+ };
3005
+ UsermavenClientImpl.prototype.flush = function () {
3006
+ return __awaiter(this, void 0, Promise, function () {
3007
+ var queue;
3008
+ var _a;
3009
+ var _this = this;
3010
+ return __generator(this, function (_b) {
3011
+ switch (_b.label) {
3012
+ case 0:
3013
+ if (isWindowAvailable() && !window.navigator.onLine) {
3014
+ this.flushing = false;
3015
+ this.scheduleFlush();
3016
+ }
3017
+ queue = this.queue.flush();
3018
+ this.flushing = false;
3019
+ if (queue.length === 0) {
3020
+ return [2 /*return*/];
3021
+ }
3022
+ _b.label = 1;
3023
+ case 1:
3024
+ _b.trys.push([1, 3, , 4]);
3025
+ return [4 /*yield*/, this.doSendJson(queue.map(function (el) { return el[0]; }))];
3026
+ case 2:
3027
+ _b.sent();
3028
+ this.attempt = 1;
3029
+ getLogger().debug("Successfully flushed ".concat(queue.length, " events from queue"));
3030
+ return [3 /*break*/, 4];
3031
+ case 3:
3032
+ _b.sent();
3033
+ queue = queue.map(function (el) { return [el[0], el[1] + 1]; }).filter(function (el) {
3034
+ if (el[1] >= _this.maxSendAttempts) {
3035
+ getLogger().error("Dropping queued event after ".concat(el[1], " attempts since max send attempts ").concat(_this.maxSendAttempts, " reached. See logs for details"));
3036
+ return false;
3037
+ }
3038
+ return true;
3039
+ });
3040
+ if (queue.length > 0) {
3041
+ (_a = this.queue).push.apply(_a, queue);
3042
+ this.scheduleFlush();
3043
+ }
3044
+ else {
3045
+ this.attempt = 1;
3046
+ }
3047
+ return [3 /*break*/, 4];
3048
+ case 4: return [2 /*return*/];
3049
+ }
3050
+ });
3051
+ });
3052
+ };
2916
3053
  UsermavenClientImpl.prototype.postHandle = function (status, response) {
2917
3054
  if (this.cookiePolicy === "strict" || this.cookiePolicy === "comply") {
2918
3055
  if (status === 200) {
@@ -2958,7 +3095,7 @@ var UsermavenClientImpl = /** @class */ (function () {
2958
3095
  UsermavenClientImpl.prototype.getCtx = function (env) {
2959
3096
  var now = new Date();
2960
3097
  var props = env.describeClient() || {};
2961
- var _a = this.sessionManager.getSessionAndWindowId(), session_id = _a.session_id, window_id = _a.window_id;
3098
+ var _a = (this.cookiePolicy !== "keep") ? { "session_id": "", "window_id": "" } : this.sessionManager.getSessionAndWindowId(), session_id = _a.session_id, window_id = _a.window_id;
2962
3099
  var company = this.userProperties['company'] || {};
2963
3100
  delete this.userProperties['company'];
2964
3101
  var payload = __assign(__assign({ event_id: "", session_id: session_id, window_id: window_id, user: __assign({ anonymous_id: this.cookiePolicy !== "strict"
@@ -2995,7 +3132,7 @@ var UsermavenClientImpl = /** @class */ (function () {
2995
3132
  };
2996
3133
  UsermavenClientImpl.prototype.init = function (options) {
2997
3134
  var _this = this;
2998
- var _a, _b;
3135
+ var _a, _b, _c, _d;
2999
3136
  if (isWindowAvailable() && !options.force_use_fetch) {
3000
3137
  if (options.fetch) {
3001
3138
  getLogger().warn("Custom fetch implementation is provided to Usermaven. However, it will be ignored since Usermaven runs in browser");
@@ -3116,9 +3253,21 @@ var UsermavenClientImpl = /** @class */ (function () {
3116
3253
  if (options.segment_hook) {
3117
3254
  interceptSegmentCalls(this);
3118
3255
  }
3256
+ if (isWindowAvailable()) {
3257
+ if (!options.disable_event_persistence) {
3258
+ this.queue = new LocalStorageQueue("jitsu-event-queue");
3259
+ this.scheduleFlush(0);
3260
+ }
3261
+ window.addEventListener("beforeunload", function () { return _this.flush(); });
3262
+ }
3263
+ this.retryTimeout = [
3264
+ (_c = options.min_send_timeout) !== null && _c !== void 0 ? _c : this.retryTimeout[0],
3265
+ (_d = options.max_send_timeout) !== null && _d !== void 0 ? _d : this.retryTimeout[1],
3266
+ ];
3267
+ if (!!options.max_send_attempts) {
3268
+ this.maxSendAttempts = options.max_send_attempts;
3269
+ }
3119
3270
  this.initialized = true;
3120
- // Set up the window close event handler "unload"
3121
- window.addEventListener && window.addEventListener('unload', this._handle_unload.bind(this));
3122
3271
  };
3123
3272
  UsermavenClientImpl.prototype.interceptAnalytics = function (analytics) {
3124
3273
  var _this = this;
@@ -204,6 +204,29 @@ export type UsermavenOptions = {
204
204
  */
205
205
  custom_headers?: Record<string, string> | (() => Record<string, string>)
206
206
 
207
+ /**
208
+ * Minimum timeout before re-attempting to send events.
209
+ * Defaults to 0.
210
+ */
211
+ min_send_timeout?: number
212
+
213
+ /**
214
+ * Maximum timeout before re-attempting to send events.
215
+ * Defaults to 2 seconds.
216
+ */
217
+ max_send_timeout?: number
218
+
219
+ /**
220
+ * Maximum number of send event attempts.
221
+ * Defaults to 4.
222
+ */
223
+ max_send_attempts?: number
224
+
225
+ /**
226
+ * Whether failed events should NOT be persisted when applicable.
227
+ */
228
+ disable_event_persistence?: boolean
229
+
207
230
  /**
208
231
  * Type of persistence required
209
232
  * Possible values: cookie | localStorage | localStorage+cookie | memory
@@ -411,6 +411,58 @@ var getHostWithProtocol = function (host) {
411
411
  }
412
412
  };
413
413
 
414
+ var MemoryQueue = /** @class */ (function () {
415
+ function MemoryQueue() {
416
+ this.queue = [];
417
+ }
418
+ MemoryQueue.prototype.flush = function () {
419
+ var queue = this.queue;
420
+ this.queue = [];
421
+ return queue;
422
+ };
423
+ MemoryQueue.prototype.push = function () {
424
+ var _a;
425
+ var values = [];
426
+ for (var _i = 0; _i < arguments.length; _i++) {
427
+ values[_i] = arguments[_i];
428
+ }
429
+ (_a = this.queue).push.apply(_a, values);
430
+ };
431
+ return MemoryQueue;
432
+ }());
433
+ var LocalStorageQueue = /** @class */ (function () {
434
+ function LocalStorageQueue(key) {
435
+ this.key = key;
436
+ }
437
+ LocalStorageQueue.prototype.flush = function () {
438
+ var queue = this.get();
439
+ if (queue.length) {
440
+ this.set([]);
441
+ }
442
+ return queue;
443
+ };
444
+ LocalStorageQueue.prototype.push = function () {
445
+ var values = [];
446
+ for (var _i = 0; _i < arguments.length; _i++) {
447
+ values[_i] = arguments[_i];
448
+ }
449
+ var queue = this.get();
450
+ queue.push.apply(queue, values);
451
+ this.set(queue);
452
+ };
453
+ LocalStorageQueue.prototype.set = function (queue) {
454
+ localStorage.setItem(this.key, JSON.stringify(queue));
455
+ };
456
+ LocalStorageQueue.prototype.get = function () {
457
+ var data = localStorage.getItem(this.key);
458
+ if (data !== null && data !== "") {
459
+ return JSON.parse(data);
460
+ }
461
+ return [];
462
+ };
463
+ return LocalStorageQueue;
464
+ }());
465
+
414
466
  var Config$1 = {
415
467
  DEBUG: false,
416
468
  LIB_VERSION: '1.0.0',
@@ -2465,8 +2517,8 @@ _.safewrap_instance_methods(autocapture);
2465
2517
 
2466
2518
  var VERSION_INFO = {
2467
2519
  env: 'production',
2468
- date: '2022-04-09T09:14:05.991Z',
2469
- version: '1.0.8'
2520
+ date: '2022-06-16T10:42:52.204Z',
2521
+ version: '1.0.9'
2470
2522
  };
2471
2523
  var USERMAVEN_VERSION = "".concat(VERSION_INFO.version, "/").concat(VERSION_INFO.env, "@").concat(VERSION_INFO.date);
2472
2524
  var MAX_AGE_TEN_YEARS = 31622400 * 10;
@@ -2841,6 +2893,11 @@ var UsermavenClientImpl = /** @class */ (function () {
2841
2893
  this.beaconApi = false;
2842
2894
  this.transport = xmlHttpTransport;
2843
2895
  this.customHeaders = function () { return ({}); };
2896
+ this.queue = new MemoryQueue();
2897
+ this.maxSendAttempts = 4;
2898
+ this.retryTimeout = [500, 1e12];
2899
+ this.flushing = false;
2900
+ this.attempt = 1;
2844
2901
  this.__autocapture_enabled = false;
2845
2902
  }
2846
2903
  // private anonymousId: string = '';
@@ -2895,6 +2952,24 @@ var UsermavenClientImpl = /** @class */ (function () {
2895
2952
  return this.sendJson(e);
2896
2953
  };
2897
2954
  UsermavenClientImpl.prototype.sendJson = function (json) {
2955
+ return __awaiter(this, void 0, Promise, function () {
2956
+ return __generator(this, function (_a) {
2957
+ switch (_a.label) {
2958
+ case 0:
2959
+ if (!(this.maxSendAttempts > 1)) return [3 /*break*/, 1];
2960
+ this.queue.push([json, 0]);
2961
+ this.scheduleFlush(0);
2962
+ return [3 /*break*/, 3];
2963
+ case 1: return [4 /*yield*/, this.doSendJson(json)];
2964
+ case 2:
2965
+ _a.sent();
2966
+ _a.label = 3;
2967
+ case 3: return [2 /*return*/];
2968
+ }
2969
+ });
2970
+ });
2971
+ };
2972
+ UsermavenClientImpl.prototype.doSendJson = function (json) {
2898
2973
  var _this = this;
2899
2974
  var cookiePolicy = this.cookiePolicy !== "keep" ? "&cookie_policy=".concat(this.cookiePolicy) : "";
2900
2975
  var ipPolicy = this.ipPolicy !== "keep" ? "&ip_policy=".concat(this.ipPolicy) : "";
@@ -2909,6 +2984,68 @@ var UsermavenClientImpl = /** @class */ (function () {
2909
2984
  return _this.postHandle(code, body);
2910
2985
  });
2911
2986
  };
2987
+ UsermavenClientImpl.prototype.scheduleFlush = function (timeout) {
2988
+ var _this = this;
2989
+ if (this.flushing) {
2990
+ return;
2991
+ }
2992
+ this.flushing = true;
2993
+ if (typeof timeout === "undefined") {
2994
+ var random = Math.random() + 1;
2995
+ var factor = Math.pow(2, this.attempt++);
2996
+ timeout = Math.min(this.retryTimeout[0] * random * factor, this.retryTimeout[1]);
2997
+ }
2998
+ getLogger().debug("Scheduling event queue flush in ".concat(timeout, " ms."));
2999
+ setTimeout(function () { return _this.flush(); }, timeout);
3000
+ };
3001
+ UsermavenClientImpl.prototype.flush = function () {
3002
+ return __awaiter(this, void 0, Promise, function () {
3003
+ var queue;
3004
+ var _a;
3005
+ var _this = this;
3006
+ return __generator(this, function (_b) {
3007
+ switch (_b.label) {
3008
+ case 0:
3009
+ if (isWindowAvailable() && !window.navigator.onLine) {
3010
+ this.flushing = false;
3011
+ this.scheduleFlush();
3012
+ }
3013
+ queue = this.queue.flush();
3014
+ this.flushing = false;
3015
+ if (queue.length === 0) {
3016
+ return [2 /*return*/];
3017
+ }
3018
+ _b.label = 1;
3019
+ case 1:
3020
+ _b.trys.push([1, 3, , 4]);
3021
+ return [4 /*yield*/, this.doSendJson(queue.map(function (el) { return el[0]; }))];
3022
+ case 2:
3023
+ _b.sent();
3024
+ this.attempt = 1;
3025
+ getLogger().debug("Successfully flushed ".concat(queue.length, " events from queue"));
3026
+ return [3 /*break*/, 4];
3027
+ case 3:
3028
+ _b.sent();
3029
+ queue = queue.map(function (el) { return [el[0], el[1] + 1]; }).filter(function (el) {
3030
+ if (el[1] >= _this.maxSendAttempts) {
3031
+ getLogger().error("Dropping queued event after ".concat(el[1], " attempts since max send attempts ").concat(_this.maxSendAttempts, " reached. See logs for details"));
3032
+ return false;
3033
+ }
3034
+ return true;
3035
+ });
3036
+ if (queue.length > 0) {
3037
+ (_a = this.queue).push.apply(_a, queue);
3038
+ this.scheduleFlush();
3039
+ }
3040
+ else {
3041
+ this.attempt = 1;
3042
+ }
3043
+ return [3 /*break*/, 4];
3044
+ case 4: return [2 /*return*/];
3045
+ }
3046
+ });
3047
+ });
3048
+ };
2912
3049
  UsermavenClientImpl.prototype.postHandle = function (status, response) {
2913
3050
  if (this.cookiePolicy === "strict" || this.cookiePolicy === "comply") {
2914
3051
  if (status === 200) {
@@ -2954,7 +3091,7 @@ var UsermavenClientImpl = /** @class */ (function () {
2954
3091
  UsermavenClientImpl.prototype.getCtx = function (env) {
2955
3092
  var now = new Date();
2956
3093
  var props = env.describeClient() || {};
2957
- var _a = this.sessionManager.getSessionAndWindowId(), session_id = _a.session_id, window_id = _a.window_id;
3094
+ var _a = (this.cookiePolicy !== "keep") ? { "session_id": "", "window_id": "" } : this.sessionManager.getSessionAndWindowId(), session_id = _a.session_id, window_id = _a.window_id;
2958
3095
  var company = this.userProperties['company'] || {};
2959
3096
  delete this.userProperties['company'];
2960
3097
  var payload = __assign(__assign({ event_id: "", session_id: session_id, window_id: window_id, user: __assign({ anonymous_id: this.cookiePolicy !== "strict"
@@ -2991,7 +3128,7 @@ var UsermavenClientImpl = /** @class */ (function () {
2991
3128
  };
2992
3129
  UsermavenClientImpl.prototype.init = function (options) {
2993
3130
  var _this = this;
2994
- var _a, _b;
3131
+ var _a, _b, _c, _d;
2995
3132
  if (isWindowAvailable() && !options.force_use_fetch) {
2996
3133
  if (options.fetch) {
2997
3134
  getLogger().warn("Custom fetch implementation is provided to Usermaven. However, it will be ignored since Usermaven runs in browser");
@@ -3112,9 +3249,21 @@ var UsermavenClientImpl = /** @class */ (function () {
3112
3249
  if (options.segment_hook) {
3113
3250
  interceptSegmentCalls(this);
3114
3251
  }
3252
+ if (isWindowAvailable()) {
3253
+ if (!options.disable_event_persistence) {
3254
+ this.queue = new LocalStorageQueue("jitsu-event-queue");
3255
+ this.scheduleFlush(0);
3256
+ }
3257
+ window.addEventListener("beforeunload", function () { return _this.flush(); });
3258
+ }
3259
+ this.retryTimeout = [
3260
+ (_c = options.min_send_timeout) !== null && _c !== void 0 ? _c : this.retryTimeout[0],
3261
+ (_d = options.max_send_timeout) !== null && _d !== void 0 ? _d : this.retryTimeout[1],
3262
+ ];
3263
+ if (!!options.max_send_attempts) {
3264
+ this.maxSendAttempts = options.max_send_attempts;
3265
+ }
3115
3266
  this.initialized = true;
3116
- // Set up the window close event handler "unload"
3117
- window.addEventListener && window.addEventListener('unload', this._handle_unload.bind(this));
3118
3267
  };
3119
3268
  UsermavenClientImpl.prototype.interceptAnalytics = function (analytics) {
3120
3269
  var _this = this;
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){let t=!!globalThis.window;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 p(e,t,n){var r;void 0===n&&(n={});var i=e+"="+encodeURIComponent(t);if(i+="; Path="+(null!==(r=n.path)&&void 0!==r?r:"/"),n.maxAge&&(i+="; Max-Age="+Math.floor(n.maxAge)),n.domain&&(i+="; Domain="+n.domain),n.expires&&(i+="; Expires="+n.expires.toUTCString()),n.httpOnly&&(i+="; HttpOnly"),n.secure&&(i+="; Secure"),n.sameSite)switch("string"==typeof n.sameSite?n.sameSite.toLowerCase():n.sameSite){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return i}var l;function d(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 h(e,t){return Array.from(e.attributes).forEach((function(e){t.setAttribute(e.nodeName,e.nodeValue)}))}function f(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");h(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){return e&&decodeURIComponent(o().document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null},m=function(e,t,n){void 0===n&&(n={}),o().document.cookie=p(e,t,n)},_=function(e,t){void 0===t&&(t="/"),document.cookie=e+"= ; expires = Thu, 01 Jan 1970 00:00:00 GMT"+(t?"; path = "+t:"")},v=function(){return Math.random().toString(36).substring(2,12)},y=function(){return Math.random().toString(36).substring(2,7)},b={utm_source:"source",utm_medium:"medium",utm_campaign:"campaign",utm_term:"term",utm_content:"content"},w={gclid:!0,fbclid:!0,dclid:!0};var k="1.0.0";const S=Array.prototype,P=Function.prototype,x=Object.prototype,O=S.slice,C=x.toString,A=x.hasOwnProperty,E="undefined"!=typeof window?window:{},I=E.navigator||{userAgent:""},N=E.document||{},U=I.userAgent,$=P.bind,j=S.forEach,T=S.indexOf,D=Array.isArray,M={};var B={trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},F=function(){if(!B.isUndefined(window.console)&&window.console){var e=["UserMaven error:",...arguments];try{window.console.error.apply(window.console,e)}catch(t){B.each(e,(function(e){window.console.error(e)}))}}};B.bind=function(e,t){var n,r;if($&&e.bind===$)return $.apply(e,O.call(arguments,1));if(!B.isFunction(e))throw new TypeError;return n=O.call(arguments,2),r=function(){if(!(this instanceof r))return e.apply(t,n.concat(O.call(arguments)));var i={};i.prototype=e.prototype;var o=new i;i.prototype=null;var s=e.apply(o,n.concat(O.call(arguments)));return Object(s)===s?s:o},r},B.bind_instance_methods=function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=B.bind(e[t],e))},B.each=function(e,t,n){if(null!=e)if(j&&e.forEach===j)e.forEach(t,n);else if(e.length===+e.length){for(var r=0,i=e.length;r<i;r++)if(r in e&&t.call(n,e[r],r,e)===M)return}else for(var o in e)if(A.call(e,o)&&t.call(n,e[o],o,e)===M)return},B.extend=function(e){return B.each(O.call(arguments,1),(function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])})),e},B.isArray=D||function(e){return"[object Array]"===C.call(e)},B.isFunction=function(e){try{return/^\s*\bfunction\b/.test(e)}catch(e){return!1}},B.include=function(e,t){var n=!1;return null===e?n:T&&e.indexOf===T?-1!=e.indexOf(t):(B.each(e,(function(e){if(n||(n=e===t))return M})),n)},B.includes=function(e,t){return-1!==e.indexOf(t)},B.isObject=function(e){return e===Object(e)&&!B.isArray(e)},B.isEmptyObject=function(e){if(B.isObject(e)){for(var t in e)if(A.call(e,t))return!1;return!0}return!1},B.isUndefined=function(e){return void 0===e},B.isString=function(e){return"[object String]"==C.call(e)},B.isDate=function(e){return"[object Date]"==C.call(e)},B.isNumber=function(e){return"[object Number]"==C.call(e)},B.encodeDates=function(e){return B.each(e,(function(t,n){B.isDate(t)?e[n]=B.formatDate(t):B.isObject(t)&&(e[n]=B.encodeDates(t))})),e},B.timestamp=function(){return Date.now=Date.now||function(){return+new Date},Date.now()},B.formatDate=function(e){function t(e){return e<10?"0"+e:e}return e.getUTCFullYear()+"-"+t(e.getUTCMonth()+1)+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())},B.safewrap=function(e){return function(){try{return e.apply(this,arguments)}catch(e){F("Implementation error. Please turn on debug and contact support@usermaven.com.")}}},B.safewrap_class=function(e,t){for(var n=0;n<t.length;n++)e.prototype[t[n]]=B.safewrap(e.prototype[t[n]])},B.safewrap_instance_methods=function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=B.safewrap(e[t]))},B.strip_empty_properties=function(e){var t={};return B.each(e,(function(e,n){B.isString(e)&&e.length>0&&(t[n]=e)})),t};const z="undefined"!=typeof Symbol?Symbol("__deepCircularCopyInProgress__"):"__deepCircularCopyInProgress__";function R(e,t){if(e!==Object(e))return t?t(e):e;if(e[z])return;let n;return e[z]=!0,B.isArray(e)?(n=[],B.each(e,(e=>{n.push(R(e,t))}))):(n={},B.each(e,((e,r)=>{r!==z&&(n[r]=R(e,t))}))),delete e[z],n}var L;B.copyAndTruncateStrings=(e,t)=>R(e,(e=>("string"==typeof e&&null!==t&&(e=e.slice(0,t)),e))),B.base64Encode=function(e){var t,n,r,i,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,c=0,u="",p=[];if(!e)return e;e=B.utf8Encode(e);do{t=(o=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,n=o>>12&63,r=o>>6&63,i=63&o,p[c++]=s.charAt(t)+s.charAt(n)+s.charAt(r)+s.charAt(i)}while(a<e.length);switch(u=p.join(""),e.length%3){case 1:u=u.slice(0,-2)+"==";break;case 2:u=u.slice(0,-1)+"="}return u},B.utf8Encode=function(e){var t,n,r,i,o="";for(t=n=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i<r;i++){var s=e.charCodeAt(i),a=null;s<128?n++:a=s>127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==a&&(n>t&&(o+=e.substring(t,n)),o+=a,t=n=i+1)}return n>t&&(o+=e.substring(t,e.length)),o},B.UUID=(L=function(){for(var e=1*new Date,t=0;e==1*new Date;)t++;return e.toString(16)+t.toString(16)},function(){var e=(window.screen.height*window.screen.width).toString(16);return L()+"-"+Math.random().toString(16).replace(".","")+"-"+function(){var e,t,n=U,r=[],i=0;function o(e,t){var n,i=0;for(n=0;n<t.length;n++)i|=r[n]<<8*n;return e^i}for(e=0;e<n.length;e++)t=n.charCodeAt(e),r.unshift(255&t),r.length>=4&&(i=o(i,r),r=[]);return r.length>0&&(i=o(i,r)),i.toString(16)}()+"-"+e+"-"+L()}),B.isBlockedUA=function(e){return!!/(google web preview|baiduspider|yandexbot|bingbot|googlebot|yahoo! slurp)/i.test(e)},B.HTTPBuildQuery=function(e,t){var n,r,i=[];return B.isUndefined(t)&&(t="&"),B.each(e,(function(e,t){n=encodeURIComponent(e.toString()),r=encodeURIComponent(t),i[i.length]=r+"="+n})),i.join(t)},B.getQueryParam=function(e,t){t=t.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(e);if(null===n||n&&"string"!=typeof n[1]&&n[1].length)return"";var r=n[1];try{r=decodeURIComponent(r)}catch(e){}return r.replace(/\+/g," ")},B.getHashParam=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},B.register_event=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,a=!0;return B.isFunction(r)&&(o=r(i)),s=n.call(t,i),!1!==o&&!1!==s||(a=!1),a}}}(t,r,a)}}}(),B.info={campaignParams:function(){var e="utm_source utm_medium utm_campaign utm_content utm_term gclid".split(" "),t="",n={};return B.each(e,(function(e){(t=B.getQueryParam(N.URL,e)).length&&(n[e]=t)})),n},searchEngine:function(e){return 0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null},searchInfo:function(e){var t=B.info.searchEngine(e),n="yahoo"!=t?"q":"p",r={};if(null!==t){r.$search_engine=t;var i=B.getQueryParam(e,n);i.length&&(r.um_keyword=i)}return r},browser:function(e,t,n){return t=t||"",n||B.includes(e," OPR/")?B.includes(e,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":B.includes(e,"IEMobile")||B.includes(e,"WPDesktop")?"Internet Explorer Mobile":B.includes(e,"SamsungBrowser/")?"Samsung Internet":B.includes(e,"Edge")||B.includes(e,"Edg/")?"Microsoft Edge":B.includes(e,"FBIOS")?"Facebook Mobile":B.includes(e,"Chrome")?"Chrome":B.includes(e,"CriOS")?"Chrome iOS":B.includes(e,"UCWEB")||B.includes(e,"UCBrowser")?"UC Browser":B.includes(e,"FxiOS")?"Firefox iOS":B.includes(t,"Apple")?B.includes(e,"Mobile")?"Mobile Safari":"Safari":B.includes(e,"Android")?"Android Mobile":B.includes(e,"Konqueror")?"Konqueror":B.includes(e,"Firefox")?"Firefox":B.includes(e,"MSIE")||B.includes(e,"Trident/")?"Internet Explorer":B.includes(e,"Gecko")?"Mozilla":""},browserVersion:function(e,t,n){var r={"Internet Explorer Mobile":/rv:(\d+(\.\d+)?)/,"Microsoft Edge":/Edge?\/(\d+(\.\d+)?)/,Chrome:/Chrome\/(\d+(\.\d+)?)/,"Chrome iOS":/CriOS\/(\d+(\.\d+)?)/,"UC Browser":/(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,Safari:/Version\/(\d+(\.\d+)?)/,"Mobile Safari":/Version\/(\d+(\.\d+)?)/,Opera:/(Opera|OPR)\/(\d+(\.\d+)?)/,Firefox:/Firefox\/(\d+(\.\d+)?)/,"Firefox iOS":/FxiOS\/(\d+(\.\d+)?)/,Konqueror:/Konqueror:(\d+(\.\d+)?)/,BlackBerry:/BlackBerry (\d+(\.\d+)?)/,"Android Mobile":/android\s(\d+(\.\d+)?)/,"Samsung Internet":/SamsungBrowser\/(\d+(\.\d+)?)/,"Internet Explorer":/(rv:|MSIE )(\d+(\.\d+)?)/,Mozilla:/rv:(\d+(\.\d+)?)/}[B.info.browser(e,t,n)];if(void 0===r)return null;var i=e.match(r);return i?parseFloat(i[i.length-2]):null},os:function(){var e=U;return/Windows/i.test(e)?/Phone/.test(e)||/WPDesktop/.test(e)?"Windows Phone":"Windows":/(iPhone|iPad|iPod)/.test(e)?"iOS":/Android/.test(e)?"Android":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Mac/i.test(e)?"Mac OS X":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"Chrome OS":""},device:function(e){return/Windows Phone/i.test(e)||/WPDesktop/.test(e)?"Windows Phone":/iPad/.test(e)?"iPad":/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Android/.test(e)&&!/Mobile/.test(e)?"Android Tablet":/Android/.test(e)?"Android":""},deviceType:function(e){const t=this.device(e);return"iPad"===t||"Android Tablet"===t?"Tablet":t?"Mobile":"Desktop"},referringDomain:function(e){var t=e.split("/");return t.length>=3?t[2]:""},properties:function(){return B.extend(B.strip_empty_properties({$os:B.info.os(),$browser:B.info.browser(U,I.vendor,window.opera),$device:B.info.device(U),$device_type:B.info.deviceType(U)}),{$current_url:window.location.href,$host:window.location.host,$pathname:window.location.pathname,$browser_version:B.info.browserVersion(U,I.vendor,window.opera),$screen_height:window.screen.height,$screen_width:window.screen.width,$viewport_height:window.innerHeight,$viewport_width:window.innerWidth,$lib:"web",$lib_version:k,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:B.timestamp()/1e3})},people_properties:function(){return B.extend(B.strip_empty_properties({$os:B.info.os(),$browser:B.info.browser(U,I.vendor,window.opera)}),{$browser_version:B.info.browserVersion(U,I.vendor,window.opera)})}},B.isObject=B.isObject,B.isBlockedUA=B.isBlockedUA,B.isEmptyObject=B.isEmptyObject,B.info=B.info,B.info.device=B.info.device,B.info.browser=B.info.browser,B.info.browserVersion=B.info.browserVersion,B.info.properties=B.info.properties;var H=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;const J={get:function(e){try{for(var t=e+"=",n=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){}return null},parse:function(e){var t;try{t=JSON.parse(J.get(e))||{}}catch(e){}return t},set:function(e,t,n,r,i){try{var o="",s="",a="";if(r){var c=document.location.hostname.match(H),u=c?c[0]:"";o=u?"; domain=."+u:""}if(n){var p=new Date;p.setTime(p.getTime()+24*n*60*60*1e3),s="; expires="+p.toGMTString()}i&&(a="; secure");var l=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; path=/"+o+a;return document.cookie=l,l}catch(e){return}},remove:function(e,t){try{J.set(e,"",-1,t)}catch(e){return}}};var W=null;const q={is_supported:function(){if(null!==W)return W;var e=!0;if(window)try{var t="__mplssupport__";q.set(t,"xyz"),'"xyz"'!==q.get(t)&&(e=!1),q.remove(t)}catch(t){e=!1}else e=!1;return W=e,e},error:function(e){},get:function(e){try{return window.localStorage.getItem(e)}catch(e){q.error(e)}return null},parse:function(e){try{return JSON.parse(q.get(e))||{}}catch(e){}return null},set:function(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch(e){q.error(e)}},remove:function(e){try{window.localStorage.removeItem(e)}catch(e){q.error(e)}}},V={...q,parse:function(e){try{let t={};try{t=J.parse(e)||{},t.distinct_id&&J.set(e,{distinct_id:t.distinct_id})}catch(e){}const n=B.extend(t,JSON.parse(q.get(e)||"{}"));return q.set(e,n),n}catch(e){}return null},set:function(e,t){try{q.set(e,t),t.distinct_id&&J.set(e,{distinct_id:t.distinct_id})}catch(e){q.error(e)}},remove:function(e){try{window.localStorage.removeItem(e),J.remove(e)}catch(e){q.error(e)}}},K={},Q={is_supported:function(){return!0},error:function(e){},parse:function(e){return K[e]||null},set:function(e,t){K[e]=t},remove:function(e){delete K[e]}},G={sessionStorageSupported:null,is_supported:function(){if(null!==G.sessionStorageSupported)return G.sessionStorageSupported;if(G.sessionStorageSupported=!0,window)try{let e="__support__",t="xyz";G.set(e,t),'"xyz"'!==G.get(e)&&(G.sessionStorageSupported=!1),G.remove(e)}catch(e){G.sessionStorageSupported=!1}else G.sessionStorageSupported=!1;return G.sessionStorageSupported},error:function(e){Config.DEBUG},get:function(e){try{return window.sessionStorage.getItem(e)}catch(e){G.error(e)}return null},parse:function(e){try{return JSON.parse(G.get(e))||null}catch(e){}return null},set:function(e,t){try{window.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){G.error(e)}},remove:function(e){try{window.sessionStorage.removeItem(e)}catch(e){G.error(e)}}};var X="__timers",Y="$sesid",Z="$enabled_feature_flags",ee=["__mps","__mpso","__mpus","__mpa","__mpap","__mpr","__mpu","__cmpns",X,"$session_recording_enabled",Y,Z],te=function(e){let t="";e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),this.props={},this.campaign_params_saved=!1,e.persistence_name?this.name="um_"+e.persistence_name:this.name="um_"+t+"_usermaven";var n=e.persistence;"cookie"!==n&&-1===n.indexOf("localStorage")&&"memory"!==n&&(F("Unknown persistence type "+n+"; falling back to cookie"),n=e.persistence="cookie"),"localStorage"===n&&q.is_supported()?this.storage=q:"localStorage+cookie"===n&&V.is_supported()?this.storage=V:this.storage="memory"===n?Q:J,this.load(),this.update_config(e),this.save()};te.prototype.properties=function(){var e={};return B.each(this.props,(function(t,n){if(n===Z&&"object"==typeof t)for(var r=Object.keys(t),i=0;i<r.length;i++)e[`$feature/${r[i]}`]=t[r[i]];else B.include(ee,n)||(e[n]=t)})),e},te.prototype.load=function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=B.extend({},e))}},te.prototype.save=function(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure)},te.prototype.remove=function(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)},te.prototype.clear=function(){this.remove(),this.props={}},te.prototype.register_once=function(e,t,n){return!!B.isObject(e)&&(void 0===t&&(t="None"),this.expire_days=void 0===n?this.default_expiry:n,B.each(e,(function(e,n){this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.props[n]=e)}),this),this.save(),!0)},te.prototype.register=function(e,t){return!!B.isObject(e)&&(this.expire_days=void 0===t?this.default_expiry:t,B.extend(this.props,e),this.save(),!0)},te.prototype.unregister=function(e){e in this.props&&(delete this.props[e],this.save())},te.prototype.update_campaign_params=function(){this.campaign_params_saved||(this.register(B.info.campaignParams()),this.campaign_params_saved=!0)},te.prototype.update_search_keyword=function(e){this.register(B.info.searchInfo(e))},te.prototype.update_referrer_info=function(e){this.register_once({$initial_referrer:e||"$direct",$initial_referring_domain:B.info.referringDomain(e)||"$direct"},""),this.register({$referrer:e||this.props.$referrer||"$direct",$referring_domain:B.info.referringDomain(e)||this.props.$referring_domain||"$direct"})},te.prototype.get_referrer_info=function(){return B.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},te.prototype.safe_merge=function(e){return B.each(this.props,(function(t,n){n in e||(e[n]=t)})),e},te.prototype.update_config=function(e){this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie)},te.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},te.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},te.prototype.get_cross_subdomain=function(){return this.cross_subdomain},te.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},te.prototype.set_event_timer=function(e,t){var n=this.props.__timers||{};n[e]=t,this.props.__timers=n,this.save()},te.prototype.remove_event_timer=function(e){var t=(this.props.__timers||{})[e];return B.isUndefined(t)||(delete this.props.__timers[e],this.save()),t};class ne{constructor(e,t){this.persistence=t,this.session_change_threshold=e.persistence_time||1800,this.session_change_threshold*=1e3,e.persistence_name?this.window_id_storage_key="um_"+e.persistence_name+"_window_id":this.window_id_storage_key="um_"+e.token+"_window_id"}_setWindowId(e){e!==this.windowId&&(this.windowId=e,!this.persistence.disabled&&G.is_supported()&&G.set(this.window_id_storage_key,e))}_getWindowId(){return this.windowId?this.windowId:!this.persistence.disabled&&G.is_supported()?G.parse(this.window_id_storage_key):null}_setSessionId(e,t){e===this.sessionId&&t===this.timestamp||(this.timestamp=t,this.sessionId=e,this.persistence.register({[Y]:[t,e]}))}_getSessionId(){return this.sessionId&&this.timestamp?[this.timestamp,this.sessionId]:this.persistence.props.$sesid||[0,null]}resetSessionId(){this._setSessionId(null,null)}getSessionAndWindowId(e=null,t=!1){if(this.persistence.disabled)return{};e=e||(new Date).getTime();let[n,r]=this._getSessionId(),i=this._getWindowId();!r||Math.abs(e-n)>this.session_change_threshold?(r=B.UUID(),i=B.UUID()):i||(i=B.UUID());const o=e;return this._setWindowId(i),this._setSessionId(r,o),{session_id:r,window_id:i}}}function re(e){switch(typeof e.className){case"string":return e.className;case"object":return e.className.baseVal||e.getAttribute("class")||"";default:return""}}function ie(e){var t="";return ue(e)&&!pe(e)&&e.childNodes&&e.childNodes.length&&B.each(e.childNodes,(function(e){ae(e)&&e.textContent&&(t+=B.trim(e.textContent).split(/(\s+)/).filter(le).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))})),B.trim(t)}function oe(e){return e&&1===e.nodeType}function se(e,t){return e&&e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function ae(e){return e&&3===e.nodeType}var ce=["a","button","form","input","select","textarea","label"];function ue(e){for(var t=e;t.parentNode&&!se(t,"body");t=t.parentNode){var n=re(t).split(" ");if(B.includes(n,"um-sensitive")||B.includes(n,"um-no-capture"))return!1}if(B.includes(re(e).split(" "),"um-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 pe(e){return!!(se(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||se(e,"select")||se(e,"textarea")||"true"===e.getAttribute("contenteditable"))}function le(e){if(null===e||B.isUndefined(e))return!1;if("string"==typeof e){e=B.trim(e);if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((e||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(e))return!1}return!0}class de{constructor(e,t=e.get_config("rageclick")){this.clicks=[],this.instance=e,this.enabled=t}click(e,t,n){if(!this.enabled)return;const 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}]}}var he={_initializedTokens:[],_previousElementSibling:function(e){if(e.previousElementSibling)return e.previousElementSibling;do{e=e.previousSibling}while(e&&!oe(e));return e},_getPropertiesFromElement:function(e,t,n){var r=e.tagName.toLowerCase(),i={tag_name:r};ce.indexOf(r)>-1&&!n&&(i.$el_text=ie(e));var o=re(e);o.length>0&&(i.classes=o.split(" ").filter((function(e){return""!==e}))),B.each(e.attributes,(function(n){var r;pe(e)&&-1===["name","id","class"].indexOf(n.name)||!t&&le(n.value)&&("string"!=typeof(r=n.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))&&!function(e){return"string"==typeof e&&e.startsWith("data-")}(n.name)&&(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 B.each(document.querySelectorAll(e.css_selector),(function(e){var n;["input","select"].indexOf(e.tagName.toLowerCase())>-1?n=e.value:e.textContent&&(n=e.textContent),le(n)&&t.push(n)})),t.join(", ")},_getCustomProperties:function(e){var t={};return B.each(this._customProperties,(function(n){B.each(n.event_selectors,(function(r){var i=document.querySelectorAll(r);B.each(i,(function(r){B.includes(e,r)&&ue(r)&&(t[n.name]=this._extractCustomPropertyValue(n))}),this)}),this)}),this),t},_getEventTarget:function(e){return void 0===e.target?e.srcElement:e.target.shadowRoot?e.composedPath()[0]:e.target},_captureEvent:function(e,t){var n=this._getEventTarget(e);if(ae(n)&&(n=n.parentNode),"click"===e.type&&this.rageclicks.click(e.clientX,e.clientY,(new Date).getTime()),function(e,t){if(!e||se(e,"html")||!oe(e))return!1;for(var n=!1,r=[e],i=!0,o=e;o.parentNode&&!se(o,"body");)if(11!==o.parentNode.nodeType){if(!(i=o.parentNode))break;if(ce.indexOf(i.tagName.toLowerCase())>-1)n=!0;else{let e=window.getComputedStyle(i);e&&"pointer"===e.getPropertyValue("cursor")&&(n=!0)}r.push(i),o=i}else r.push(o.parentNode.host),o=o.parentNode.host;let s=window.getComputedStyle(e);if(s&&"pointer"===s.getPropertyValue("cursor")&&"click"===t.type)return!0;var a=e.tagName.toLowerCase();switch(a){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&&(ce.indexOf(a)>-1||"true"===e.getAttribute("contenteditable"))}}(n,e)){for(var r=[n],i=n;i.parentNode&&!se(i,"body");)11!==i.parentNode.nodeType?(r.push(i.parentNode),i=i.parentNode):(r.push(i.parentNode.host),i=i.parentNode.host);var o,s=[],a=!1;if(B.each(r,(function(e){var n=ue(e);"a"===e.tagName.toLowerCase()&&(o=e.getAttribute("href"),o=n&&le(o)&&o);var r=re(e).split(" ");B.includes(r,"um-no-capture")&&(a=!0),s.push(this._getPropertiesFromElement(e,t.get_config("mask_all_element_attributes"),t.get_config("mask_all_text")))}),this),t.get_config("mask_all_text")||(s[0].$el_text=ie(n)),o&&(s[0].attr__href=o),a)return!1;var c=B.extend(this._getDefaultProperties(e.type),{$elements:s},this._getCustomProperties(r));return t.capture("$autocapture",c),!0}},_navigate:function(e){window.location.href=e},_addDomEventHandlers:function(e){var t=B.bind((function(t){t=t||window.event,this._captureEvent(t,e)}),this);B.register_event(document,"submit",t,!1,!0),B.register_event(document,"change",t,!1,!0),B.register_event(document,"click",t,!1,!0)},_customProperties:{},init:function(e){var t=e.get_config("token");console.log('Initializing autocapture for token "'+t+'"'),this._initializedTokens.indexOf(t)>-1?console.log('autocapture already initialized for token "'+t+'"'):(this._initializedTokens.push(t),e.get_config("autocapture")?this._addDomEventHandlers(e):e.__autocapture_enabled=!1,this.rageclicks=new de(e))},enabledForProject:function(e,t,n){t=B.isUndefined(t)?10:t,n=B.isUndefined(n)?10:n;for(var r=0,i=0;i<e.length;i++)r+=e.charCodeAt(i);return r%t<n},isBrowserSupported:function(){return B.isFunction(document.querySelectorAll)}};B.bind_instance_methods(he),B.safewrap_instance_methods(he);var fe="__buildEnv__",ge="__buildDate__",me="".concat("__buildVersion__","/").concat(fe,"@").concat(ge),_e=316224e3,ve=function(e,t){c().debug("Sending beacon",t);var n=new Blob([t],{type:"text/plain"});return navigator.sendBeacon(e,n),Promise.resolve()};var ye=function(e,t){return console.log("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 be(e,t){void 0===t&&(t=void 0),""!=(t=null!=t?t:window.location.pathname)&&"/"!=t&&(_(e,t),be(e,t.slice(0,t.lastIndexOf("/"))))}var we=function(){function e(e,t){this.cookieDomain=e,this.cookieName=t}return e.prototype.save=function(e){m(this.cookieName,JSON.stringify(e),{domain:this.cookieDomain,secure:"http:"!==document.location.protocol,maxAge:_e})},e.prototype.restore=function(){be(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(){_(this.cookieName)},e}(),ke=function(){function e(){}return e.prototype.save=function(e){},e.prototype.restore=function(){},e.prototype.delete=function(){},e}();var Se={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;be(t);var r=g(t);if(r)return c().debug("Existing user id",r),r;var i=v();return c().debug("New user id",i),m(t,i,{domain:n,secure:"http:"!==document.location.protocol,maxAge:_e}),i}};var Pe={getSourceIp:function(){},describeClient:function(){return{}},getAnonymousId:function(){return""}},xe=function(){return Se},Oe=function(){return Pe},Ce=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(e){c().error("Failed to send",t,e),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)}))},Ae=function(){function r(){this.userProperties={},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=Ce,this.customHeaders=function(){return{}},this.__autocapture_enabled=!1}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.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()?xe():Oe()),this.restoreId();var c=this.getCtx(s),u=e(e({},this.permanentProperties.globalProps),null!==(o=this.permanentProperties.propsPerEvent[t])&&void 0!==o?o:{}),p=e({api_key:this.apiKey,src:n,event_type:t},a),l=s.getSourceIp();return l&&(p.source_ip=l),this.compatMode?e(e(e({},u),{eventn_ctx:c}),p):e(e(e({},u),c),p)},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){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(y(),"?p_").concat(y(),"=").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.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(),_(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,p=a.id,l=a.value;if("tag"===u){var d=document.createElement("div");d.id=p,f(d,l),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=this.sessionManager.getSessionAndWindowId(),o=i.session_id,s=i.window_id,a=this.userProperties.company||{};delete this.userProperties.company;var c,u,p=e(e({event_id:"",session_id:o,window_id:s,user:e({anonymous_id:"strict"!==this.cookiePolicy?t.getAnonymousId({name:this.idCookieName,domain:this.cookieDomain}):""},this.userProperties),ids:this._getIds(),utc_time:(c=n.toISOString(),u=c.split(".")[1],u?u.length>=7?c:c.slice(0,-1)+"0".repeat(7-u.length)+"Z":c),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=b[n];i?t.utm[i]=r:w[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(a).length&&(p.company=a),p},r.prototype._getIds=function(){if(!i())return{};for(var e=function(e){if(void 0===e&&(e=!1),e&&l)return l;var t=d(document.cookie);return l=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.track=function(e,t){var n=t||{};c().debug("track event of type",e,n);var r=this.makeEvent(e,this.compatMode?"eventn":"usermaven",t||{});return this.sendJson(r)},r.prototype.init=function(r){var o,p,l,d,h,f=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?ve:Ce;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=(l=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;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,l(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:throw a=n.sent(),c().error("Failed to send",i,a),s(-1,{}),new Error("Failed to send JSON. See console logs");case 3:if(200!==t.status)throw c().warn("Failed to send data to ".concat(r," (#").concat(t.status," - ").concat(t.statusText,")"),i),new Error("Failed to send JSON. Error code: ".concat(t.status,". See logs for details"));return[4,t.json()];case 4:return u=n.sent(),s(t.status,u),[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=ye),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&&(d=r.log_level,(h=s[d.toLocaleUpperCase()])||(console.warn("Can't find log level with name ".concat(d.toLocaleUpperCase(),", defaulting to INFO")),h=s.INFO),a=u(h)),this.initialOptions=r,c().debug("Initializing Usemaven Tracker tracker",r,me),r.key){if(this.compatMode=void 0!==r.compat_mode&&!!r.compat_mode,this.cookieDomain=r.cookie_domain||function(){if(i())return".".concat((e=location.hostname,t=function(e){return(e.indexOf("//")>-1?e.split("/")[2]:e.split("/")[0]).split(":")[0].split("?")[0]}(e),n=t.split("."),(r=n.length)>2&&(t=n[r-2]+"."+n[r-1],2==n[r-2].length&&2==n[r-1].length&&(t=n[r-3]+"."+t)),t));var e,t,n,r}(),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:"//"+e}(r.tracking_host||"t.usermaven.com"),this.randomizeUrl=r.randomize_url||!1,this.idCookieName=r.cookie_name||"__eventn_id",this.apiKey=r.key,"strict"===this.cookiePolicy?this.propsPersistance=new ke:this.propsPersistance=i()?new we(this.cookieDomain,this.idCookieName+"_props"):new ke,"strict"===this.cookiePolicy?this.userIdPersistence=new ke:this.userIdPersistence=i()?new we(this.cookieDomain,this.idCookieName+"_usr"):new ke,this.propsPersistance){var g=this.propsPersistance.restore();g&&(this.permanentProperties=g,this.permanentProperties.globalProps=null!==(o=g.globalProps)&&void 0!==o?o:{},this.permanentProperties.propsPerEvent=null!==(p=g.propsPerEvent)&&void 0!==p?p:{}),c().debug("Restored persistent properties",this.permanentProperties)}this.config=B.extend({},{persistence:"cookie",persistence_name:"session",autocapture:!1,capture_pageview:!0,store_google:!1,save_referrer:!1,properties_string_max_length:null,property_blacklist:[],sanitize_properties:null},r||{},this.config||{},{token:this.apiKey}),c().debug("Default Configuration",this.config),this.manageSession(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 f._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),this.initialized=!0,window.addEventListener&&window.addEventListener("unload",this._handle_unload.bind(this))}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.manageSession=function(e){c().debug("Options",e),e=e||{},c().debug("Options",e);var t={persistence:e.persistence||"cookie",persistence_name:e.persistence_name||"session",cross_subdomain_cookie:e.cross_subdomain_cookie||!0};this.config=B.extend(t,this.config||{},{token:this.apiKey}),c().debug("Default Configuration",this.config),this.persistence=new te(this.config),c().debug("Persistence Configuration",this.persistence),this.sessionManager=new ne(this.config,this.persistence),c().debug("Session Configuration",this.sessionManager)},r.prototype.manageAutoCapture=function(e){if(c().debug("Auto Capture Status: ",this.config.autocapture),this.__autocapture_enabled=this.config.autocapture,this.__autocapture_enabled){he.enabledForProject(this.apiKey,100,100)?he.isBrowserSupported()?he.init(this):(this.config.autocapture=!1,console.log("Disabling Automatic Event Collection because this browser is not supported")):(this.config.autocapture=!1,console.log("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(B.isUndefined(e)||"string"!=typeof e)console.error("No event name provided to posthog.capture");else if(!B.isBlockedUA(U)){var i=this.persistence.remove_event_timer(e);this.persistence.update_search_keyword(document.referrer),this.get_config("store_google")&&this.persistence.update_campaign_params(),this.get_config("save_referrer")&&this.persistence.update_referrer_info(document.referrer);var o={event:e+(t.$event_type?"_"+t.$event_type:""),properties:this._calculate_event_properties(e,t,i)};(null===(r=null===(n=(o=B.copyAndTruncateStrings(o,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",o.properties)}}else console.error("Trying to capture event before initialization")},r.prototype._calculate_event_properties=function(e,t,n){var r,i,o=t||{};if("$snapshot"===e)return o;if(!B.isUndefined(n)){var s=(new Date).getTime()-n;o.$duration=parseFloat((s/1e3).toFixed(3))}o=B.extend({},this.persistence.properties(),o);var a=this.get_config("property_blacklist");B.isArray(a)?B.each(a,(function(e){delete o[e]})):console.error("Invalid value for property_blacklist config: "+a);var c=this.get_config("sanitize_properties");c&&(o=c(o,e));var u={},p=o.$elements||[];return p.length&&(u=p[0]),o.autocapture_attributes=u,o.autocapture_attributes.el_text=null!==(r=o.autocapture_attributes.$el_text)&&void 0!==r?r:"",o.autocapture_attributes.event_type=null!==(i=o.$event_type)&&void 0!==i?i:"",delete o.$ce_version,delete o.$event_type,delete o.$initial_referrer,delete o.$initial_referring_domain,delete o.$referrer,delete o.$referring_domain,delete o.$elements,delete o.autocapture_attributes.$el_text,delete o.autocapture_attributes.nth_child,delete o.autocapture_attributes.nth_of_type,o},r.prototype._handle_unload=function(){this.get_config("capture_pageview")&&this.capture("$pageleave")},r}();var Ee=["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","persistence","persistence_name","project_id","cross_subdomain_cookie","persistence_time","disable_persistence","autocapture","capture_pageview","properties_string_max_length","property_blacklist"];var Ie="data-suppress-interception-warning";function Ne(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(Ie,'="true"\n script attribute\n ')}function Ue(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 $e=window,je=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};Ee.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 Ae;return t.init(e),t}(r),!r.segment_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(Ie)||c().warn(Ne("segment")),!r.ga_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(Ie)||c().warn(Ne("ga"));var i=function(){var t=e.usermavenQ=e.usermavenQ||[];t.push(arguments),Ue(t,e.usermavenClient)};return e.usermaven=i,console.log(r),r.project_id&&i("set",{project_id:r.project_id}),"true"!==t.getAttribute("data-init-only")&&"yes"!==t.getAttribute("data-init-only")&&(Object.keys(r).includes("capture_pageview")&&!r.capture_pageview||i("track","pageview")),e.usermavenClient}c().warn("Usermaven script is not properly initialized. The definition must contain data-usermaven-api-key as a parameter")}($e);je?(c().debug("Usermaven in-browser tracker has been initialized"),$e.usermaven=function(){var e=$e.usermavenQ=$e.usermavenQ||[];e.push(arguments),Ue(e,je)},$e.usermavenQ&&(c().debug("Initial queue size of ".concat($e.usermavenQ.length," will be processed")),Ue($e.usermavenQ,je))):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{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){let t=!!globalThis.window;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 p(e,t,n){var r;void 0===n&&(n={});var i=e+"="+encodeURIComponent(t);if(i+="; Path="+(null!==(r=n.path)&&void 0!==r?r:"/"),n.maxAge&&(i+="; Max-Age="+Math.floor(n.maxAge)),n.domain&&(i+="; Domain="+n.domain),n.expires&&(i+="; Expires="+n.expires.toUTCString()),n.httpOnly&&(i+="; HttpOnly"),n.secure&&(i+="; Secure"),n.sameSite)switch("string"==typeof n.sameSite?n.sameSite.toLowerCase():n.sameSite){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return i}var l;function d(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 h(e,t){return Array.from(e.attributes).forEach((function(e){t.setAttribute(e.nodeName,e.nodeValue)}))}function f(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");h(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 m=function(e){return e&&decodeURIComponent(o().document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null},g=function(e,t,n){void 0===n&&(n={}),o().document.cookie=p(e,t,n)},_=function(e,t){void 0===t&&(t="/"),document.cookie=e+"= ; expires = Thu, 01 Jan 1970 00:00:00 GMT"+(t?"; path = "+t:"")},v=function(){return Math.random().toString(36).substring(2,12)},y=function(){return Math.random().toString(36).substring(2,7)},b={utm_source:"source",utm_medium:"medium",utm_campaign:"campaign",utm_term:"term",utm_content:"content"},w={gclid:!0,fbclid:!0,dclid:!0};var k=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}(),P="1.0.0";const x=Array.prototype,O=Function.prototype,C=Object.prototype,A=x.slice,I=C.toString,E=C.hasOwnProperty,N="undefined"!=typeof window?window:{},T=N.navigator||{userAgent:""},U=N.document||{},$=T.userAgent,j=O.bind,D=x.forEach,M=x.indexOf,B=Array.isArray,F={};var z={trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},R=function(){if(!z.isUndefined(window.console)&&window.console){var e=["UserMaven error:",...arguments];try{window.console.error.apply(window.console,e)}catch(t){z.each(e,(function(e){window.console.error(e)}))}}};z.bind=function(e,t){var n,r;if(j&&e.bind===j)return j.apply(e,A.call(arguments,1));if(!z.isFunction(e))throw new TypeError;return n=A.call(arguments,2),r=function(){if(!(this instanceof r))return e.apply(t,n.concat(A.call(arguments)));var i={};i.prototype=e.prototype;var o=new i;i.prototype=null;var s=e.apply(o,n.concat(A.call(arguments)));return Object(s)===s?s:o},r},z.bind_instance_methods=function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=z.bind(e[t],e))},z.each=function(e,t,n){if(null!=e)if(D&&e.forEach===D)e.forEach(t,n);else if(e.length===+e.length){for(var r=0,i=e.length;r<i;r++)if(r in e&&t.call(n,e[r],r,e)===F)return}else for(var o in e)if(E.call(e,o)&&t.call(n,e[o],o,e)===F)return},z.extend=function(e){return z.each(A.call(arguments,1),(function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])})),e},z.isArray=B||function(e){return"[object Array]"===I.call(e)},z.isFunction=function(e){try{return/^\s*\bfunction\b/.test(e)}catch(e){return!1}},z.include=function(e,t){var n=!1;return null===e?n:M&&e.indexOf===M?-1!=e.indexOf(t):(z.each(e,(function(e){if(n||(n=e===t))return F})),n)},z.includes=function(e,t){return-1!==e.indexOf(t)},z.isObject=function(e){return e===Object(e)&&!z.isArray(e)},z.isEmptyObject=function(e){if(z.isObject(e)){for(var t in e)if(E.call(e,t))return!1;return!0}return!1},z.isUndefined=function(e){return void 0===e},z.isString=function(e){return"[object String]"==I.call(e)},z.isDate=function(e){return"[object Date]"==I.call(e)},z.isNumber=function(e){return"[object Number]"==I.call(e)},z.encodeDates=function(e){return z.each(e,(function(t,n){z.isDate(t)?e[n]=z.formatDate(t):z.isObject(t)&&(e[n]=z.encodeDates(t))})),e},z.timestamp=function(){return Date.now=Date.now||function(){return+new Date},Date.now()},z.formatDate=function(e){function t(e){return e<10?"0"+e:e}return e.getUTCFullYear()+"-"+t(e.getUTCMonth()+1)+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())},z.safewrap=function(e){return function(){try{return e.apply(this,arguments)}catch(e){R("Implementation error. Please turn on debug and contact support@usermaven.com.")}}},z.safewrap_class=function(e,t){for(var n=0;n<t.length;n++)e.prototype[t[n]]=z.safewrap(e.prototype[t[n]])},z.safewrap_instance_methods=function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=z.safewrap(e[t]))},z.strip_empty_properties=function(e){var t={};return z.each(e,(function(e,n){z.isString(e)&&e.length>0&&(t[n]=e)})),t};const J="undefined"!=typeof Symbol?Symbol("__deepCircularCopyInProgress__"):"__deepCircularCopyInProgress__";function L(e,t){if(e!==Object(e))return t?t(e):e;if(e[J])return;let n;return e[J]=!0,z.isArray(e)?(n=[],z.each(e,(e=>{n.push(L(e,t))}))):(n={},z.each(e,((e,r)=>{r!==J&&(n[r]=L(e,t))}))),delete e[J],n}var q;z.copyAndTruncateStrings=(e,t)=>L(e,(e=>("string"==typeof e&&null!==t&&(e=e.slice(0,t)),e))),z.base64Encode=function(e){var t,n,r,i,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,c=0,u="",p=[];if(!e)return e;e=z.utf8Encode(e);do{t=(o=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,n=o>>12&63,r=o>>6&63,i=63&o,p[c++]=s.charAt(t)+s.charAt(n)+s.charAt(r)+s.charAt(i)}while(a<e.length);switch(u=p.join(""),e.length%3){case 1:u=u.slice(0,-2)+"==";break;case 2:u=u.slice(0,-1)+"="}return u},z.utf8Encode=function(e){var t,n,r,i,o="";for(t=n=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i<r;i++){var s=e.charCodeAt(i),a=null;s<128?n++:a=s>127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==a&&(n>t&&(o+=e.substring(t,n)),o+=a,t=n=i+1)}return n>t&&(o+=e.substring(t,e.length)),o},z.UUID=(q=function(){for(var e=1*new Date,t=0;e==1*new Date;)t++;return e.toString(16)+t.toString(16)},function(){var e=(window.screen.height*window.screen.width).toString(16);return q()+"-"+Math.random().toString(16).replace(".","")+"-"+function(){var e,t,n=$,r=[],i=0;function o(e,t){var n,i=0;for(n=0;n<t.length;n++)i|=r[n]<<8*n;return e^i}for(e=0;e<n.length;e++)t=n.charCodeAt(e),r.unshift(255&t),r.length>=4&&(i=o(i,r),r=[]);return r.length>0&&(i=o(i,r)),i.toString(16)}()+"-"+e+"-"+q()}),z.isBlockedUA=function(e){return!!/(google web preview|baiduspider|yandexbot|bingbot|googlebot|yahoo! slurp)/i.test(e)},z.HTTPBuildQuery=function(e,t){var n,r,i=[];return z.isUndefined(t)&&(t="&"),z.each(e,(function(e,t){n=encodeURIComponent(e.toString()),r=encodeURIComponent(t),i[i.length]=r+"="+n})),i.join(t)},z.getQueryParam=function(e,t){t=t.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(e);if(null===n||n&&"string"!=typeof n[1]&&n[1].length)return"";var r=n[1];try{r=decodeURIComponent(r)}catch(e){}return r.replace(/\+/g," ")},z.getHashParam=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},z.register_event=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,a=!0;return z.isFunction(r)&&(o=r(i)),s=n.call(t,i),!1!==o&&!1!==s||(a=!1),a}}}(t,r,a)}}}(),z.info={campaignParams:function(){var e="utm_source utm_medium utm_campaign utm_content utm_term gclid".split(" "),t="",n={};return z.each(e,(function(e){(t=z.getQueryParam(U.URL,e)).length&&(n[e]=t)})),n},searchEngine:function(e){return 0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null},searchInfo:function(e){var t=z.info.searchEngine(e),n="yahoo"!=t?"q":"p",r={};if(null!==t){r.$search_engine=t;var i=z.getQueryParam(e,n);i.length&&(r.um_keyword=i)}return r},browser:function(e,t,n){return t=t||"",n||z.includes(e," OPR/")?z.includes(e,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":z.includes(e,"IEMobile")||z.includes(e,"WPDesktop")?"Internet Explorer Mobile":z.includes(e,"SamsungBrowser/")?"Samsung Internet":z.includes(e,"Edge")||z.includes(e,"Edg/")?"Microsoft Edge":z.includes(e,"FBIOS")?"Facebook Mobile":z.includes(e,"Chrome")?"Chrome":z.includes(e,"CriOS")?"Chrome iOS":z.includes(e,"UCWEB")||z.includes(e,"UCBrowser")?"UC Browser":z.includes(e,"FxiOS")?"Firefox iOS":z.includes(t,"Apple")?z.includes(e,"Mobile")?"Mobile Safari":"Safari":z.includes(e,"Android")?"Android Mobile":z.includes(e,"Konqueror")?"Konqueror":z.includes(e,"Firefox")?"Firefox":z.includes(e,"MSIE")||z.includes(e,"Trident/")?"Internet Explorer":z.includes(e,"Gecko")?"Mozilla":""},browserVersion:function(e,t,n){var r={"Internet Explorer Mobile":/rv:(\d+(\.\d+)?)/,"Microsoft Edge":/Edge?\/(\d+(\.\d+)?)/,Chrome:/Chrome\/(\d+(\.\d+)?)/,"Chrome iOS":/CriOS\/(\d+(\.\d+)?)/,"UC Browser":/(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,Safari:/Version\/(\d+(\.\d+)?)/,"Mobile Safari":/Version\/(\d+(\.\d+)?)/,Opera:/(Opera|OPR)\/(\d+(\.\d+)?)/,Firefox:/Firefox\/(\d+(\.\d+)?)/,"Firefox iOS":/FxiOS\/(\d+(\.\d+)?)/,Konqueror:/Konqueror:(\d+(\.\d+)?)/,BlackBerry:/BlackBerry (\d+(\.\d+)?)/,"Android Mobile":/android\s(\d+(\.\d+)?)/,"Samsung Internet":/SamsungBrowser\/(\d+(\.\d+)?)/,"Internet Explorer":/(rv:|MSIE )(\d+(\.\d+)?)/,Mozilla:/rv:(\d+(\.\d+)?)/}[z.info.browser(e,t,n)];if(void 0===r)return null;var i=e.match(r);return i?parseFloat(i[i.length-2]):null},os:function(){var e=$;return/Windows/i.test(e)?/Phone/.test(e)||/WPDesktop/.test(e)?"Windows Phone":"Windows":/(iPhone|iPad|iPod)/.test(e)?"iOS":/Android/.test(e)?"Android":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Mac/i.test(e)?"Mac OS X":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"Chrome OS":""},device:function(e){return/Windows Phone/i.test(e)||/WPDesktop/.test(e)?"Windows Phone":/iPad/.test(e)?"iPad":/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Android/.test(e)&&!/Mobile/.test(e)?"Android Tablet":/Android/.test(e)?"Android":""},deviceType:function(e){const t=this.device(e);return"iPad"===t||"Android Tablet"===t?"Tablet":t?"Mobile":"Desktop"},referringDomain:function(e){var t=e.split("/");return t.length>=3?t[2]:""},properties:function(){return z.extend(z.strip_empty_properties({$os:z.info.os(),$browser:z.info.browser($,T.vendor,window.opera),$device:z.info.device($),$device_type:z.info.deviceType($)}),{$current_url:window.location.href,$host:window.location.host,$pathname:window.location.pathname,$browser_version:z.info.browserVersion($,T.vendor,window.opera),$screen_height:window.screen.height,$screen_width:window.screen.width,$viewport_height:window.innerHeight,$viewport_width:window.innerWidth,$lib:"web",$lib_version:P,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:z.timestamp()/1e3})},people_properties:function(){return z.extend(z.strip_empty_properties({$os:z.info.os(),$browser:z.info.browser($,T.vendor,window.opera)}),{$browser_version:z.info.browserVersion($,T.vendor,window.opera)})}},z.isObject=z.isObject,z.isBlockedUA=z.isBlockedUA,z.isEmptyObject=z.isEmptyObject,z.info=z.info,z.info.device=z.info.device,z.info.browser=z.info.browser,z.info.browserVersion=z.info.browserVersion,z.info.properties=z.info.properties;var H=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;const W={get:function(e){try{for(var t=e+"=",n=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){}return null},parse:function(e){var t;try{t=JSON.parse(W.get(e))||{}}catch(e){}return t},set:function(e,t,n,r,i){try{var o="",s="",a="";if(r){var c=document.location.hostname.match(H),u=c?c[0]:"";o=u?"; domain=."+u:""}if(n){var p=new Date;p.setTime(p.getTime()+24*n*60*60*1e3),s="; expires="+p.toGMTString()}i&&(a="; secure");var l=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; path=/"+o+a;return document.cookie=l,l}catch(e){return}},remove:function(e,t){try{W.set(e,"",-1,t)}catch(e){return}}};var V=null;const K={is_supported:function(){if(null!==V)return V;var e=!0;if(window)try{var t="__mplssupport__";K.set(t,"xyz"),'"xyz"'!==K.get(t)&&(e=!1),K.remove(t)}catch(t){e=!1}else e=!1;return V=e,e},error:function(e){},get:function(e){try{return window.localStorage.getItem(e)}catch(e){K.error(e)}return null},parse:function(e){try{return JSON.parse(K.get(e))||{}}catch(e){}return null},set:function(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch(e){K.error(e)}},remove:function(e){try{window.localStorage.removeItem(e)}catch(e){K.error(e)}}},Q={...K,parse:function(e){try{let t={};try{t=W.parse(e)||{},t.distinct_id&&W.set(e,{distinct_id:t.distinct_id})}catch(e){}const n=z.extend(t,JSON.parse(K.get(e)||"{}"));return K.set(e,n),n}catch(e){}return null},set:function(e,t){try{K.set(e,t),t.distinct_id&&W.set(e,{distinct_id:t.distinct_id})}catch(e){K.error(e)}},remove:function(e){try{window.localStorage.removeItem(e),W.remove(e)}catch(e){K.error(e)}}},G={},X={is_supported:function(){return!0},error:function(e){},parse:function(e){return G[e]||null},set:function(e,t){G[e]=t},remove:function(e){delete G[e]}},Y={sessionStorageSupported:null,is_supported:function(){if(null!==Y.sessionStorageSupported)return Y.sessionStorageSupported;if(Y.sessionStorageSupported=!0,window)try{let e="__support__",t="xyz";Y.set(e,t),'"xyz"'!==Y.get(e)&&(Y.sessionStorageSupported=!1),Y.remove(e)}catch(e){Y.sessionStorageSupported=!1}else Y.sessionStorageSupported=!1;return Y.sessionStorageSupported},error:function(e){Config.DEBUG},get:function(e){try{return window.sessionStorage.getItem(e)}catch(e){Y.error(e)}return null},parse:function(e){try{return JSON.parse(Y.get(e))||null}catch(e){}return null},set:function(e,t){try{window.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){Y.error(e)}},remove:function(e){try{window.sessionStorage.removeItem(e)}catch(e){Y.error(e)}}};var Z="__timers",ee="$sesid",te="$enabled_feature_flags",ne=["__mps","__mpso","__mpus","__mpa","__mpap","__mpr","__mpu","__cmpns",Z,"$session_recording_enabled",ee,te],re=function(e){let t="";e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),this.props={},this.campaign_params_saved=!1,e.persistence_name?this.name="um_"+e.persistence_name:this.name="um_"+t+"_usermaven";var n=e.persistence;"cookie"!==n&&-1===n.indexOf("localStorage")&&"memory"!==n&&(R("Unknown persistence type "+n+"; falling back to cookie"),n=e.persistence="cookie"),"localStorage"===n&&K.is_supported()?this.storage=K:"localStorage+cookie"===n&&Q.is_supported()?this.storage=Q:this.storage="memory"===n?X:W,this.load(),this.update_config(e),this.save()};re.prototype.properties=function(){var e={};return z.each(this.props,(function(t,n){if(n===te&&"object"==typeof t)for(var r=Object.keys(t),i=0;i<r.length;i++)e[`$feature/${r[i]}`]=t[r[i]];else z.include(ne,n)||(e[n]=t)})),e},re.prototype.load=function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=z.extend({},e))}},re.prototype.save=function(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure)},re.prototype.remove=function(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)},re.prototype.clear=function(){this.remove(),this.props={}},re.prototype.register_once=function(e,t,n){return!!z.isObject(e)&&(void 0===t&&(t="None"),this.expire_days=void 0===n?this.default_expiry:n,z.each(e,(function(e,n){this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.props[n]=e)}),this),this.save(),!0)},re.prototype.register=function(e,t){return!!z.isObject(e)&&(this.expire_days=void 0===t?this.default_expiry:t,z.extend(this.props,e),this.save(),!0)},re.prototype.unregister=function(e){e in this.props&&(delete this.props[e],this.save())},re.prototype.update_campaign_params=function(){this.campaign_params_saved||(this.register(z.info.campaignParams()),this.campaign_params_saved=!0)},re.prototype.update_search_keyword=function(e){this.register(z.info.searchInfo(e))},re.prototype.update_referrer_info=function(e){this.register_once({$initial_referrer:e||"$direct",$initial_referring_domain:z.info.referringDomain(e)||"$direct"},""),this.register({$referrer:e||this.props.$referrer||"$direct",$referring_domain:z.info.referringDomain(e)||this.props.$referring_domain||"$direct"})},re.prototype.get_referrer_info=function(){return z.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},re.prototype.safe_merge=function(e){return z.each(this.props,(function(t,n){n in e||(e[n]=t)})),e},re.prototype.update_config=function(e){this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie)},re.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},re.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},re.prototype.get_cross_subdomain=function(){return this.cross_subdomain},re.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},re.prototype.set_event_timer=function(e,t){var n=this.props.__timers||{};n[e]=t,this.props.__timers=n,this.save()},re.prototype.remove_event_timer=function(e){var t=(this.props.__timers||{})[e];return z.isUndefined(t)||(delete this.props.__timers[e],this.save()),t};class ie{constructor(e,t){this.persistence=t,this.session_change_threshold=e.persistence_time||1800,this.session_change_threshold*=1e3,e.persistence_name?this.window_id_storage_key="um_"+e.persistence_name+"_window_id":this.window_id_storage_key="um_"+e.token+"_window_id"}_setWindowId(e){e!==this.windowId&&(this.windowId=e,!this.persistence.disabled&&Y.is_supported()&&Y.set(this.window_id_storage_key,e))}_getWindowId(){return this.windowId?this.windowId:!this.persistence.disabled&&Y.is_supported()?Y.parse(this.window_id_storage_key):null}_setSessionId(e,t){e===this.sessionId&&t===this.timestamp||(this.timestamp=t,this.sessionId=e,this.persistence.register({[ee]:[t,e]}))}_getSessionId(){return this.sessionId&&this.timestamp?[this.timestamp,this.sessionId]:this.persistence.props.$sesid||[0,null]}resetSessionId(){this._setSessionId(null,null)}getSessionAndWindowId(e=null,t=!1){if(this.persistence.disabled)return{};e=e||(new Date).getTime();let[n,r]=this._getSessionId(),i=this._getWindowId();!r||Math.abs(e-n)>this.session_change_threshold?(r=z.UUID(),i=z.UUID()):i||(i=z.UUID());const o=e;return this._setWindowId(i),this._setSessionId(r,o),{session_id:r,window_id:i}}}function oe(e){switch(typeof e.className){case"string":return e.className;case"object":return e.className.baseVal||e.getAttribute("class")||"";default:return""}}function se(e){var t="";return le(e)&&!de(e)&&e.childNodes&&e.childNodes.length&&z.each(e.childNodes,(function(e){ue(e)&&e.textContent&&(t+=z.trim(e.textContent).split(/(\s+)/).filter(he).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))})),z.trim(t)}function ae(e){return e&&1===e.nodeType}function ce(e,t){return e&&e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function ue(e){return e&&3===e.nodeType}var pe=["a","button","form","input","select","textarea","label"];function le(e){for(var t=e;t.parentNode&&!ce(t,"body");t=t.parentNode){var n=oe(t).split(" ");if(z.includes(n,"um-sensitive")||z.includes(n,"um-no-capture"))return!1}if(z.includes(oe(e).split(" "),"um-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 de(e){return!!(ce(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||ce(e,"select")||ce(e,"textarea")||"true"===e.getAttribute("contenteditable"))}function he(e){if(null===e||z.isUndefined(e))return!1;if("string"==typeof e){e=z.trim(e);if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((e||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(e))return!1}return!0}class fe{constructor(e,t=e.get_config("rageclick")){this.clicks=[],this.instance=e,this.enabled=t}click(e,t,n){if(!this.enabled)return;const 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}]}}var me={_initializedTokens:[],_previousElementSibling:function(e){if(e.previousElementSibling)return e.previousElementSibling;do{e=e.previousSibling}while(e&&!ae(e));return e},_getPropertiesFromElement:function(e,t,n){var r=e.tagName.toLowerCase(),i={tag_name:r};pe.indexOf(r)>-1&&!n&&(i.$el_text=se(e));var o=oe(e);o.length>0&&(i.classes=o.split(" ").filter((function(e){return""!==e}))),z.each(e.attributes,(function(n){var r;de(e)&&-1===["name","id","class"].indexOf(n.name)||!t&&he(n.value)&&("string"!=typeof(r=n.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))&&!function(e){return"string"==typeof e&&e.startsWith("data-")}(n.name)&&(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 z.each(document.querySelectorAll(e.css_selector),(function(e){var n;["input","select"].indexOf(e.tagName.toLowerCase())>-1?n=e.value:e.textContent&&(n=e.textContent),he(n)&&t.push(n)})),t.join(", ")},_getCustomProperties:function(e){var t={};return z.each(this._customProperties,(function(n){z.each(n.event_selectors,(function(r){var i=document.querySelectorAll(r);z.each(i,(function(r){z.includes(e,r)&&le(r)&&(t[n.name]=this._extractCustomPropertyValue(n))}),this)}),this)}),this),t},_getEventTarget:function(e){return void 0===e.target?e.srcElement:e.target.shadowRoot?e.composedPath()[0]:e.target},_captureEvent:function(e,t){var n=this._getEventTarget(e);if(ue(n)&&(n=n.parentNode),"click"===e.type&&this.rageclicks.click(e.clientX,e.clientY,(new Date).getTime()),function(e,t){if(!e||ce(e,"html")||!ae(e))return!1;for(var n=!1,r=[e],i=!0,o=e;o.parentNode&&!ce(o,"body");)if(11!==o.parentNode.nodeType){if(!(i=o.parentNode))break;if(pe.indexOf(i.tagName.toLowerCase())>-1)n=!0;else{let e=window.getComputedStyle(i);e&&"pointer"===e.getPropertyValue("cursor")&&(n=!0)}r.push(i),o=i}else r.push(o.parentNode.host),o=o.parentNode.host;let s=window.getComputedStyle(e);if(s&&"pointer"===s.getPropertyValue("cursor")&&"click"===t.type)return!0;var a=e.tagName.toLowerCase();switch(a){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&&(pe.indexOf(a)>-1||"true"===e.getAttribute("contenteditable"))}}(n,e)){for(var r=[n],i=n;i.parentNode&&!ce(i,"body");)11!==i.parentNode.nodeType?(r.push(i.parentNode),i=i.parentNode):(r.push(i.parentNode.host),i=i.parentNode.host);var o,s=[],a=!1;if(z.each(r,(function(e){var n=le(e);"a"===e.tagName.toLowerCase()&&(o=e.getAttribute("href"),o=n&&he(o)&&o);var r=oe(e).split(" ");z.includes(r,"um-no-capture")&&(a=!0),s.push(this._getPropertiesFromElement(e,t.get_config("mask_all_element_attributes"),t.get_config("mask_all_text")))}),this),t.get_config("mask_all_text")||(s[0].$el_text=se(n)),o&&(s[0].attr__href=o),a)return!1;var c=z.extend(this._getDefaultProperties(e.type),{$elements:s},this._getCustomProperties(r));return t.capture("$autocapture",c),!0}},_navigate:function(e){window.location.href=e},_addDomEventHandlers:function(e){var t=z.bind((function(t){t=t||window.event,this._captureEvent(t,e)}),this);z.register_event(document,"submit",t,!1,!0),z.register_event(document,"change",t,!1,!0),z.register_event(document,"click",t,!1,!0)},_customProperties:{},init:function(e){var t=e.get_config("token");console.log('Initializing autocapture for token "'+t+'"'),this._initializedTokens.indexOf(t)>-1?console.log('autocapture already initialized for token "'+t+'"'):(this._initializedTokens.push(t),e.get_config("autocapture")?this._addDomEventHandlers(e):e.__autocapture_enabled=!1,this.rageclicks=new fe(e))},enabledForProject:function(e,t,n){t=z.isUndefined(t)?10:t,n=z.isUndefined(n)?10:n;for(var r=0,i=0;i<e.length;i++)r+=e.charCodeAt(i);return r%t<n},isBrowserSupported:function(){return z.isFunction(document.querySelectorAll)}};z.bind_instance_methods(me),z.safewrap_instance_methods(me);var ge="__buildEnv__",_e="__buildDate__",ve="".concat("__buildVersion__","/").concat(ge,"@").concat(_e),ye=316224e3,be=function(e,t){c().debug("Sending beacon",t);var n=new Blob([t],{type:"text/plain"});return navigator.sendBeacon(e,n),Promise.resolve()};var we=function(e,t){return console.log("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 ke(e,t){void 0===t&&(t=void 0),""!=(t=null!=t?t:window.location.pathname)&&"/"!=t&&(_(e,t),ke(e,t.slice(0,t.lastIndexOf("/"))))}var Se=function(){function e(e,t){this.cookieDomain=e,this.cookieName=t}return e.prototype.save=function(e){g(this.cookieName,JSON.stringify(e),{domain:this.cookieDomain,secure:"http:"!==document.location.protocol,maxAge:ye})},e.prototype.restore=function(){ke(this.cookieName);var e=m(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(){_(this.cookieName)},e}(),Pe=function(){function e(){}return e.prototype.save=function(e){},e.prototype.restore=function(){},e.prototype.delete=function(){},e}();var xe={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;ke(t);var r=m(t);if(r)return c().debug("Existing user id",r),r;var i=v();return c().debug("New user id",i),g(t,i,{domain:n,secure:"http:"!==document.location.protocol,maxAge:ye}),i}};var Oe={getSourceIp:function(){},describeClient:function(){return{}},getAnonymousId:function(){return""}},Ce=function(){return xe},Ae=function(){return Oe},Ie=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(e){c().error("Failed to send",t,e),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)}))},Ee=function(){function r(){this.userProperties={},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=Ie,this.customHeaders=function(){return{}},this.queue=new k,this.maxSendAttempts=4,this.retryTimeout=[500,1e12],this.flushing=!1,this.attempt=1,this.__autocapture_enabled=!1}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.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()?Ce():Ae()),this.restoreId();var c=this.getCtx(s),u=e(e({},this.permanentProperties.globalProps),null!==(o=this.permanentProperties.propsPerEvent[t])&&void 0!==o?o:{}),p=e({api_key:this.apiKey,src:n,event_type:t},a),l=s.getSourceIp();return l&&(p.source_ip=l),this.compatMode?e(e(e({},u),{eventn_ctx:c}),p):e(e(e({},u),c),p)},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 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]}}))}))},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(y(),"?p_").concat(y(),"=").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(),(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(),_(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,p=a.id,l=a.value;if("tag"===u){var d=document.createElement("div");d.id=p,f(d,l),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="keep"!==this.cookiePolicy?{session_id:"",window_id:""}:this.sessionManager.getSessionAndWindowId(),o=i.session_id,s=i.window_id,a=this.userProperties.company||{};delete this.userProperties.company;var c,u,p=e(e({event_id:"",session_id:o,window_id:s,user:e({anonymous_id:"strict"!==this.cookiePolicy?t.getAnonymousId({name:this.idCookieName,domain:this.cookieDomain}):""},this.userProperties),ids:this._getIds(),utc_time:(c=n.toISOString(),u=c.split(".")[1],u?u.length>=7?c:c.slice(0,-1)+"0".repeat(7-u.length)+"Z":c),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=b[n];i?t.utm[i]=r:w[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(a).length&&(p.company=a),p},r.prototype._getIds=function(){if(!i())return{};for(var e=function(e){if(void 0===e&&(e=!1),e&&l)return l;var t=d(document.cookie);return l=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.track=function(e,t){var n=t||{};c().debug("track event of type",e,n);var r=this.makeEvent(e,this.compatMode?"eventn":"usermaven",t||{});return this.sendJson(r)},r.prototype.init=function(r){var o,p,l,d,h,f,m,g=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?be:Ie;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=(h=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;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,h(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:throw a=n.sent(),c().error("Failed to send",i,a),s(-1,{}),new Error("Failed to send JSON. See console logs");case 3:if(200!==t.status)throw c().warn("Failed to send data to ".concat(r," (#").concat(t.status," - ").concat(t.statusText,")"),i),new Error("Failed to send JSON. Error code: ".concat(t.status,". See logs for details"));return[4,t.json()];case 4:return u=n.sent(),s(t.status,u),[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=we),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&&(f=r.log_level,(m=s[f.toLocaleUpperCase()])||(console.warn("Can't find log level with name ".concat(f.toLocaleUpperCase(),", defaulting to INFO")),m=s.INFO),a=u(m)),this.initialOptions=r,c().debug("Initializing Usemaven Tracker tracker",r,ve),r.key){if(this.compatMode=void 0!==r.compat_mode&&!!r.compat_mode,this.cookieDomain=r.cookie_domain||function(){if(i())return".".concat((e=location.hostname,t=function(e){return(e.indexOf("//")>-1?e.split("/")[2]:e.split("/")[0]).split(":")[0].split("?")[0]}(e),n=t.split("."),(r=n.length)>2&&(t=n[r-2]+"."+n[r-1],2==n[r-2].length&&2==n[r-1].length&&(t=n[r-3]+"."+t)),t));var e,t,n,r}(),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:"//"+e}(r.tracking_host||"t.usermaven.com"),this.randomizeUrl=r.randomize_url||!1,this.idCookieName=r.cookie_name||"__eventn_id",this.apiKey=r.key,"strict"===this.cookiePolicy?this.propsPersistance=new Pe:this.propsPersistance=i()?new Se(this.cookieDomain,this.idCookieName+"_props"):new Pe,"strict"===this.cookiePolicy?this.userIdPersistence=new Pe:this.userIdPersistence=i()?new Se(this.cookieDomain,this.idCookieName+"_usr"):new Pe,this.propsPersistance){var _=this.propsPersistance.restore();_&&(this.permanentProperties=_,this.permanentProperties.globalProps=null!==(o=_.globalProps)&&void 0!==o?o:{},this.permanentProperties.propsPerEvent=null!==(p=_.propsPerEvent)&&void 0!==p?p:{}),c().debug("Restored persistent properties",this.permanentProperties)}this.config=z.extend({},{persistence:"cookie",persistence_name:"session",autocapture:!1,capture_pageview:!0,store_google:!1,save_referrer:!1,properties_string_max_length:null,property_blacklist:[],sanitize_properties:null},r||{},this.config||{},{token:this.apiKey}),c().debug("Default Configuration",this.config),this.manageSession(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 g._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 g.flush()}))),this.retryTimeout=[null!==(l=r.min_send_timeout)&&void 0!==l?l:this.retryTimeout[0],null!==(d=r.max_send_timeout)&&void 0!==d?d: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.manageSession=function(e){c().debug("Options",e),e=e||{},c().debug("Options",e);var t={persistence:e.persistence||"cookie",persistence_name:e.persistence_name||"session",cross_subdomain_cookie:e.cross_subdomain_cookie||!0};this.config=z.extend(t,this.config||{},{token:this.apiKey}),c().debug("Default Configuration",this.config),this.persistence=new re(this.config),c().debug("Persistence Configuration",this.persistence),this.sessionManager=new ie(this.config,this.persistence),c().debug("Session Configuration",this.sessionManager)},r.prototype.manageAutoCapture=function(e){if(c().debug("Auto Capture Status: ",this.config.autocapture),this.__autocapture_enabled=this.config.autocapture,this.__autocapture_enabled){me.enabledForProject(this.apiKey,100,100)?me.isBrowserSupported()?me.init(this):(this.config.autocapture=!1,console.log("Disabling Automatic Event Collection because this browser is not supported")):(this.config.autocapture=!1,console.log("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(z.isUndefined(e)||"string"!=typeof e)console.error("No event name provided to posthog.capture");else if(!z.isBlockedUA($)){var i=this.persistence.remove_event_timer(e);this.persistence.update_search_keyword(document.referrer),this.get_config("store_google")&&this.persistence.update_campaign_params(),this.get_config("save_referrer")&&this.persistence.update_referrer_info(document.referrer);var o={event:e+(t.$event_type?"_"+t.$event_type:""),properties:this._calculate_event_properties(e,t,i)};(null===(r=null===(n=(o=z.copyAndTruncateStrings(o,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",o.properties)}}else console.error("Trying to capture event before initialization")},r.prototype._calculate_event_properties=function(e,t,n){var r,i,o=t||{};if("$snapshot"===e)return o;if(!z.isUndefined(n)){var s=(new Date).getTime()-n;o.$duration=parseFloat((s/1e3).toFixed(3))}o=z.extend({},this.persistence.properties(),o);var a=this.get_config("property_blacklist");z.isArray(a)?z.each(a,(function(e){delete o[e]})):console.error("Invalid value for property_blacklist config: "+a);var c=this.get_config("sanitize_properties");c&&(o=c(o,e));var u={},p=o.$elements||[];return p.length&&(u=p[0]),o.autocapture_attributes=u,o.autocapture_attributes.el_text=null!==(r=o.autocapture_attributes.$el_text)&&void 0!==r?r:"",o.autocapture_attributes.event_type=null!==(i=o.$event_type)&&void 0!==i?i:"",delete o.$ce_version,delete o.$event_type,delete o.$initial_referrer,delete o.$initial_referring_domain,delete o.$referrer,delete o.$referring_domain,delete o.$elements,delete o.autocapture_attributes.$el_text,delete o.autocapture_attributes.nth_child,delete o.autocapture_attributes.nth_of_type,o},r.prototype._handle_unload=function(){this.get_config("capture_pageview")&&this.capture("$pageleave")},r}();var Ne=["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","persistence","persistence_name","project_id","cross_subdomain_cookie","persistence_time","disable_persistence","autocapture","capture_pageview","properties_string_max_length","property_blacklist"];var Te="data-suppress-interception-warning";function Ue(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(Te,'="true"\n script attribute\n ')}function $e(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 je=window,De=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};Ne.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 Ee;return t.init(e),t}(r),!r.segment_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(Te)||c().warn(Ue("segment")),!r.ga_hook||null===t.getAttribute("defer")&&null===t.getAttribute("async")||null!==t.getAttribute(Te)||c().warn(Ue("ga"));var i=function(){var t=e.usermavenQ=e.usermavenQ||[];t.push(arguments),$e(t,e.usermavenClient)};return e.usermaven=i,console.log(r),r.project_id&&i("set",{project_id:r.project_id}),"true"!==t.getAttribute("data-init-only")&&"yes"!==t.getAttribute("data-init-only")&&(Object.keys(r).includes("capture_pageview")&&!r.capture_pageview||i("track","pageview")),e.usermavenClient}c().warn("Usermaven script is not properly initialized. The definition must contain data-usermaven-api-key as a parameter")}(je);De?(c().debug("Usermaven in-browser tracker has been initialized"),je.usermaven=function(){var e=je.usermavenQ=je.usermavenQ||[];e.push(arguments),$e(e,De)},je.usermavenQ&&(c().debug("Initial queue size of ".concat(je.usermavenQ.length," will be processed")),$e(je.usermavenQ,De))):c().error("Usermaven tracker has not been initialized (reason unknown)")}else c().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.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Usermaven JavaScript SDK.",
5
5
  "main": "dist/npm/usermaven.cjs.js",
6
6
  "module": "dist/npm/dist/usermaven.es.js",