stream-engine-player 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
@@ -5658,7 +5658,7 @@ var require_stream_engine_player = __commonJS({
|
|
5658
5658
|
}
|
5659
5659
|
return _this;
|
5660
5660
|
}
|
5661
|
-
TimelineController2.prototype.addCues = function(trackName, startTime2, endTime,
|
5661
|
+
TimelineController2.prototype.addCues = function(trackName, startTime2, endTime, screen2) {
|
5662
5662
|
var ranges = this.cueRanges;
|
5663
5663
|
var merged = false;
|
5664
5664
|
for (var i2 = ranges.length; i2--; ) {
|
@@ -5676,7 +5676,7 @@ var require_stream_engine_player = __commonJS({
|
|
5676
5676
|
if (!merged) {
|
5677
5677
|
ranges.push([startTime2, endTime]);
|
5678
5678
|
}
|
5679
|
-
this.Cues.newCue(this.captionsTracks[trackName], startTime2, endTime,
|
5679
|
+
this.Cues.newCue(this.captionsTracks[trackName], startTime2, endTime, screen2);
|
5680
5680
|
};
|
5681
5681
|
TimelineController2.prototype.onInitPtsFound = function(data) {
|
5682
5682
|
var _this = this;
|
@@ -6319,7 +6319,7 @@ var require_stream_engine_player = __commonJS({
|
|
6319
6319
|
var errors_1 = __webpack_require__("./src/errors.js");
|
6320
6320
|
var events_1 = __webpack_require__("./src/events.js");
|
6321
6321
|
function getAudioConfig(observer, data, offset, audioCodec) {
|
6322
|
-
var adtsObjectType, adtsSampleingIndex, adtsExtensionSampleingIndex, adtsChanelConfig, config,
|
6322
|
+
var adtsObjectType, adtsSampleingIndex, adtsExtensionSampleingIndex, adtsChanelConfig, config, userAgent2 = navigator.userAgent.toLowerCase(), manifestCodec = audioCodec, adtsSampleingRates = [
|
6323
6323
|
96e3,
|
6324
6324
|
88200,
|
6325
6325
|
64e3,
|
@@ -6343,7 +6343,7 @@ var require_stream_engine_player = __commonJS({
|
|
6343
6343
|
adtsChanelConfig = (data[offset + 2] & 1) << 2;
|
6344
6344
|
adtsChanelConfig |= (data[offset + 3] & 192) >>> 6;
|
6345
6345
|
logger_1.logger.log("manifest codec:" + audioCodec + ",ADTS data:type:" + adtsObjectType + ",sampleingIndex:" + adtsSampleingIndex + "[" + adtsSampleingRates[adtsSampleingIndex] + "Hz],channelConfig:" + adtsChanelConfig);
|
6346
|
-
if (/firefox/i.test(
|
6346
|
+
if (/firefox/i.test(userAgent2)) {
|
6347
6347
|
if (adtsSampleingIndex >= 6) {
|
6348
6348
|
adtsObjectType = 5;
|
6349
6349
|
config = new Array(4);
|
@@ -6353,7 +6353,7 @@ var require_stream_engine_player = __commonJS({
|
|
6353
6353
|
config = new Array(2);
|
6354
6354
|
adtsExtensionSampleingIndex = adtsSampleingIndex;
|
6355
6355
|
}
|
6356
|
-
} else if (
|
6356
|
+
} else if (userAgent2.indexOf("android") !== -1) {
|
6357
6357
|
adtsObjectType = 2;
|
6358
6358
|
config = new Array(2);
|
6359
6359
|
adtsExtensionSampleingIndex = adtsSampleingIndex;
|
@@ -6363,7 +6363,7 @@ var require_stream_engine_player = __commonJS({
|
|
6363
6363
|
if (audioCodec && (audioCodec.indexOf("mp4a.40.29") !== -1 || audioCodec.indexOf("mp4a.40.5") !== -1) || !audioCodec && adtsSampleingIndex >= 6) {
|
6364
6364
|
adtsExtensionSampleingIndex = adtsSampleingIndex - 3;
|
6365
6365
|
} else {
|
6366
|
-
if (audioCodec && audioCodec.indexOf("mp4a.40.2") !== -1 && (adtsSampleingIndex >= 6 && adtsChanelConfig === 1 || /vivaldi/i.test(
|
6366
|
+
if (audioCodec && audioCodec.indexOf("mp4a.40.2") !== -1 && (adtsSampleingIndex >= 6 && adtsChanelConfig === 1 || /vivaldi/i.test(userAgent2)) || !audioCodec && adtsChanelConfig === 1) {
|
6367
6367
|
adtsObjectType = 2;
|
6368
6368
|
config = new Array(2);
|
6369
6369
|
}
|
@@ -11266,8 +11266,8 @@ var require_stream_engine_player = __commonJS({
|
|
11266
11266
|
this.observer = observer;
|
11267
11267
|
this.config = config;
|
11268
11268
|
this.typeSupported = typeSupported;
|
11269
|
-
var
|
11270
|
-
this.isSafari = vendor && vendor.indexOf("Apple") > -1 &&
|
11269
|
+
var userAgent2 = navigator.userAgent;
|
11270
|
+
this.isSafari = vendor && vendor.indexOf("Apple") > -1 && userAgent2 && !userAgent2.match("CriOS");
|
11271
11271
|
this.ISGenerated = false;
|
11272
11272
|
}
|
11273
11273
|
MP4Remuxer2.prototype.destroy = function() {
|
@@ -12618,8 +12618,8 @@ var require_stream_engine_player = __commonJS({
|
|
12618
12618
|
for (var i2 = 0; i2 < chars.length; i2++) {
|
12619
12619
|
this.writeScreen.insertChar(chars[i2]);
|
12620
12620
|
}
|
12621
|
-
var
|
12622
|
-
logger2.log("INFO",
|
12621
|
+
var screen2 = this.writeScreen === this.displayedMemory ? "DISP" : "NON_DISP";
|
12622
|
+
logger2.log("INFO", screen2 + ": " + this.writeScreen.getDisplayText(true));
|
12623
12623
|
if (this.mode === "MODE_PAINT-ON" || this.mode === "MODE_ROLL-UP") {
|
12624
12624
|
logger2.log("TEXT", "DISPLAYED: " + this.displayedMemory.getDisplayText(true));
|
12625
12625
|
this.outputDataUpdate();
|
@@ -13416,12 +13416,12 @@ var require_stream_engine_player = __commonJS({
|
|
13416
13416
|
this.timelineController.addCues(this.trackName, this.startTime, this.endTime, this.screen);
|
13417
13417
|
this.startTime = null;
|
13418
13418
|
};
|
13419
|
-
OutputFilter2.prototype.newCue = function(startTime2, endTime,
|
13419
|
+
OutputFilter2.prototype.newCue = function(startTime2, endTime, screen2) {
|
13420
13420
|
if (this.startTime === null || this.startTime > startTime2) {
|
13421
13421
|
this.startTime = startTime2;
|
13422
13422
|
}
|
13423
13423
|
this.endTime = endTime;
|
13424
|
-
this.screen =
|
13424
|
+
this.screen = screen2;
|
13425
13425
|
this.timelineController.createCaptionsTrack(this.trackName);
|
13426
13426
|
};
|
13427
13427
|
return OutputFilter2;
|
@@ -14283,17 +14283,17 @@ var require_stream_engine_player = __commonJS({
|
|
14283
14283
|
});
|
14284
14284
|
})(hls);
|
14285
14285
|
const Hls$2 = /* @__PURE__ */ getDefaultExportFromCjs(hls.exports);
|
14286
|
-
var win$
|
14286
|
+
var win$3;
|
14287
14287
|
if (typeof window !== "undefined") {
|
14288
|
-
win$
|
14288
|
+
win$3 = window;
|
14289
14289
|
} else if (typeof commonjsGlobal !== "undefined") {
|
14290
|
-
win$
|
14290
|
+
win$3 = commonjsGlobal;
|
14291
14291
|
} else if (typeof self !== "undefined") {
|
14292
|
-
win$
|
14292
|
+
win$3 = self;
|
14293
14293
|
} else {
|
14294
|
-
win$
|
14294
|
+
win$3 = {};
|
14295
14295
|
}
|
14296
|
-
var window_1$1 = win$
|
14296
|
+
var window_1$1 = win$3;
|
14297
14297
|
const __viteBrowserExternal = {};
|
14298
14298
|
const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
14299
14299
|
__proto__: null,
|
@@ -14453,12 +14453,12 @@ var require_stream_engine_player = __commonJS({
|
|
14453
14453
|
})(keycode$1, keycode$1.exports);
|
14454
14454
|
const keycode = keycode$1.exports;
|
14455
14455
|
var isFunction_1 = isFunction$1;
|
14456
|
-
var toString$
|
14456
|
+
var toString$2 = Object.prototype.toString;
|
14457
14457
|
function isFunction$1(fn) {
|
14458
14458
|
if (!fn) {
|
14459
14459
|
return false;
|
14460
14460
|
}
|
14461
|
-
var string = toString$
|
14461
|
+
var string = toString$2.call(fn);
|
14462
14462
|
return string === "[object Function]" || typeof fn === "function" && string !== "[object RegExp]" || typeof window !== "undefined" && (fn === window.setTimeout || fn === window.alert || fn === window.confirm || fn === window.prompt);
|
14463
14463
|
}
|
14464
14464
|
var trim = function(string) {
|
@@ -14485,13 +14485,13 @@ var require_stream_engine_player = __commonJS({
|
|
14485
14485
|
return result;
|
14486
14486
|
};
|
14487
14487
|
var immutable = extend$1;
|
14488
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
14488
|
+
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
14489
14489
|
function extend$1() {
|
14490
14490
|
var target = {};
|
14491
14491
|
for (var i2 = 0; i2 < arguments.length; i2++) {
|
14492
14492
|
var source = arguments[i2];
|
14493
14493
|
for (var key in source) {
|
14494
|
-
if (hasOwnProperty.call(source, key)) {
|
14494
|
+
if (hasOwnProperty$1.call(source, key)) {
|
14495
14495
|
target[key] = source[key];
|
14496
14496
|
}
|
14497
14497
|
}
|
@@ -16247,17 +16247,17 @@ var require_stream_engine_player = __commonJS({
|
|
16247
16247
|
};
|
16248
16248
|
return _extends.apply(this, arguments);
|
16249
16249
|
}
|
16250
|
-
var win$
|
16250
|
+
var win$2;
|
16251
16251
|
if (typeof window !== "undefined") {
|
16252
|
-
win$
|
16252
|
+
win$2 = window;
|
16253
16253
|
} else if (typeof commonjsGlobal !== "undefined") {
|
16254
|
-
win$
|
16254
|
+
win$2 = commonjsGlobal;
|
16255
16255
|
} else if (typeof self !== "undefined") {
|
16256
|
-
win$
|
16256
|
+
win$2 = self;
|
16257
16257
|
} else {
|
16258
|
-
win$
|
16258
|
+
win$2 = {};
|
16259
16259
|
}
|
16260
|
-
var window_1 = win$
|
16260
|
+
var window_1 = win$2;
|
16261
16261
|
var atob$1 = function atob2(s) {
|
16262
16262
|
return window_1.atob ? window_1.atob(s) : Buffer.from(s, "base64").toString("binary");
|
16263
16263
|
};
|
@@ -21392,7 +21392,7 @@ var require_stream_engine_player = __commonJS({
|
|
21392
21392
|
}
|
21393
21393
|
var log = createLogger("VIDEOJS");
|
21394
21394
|
var createLogger$1 = log.createLogger;
|
21395
|
-
var toString = Object.prototype.toString;
|
21395
|
+
var toString$1 = Object.prototype.toString;
|
21396
21396
|
var keys = function keys2(object) {
|
21397
21397
|
return isObject(object) ? Object.keys(object) : [];
|
21398
21398
|
};
|
@@ -21430,7 +21430,7 @@ var require_stream_engine_player = __commonJS({
|
|
21430
21430
|
return !!value && typeof value === "object";
|
21431
21431
|
}
|
21432
21432
|
function isPlain(value) {
|
21433
|
-
return isObject(value) && toString.call(value) === "[object Object]" && value.constructor === Object;
|
21433
|
+
return isObject(value) && toString$1.call(value) === "[object Object]" && value.constructor === Object;
|
21434
21434
|
}
|
21435
21435
|
function computedStyle(el, prop) {
|
21436
21436
|
if (!el || !prop) {
|
@@ -29310,8 +29310,8 @@ var require_stream_engine_player = __commonJS({
|
|
29310
29310
|
};
|
29311
29311
|
_proto.supportsFullScreen = function supportsFullScreen() {
|
29312
29312
|
if (typeof this.el_.webkitEnterFullScreen === "function") {
|
29313
|
-
var
|
29314
|
-
if (/Android/.test(
|
29313
|
+
var userAgent2 = window_1$1.navigator && window_1$1.navigator.userAgent || "";
|
29314
|
+
if (/Android/.test(userAgent2) || !/Chrome|Mac OS X 10.5/.test(userAgent2)) {
|
29315
29315
|
return true;
|
29316
29316
|
}
|
29317
29317
|
}
|
@@ -31593,7 +31593,7 @@ var require_stream_engine_player = __commonJS({
|
|
31593
31593
|
};
|
31594
31594
|
});
|
31595
31595
|
Player.players = {};
|
31596
|
-
var navigator$
|
31596
|
+
var navigator$2 = window_1$1.navigator;
|
31597
31597
|
Player.prototype.options_ = {
|
31598
31598
|
techOrder: Tech.defaultTechOrder_,
|
31599
31599
|
html5: {},
|
@@ -31602,7 +31602,7 @@ var require_stream_engine_player = __commonJS({
|
|
31602
31602
|
playbackRates: [],
|
31603
31603
|
liveui: false,
|
31604
31604
|
children: ["mediaLoader", "posterImage", "textTrackDisplay", "loadingSpinner", "bigPlayButton", "liveTracker", "controlBar", "errorDisplay", "textTrackSettings", "resizeManager"],
|
31605
|
-
language: navigator$
|
31605
|
+
language: navigator$2 && (navigator$2.languages && navigator$2.languages[0] || navigator$2.userLanguage || navigator$2.language) || "en",
|
31606
31606
|
languages: {},
|
31607
31607
|
notSupportedMessage: "No compatible source was found for this media.",
|
31608
31608
|
fullscreen: {
|
@@ -33314,7 +33314,7 @@ var require_stream_engine_player = __commonJS({
|
|
33314
33314
|
}
|
33315
33315
|
}
|
33316
33316
|
};
|
33317
|
-
var win = typeof window !== "undefined" ? window : {}, TARGET = typeof Symbol === "undefined" ? "__target" : Symbol(), SCRIPT_TYPE = "application/javascript", BlobBuilder$1 = win.BlobBuilder || win.WebKitBlobBuilder || win.MozBlobBuilder || win.MSBlobBuilder, URL = win.URL || win.webkitURL || URL && URL.msURL, Worker$1 = win.Worker;
|
33317
|
+
var win$1 = typeof window !== "undefined" ? window : {}, TARGET = typeof Symbol === "undefined" ? "__target" : Symbol(), SCRIPT_TYPE = "application/javascript", BlobBuilder$1 = win$1.BlobBuilder || win$1.WebKitBlobBuilder || win$1.MozBlobBuilder || win$1.MSBlobBuilder, URL$1 = win$1.URL || win$1.webkitURL || URL$1 && URL$1.msURL, Worker$1 = win$1.Worker;
|
33318
33318
|
function shimWorker(filename, fn) {
|
33319
33319
|
return function ShimWorker(forceFallback) {
|
33320
33320
|
var o = this;
|
@@ -33359,7 +33359,7 @@ var require_stream_engine_player = __commonJS({
|
|
33359
33359
|
} catch (e) {
|
33360
33360
|
Worker$1 = null;
|
33361
33361
|
} finally {
|
33362
|
-
URL.revokeObjectURL(objURL);
|
33362
|
+
URL$1.revokeObjectURL(objURL);
|
33363
33363
|
if (testWorker) {
|
33364
33364
|
testWorker.terminate();
|
33365
33365
|
}
|
@@ -33367,13 +33367,13 @@ var require_stream_engine_player = __commonJS({
|
|
33367
33367
|
}
|
33368
33368
|
function createSourceObject(str) {
|
33369
33369
|
try {
|
33370
|
-
return URL.createObjectURL(new Blob([str], {
|
33370
|
+
return URL$1.createObjectURL(new Blob([str], {
|
33371
33371
|
type: SCRIPT_TYPE
|
33372
33372
|
}));
|
33373
33373
|
} catch (e) {
|
33374
33374
|
var blob = new BlobBuilder$1();
|
33375
33375
|
blob.append(str);
|
33376
|
-
return URL.createObjectURL(blob.getBlob(type));
|
33376
|
+
return URL$1.createObjectURL(blob.getBlob(type));
|
33377
33377
|
}
|
33378
33378
|
}
|
33379
33379
|
function wrapTerminate(worker, objURL2) {
|
@@ -33383,7 +33383,7 @@ var require_stream_engine_player = __commonJS({
|
|
33383
33383
|
worker.objURL = objURL2;
|
33384
33384
|
worker.terminate = function() {
|
33385
33385
|
if (worker.objURL)
|
33386
|
-
URL.revokeObjectURL(worker.objURL);
|
33386
|
+
URL$1.revokeObjectURL(worker.objURL);
|
33387
33387
|
term.call(worker);
|
33388
33388
|
};
|
33389
33389
|
}
|
@@ -38163,7 +38163,7 @@ var require_stream_engine_player = __commonJS({
|
|
38163
38163
|
};
|
38164
38164
|
MediaSource.open = open;
|
38165
38165
|
MediaSource.supportsNativeMediaSources = supportsNativeMediaSources;
|
38166
|
-
var URL$1 = {
|
38166
|
+
var URL$1$1 = {
|
38167
38167
|
createObjectURL: function createObjectURL(object) {
|
38168
38168
|
var objectUrlPrefix = "blob:vjs-media-source/";
|
38169
38169
|
var url = void 0;
|
@@ -38184,7 +38184,7 @@ var require_stream_engine_player = __commonJS({
|
|
38184
38184
|
}
|
38185
38185
|
};
|
38186
38186
|
videojs$1.MediaSource = MediaSource;
|
38187
|
-
videojs$1.URL = URL$1;
|
38187
|
+
videojs$1.URL = URL$1$1;
|
38188
38188
|
var EventTarget$1$1 = videojs$1.EventTarget, mergeOptions$2 = videojs$1.mergeOptions;
|
38189
38189
|
var updateMaster$1 = function updateMaster$$1(oldMaster, newMaster) {
|
38190
38190
|
var noChanges = void 0;
|
@@ -38691,7 +38691,7 @@ var require_stream_engine_player = __commonJS({
|
|
38691
38691
|
}]);
|
38692
38692
|
return DashPlaylistLoader2;
|
38693
38693
|
}(EventTarget$1$1);
|
38694
|
-
var logger = function logger2(source) {
|
38694
|
+
var logger$3 = function logger2(source) {
|
38695
38695
|
if (videojs$1.log.debug) {
|
38696
38696
|
return videojs$1.log.debug.bind(videojs$1, "VHS:", source + " >");
|
38697
38697
|
}
|
@@ -38710,7 +38710,7 @@ var require_stream_engine_player = __commonJS({
|
|
38710
38710
|
this.processedAppend_ = false;
|
38711
38711
|
this.type_ = type2;
|
38712
38712
|
this.mimeType_ = mimeType;
|
38713
|
-
this.logger_ = logger("SourceUpdater[" + type2 + "][" + mimeType + "]");
|
38713
|
+
this.logger_ = logger$3("SourceUpdater[" + type2 + "][" + mimeType + "]");
|
38714
38714
|
if (mediaSource.readyState === "closed") {
|
38715
38715
|
mediaSource.addEventListener("sourceopen", this.createSourceBuffer_.bind(this, mimeType, sourceBufferEmitter));
|
38716
38716
|
} else {
|
@@ -38854,7 +38854,7 @@ var require_stream_engine_player = __commonJS({
|
|
38854
38854
|
}]);
|
38855
38855
|
return SourceUpdater2;
|
38856
38856
|
}();
|
38857
|
-
var Config = {
|
38857
|
+
var Config$1 = {
|
38858
38858
|
GOAL_BUFFER_LENGTH: 30,
|
38859
38859
|
MAX_GOAL_BUFFER_LENGTH: 60,
|
38860
38860
|
GOAL_BUFFER_LENGTH_RATE: 1,
|
@@ -39169,7 +39169,7 @@ var require_stream_engine_player = __commonJS({
|
|
39169
39169
|
});
|
39170
39170
|
}
|
39171
39171
|
var bandwidthPlaylistReps = enabledPlaylistReps.filter(function(rep) {
|
39172
|
-
return rep.bandwidth * Config.BANDWIDTH_VARIANCE < playerBandwidth;
|
39172
|
+
return rep.bandwidth * Config$1.BANDWIDTH_VARIANCE < playerBandwidth;
|
39173
39173
|
});
|
39174
39174
|
var highestRemainingBandwidthRep = bandwidthPlaylistReps[bandwidthPlaylistReps.length - 1];
|
39175
39175
|
var bandwidthBestRep = bandwidthPlaylistReps.filter(function(rep) {
|
@@ -39402,7 +39402,7 @@ var require_stream_engine_player = __commonJS({
|
|
39402
39402
|
return _this.ended_ = false;
|
39403
39403
|
});
|
39404
39404
|
_this.fetchAtBuffer_ = false;
|
39405
|
-
_this.logger_ = logger("SegmentLoader[" + _this.loaderType_ + "]");
|
39405
|
+
_this.logger_ = logger$3("SegmentLoader[" + _this.loaderType_ + "]");
|
39406
39406
|
Object.defineProperty(_this, "state", {
|
39407
39407
|
get: function get$$1() {
|
39408
39408
|
return this.state_;
|
@@ -39844,7 +39844,7 @@ var require_stream_engine_player = __commonJS({
|
|
39844
39844
|
if (!switchCandidate.playlist || switchCandidate.playlist.uri === this.playlist_.uri || timeSavedBySwitching < minimumTimeSaving) {
|
39845
39845
|
return false;
|
39846
39846
|
}
|
39847
|
-
this.bandwidth = switchCandidate.playlist.attributes.BANDWIDTH * Config.BANDWIDTH_VARIANCE + 1;
|
39847
|
+
this.bandwidth = switchCandidate.playlist.attributes.BANDWIDTH * Config$1.BANDWIDTH_VARIANCE + 1;
|
39848
39848
|
this.abort();
|
39849
39849
|
this.trigger("earlyabort");
|
39850
39850
|
return true;
|
@@ -40551,7 +40551,7 @@ var require_stream_engine_player = __commonJS({
|
|
40551
40551
|
_this.timelines = [];
|
40552
40552
|
_this.discontinuities = [];
|
40553
40553
|
_this.datetimeToDisplayTime = null;
|
40554
|
-
_this.logger_ = logger("SyncController");
|
40554
|
+
_this.logger_ = logger$3("SyncController");
|
40555
40555
|
return _this;
|
40556
40556
|
}
|
40557
40557
|
createClass(SyncController2, [{
|
@@ -41582,7 +41582,7 @@ var require_stream_engine_player = __commonJS({
|
|
41582
41582
|
loaderStats.forEach(function(stat) {
|
41583
41583
|
_this[stat + "_"] = sumLoaderStat.bind(_this, stat);
|
41584
41584
|
});
|
41585
|
-
_this.logger_ = logger("MPC");
|
41585
|
+
_this.logger_ = logger$3("MPC");
|
41586
41586
|
_this.masterPlaylistLoader_.load();
|
41587
41587
|
return _this;
|
41588
41588
|
}
|
@@ -41786,7 +41786,7 @@ var require_stream_engine_player = __commonJS({
|
|
41786
41786
|
var buffered2 = _this3.tech_.buffered();
|
41787
41787
|
var forwardBuffer = buffered2.length ? buffered2.end(buffered2.length - 1) - _this3.tech_.currentTime() : 0;
|
41788
41788
|
var bufferLowWaterLine = _this3.bufferLowWaterLine();
|
41789
|
-
if (!currentPlaylist.endList || _this3.duration() < Config.MAX_BUFFER_LOW_WATER_LINE || nextPlaylist.attributes.BANDWIDTH < currentPlaylist.attributes.BANDWIDTH || forwardBuffer >= bufferLowWaterLine) {
|
41789
|
+
if (!currentPlaylist.endList || _this3.duration() < Config$1.MAX_BUFFER_LOW_WATER_LINE || nextPlaylist.attributes.BANDWIDTH < currentPlaylist.attributes.BANDWIDTH || forwardBuffer >= bufferLowWaterLine) {
|
41790
41790
|
_this3.masterPlaylistLoader_.media(nextPlaylist);
|
41791
41791
|
}
|
41792
41792
|
_this3.tech_.trigger("bandwidthupdate");
|
@@ -42262,18 +42262,18 @@ var require_stream_engine_player = __commonJS({
|
|
42262
42262
|
key: "goalBufferLength",
|
42263
42263
|
value: function goalBufferLength() {
|
42264
42264
|
var currentTime = this.tech_.currentTime();
|
42265
|
-
var initial = Config.GOAL_BUFFER_LENGTH;
|
42266
|
-
var rate = Config.GOAL_BUFFER_LENGTH_RATE;
|
42267
|
-
var max = Math.max(initial, Config.MAX_GOAL_BUFFER_LENGTH);
|
42265
|
+
var initial = Config$1.GOAL_BUFFER_LENGTH;
|
42266
|
+
var rate = Config$1.GOAL_BUFFER_LENGTH_RATE;
|
42267
|
+
var max = Math.max(initial, Config$1.MAX_GOAL_BUFFER_LENGTH);
|
42268
42268
|
return Math.min(initial + currentTime * rate, max);
|
42269
42269
|
}
|
42270
42270
|
}, {
|
42271
42271
|
key: "bufferLowWaterLine",
|
42272
42272
|
value: function bufferLowWaterLine() {
|
42273
42273
|
var currentTime = this.tech_.currentTime();
|
42274
|
-
var initial = Config.BUFFER_LOW_WATER_LINE;
|
42275
|
-
var rate = Config.BUFFER_LOW_WATER_LINE_RATE;
|
42276
|
-
var max = Math.max(initial, Config.MAX_BUFFER_LOW_WATER_LINE);
|
42274
|
+
var initial = Config$1.BUFFER_LOW_WATER_LINE;
|
42275
|
+
var rate = Config$1.BUFFER_LOW_WATER_LINE_RATE;
|
42276
|
+
var max = Math.max(initial, Config$1.MAX_BUFFER_LOW_WATER_LINE);
|
42277
42277
|
return Math.min(initial + currentTime * rate, max);
|
42278
42278
|
}
|
42279
42279
|
}]);
|
@@ -42341,7 +42341,7 @@ var require_stream_engine_player = __commonJS({
|
|
42341
42341
|
this.lastRecordedTime = null;
|
42342
42342
|
this.timer_ = null;
|
42343
42343
|
this.checkCurrentTimeTimeout_ = null;
|
42344
|
-
this.logger_ = logger("PlaybackWatcher");
|
42344
|
+
this.logger_ = logger$3("PlaybackWatcher");
|
42345
42345
|
this.logger_("initialize");
|
42346
42346
|
var canPlayHandler = function canPlayHandler2() {
|
42347
42347
|
return _this.monitorCurrentTime_();
|
@@ -42681,7 +42681,7 @@ var require_stream_engine_player = __commonJS({
|
|
42681
42681
|
Object.defineProperty(Hls$1, prop, {
|
42682
42682
|
get: function get$$1() {
|
42683
42683
|
videojs$1.log.warn("using Hls." + prop + " is UNSAFE be sure you know what you are doing");
|
42684
|
-
return Config[prop];
|
42684
|
+
return Config$1[prop];
|
42685
42685
|
},
|
42686
42686
|
set: function set$$1(value) {
|
42687
42687
|
videojs$1.log.warn("using Hls." + prop + " is UNSAFE be sure you know what you are doing");
|
@@ -42689,7 +42689,7 @@ var require_stream_engine_player = __commonJS({
|
|
42689
42689
|
videojs$1.log.warn("value of Hls." + prop + " must be greater than or equal to 0");
|
42690
42690
|
return;
|
42691
42691
|
}
|
42692
|
-
Config[prop] = value;
|
42692
|
+
Config$1[prop] = value;
|
42693
42693
|
}
|
42694
42694
|
});
|
42695
42695
|
});
|
@@ -42915,9 +42915,9 @@ var require_stream_engine_player = __commonJS({
|
|
42915
42915
|
}
|
42916
42916
|
}
|
42917
42917
|
if (typeof this.options_.bandwidth !== "number") {
|
42918
|
-
this.options_.bandwidth = Config.INITIAL_BANDWIDTH;
|
42918
|
+
this.options_.bandwidth = Config$1.INITIAL_BANDWIDTH;
|
42919
42919
|
}
|
42920
|
-
this.options_.enableLowInitialPlaylist = this.options_.enableLowInitialPlaylist && this.options_.bandwidth === Config.INITIAL_BANDWIDTH;
|
42920
|
+
this.options_.enableLowInitialPlaylist = this.options_.enableLowInitialPlaylist && this.options_.bandwidth === Config$1.INITIAL_BANDWIDTH;
|
42921
42921
|
["withCredentials", "limitRenditionByPlayerDimensions", "bandwidth", "smoothQualityChange", "customTagParsers", "customTagMappers", "handleManifestRedirects", "cacheEncryptionKeys"].forEach(function(option) {
|
42922
42922
|
if (typeof _this2.source_[option] !== "undefined") {
|
42923
42923
|
_this2.options_[option] = _this2.source_[option];
|
@@ -43255,7 +43255,7 @@ var require_stream_engine_player = __commonJS({
|
|
43255
43255
|
};
|
43256
43256
|
if (typeof videojs$1.MediaSource === "undefined" || typeof videojs$1.URL === "undefined") {
|
43257
43257
|
videojs$1.MediaSource = MediaSource;
|
43258
|
-
videojs$1.URL = URL$1;
|
43258
|
+
videojs$1.URL = URL$1$1;
|
43259
43259
|
}
|
43260
43260
|
if (MediaSource.supportsNativeMediaSources()) {
|
43261
43261
|
videojs$1.getTech("Html5").registerSourceHandler(HlsSourceHandler, 0);
|
@@ -43277,7 +43277,7 @@ var require_stream_engine_player = __commonJS({
|
|
43277
43277
|
default: videojs$1
|
43278
43278
|
}, Symbol.toStringTag, { value: "Module" }));
|
43279
43279
|
const name$1 = "stream-engine-player";
|
43280
|
-
const version$2 = "0.0.
|
43280
|
+
const version$2 = "0.0.12";
|
43281
43281
|
const description = "Stream engine player";
|
43282
43282
|
const type$1 = "module";
|
43283
43283
|
const files$1 = [
|
@@ -43304,6 +43304,7 @@ var require_stream_engine_player = __commonJS({
|
|
43304
43304
|
"include-media": "^2.0.0",
|
43305
43305
|
localforage: "^1.10.0",
|
43306
43306
|
"m3u8-parser": "^7.1.0",
|
43307
|
+
"mixpanel-browser": "2.52.0",
|
43307
43308
|
"video.js": "7.6.6",
|
43308
43309
|
"videojs-youtube": "^2.6.1",
|
43309
43310
|
"videojs-ima": "1.7.5",
|
@@ -52435,13 +52436,11 @@ var require_stream_engine_player = __commonJS({
|
|
52435
52436
|
}
|
52436
52437
|
let wrapper = document.createElement("div");
|
52437
52438
|
wrapper.className = wrapperClass;
|
52438
|
-
console.log(this.player.tech(true).el_);
|
52439
52439
|
this.player.videoWrapper = wrapAll(this.player.tech(true).el_, [
|
52440
52440
|
".video-js .vjs-mask",
|
52441
52441
|
".video-js .vjs-loading-spinner",
|
52442
52442
|
".video-js .vjs-text-track-display"
|
52443
52443
|
], [wrapper]);
|
52444
|
-
console.log(this.player.videoWrapper);
|
52445
52444
|
}
|
52446
52445
|
},
|
52447
52446
|
wrapControls: function(wrapperClass) {
|
@@ -54931,11 +54930,4308 @@ var require_stream_engine_player = __commonJS({
|
|
54931
54930
|
});
|
54932
54931
|
}();
|
54933
54932
|
})(videojsMux);
|
54934
|
-
|
54935
|
-
|
54936
|
-
|
54937
|
-
|
54938
|
-
|
54933
|
+
var Config = {
|
54934
|
+
DEBUG: false,
|
54935
|
+
LIB_VERSION: "2.52.0"
|
54936
|
+
};
|
54937
|
+
var win;
|
54938
|
+
if (typeof window === "undefined") {
|
54939
|
+
var loc = {
|
54940
|
+
hostname: ""
|
54941
|
+
};
|
54942
|
+
win = {
|
54943
|
+
navigator: { userAgent: "" },
|
54944
|
+
document: {
|
54945
|
+
location: loc,
|
54946
|
+
referrer: ""
|
54947
|
+
},
|
54948
|
+
screen: { width: 0, height: 0 },
|
54949
|
+
location: loc
|
54950
|
+
};
|
54951
|
+
} else {
|
54952
|
+
win = window;
|
54953
|
+
}
|
54954
|
+
var MAX_RECORDING_MS = 24 * 60 * 60 * 1e3;
|
54955
|
+
var ArrayProto = Array.prototype, FuncProto = Function.prototype, ObjProto = Object.prototype, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty, windowConsole = win.console, navigator$1 = win.navigator, document$1 = win.document, windowOpera = win.opera, screen = win.screen, userAgent = navigator$1.userAgent;
|
54956
|
+
var nativeBind = FuncProto.bind, nativeForEach = ArrayProto.forEach, nativeIndexOf = ArrayProto.indexOf, nativeMap = ArrayProto.map, nativeIsArray = Array.isArray, breaker = {};
|
54957
|
+
var _$1 = {
|
54958
|
+
trim: function(str) {
|
54959
|
+
return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
54960
|
+
}
|
54961
|
+
};
|
54962
|
+
var console$1 = {
|
54963
|
+
log: function() {
|
54964
|
+
if (Config.DEBUG && !_$1.isUndefined(windowConsole) && windowConsole) {
|
54965
|
+
try {
|
54966
|
+
windowConsole.log.apply(windowConsole, arguments);
|
54967
|
+
} catch (err) {
|
54968
|
+
_$1.each(arguments, function(arg) {
|
54969
|
+
windowConsole.log(arg);
|
54970
|
+
});
|
54971
|
+
}
|
54972
|
+
}
|
54973
|
+
},
|
54974
|
+
warn: function() {
|
54975
|
+
if (Config.DEBUG && !_$1.isUndefined(windowConsole) && windowConsole) {
|
54976
|
+
var args = ["Mixpanel warning:"].concat(_$1.toArray(arguments));
|
54977
|
+
try {
|
54978
|
+
windowConsole.warn.apply(windowConsole, args);
|
54979
|
+
} catch (err) {
|
54980
|
+
_$1.each(args, function(arg) {
|
54981
|
+
windowConsole.warn(arg);
|
54982
|
+
});
|
54983
|
+
}
|
54984
|
+
}
|
54985
|
+
},
|
54986
|
+
error: function() {
|
54987
|
+
if (Config.DEBUG && !_$1.isUndefined(windowConsole) && windowConsole) {
|
54988
|
+
var args = ["Mixpanel error:"].concat(_$1.toArray(arguments));
|
54989
|
+
try {
|
54990
|
+
windowConsole.error.apply(windowConsole, args);
|
54991
|
+
} catch (err) {
|
54992
|
+
_$1.each(args, function(arg) {
|
54993
|
+
windowConsole.error(arg);
|
54994
|
+
});
|
54995
|
+
}
|
54996
|
+
}
|
54997
|
+
},
|
54998
|
+
critical: function() {
|
54999
|
+
if (!_$1.isUndefined(windowConsole) && windowConsole) {
|
55000
|
+
var args = ["Mixpanel error:"].concat(_$1.toArray(arguments));
|
55001
|
+
try {
|
55002
|
+
windowConsole.error.apply(windowConsole, args);
|
55003
|
+
} catch (err) {
|
55004
|
+
_$1.each(args, function(arg) {
|
55005
|
+
windowConsole.error(arg);
|
55006
|
+
});
|
55007
|
+
}
|
55008
|
+
}
|
55009
|
+
}
|
55010
|
+
};
|
55011
|
+
var log_func_with_prefix = function(func, prefix) {
|
55012
|
+
return function() {
|
55013
|
+
arguments[0] = "[" + prefix + "] " + arguments[0];
|
55014
|
+
return func.apply(console$1, arguments);
|
55015
|
+
};
|
55016
|
+
};
|
55017
|
+
var console_with_prefix = function(prefix) {
|
55018
|
+
return {
|
55019
|
+
log: log_func_with_prefix(console$1.log, prefix),
|
55020
|
+
error: log_func_with_prefix(console$1.error, prefix),
|
55021
|
+
critical: log_func_with_prefix(console$1.critical, prefix)
|
55022
|
+
};
|
55023
|
+
};
|
55024
|
+
_$1.bind = function(func, context) {
|
55025
|
+
var args, bound;
|
55026
|
+
if (nativeBind && func.bind === nativeBind) {
|
55027
|
+
return nativeBind.apply(func, slice.call(arguments, 1));
|
55028
|
+
}
|
55029
|
+
if (!_$1.isFunction(func)) {
|
55030
|
+
throw new TypeError();
|
55031
|
+
}
|
55032
|
+
args = slice.call(arguments, 2);
|
55033
|
+
bound = function() {
|
55034
|
+
if (!(this instanceof bound)) {
|
55035
|
+
return func.apply(context, args.concat(slice.call(arguments)));
|
55036
|
+
}
|
55037
|
+
var ctor = {};
|
55038
|
+
ctor.prototype = func.prototype;
|
55039
|
+
var self2 = new ctor();
|
55040
|
+
ctor.prototype = null;
|
55041
|
+
var result = func.apply(self2, args.concat(slice.call(arguments)));
|
55042
|
+
if (Object(result) === result) {
|
55043
|
+
return result;
|
55044
|
+
}
|
55045
|
+
return self2;
|
55046
|
+
};
|
55047
|
+
return bound;
|
55048
|
+
};
|
55049
|
+
_$1.each = function(obj2, iterator, context) {
|
55050
|
+
if (obj2 === null || obj2 === void 0) {
|
55051
|
+
return;
|
55052
|
+
}
|
55053
|
+
if (nativeForEach && obj2.forEach === nativeForEach) {
|
55054
|
+
obj2.forEach(iterator, context);
|
55055
|
+
} else if (obj2.length === +obj2.length) {
|
55056
|
+
for (var i2 = 0, l = obj2.length; i2 < l; i2++) {
|
55057
|
+
if (i2 in obj2 && iterator.call(context, obj2[i2], i2, obj2) === breaker) {
|
55058
|
+
return;
|
55059
|
+
}
|
55060
|
+
}
|
55061
|
+
} else {
|
55062
|
+
for (var key in obj2) {
|
55063
|
+
if (hasOwnProperty.call(obj2, key)) {
|
55064
|
+
if (iterator.call(context, obj2[key], key, obj2) === breaker) {
|
55065
|
+
return;
|
55066
|
+
}
|
55067
|
+
}
|
55068
|
+
}
|
55069
|
+
}
|
55070
|
+
};
|
55071
|
+
_$1.extend = function(obj2) {
|
55072
|
+
_$1.each(slice.call(arguments, 1), function(source) {
|
55073
|
+
for (var prop in source) {
|
55074
|
+
if (source[prop] !== void 0) {
|
55075
|
+
obj2[prop] = source[prop];
|
55076
|
+
}
|
55077
|
+
}
|
55078
|
+
});
|
55079
|
+
return obj2;
|
55080
|
+
};
|
55081
|
+
_$1.isArray = nativeIsArray || function(obj2) {
|
55082
|
+
return toString.call(obj2) === "[object Array]";
|
55083
|
+
};
|
55084
|
+
_$1.isFunction = function(f) {
|
55085
|
+
try {
|
55086
|
+
return /^\s*\bfunction\b/.test(f);
|
55087
|
+
} catch (x) {
|
55088
|
+
return false;
|
55089
|
+
}
|
55090
|
+
};
|
55091
|
+
_$1.isArguments = function(obj2) {
|
55092
|
+
return !!(obj2 && hasOwnProperty.call(obj2, "callee"));
|
55093
|
+
};
|
55094
|
+
_$1.toArray = function(iterable) {
|
55095
|
+
if (!iterable) {
|
55096
|
+
return [];
|
55097
|
+
}
|
55098
|
+
if (iterable.toArray) {
|
55099
|
+
return iterable.toArray();
|
55100
|
+
}
|
55101
|
+
if (_$1.isArray(iterable)) {
|
55102
|
+
return slice.call(iterable);
|
55103
|
+
}
|
55104
|
+
if (_$1.isArguments(iterable)) {
|
55105
|
+
return slice.call(iterable);
|
55106
|
+
}
|
55107
|
+
return _$1.values(iterable);
|
55108
|
+
};
|
55109
|
+
_$1.map = function(arr, callback, context) {
|
55110
|
+
if (nativeMap && arr.map === nativeMap) {
|
55111
|
+
return arr.map(callback, context);
|
55112
|
+
} else {
|
55113
|
+
var results = [];
|
55114
|
+
_$1.each(arr, function(item) {
|
55115
|
+
results.push(callback.call(context, item));
|
55116
|
+
});
|
55117
|
+
return results;
|
55118
|
+
}
|
55119
|
+
};
|
55120
|
+
_$1.keys = function(obj2) {
|
55121
|
+
var results = [];
|
55122
|
+
if (obj2 === null) {
|
55123
|
+
return results;
|
55124
|
+
}
|
55125
|
+
_$1.each(obj2, function(value, key) {
|
55126
|
+
results[results.length] = key;
|
55127
|
+
});
|
55128
|
+
return results;
|
55129
|
+
};
|
55130
|
+
_$1.values = function(obj2) {
|
55131
|
+
var results = [];
|
55132
|
+
if (obj2 === null) {
|
55133
|
+
return results;
|
55134
|
+
}
|
55135
|
+
_$1.each(obj2, function(value) {
|
55136
|
+
results[results.length] = value;
|
55137
|
+
});
|
55138
|
+
return results;
|
55139
|
+
};
|
55140
|
+
_$1.include = function(obj2, target) {
|
55141
|
+
var found = false;
|
55142
|
+
if (obj2 === null) {
|
55143
|
+
return found;
|
55144
|
+
}
|
55145
|
+
if (nativeIndexOf && obj2.indexOf === nativeIndexOf) {
|
55146
|
+
return obj2.indexOf(target) != -1;
|
55147
|
+
}
|
55148
|
+
_$1.each(obj2, function(value) {
|
55149
|
+
if (found || (found = value === target)) {
|
55150
|
+
return breaker;
|
55151
|
+
}
|
55152
|
+
});
|
55153
|
+
return found;
|
55154
|
+
};
|
55155
|
+
_$1.includes = function(str, needle) {
|
55156
|
+
return str.indexOf(needle) !== -1;
|
55157
|
+
};
|
55158
|
+
_$1.inherit = function(subclass, superclass) {
|
55159
|
+
subclass.prototype = new superclass();
|
55160
|
+
subclass.prototype.constructor = subclass;
|
55161
|
+
subclass.superclass = superclass.prototype;
|
55162
|
+
return subclass;
|
55163
|
+
};
|
55164
|
+
_$1.isObject = function(obj2) {
|
55165
|
+
return obj2 === Object(obj2) && !_$1.isArray(obj2);
|
55166
|
+
};
|
55167
|
+
_$1.isEmptyObject = function(obj2) {
|
55168
|
+
if (_$1.isObject(obj2)) {
|
55169
|
+
for (var key in obj2) {
|
55170
|
+
if (hasOwnProperty.call(obj2, key)) {
|
55171
|
+
return false;
|
55172
|
+
}
|
55173
|
+
}
|
55174
|
+
return true;
|
55175
|
+
}
|
55176
|
+
return false;
|
55177
|
+
};
|
55178
|
+
_$1.isUndefined = function(obj2) {
|
55179
|
+
return obj2 === void 0;
|
55180
|
+
};
|
55181
|
+
_$1.isString = function(obj2) {
|
55182
|
+
return toString.call(obj2) == "[object String]";
|
55183
|
+
};
|
55184
|
+
_$1.isDate = function(obj2) {
|
55185
|
+
return toString.call(obj2) == "[object Date]";
|
55186
|
+
};
|
55187
|
+
_$1.isNumber = function(obj2) {
|
55188
|
+
return toString.call(obj2) == "[object Number]";
|
55189
|
+
};
|
55190
|
+
_$1.isElement = function(obj2) {
|
55191
|
+
return !!(obj2 && obj2.nodeType === 1);
|
55192
|
+
};
|
55193
|
+
_$1.encodeDates = function(obj2) {
|
55194
|
+
_$1.each(obj2, function(v, k) {
|
55195
|
+
if (_$1.isDate(v)) {
|
55196
|
+
obj2[k] = _$1.formatDate(v);
|
55197
|
+
} else if (_$1.isObject(v)) {
|
55198
|
+
obj2[k] = _$1.encodeDates(v);
|
55199
|
+
}
|
55200
|
+
});
|
55201
|
+
return obj2;
|
55202
|
+
};
|
55203
|
+
_$1.timestamp = function() {
|
55204
|
+
Date.now = Date.now || function() {
|
55205
|
+
return +new Date();
|
55206
|
+
};
|
55207
|
+
return Date.now();
|
55208
|
+
};
|
55209
|
+
_$1.formatDate = function(d) {
|
55210
|
+
function pad(n) {
|
55211
|
+
return n < 10 ? "0" + n : n;
|
55212
|
+
}
|
55213
|
+
return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds());
|
55214
|
+
};
|
55215
|
+
_$1.strip_empty_properties = function(p) {
|
55216
|
+
var ret = {};
|
55217
|
+
_$1.each(p, function(v, k) {
|
55218
|
+
if (_$1.isString(v) && v.length > 0) {
|
55219
|
+
ret[k] = v;
|
55220
|
+
}
|
55221
|
+
});
|
55222
|
+
return ret;
|
55223
|
+
};
|
55224
|
+
_$1.truncate = function(obj2, length) {
|
55225
|
+
var ret;
|
55226
|
+
if (typeof obj2 === "string") {
|
55227
|
+
ret = obj2.slice(0, length);
|
55228
|
+
} else if (_$1.isArray(obj2)) {
|
55229
|
+
ret = [];
|
55230
|
+
_$1.each(obj2, function(val) {
|
55231
|
+
ret.push(_$1.truncate(val, length));
|
55232
|
+
});
|
55233
|
+
} else if (_$1.isObject(obj2)) {
|
55234
|
+
ret = {};
|
55235
|
+
_$1.each(obj2, function(val, key) {
|
55236
|
+
ret[key] = _$1.truncate(val, length);
|
55237
|
+
});
|
55238
|
+
} else {
|
55239
|
+
ret = obj2;
|
55240
|
+
}
|
55241
|
+
return ret;
|
55242
|
+
};
|
55243
|
+
_$1.JSONEncode = function() {
|
55244
|
+
return function(mixed_val) {
|
55245
|
+
var value = mixed_val;
|
55246
|
+
var quote = function(string) {
|
55247
|
+
var escapable = /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
55248
|
+
var meta = {
|
55249
|
+
"\b": "\\b",
|
55250
|
+
" ": "\\t",
|
55251
|
+
"\n": "\\n",
|
55252
|
+
"\f": "\\f",
|
55253
|
+
"\r": "\\r",
|
55254
|
+
'"': '\\"',
|
55255
|
+
"\\": "\\\\"
|
55256
|
+
};
|
55257
|
+
escapable.lastIndex = 0;
|
55258
|
+
return escapable.test(string) ? '"' + string.replace(escapable, function(a) {
|
55259
|
+
var c = meta[a];
|
55260
|
+
return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
|
55261
|
+
}) + '"' : '"' + string + '"';
|
55262
|
+
};
|
55263
|
+
var str = function(key, holder) {
|
55264
|
+
var gap = "";
|
55265
|
+
var indent = " ";
|
55266
|
+
var i2 = 0;
|
55267
|
+
var k = "";
|
55268
|
+
var v = "";
|
55269
|
+
var length = 0;
|
55270
|
+
var mind = gap;
|
55271
|
+
var partial = [];
|
55272
|
+
var value2 = holder[key];
|
55273
|
+
if (value2 && typeof value2 === "object" && typeof value2.toJSON === "function") {
|
55274
|
+
value2 = value2.toJSON(key);
|
55275
|
+
}
|
55276
|
+
switch (typeof value2) {
|
55277
|
+
case "string":
|
55278
|
+
return quote(value2);
|
55279
|
+
case "number":
|
55280
|
+
return isFinite(value2) ? String(value2) : "null";
|
55281
|
+
case "boolean":
|
55282
|
+
case "null":
|
55283
|
+
return String(value2);
|
55284
|
+
case "object":
|
55285
|
+
if (!value2) {
|
55286
|
+
return "null";
|
55287
|
+
}
|
55288
|
+
gap += indent;
|
55289
|
+
partial = [];
|
55290
|
+
if (toString.apply(value2) === "[object Array]") {
|
55291
|
+
length = value2.length;
|
55292
|
+
for (i2 = 0; i2 < length; i2 += 1) {
|
55293
|
+
partial[i2] = str(i2, value2) || "null";
|
55294
|
+
}
|
55295
|
+
v = partial.length === 0 ? "[]" : gap ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" : "[" + partial.join(",") + "]";
|
55296
|
+
gap = mind;
|
55297
|
+
return v;
|
55298
|
+
}
|
55299
|
+
for (k in value2) {
|
55300
|
+
if (hasOwnProperty.call(value2, k)) {
|
55301
|
+
v = str(k, value2);
|
55302
|
+
if (v) {
|
55303
|
+
partial.push(quote(k) + (gap ? ": " : ":") + v);
|
55304
|
+
}
|
55305
|
+
}
|
55306
|
+
}
|
55307
|
+
v = partial.length === 0 ? "{}" : gap ? "{" + partial.join(",") + mind + "}" : "{" + partial.join(",") + "}";
|
55308
|
+
gap = mind;
|
55309
|
+
return v;
|
55310
|
+
}
|
55311
|
+
};
|
55312
|
+
return str("", {
|
55313
|
+
"": value
|
55314
|
+
});
|
55315
|
+
};
|
55316
|
+
}();
|
55317
|
+
_$1.JSONDecode = function() {
|
55318
|
+
var at, ch, escapee = {
|
55319
|
+
'"': '"',
|
55320
|
+
"\\": "\\",
|
55321
|
+
"/": "/",
|
55322
|
+
"b": "\b",
|
55323
|
+
"f": "\f",
|
55324
|
+
"n": "\n",
|
55325
|
+
"r": "\r",
|
55326
|
+
"t": " "
|
55327
|
+
}, text, error = function(m) {
|
55328
|
+
var e = new SyntaxError(m);
|
55329
|
+
e.at = at;
|
55330
|
+
e.text = text;
|
55331
|
+
throw e;
|
55332
|
+
}, next = function(c) {
|
55333
|
+
if (c && c !== ch) {
|
55334
|
+
error("Expected '" + c + "' instead of '" + ch + "'");
|
55335
|
+
}
|
55336
|
+
ch = text.charAt(at);
|
55337
|
+
at += 1;
|
55338
|
+
return ch;
|
55339
|
+
}, number = function() {
|
55340
|
+
var number2, string2 = "";
|
55341
|
+
if (ch === "-") {
|
55342
|
+
string2 = "-";
|
55343
|
+
next("-");
|
55344
|
+
}
|
55345
|
+
while (ch >= "0" && ch <= "9") {
|
55346
|
+
string2 += ch;
|
55347
|
+
next();
|
55348
|
+
}
|
55349
|
+
if (ch === ".") {
|
55350
|
+
string2 += ".";
|
55351
|
+
while (next() && ch >= "0" && ch <= "9") {
|
55352
|
+
string2 += ch;
|
55353
|
+
}
|
55354
|
+
}
|
55355
|
+
if (ch === "e" || ch === "E") {
|
55356
|
+
string2 += ch;
|
55357
|
+
next();
|
55358
|
+
if (ch === "-" || ch === "+") {
|
55359
|
+
string2 += ch;
|
55360
|
+
next();
|
55361
|
+
}
|
55362
|
+
while (ch >= "0" && ch <= "9") {
|
55363
|
+
string2 += ch;
|
55364
|
+
next();
|
55365
|
+
}
|
55366
|
+
}
|
55367
|
+
number2 = +string2;
|
55368
|
+
if (!isFinite(number2)) {
|
55369
|
+
error("Bad number");
|
55370
|
+
} else {
|
55371
|
+
return number2;
|
55372
|
+
}
|
55373
|
+
}, string = function() {
|
55374
|
+
var hex, i2, string2 = "", uffff;
|
55375
|
+
if (ch === '"') {
|
55376
|
+
while (next()) {
|
55377
|
+
if (ch === '"') {
|
55378
|
+
next();
|
55379
|
+
return string2;
|
55380
|
+
}
|
55381
|
+
if (ch === "\\") {
|
55382
|
+
next();
|
55383
|
+
if (ch === "u") {
|
55384
|
+
uffff = 0;
|
55385
|
+
for (i2 = 0; i2 < 4; i2 += 1) {
|
55386
|
+
hex = parseInt(next(), 16);
|
55387
|
+
if (!isFinite(hex)) {
|
55388
|
+
break;
|
55389
|
+
}
|
55390
|
+
uffff = uffff * 16 + hex;
|
55391
|
+
}
|
55392
|
+
string2 += String.fromCharCode(uffff);
|
55393
|
+
} else if (typeof escapee[ch] === "string") {
|
55394
|
+
string2 += escapee[ch];
|
55395
|
+
} else {
|
55396
|
+
break;
|
55397
|
+
}
|
55398
|
+
} else {
|
55399
|
+
string2 += ch;
|
55400
|
+
}
|
55401
|
+
}
|
55402
|
+
}
|
55403
|
+
error("Bad string");
|
55404
|
+
}, white = function() {
|
55405
|
+
while (ch && ch <= " ") {
|
55406
|
+
next();
|
55407
|
+
}
|
55408
|
+
}, word = function() {
|
55409
|
+
switch (ch) {
|
55410
|
+
case "t":
|
55411
|
+
next("t");
|
55412
|
+
next("r");
|
55413
|
+
next("u");
|
55414
|
+
next("e");
|
55415
|
+
return true;
|
55416
|
+
case "f":
|
55417
|
+
next("f");
|
55418
|
+
next("a");
|
55419
|
+
next("l");
|
55420
|
+
next("s");
|
55421
|
+
next("e");
|
55422
|
+
return false;
|
55423
|
+
case "n":
|
55424
|
+
next("n");
|
55425
|
+
next("u");
|
55426
|
+
next("l");
|
55427
|
+
next("l");
|
55428
|
+
return null;
|
55429
|
+
}
|
55430
|
+
error('Unexpected "' + ch + '"');
|
55431
|
+
}, value, array = function() {
|
55432
|
+
var array2 = [];
|
55433
|
+
if (ch === "[") {
|
55434
|
+
next("[");
|
55435
|
+
white();
|
55436
|
+
if (ch === "]") {
|
55437
|
+
next("]");
|
55438
|
+
return array2;
|
55439
|
+
}
|
55440
|
+
while (ch) {
|
55441
|
+
array2.push(value());
|
55442
|
+
white();
|
55443
|
+
if (ch === "]") {
|
55444
|
+
next("]");
|
55445
|
+
return array2;
|
55446
|
+
}
|
55447
|
+
next(",");
|
55448
|
+
white();
|
55449
|
+
}
|
55450
|
+
}
|
55451
|
+
error("Bad array");
|
55452
|
+
}, object = function() {
|
55453
|
+
var key, object2 = {};
|
55454
|
+
if (ch === "{") {
|
55455
|
+
next("{");
|
55456
|
+
white();
|
55457
|
+
if (ch === "}") {
|
55458
|
+
next("}");
|
55459
|
+
return object2;
|
55460
|
+
}
|
55461
|
+
while (ch) {
|
55462
|
+
key = string();
|
55463
|
+
white();
|
55464
|
+
next(":");
|
55465
|
+
if (Object.hasOwnProperty.call(object2, key)) {
|
55466
|
+
error('Duplicate key "' + key + '"');
|
55467
|
+
}
|
55468
|
+
object2[key] = value();
|
55469
|
+
white();
|
55470
|
+
if (ch === "}") {
|
55471
|
+
next("}");
|
55472
|
+
return object2;
|
55473
|
+
}
|
55474
|
+
next(",");
|
55475
|
+
white();
|
55476
|
+
}
|
55477
|
+
}
|
55478
|
+
error("Bad object");
|
55479
|
+
};
|
55480
|
+
value = function() {
|
55481
|
+
white();
|
55482
|
+
switch (ch) {
|
55483
|
+
case "{":
|
55484
|
+
return object();
|
55485
|
+
case "[":
|
55486
|
+
return array();
|
55487
|
+
case '"':
|
55488
|
+
return string();
|
55489
|
+
case "-":
|
55490
|
+
return number();
|
55491
|
+
default:
|
55492
|
+
return ch >= "0" && ch <= "9" ? number() : word();
|
55493
|
+
}
|
55494
|
+
};
|
55495
|
+
return function(source) {
|
55496
|
+
var result;
|
55497
|
+
text = source;
|
55498
|
+
at = 0;
|
55499
|
+
ch = " ";
|
55500
|
+
result = value();
|
55501
|
+
white();
|
55502
|
+
if (ch) {
|
55503
|
+
error("Syntax error");
|
55504
|
+
}
|
55505
|
+
return result;
|
55506
|
+
};
|
55507
|
+
}();
|
55508
|
+
_$1.base64Encode = function(data) {
|
55509
|
+
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
55510
|
+
var o1, o2, o3, h1, h2, h3, h4, bits, i2 = 0, ac = 0, enc = "", tmp_arr = [];
|
55511
|
+
if (!data) {
|
55512
|
+
return data;
|
55513
|
+
}
|
55514
|
+
data = _$1.utf8Encode(data);
|
55515
|
+
do {
|
55516
|
+
o1 = data.charCodeAt(i2++);
|
55517
|
+
o2 = data.charCodeAt(i2++);
|
55518
|
+
o3 = data.charCodeAt(i2++);
|
55519
|
+
bits = o1 << 16 | o2 << 8 | o3;
|
55520
|
+
h1 = bits >> 18 & 63;
|
55521
|
+
h2 = bits >> 12 & 63;
|
55522
|
+
h3 = bits >> 6 & 63;
|
55523
|
+
h4 = bits & 63;
|
55524
|
+
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
|
55525
|
+
} while (i2 < data.length);
|
55526
|
+
enc = tmp_arr.join("");
|
55527
|
+
switch (data.length % 3) {
|
55528
|
+
case 1:
|
55529
|
+
enc = enc.slice(0, -2) + "==";
|
55530
|
+
break;
|
55531
|
+
case 2:
|
55532
|
+
enc = enc.slice(0, -1) + "=";
|
55533
|
+
break;
|
55534
|
+
}
|
55535
|
+
return enc;
|
55536
|
+
};
|
55537
|
+
_$1.utf8Encode = function(string) {
|
55538
|
+
string = (string + "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
55539
|
+
var utftext = "", start2, end2;
|
55540
|
+
var stringl = 0, n;
|
55541
|
+
start2 = end2 = 0;
|
55542
|
+
stringl = string.length;
|
55543
|
+
for (n = 0; n < stringl; n++) {
|
55544
|
+
var c1 = string.charCodeAt(n);
|
55545
|
+
var enc = null;
|
55546
|
+
if (c1 < 128) {
|
55547
|
+
end2++;
|
55548
|
+
} else if (c1 > 127 && c1 < 2048) {
|
55549
|
+
enc = String.fromCharCode(c1 >> 6 | 192, c1 & 63 | 128);
|
55550
|
+
} else {
|
55551
|
+
enc = String.fromCharCode(c1 >> 12 | 224, c1 >> 6 & 63 | 128, c1 & 63 | 128);
|
55552
|
+
}
|
55553
|
+
if (enc !== null) {
|
55554
|
+
if (end2 > start2) {
|
55555
|
+
utftext += string.substring(start2, end2);
|
55556
|
+
}
|
55557
|
+
utftext += enc;
|
55558
|
+
start2 = end2 = n + 1;
|
55559
|
+
}
|
55560
|
+
}
|
55561
|
+
if (end2 > start2) {
|
55562
|
+
utftext += string.substring(start2, string.length);
|
55563
|
+
}
|
55564
|
+
return utftext;
|
55565
|
+
};
|
55566
|
+
_$1.UUID = function() {
|
55567
|
+
var T = function() {
|
55568
|
+
var time = 1 * new Date();
|
55569
|
+
var ticks;
|
55570
|
+
if (win.performance && win.performance.now) {
|
55571
|
+
ticks = win.performance.now();
|
55572
|
+
} else {
|
55573
|
+
ticks = 0;
|
55574
|
+
while (time == 1 * new Date()) {
|
55575
|
+
ticks++;
|
55576
|
+
}
|
55577
|
+
}
|
55578
|
+
return time.toString(16) + Math.floor(ticks).toString(16);
|
55579
|
+
};
|
55580
|
+
var R = function() {
|
55581
|
+
return Math.random().toString(16).replace(".", "");
|
55582
|
+
};
|
55583
|
+
var UA = function() {
|
55584
|
+
var ua = userAgent, i2, ch, buffer = [], ret = 0;
|
55585
|
+
function xor(result, byte_array) {
|
55586
|
+
var j, tmp = 0;
|
55587
|
+
for (j = 0; j < byte_array.length; j++) {
|
55588
|
+
tmp |= buffer[j] << j * 8;
|
55589
|
+
}
|
55590
|
+
return result ^ tmp;
|
55591
|
+
}
|
55592
|
+
for (i2 = 0; i2 < ua.length; i2++) {
|
55593
|
+
ch = ua.charCodeAt(i2);
|
55594
|
+
buffer.unshift(ch & 255);
|
55595
|
+
if (buffer.length >= 4) {
|
55596
|
+
ret = xor(ret, buffer);
|
55597
|
+
buffer = [];
|
55598
|
+
}
|
55599
|
+
}
|
55600
|
+
if (buffer.length > 0) {
|
55601
|
+
ret = xor(ret, buffer);
|
55602
|
+
}
|
55603
|
+
return ret.toString(16);
|
55604
|
+
};
|
55605
|
+
return function() {
|
55606
|
+
var se = (screen.height * screen.width).toString(16);
|
55607
|
+
return T() + "-" + R() + "-" + UA() + "-" + se + "-" + T();
|
55608
|
+
};
|
55609
|
+
}();
|
55610
|
+
var BLOCKED_UA_STRS = [
|
55611
|
+
"ahrefsbot",
|
55612
|
+
"ahrefssiteaudit",
|
55613
|
+
"baiduspider",
|
55614
|
+
"bingbot",
|
55615
|
+
"bingpreview",
|
55616
|
+
"chrome-lighthouse",
|
55617
|
+
"facebookexternal",
|
55618
|
+
"petalbot",
|
55619
|
+
"pinterest",
|
55620
|
+
"screaming frog",
|
55621
|
+
"yahoo! slurp",
|
55622
|
+
"yandexbot",
|
55623
|
+
"adsbot-google",
|
55624
|
+
"apis-google",
|
55625
|
+
"duplexweb-google",
|
55626
|
+
"feedfetcher-google",
|
55627
|
+
"google favicon",
|
55628
|
+
"google web preview",
|
55629
|
+
"google-read-aloud",
|
55630
|
+
"googlebot",
|
55631
|
+
"googleweblight",
|
55632
|
+
"mediapartners-google",
|
55633
|
+
"storebot-google"
|
55634
|
+
];
|
55635
|
+
_$1.isBlockedUA = function(ua) {
|
55636
|
+
var i2;
|
55637
|
+
ua = ua.toLowerCase();
|
55638
|
+
for (i2 = 0; i2 < BLOCKED_UA_STRS.length; i2++) {
|
55639
|
+
if (ua.indexOf(BLOCKED_UA_STRS[i2]) !== -1) {
|
55640
|
+
return true;
|
55641
|
+
}
|
55642
|
+
}
|
55643
|
+
return false;
|
55644
|
+
};
|
55645
|
+
_$1.HTTPBuildQuery = function(formdata, arg_separator) {
|
55646
|
+
var use_val, use_key, tmp_arr = [];
|
55647
|
+
if (_$1.isUndefined(arg_separator)) {
|
55648
|
+
arg_separator = "&";
|
55649
|
+
}
|
55650
|
+
_$1.each(formdata, function(val, key) {
|
55651
|
+
use_val = encodeURIComponent(val.toString());
|
55652
|
+
use_key = encodeURIComponent(key);
|
55653
|
+
tmp_arr[tmp_arr.length] = use_key + "=" + use_val;
|
55654
|
+
});
|
55655
|
+
return tmp_arr.join(arg_separator);
|
55656
|
+
};
|
55657
|
+
_$1.getQueryParam = function(url, param) {
|
55658
|
+
param = param.replace(/[[]/, "\\[").replace(/[\]]/, "\\]");
|
55659
|
+
var regexS = "[\\?&]" + param + "=([^&#]*)", regex = new RegExp(regexS), results = regex.exec(url);
|
55660
|
+
if (results === null || results && typeof results[1] !== "string" && results[1].length) {
|
55661
|
+
return "";
|
55662
|
+
} else {
|
55663
|
+
var result = results[1];
|
55664
|
+
try {
|
55665
|
+
result = decodeURIComponent(result);
|
55666
|
+
} catch (err) {
|
55667
|
+
console$1.error("Skipping decoding for malformed query param: " + result);
|
55668
|
+
}
|
55669
|
+
return result.replace(/\+/g, " ");
|
55670
|
+
}
|
55671
|
+
};
|
55672
|
+
_$1.cookie = {
|
55673
|
+
get: function(name2) {
|
55674
|
+
var nameEQ = name2 + "=";
|
55675
|
+
var ca = document$1.cookie.split(";");
|
55676
|
+
for (var i2 = 0; i2 < ca.length; i2++) {
|
55677
|
+
var c = ca[i2];
|
55678
|
+
while (c.charAt(0) == " ") {
|
55679
|
+
c = c.substring(1, c.length);
|
55680
|
+
}
|
55681
|
+
if (c.indexOf(nameEQ) === 0) {
|
55682
|
+
return decodeURIComponent(c.substring(nameEQ.length, c.length));
|
55683
|
+
}
|
55684
|
+
}
|
55685
|
+
return null;
|
55686
|
+
},
|
55687
|
+
parse: function(name2) {
|
55688
|
+
var cookie;
|
55689
|
+
try {
|
55690
|
+
cookie = _$1.JSONDecode(_$1.cookie.get(name2)) || {};
|
55691
|
+
} catch (err) {
|
55692
|
+
}
|
55693
|
+
return cookie;
|
55694
|
+
},
|
55695
|
+
set_seconds: function(name2, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
|
55696
|
+
var cdomain = "", expires = "", secure = "";
|
55697
|
+
if (domain_override) {
|
55698
|
+
cdomain = "; domain=" + domain_override;
|
55699
|
+
} else if (is_cross_subdomain) {
|
55700
|
+
var domain = extract_domain(document$1.location.hostname);
|
55701
|
+
cdomain = domain ? "; domain=." + domain : "";
|
55702
|
+
}
|
55703
|
+
if (seconds) {
|
55704
|
+
var date = new Date();
|
55705
|
+
date.setTime(date.getTime() + seconds * 1e3);
|
55706
|
+
expires = "; expires=" + date.toGMTString();
|
55707
|
+
}
|
55708
|
+
if (is_cross_site) {
|
55709
|
+
is_secure = true;
|
55710
|
+
secure = "; SameSite=None";
|
55711
|
+
}
|
55712
|
+
if (is_secure) {
|
55713
|
+
secure += "; secure";
|
55714
|
+
}
|
55715
|
+
document$1.cookie = name2 + "=" + encodeURIComponent(value) + expires + "; path=/" + cdomain + secure;
|
55716
|
+
},
|
55717
|
+
set: function(name2, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
|
55718
|
+
var cdomain = "", expires = "", secure = "";
|
55719
|
+
if (domain_override) {
|
55720
|
+
cdomain = "; domain=" + domain_override;
|
55721
|
+
} else if (is_cross_subdomain) {
|
55722
|
+
var domain = extract_domain(document$1.location.hostname);
|
55723
|
+
cdomain = domain ? "; domain=." + domain : "";
|
55724
|
+
}
|
55725
|
+
if (days) {
|
55726
|
+
var date = new Date();
|
55727
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
55728
|
+
expires = "; expires=" + date.toGMTString();
|
55729
|
+
}
|
55730
|
+
if (is_cross_site) {
|
55731
|
+
is_secure = true;
|
55732
|
+
secure = "; SameSite=None";
|
55733
|
+
}
|
55734
|
+
if (is_secure) {
|
55735
|
+
secure += "; secure";
|
55736
|
+
}
|
55737
|
+
var new_cookie_val = name2 + "=" + encodeURIComponent(value) + expires + "; path=/" + cdomain + secure;
|
55738
|
+
document$1.cookie = new_cookie_val;
|
55739
|
+
return new_cookie_val;
|
55740
|
+
},
|
55741
|
+
remove: function(name2, is_cross_subdomain, domain_override) {
|
55742
|
+
_$1.cookie.set(name2, "", -1, is_cross_subdomain, false, false, domain_override);
|
55743
|
+
}
|
55744
|
+
};
|
55745
|
+
var _localStorageSupported = null;
|
55746
|
+
var localStorageSupported = function(storage, forceCheck) {
|
55747
|
+
if (_localStorageSupported !== null && !forceCheck) {
|
55748
|
+
return _localStorageSupported;
|
55749
|
+
}
|
55750
|
+
var supported = true;
|
55751
|
+
try {
|
55752
|
+
storage = storage || window.localStorage;
|
55753
|
+
var key = "__mplss_" + cheap_guid(8), val = "xyz";
|
55754
|
+
storage.setItem(key, val);
|
55755
|
+
if (storage.getItem(key) !== val) {
|
55756
|
+
supported = false;
|
55757
|
+
}
|
55758
|
+
storage.removeItem(key);
|
55759
|
+
} catch (err) {
|
55760
|
+
supported = false;
|
55761
|
+
}
|
55762
|
+
_localStorageSupported = supported;
|
55763
|
+
return supported;
|
55764
|
+
};
|
55765
|
+
_$1.localStorage = {
|
55766
|
+
is_supported: function(force_check) {
|
55767
|
+
var supported = localStorageSupported(null, force_check);
|
55768
|
+
if (!supported) {
|
55769
|
+
console$1.error("localStorage unsupported; falling back to cookie store");
|
55770
|
+
}
|
55771
|
+
return supported;
|
55772
|
+
},
|
55773
|
+
error: function(msg) {
|
55774
|
+
console$1.error("localStorage error: " + msg);
|
55775
|
+
},
|
55776
|
+
get: function(name2) {
|
55777
|
+
try {
|
55778
|
+
return window.localStorage.getItem(name2);
|
55779
|
+
} catch (err) {
|
55780
|
+
_$1.localStorage.error(err);
|
55781
|
+
}
|
55782
|
+
return null;
|
55783
|
+
},
|
55784
|
+
parse: function(name2) {
|
55785
|
+
try {
|
55786
|
+
return _$1.JSONDecode(_$1.localStorage.get(name2)) || {};
|
55787
|
+
} catch (err) {
|
55788
|
+
}
|
55789
|
+
return null;
|
55790
|
+
},
|
55791
|
+
set: function(name2, value) {
|
55792
|
+
try {
|
55793
|
+
window.localStorage.setItem(name2, value);
|
55794
|
+
} catch (err) {
|
55795
|
+
_$1.localStorage.error(err);
|
55796
|
+
}
|
55797
|
+
},
|
55798
|
+
remove: function(name2) {
|
55799
|
+
try {
|
55800
|
+
window.localStorage.removeItem(name2);
|
55801
|
+
} catch (err) {
|
55802
|
+
_$1.localStorage.error(err);
|
55803
|
+
}
|
55804
|
+
}
|
55805
|
+
};
|
55806
|
+
_$1.register_event = function() {
|
55807
|
+
var register_event = function(element, type2, handler, oldSchool, useCapture) {
|
55808
|
+
if (!element) {
|
55809
|
+
console$1.error("No valid element provided to register_event");
|
55810
|
+
return;
|
55811
|
+
}
|
55812
|
+
if (element.addEventListener && !oldSchool) {
|
55813
|
+
element.addEventListener(type2, handler, !!useCapture);
|
55814
|
+
} else {
|
55815
|
+
var ontype = "on" + type2;
|
55816
|
+
var old_handler = element[ontype];
|
55817
|
+
element[ontype] = makeHandler(element, handler, old_handler);
|
55818
|
+
}
|
55819
|
+
};
|
55820
|
+
function makeHandler(element, new_handler, old_handlers) {
|
55821
|
+
var handler = function(event2) {
|
55822
|
+
event2 = event2 || fixEvent2(window.event);
|
55823
|
+
if (!event2) {
|
55824
|
+
return void 0;
|
55825
|
+
}
|
55826
|
+
var ret = true;
|
55827
|
+
var old_result, new_result;
|
55828
|
+
if (_$1.isFunction(old_handlers)) {
|
55829
|
+
old_result = old_handlers(event2);
|
55830
|
+
}
|
55831
|
+
new_result = new_handler.call(element, event2);
|
55832
|
+
if (false === old_result || false === new_result) {
|
55833
|
+
ret = false;
|
55834
|
+
}
|
55835
|
+
return ret;
|
55836
|
+
};
|
55837
|
+
return handler;
|
55838
|
+
}
|
55839
|
+
function fixEvent2(event2) {
|
55840
|
+
if (event2) {
|
55841
|
+
event2.preventDefault = fixEvent2.preventDefault;
|
55842
|
+
event2.stopPropagation = fixEvent2.stopPropagation;
|
55843
|
+
}
|
55844
|
+
return event2;
|
55845
|
+
}
|
55846
|
+
fixEvent2.preventDefault = function() {
|
55847
|
+
this.returnValue = false;
|
55848
|
+
};
|
55849
|
+
fixEvent2.stopPropagation = function() {
|
55850
|
+
this.cancelBubble = true;
|
55851
|
+
};
|
55852
|
+
return register_event;
|
55853
|
+
}();
|
55854
|
+
var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
|
55855
|
+
_$1.dom_query = function() {
|
55856
|
+
function getAllChildren(e) {
|
55857
|
+
return e.all ? e.all : e.getElementsByTagName("*");
|
55858
|
+
}
|
55859
|
+
var bad_whitespace = /[\t\r\n]/g;
|
55860
|
+
function hasClass2(elem, selector) {
|
55861
|
+
var className = " " + selector + " ";
|
55862
|
+
return (" " + elem.className + " ").replace(bad_whitespace, " ").indexOf(className) >= 0;
|
55863
|
+
}
|
55864
|
+
function getElementsBySelector(selector) {
|
55865
|
+
if (!document$1.getElementsByTagName) {
|
55866
|
+
return [];
|
55867
|
+
}
|
55868
|
+
var tokens = selector.split(" ");
|
55869
|
+
var token, bits, tagName, found, foundCount, i2, j, k, elements, currentContextIndex;
|
55870
|
+
var currentContext = [document$1];
|
55871
|
+
for (i2 = 0; i2 < tokens.length; i2++) {
|
55872
|
+
token = tokens[i2].replace(/^\s+/, "").replace(/\s+$/, "");
|
55873
|
+
if (token.indexOf("#") > -1) {
|
55874
|
+
bits = token.split("#");
|
55875
|
+
tagName = bits[0];
|
55876
|
+
var id = bits[1];
|
55877
|
+
var element = document$1.getElementById(id);
|
55878
|
+
if (!element || tagName && element.nodeName.toLowerCase() != tagName) {
|
55879
|
+
return [];
|
55880
|
+
}
|
55881
|
+
currentContext = [element];
|
55882
|
+
continue;
|
55883
|
+
}
|
55884
|
+
if (token.indexOf(".") > -1) {
|
55885
|
+
bits = token.split(".");
|
55886
|
+
tagName = bits[0];
|
55887
|
+
var className = bits[1];
|
55888
|
+
if (!tagName) {
|
55889
|
+
tagName = "*";
|
55890
|
+
}
|
55891
|
+
found = [];
|
55892
|
+
foundCount = 0;
|
55893
|
+
for (j = 0; j < currentContext.length; j++) {
|
55894
|
+
if (tagName == "*") {
|
55895
|
+
elements = getAllChildren(currentContext[j]);
|
55896
|
+
} else {
|
55897
|
+
elements = currentContext[j].getElementsByTagName(tagName);
|
55898
|
+
}
|
55899
|
+
for (k = 0; k < elements.length; k++) {
|
55900
|
+
found[foundCount++] = elements[k];
|
55901
|
+
}
|
55902
|
+
}
|
55903
|
+
currentContext = [];
|
55904
|
+
currentContextIndex = 0;
|
55905
|
+
for (j = 0; j < found.length; j++) {
|
55906
|
+
if (found[j].className && _$1.isString(found[j].className) && hasClass2(found[j], className)) {
|
55907
|
+
currentContext[currentContextIndex++] = found[j];
|
55908
|
+
}
|
55909
|
+
}
|
55910
|
+
continue;
|
55911
|
+
}
|
55912
|
+
var token_match = token.match(TOKEN_MATCH_REGEX);
|
55913
|
+
if (token_match) {
|
55914
|
+
tagName = token_match[1];
|
55915
|
+
var attrName = token_match[2];
|
55916
|
+
var attrOperator = token_match[3];
|
55917
|
+
var attrValue = token_match[4];
|
55918
|
+
if (!tagName) {
|
55919
|
+
tagName = "*";
|
55920
|
+
}
|
55921
|
+
found = [];
|
55922
|
+
foundCount = 0;
|
55923
|
+
for (j = 0; j < currentContext.length; j++) {
|
55924
|
+
if (tagName == "*") {
|
55925
|
+
elements = getAllChildren(currentContext[j]);
|
55926
|
+
} else {
|
55927
|
+
elements = currentContext[j].getElementsByTagName(tagName);
|
55928
|
+
}
|
55929
|
+
for (k = 0; k < elements.length; k++) {
|
55930
|
+
found[foundCount++] = elements[k];
|
55931
|
+
}
|
55932
|
+
}
|
55933
|
+
currentContext = [];
|
55934
|
+
currentContextIndex = 0;
|
55935
|
+
var checkFunction;
|
55936
|
+
switch (attrOperator) {
|
55937
|
+
case "=":
|
55938
|
+
checkFunction = function(e) {
|
55939
|
+
return e.getAttribute(attrName) == attrValue;
|
55940
|
+
};
|
55941
|
+
break;
|
55942
|
+
case "~":
|
55943
|
+
checkFunction = function(e) {
|
55944
|
+
return e.getAttribute(attrName).match(new RegExp("\\b" + attrValue + "\\b"));
|
55945
|
+
};
|
55946
|
+
break;
|
55947
|
+
case "|":
|
55948
|
+
checkFunction = function(e) {
|
55949
|
+
return e.getAttribute(attrName).match(new RegExp("^" + attrValue + "-?"));
|
55950
|
+
};
|
55951
|
+
break;
|
55952
|
+
case "^":
|
55953
|
+
checkFunction = function(e) {
|
55954
|
+
return e.getAttribute(attrName).indexOf(attrValue) === 0;
|
55955
|
+
};
|
55956
|
+
break;
|
55957
|
+
case "$":
|
55958
|
+
checkFunction = function(e) {
|
55959
|
+
return e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length;
|
55960
|
+
};
|
55961
|
+
break;
|
55962
|
+
case "*":
|
55963
|
+
checkFunction = function(e) {
|
55964
|
+
return e.getAttribute(attrName).indexOf(attrValue) > -1;
|
55965
|
+
};
|
55966
|
+
break;
|
55967
|
+
default:
|
55968
|
+
checkFunction = function(e) {
|
55969
|
+
return e.getAttribute(attrName);
|
55970
|
+
};
|
55971
|
+
}
|
55972
|
+
currentContext = [];
|
55973
|
+
currentContextIndex = 0;
|
55974
|
+
for (j = 0; j < found.length; j++) {
|
55975
|
+
if (checkFunction(found[j])) {
|
55976
|
+
currentContext[currentContextIndex++] = found[j];
|
55977
|
+
}
|
55978
|
+
}
|
55979
|
+
continue;
|
55980
|
+
}
|
55981
|
+
tagName = token;
|
55982
|
+
found = [];
|
55983
|
+
foundCount = 0;
|
55984
|
+
for (j = 0; j < currentContext.length; j++) {
|
55985
|
+
elements = currentContext[j].getElementsByTagName(tagName);
|
55986
|
+
for (k = 0; k < elements.length; k++) {
|
55987
|
+
found[foundCount++] = elements[k];
|
55988
|
+
}
|
55989
|
+
}
|
55990
|
+
currentContext = found;
|
55991
|
+
}
|
55992
|
+
return currentContext;
|
55993
|
+
}
|
55994
|
+
return function(query) {
|
55995
|
+
if (_$1.isElement(query)) {
|
55996
|
+
return [query];
|
55997
|
+
} else if (_$1.isObject(query) && !_$1.isUndefined(query.length)) {
|
55998
|
+
return query;
|
55999
|
+
} else {
|
56000
|
+
return getElementsBySelector.call(this, query);
|
56001
|
+
}
|
56002
|
+
};
|
56003
|
+
}();
|
56004
|
+
var CAMPAIGN_KEYWORDS = ["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term"];
|
56005
|
+
var CLICK_IDS = ["dclid", "fbclid", "gclid", "ko_click_id", "li_fat_id", "msclkid", "ttclid", "twclid", "wbraid"];
|
56006
|
+
_$1.info = {
|
56007
|
+
campaignParams: function(default_value) {
|
56008
|
+
var kw = "", params = {};
|
56009
|
+
_$1.each(CAMPAIGN_KEYWORDS, function(kwkey) {
|
56010
|
+
kw = _$1.getQueryParam(document$1.URL, kwkey);
|
56011
|
+
if (kw.length) {
|
56012
|
+
params[kwkey] = kw;
|
56013
|
+
} else if (default_value !== void 0) {
|
56014
|
+
params[kwkey] = default_value;
|
56015
|
+
}
|
56016
|
+
});
|
56017
|
+
return params;
|
56018
|
+
},
|
56019
|
+
clickParams: function() {
|
56020
|
+
var id = "", params = {};
|
56021
|
+
_$1.each(CLICK_IDS, function(idkey) {
|
56022
|
+
id = _$1.getQueryParam(document$1.URL, idkey);
|
56023
|
+
if (id.length) {
|
56024
|
+
params[idkey] = id;
|
56025
|
+
}
|
56026
|
+
});
|
56027
|
+
return params;
|
56028
|
+
},
|
56029
|
+
marketingParams: function() {
|
56030
|
+
return _$1.extend(_$1.info.campaignParams(), _$1.info.clickParams());
|
56031
|
+
},
|
56032
|
+
searchEngine: function(referrer) {
|
56033
|
+
if (referrer.search("https?://(.*)google.([^/?]*)") === 0) {
|
56034
|
+
return "google";
|
56035
|
+
} else if (referrer.search("https?://(.*)bing.com") === 0) {
|
56036
|
+
return "bing";
|
56037
|
+
} else if (referrer.search("https?://(.*)yahoo.com") === 0) {
|
56038
|
+
return "yahoo";
|
56039
|
+
} else if (referrer.search("https?://(.*)duckduckgo.com") === 0) {
|
56040
|
+
return "duckduckgo";
|
56041
|
+
} else {
|
56042
|
+
return null;
|
56043
|
+
}
|
56044
|
+
},
|
56045
|
+
searchInfo: function(referrer) {
|
56046
|
+
var search = _$1.info.searchEngine(referrer), param = search != "yahoo" ? "q" : "p", ret = {};
|
56047
|
+
if (search !== null) {
|
56048
|
+
ret["$search_engine"] = search;
|
56049
|
+
var keyword = _$1.getQueryParam(referrer, param);
|
56050
|
+
if (keyword.length) {
|
56051
|
+
ret["mp_keyword"] = keyword;
|
56052
|
+
}
|
56053
|
+
}
|
56054
|
+
return ret;
|
56055
|
+
},
|
56056
|
+
browser: function(user_agent, vendor, opera) {
|
56057
|
+
vendor = vendor || "";
|
56058
|
+
if (opera || _$1.includes(user_agent, " OPR/")) {
|
56059
|
+
if (_$1.includes(user_agent, "Mini")) {
|
56060
|
+
return "Opera Mini";
|
56061
|
+
}
|
56062
|
+
return "Opera";
|
56063
|
+
} else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
|
56064
|
+
return "BlackBerry";
|
56065
|
+
} else if (_$1.includes(user_agent, "IEMobile") || _$1.includes(user_agent, "WPDesktop")) {
|
56066
|
+
return "Internet Explorer Mobile";
|
56067
|
+
} else if (_$1.includes(user_agent, "SamsungBrowser/")) {
|
56068
|
+
return "Samsung Internet";
|
56069
|
+
} else if (_$1.includes(user_agent, "Edge") || _$1.includes(user_agent, "Edg/")) {
|
56070
|
+
return "Microsoft Edge";
|
56071
|
+
} else if (_$1.includes(user_agent, "FBIOS")) {
|
56072
|
+
return "Facebook Mobile";
|
56073
|
+
} else if (_$1.includes(user_agent, "Chrome")) {
|
56074
|
+
return "Chrome";
|
56075
|
+
} else if (_$1.includes(user_agent, "CriOS")) {
|
56076
|
+
return "Chrome iOS";
|
56077
|
+
} else if (_$1.includes(user_agent, "UCWEB") || _$1.includes(user_agent, "UCBrowser")) {
|
56078
|
+
return "UC Browser";
|
56079
|
+
} else if (_$1.includes(user_agent, "FxiOS")) {
|
56080
|
+
return "Firefox iOS";
|
56081
|
+
} else if (_$1.includes(vendor, "Apple")) {
|
56082
|
+
if (_$1.includes(user_agent, "Mobile")) {
|
56083
|
+
return "Mobile Safari";
|
56084
|
+
}
|
56085
|
+
return "Safari";
|
56086
|
+
} else if (_$1.includes(user_agent, "Android")) {
|
56087
|
+
return "Android Mobile";
|
56088
|
+
} else if (_$1.includes(user_agent, "Konqueror")) {
|
56089
|
+
return "Konqueror";
|
56090
|
+
} else if (_$1.includes(user_agent, "Firefox")) {
|
56091
|
+
return "Firefox";
|
56092
|
+
} else if (_$1.includes(user_agent, "MSIE") || _$1.includes(user_agent, "Trident/")) {
|
56093
|
+
return "Internet Explorer";
|
56094
|
+
} else if (_$1.includes(user_agent, "Gecko")) {
|
56095
|
+
return "Mozilla";
|
56096
|
+
} else {
|
56097
|
+
return "";
|
56098
|
+
}
|
56099
|
+
},
|
56100
|
+
browserVersion: function(userAgent2, vendor, opera) {
|
56101
|
+
var browser2 = _$1.info.browser(userAgent2, vendor, opera);
|
56102
|
+
var versionRegexs = {
|
56103
|
+
"Internet Explorer Mobile": /rv:(\d+(\.\d+)?)/,
|
56104
|
+
"Microsoft Edge": /Edge?\/(\d+(\.\d+)?)/,
|
56105
|
+
"Chrome": /Chrome\/(\d+(\.\d+)?)/,
|
56106
|
+
"Chrome iOS": /CriOS\/(\d+(\.\d+)?)/,
|
56107
|
+
"UC Browser": /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
|
56108
|
+
"Safari": /Version\/(\d+(\.\d+)?)/,
|
56109
|
+
"Mobile Safari": /Version\/(\d+(\.\d+)?)/,
|
56110
|
+
"Opera": /(Opera|OPR)\/(\d+(\.\d+)?)/,
|
56111
|
+
"Firefox": /Firefox\/(\d+(\.\d+)?)/,
|
56112
|
+
"Firefox iOS": /FxiOS\/(\d+(\.\d+)?)/,
|
56113
|
+
"Konqueror": /Konqueror:(\d+(\.\d+)?)/,
|
56114
|
+
"BlackBerry": /BlackBerry (\d+(\.\d+)?)/,
|
56115
|
+
"Android Mobile": /android\s(\d+(\.\d+)?)/,
|
56116
|
+
"Samsung Internet": /SamsungBrowser\/(\d+(\.\d+)?)/,
|
56117
|
+
"Internet Explorer": /(rv:|MSIE )(\d+(\.\d+)?)/,
|
56118
|
+
"Mozilla": /rv:(\d+(\.\d+)?)/
|
56119
|
+
};
|
56120
|
+
var regex = versionRegexs[browser2];
|
56121
|
+
if (regex === void 0) {
|
56122
|
+
return null;
|
56123
|
+
}
|
56124
|
+
var matches = userAgent2.match(regex);
|
56125
|
+
if (!matches) {
|
56126
|
+
return null;
|
56127
|
+
}
|
56128
|
+
return parseFloat(matches[matches.length - 2]);
|
56129
|
+
},
|
56130
|
+
os: function() {
|
56131
|
+
var a = userAgent;
|
56132
|
+
if (/Windows/i.test(a)) {
|
56133
|
+
if (/Phone/.test(a) || /WPDesktop/.test(a)) {
|
56134
|
+
return "Windows Phone";
|
56135
|
+
}
|
56136
|
+
return "Windows";
|
56137
|
+
} else if (/(iPhone|iPad|iPod)/.test(a)) {
|
56138
|
+
return "iOS";
|
56139
|
+
} else if (/Android/.test(a)) {
|
56140
|
+
return "Android";
|
56141
|
+
} else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
|
56142
|
+
return "BlackBerry";
|
56143
|
+
} else if (/Mac/i.test(a)) {
|
56144
|
+
return "Mac OS X";
|
56145
|
+
} else if (/Linux/.test(a)) {
|
56146
|
+
return "Linux";
|
56147
|
+
} else if (/CrOS/.test(a)) {
|
56148
|
+
return "Chrome OS";
|
56149
|
+
} else {
|
56150
|
+
return "";
|
56151
|
+
}
|
56152
|
+
},
|
56153
|
+
device: function(user_agent) {
|
56154
|
+
if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
|
56155
|
+
return "Windows Phone";
|
56156
|
+
} else if (/iPad/.test(user_agent)) {
|
56157
|
+
return "iPad";
|
56158
|
+
} else if (/iPod/.test(user_agent)) {
|
56159
|
+
return "iPod Touch";
|
56160
|
+
} else if (/iPhone/.test(user_agent)) {
|
56161
|
+
return "iPhone";
|
56162
|
+
} else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
|
56163
|
+
return "BlackBerry";
|
56164
|
+
} else if (/Android/.test(user_agent)) {
|
56165
|
+
return "Android";
|
56166
|
+
} else {
|
56167
|
+
return "";
|
56168
|
+
}
|
56169
|
+
},
|
56170
|
+
referringDomain: function(referrer) {
|
56171
|
+
var split = referrer.split("/");
|
56172
|
+
if (split.length >= 3) {
|
56173
|
+
return split[2];
|
56174
|
+
}
|
56175
|
+
return "";
|
56176
|
+
},
|
56177
|
+
currentUrl: function() {
|
56178
|
+
return win.location.href;
|
56179
|
+
},
|
56180
|
+
properties: function(extra_props) {
|
56181
|
+
if (typeof extra_props !== "object") {
|
56182
|
+
extra_props = {};
|
56183
|
+
}
|
56184
|
+
return _$1.extend(_$1.strip_empty_properties({
|
56185
|
+
"$os": _$1.info.os(),
|
56186
|
+
"$browser": _$1.info.browser(userAgent, navigator$1.vendor, windowOpera),
|
56187
|
+
"$referrer": document$1.referrer,
|
56188
|
+
"$referring_domain": _$1.info.referringDomain(document$1.referrer),
|
56189
|
+
"$device": _$1.info.device(userAgent)
|
56190
|
+
}), {
|
56191
|
+
"$current_url": _$1.info.currentUrl(),
|
56192
|
+
"$browser_version": _$1.info.browserVersion(userAgent, navigator$1.vendor, windowOpera),
|
56193
|
+
"$screen_height": screen.height,
|
56194
|
+
"$screen_width": screen.width,
|
56195
|
+
"mp_lib": "web",
|
56196
|
+
"$lib_version": Config.LIB_VERSION,
|
56197
|
+
"$insert_id": cheap_guid(),
|
56198
|
+
"time": _$1.timestamp() / 1e3
|
56199
|
+
}, _$1.strip_empty_properties(extra_props));
|
56200
|
+
},
|
56201
|
+
people_properties: function() {
|
56202
|
+
return _$1.extend(_$1.strip_empty_properties({
|
56203
|
+
"$os": _$1.info.os(),
|
56204
|
+
"$browser": _$1.info.browser(userAgent, navigator$1.vendor, windowOpera)
|
56205
|
+
}), {
|
56206
|
+
"$browser_version": _$1.info.browserVersion(userAgent, navigator$1.vendor, windowOpera)
|
56207
|
+
});
|
56208
|
+
},
|
56209
|
+
mpPageViewProperties: function() {
|
56210
|
+
return _$1.strip_empty_properties({
|
56211
|
+
"current_page_title": document$1.title,
|
56212
|
+
"current_domain": win.location.hostname,
|
56213
|
+
"current_url_path": win.location.pathname,
|
56214
|
+
"current_url_protocol": win.location.protocol,
|
56215
|
+
"current_url_search": win.location.search
|
56216
|
+
});
|
56217
|
+
}
|
56218
|
+
};
|
56219
|
+
var cheap_guid = function(maxlen) {
|
56220
|
+
var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
|
56221
|
+
return maxlen ? guid.substring(0, maxlen) : guid;
|
56222
|
+
};
|
56223
|
+
var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
|
56224
|
+
var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
|
56225
|
+
var extract_domain = function(hostname) {
|
56226
|
+
var domain_regex = DOMAIN_MATCH_REGEX;
|
56227
|
+
var parts = hostname.split(".");
|
56228
|
+
var tld = parts[parts.length - 1];
|
56229
|
+
if (tld.length > 4 || tld === "com" || tld === "org") {
|
56230
|
+
domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
|
56231
|
+
}
|
56232
|
+
var matches = hostname.match(domain_regex);
|
56233
|
+
return matches ? matches[0] : "";
|
56234
|
+
};
|
56235
|
+
var JSONStringify = null, JSONParse = null;
|
56236
|
+
if (typeof JSON !== "undefined") {
|
56237
|
+
JSONStringify = JSON.stringify;
|
56238
|
+
JSONParse = JSON.parse;
|
56239
|
+
}
|
56240
|
+
JSONStringify = JSONStringify || _$1.JSONEncode;
|
56241
|
+
JSONParse = JSONParse || _$1.JSONDecode;
|
56242
|
+
_$1["toArray"] = _$1.toArray;
|
56243
|
+
_$1["isObject"] = _$1.isObject;
|
56244
|
+
_$1["JSONEncode"] = _$1.JSONEncode;
|
56245
|
+
_$1["JSONDecode"] = _$1.JSONDecode;
|
56246
|
+
_$1["isBlockedUA"] = _$1.isBlockedUA;
|
56247
|
+
_$1["isEmptyObject"] = _$1.isEmptyObject;
|
56248
|
+
_$1["info"] = _$1.info;
|
56249
|
+
_$1["info"]["device"] = _$1.info.device;
|
56250
|
+
_$1["info"]["browser"] = _$1.info.browser;
|
56251
|
+
_$1["info"]["browserVersion"] = _$1.info.browserVersion;
|
56252
|
+
_$1["info"]["properties"] = _$1.info.properties;
|
56253
|
+
var DomTracker = function() {
|
56254
|
+
};
|
56255
|
+
DomTracker.prototype.create_properties = function() {
|
56256
|
+
};
|
56257
|
+
DomTracker.prototype.event_handler = function() {
|
56258
|
+
};
|
56259
|
+
DomTracker.prototype.after_track_handler = function() {
|
56260
|
+
};
|
56261
|
+
DomTracker.prototype.init = function(mixpanel_instance) {
|
56262
|
+
this.mp = mixpanel_instance;
|
56263
|
+
return this;
|
56264
|
+
};
|
56265
|
+
DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
|
56266
|
+
var that = this;
|
56267
|
+
var elements = _$1.dom_query(query);
|
56268
|
+
if (elements.length === 0) {
|
56269
|
+
console$1.error("The DOM query (" + query + ") returned 0 elements");
|
56270
|
+
return;
|
56271
|
+
}
|
56272
|
+
_$1.each(elements, function(element) {
|
56273
|
+
_$1.register_event(element, this.override_event, function(e) {
|
56274
|
+
var options = {};
|
56275
|
+
var props = that.create_properties(properties, this);
|
56276
|
+
var timeout = that.mp.get_config("track_links_timeout");
|
56277
|
+
that.event_handler(e, this, options);
|
56278
|
+
window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
|
56279
|
+
that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
|
56280
|
+
});
|
56281
|
+
}, this);
|
56282
|
+
return true;
|
56283
|
+
};
|
56284
|
+
DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
|
56285
|
+
timeout_occured = timeout_occured || false;
|
56286
|
+
var that = this;
|
56287
|
+
return function() {
|
56288
|
+
if (options.callback_fired) {
|
56289
|
+
return;
|
56290
|
+
}
|
56291
|
+
options.callback_fired = true;
|
56292
|
+
if (user_callback && user_callback(timeout_occured, props) === false) {
|
56293
|
+
return;
|
56294
|
+
}
|
56295
|
+
that.after_track_handler(props, options, timeout_occured);
|
56296
|
+
};
|
56297
|
+
};
|
56298
|
+
DomTracker.prototype.create_properties = function(properties, element) {
|
56299
|
+
var props;
|
56300
|
+
if (typeof properties === "function") {
|
56301
|
+
props = properties(element);
|
56302
|
+
} else {
|
56303
|
+
props = _$1.extend({}, properties);
|
56304
|
+
}
|
56305
|
+
return props;
|
56306
|
+
};
|
56307
|
+
var LinkTracker = function() {
|
56308
|
+
this.override_event = "click";
|
56309
|
+
};
|
56310
|
+
_$1.inherit(LinkTracker, DomTracker);
|
56311
|
+
LinkTracker.prototype.create_properties = function(properties, element) {
|
56312
|
+
var props = LinkTracker.superclass.create_properties.apply(this, arguments);
|
56313
|
+
if (element.href) {
|
56314
|
+
props["url"] = element.href;
|
56315
|
+
}
|
56316
|
+
return props;
|
56317
|
+
};
|
56318
|
+
LinkTracker.prototype.event_handler = function(evt, element, options) {
|
56319
|
+
options.new_tab = evt.which === 2 || evt.metaKey || evt.ctrlKey || element.target === "_blank";
|
56320
|
+
options.href = element.href;
|
56321
|
+
if (!options.new_tab) {
|
56322
|
+
evt.preventDefault();
|
56323
|
+
}
|
56324
|
+
};
|
56325
|
+
LinkTracker.prototype.after_track_handler = function(props, options) {
|
56326
|
+
if (options.new_tab) {
|
56327
|
+
return;
|
56328
|
+
}
|
56329
|
+
setTimeout(function() {
|
56330
|
+
window.location = options.href;
|
56331
|
+
}, 0);
|
56332
|
+
};
|
56333
|
+
var FormTracker = function() {
|
56334
|
+
this.override_event = "submit";
|
56335
|
+
};
|
56336
|
+
_$1.inherit(FormTracker, DomTracker);
|
56337
|
+
FormTracker.prototype.event_handler = function(evt, element, options) {
|
56338
|
+
options.element = element;
|
56339
|
+
evt.preventDefault();
|
56340
|
+
};
|
56341
|
+
FormTracker.prototype.after_track_handler = function(props, options) {
|
56342
|
+
setTimeout(function() {
|
56343
|
+
options.element.submit();
|
56344
|
+
}, 0);
|
56345
|
+
};
|
56346
|
+
var logger$2 = console_with_prefix("lock");
|
56347
|
+
var SharedLock = function(key, options) {
|
56348
|
+
options = options || {};
|
56349
|
+
this.storageKey = key;
|
56350
|
+
this.storage = options.storage || window.localStorage;
|
56351
|
+
this.pollIntervalMS = options.pollIntervalMS || 100;
|
56352
|
+
this.timeoutMS = options.timeoutMS || 2e3;
|
56353
|
+
};
|
56354
|
+
SharedLock.prototype.withLock = function(lockedCB, errorCB, pid) {
|
56355
|
+
if (!pid && typeof errorCB !== "function") {
|
56356
|
+
pid = errorCB;
|
56357
|
+
errorCB = null;
|
56358
|
+
}
|
56359
|
+
var i2 = pid || new Date().getTime() + "|" + Math.random();
|
56360
|
+
var startTime2 = new Date().getTime();
|
56361
|
+
var key = this.storageKey;
|
56362
|
+
var pollIntervalMS = this.pollIntervalMS;
|
56363
|
+
var timeoutMS = this.timeoutMS;
|
56364
|
+
var storage = this.storage;
|
56365
|
+
var keyX = key + ":X";
|
56366
|
+
var keyY = key + ":Y";
|
56367
|
+
var keyZ = key + ":Z";
|
56368
|
+
var reportError = function(err) {
|
56369
|
+
errorCB && errorCB(err);
|
56370
|
+
};
|
56371
|
+
var delay = function(cb) {
|
56372
|
+
if (new Date().getTime() - startTime2 > timeoutMS) {
|
56373
|
+
logger$2.error("Timeout waiting for mutex on " + key + "; clearing lock. [" + i2 + "]");
|
56374
|
+
storage.removeItem(keyZ);
|
56375
|
+
storage.removeItem(keyY);
|
56376
|
+
loop();
|
56377
|
+
return;
|
56378
|
+
}
|
56379
|
+
setTimeout(function() {
|
56380
|
+
try {
|
56381
|
+
cb();
|
56382
|
+
} catch (err) {
|
56383
|
+
reportError(err);
|
56384
|
+
}
|
56385
|
+
}, pollIntervalMS * (Math.random() + 0.1));
|
56386
|
+
};
|
56387
|
+
var waitFor = function(predicate, cb) {
|
56388
|
+
if (predicate()) {
|
56389
|
+
cb();
|
56390
|
+
} else {
|
56391
|
+
delay(function() {
|
56392
|
+
waitFor(predicate, cb);
|
56393
|
+
});
|
56394
|
+
}
|
56395
|
+
};
|
56396
|
+
var getSetY = function() {
|
56397
|
+
var valY = storage.getItem(keyY);
|
56398
|
+
if (valY && valY !== i2) {
|
56399
|
+
return false;
|
56400
|
+
} else {
|
56401
|
+
storage.setItem(keyY, i2);
|
56402
|
+
if (storage.getItem(keyY) === i2) {
|
56403
|
+
return true;
|
56404
|
+
} else {
|
56405
|
+
if (!localStorageSupported(storage, true)) {
|
56406
|
+
throw new Error("localStorage support dropped while acquiring lock");
|
56407
|
+
}
|
56408
|
+
return false;
|
56409
|
+
}
|
56410
|
+
}
|
56411
|
+
};
|
56412
|
+
var loop = function() {
|
56413
|
+
storage.setItem(keyX, i2);
|
56414
|
+
waitFor(getSetY, function() {
|
56415
|
+
if (storage.getItem(keyX) === i2) {
|
56416
|
+
criticalSection();
|
56417
|
+
return;
|
56418
|
+
}
|
56419
|
+
delay(function() {
|
56420
|
+
if (storage.getItem(keyY) !== i2) {
|
56421
|
+
loop();
|
56422
|
+
return;
|
56423
|
+
}
|
56424
|
+
waitFor(function() {
|
56425
|
+
return !storage.getItem(keyZ);
|
56426
|
+
}, criticalSection);
|
56427
|
+
});
|
56428
|
+
});
|
56429
|
+
};
|
56430
|
+
var criticalSection = function() {
|
56431
|
+
storage.setItem(keyZ, "1");
|
56432
|
+
try {
|
56433
|
+
lockedCB();
|
56434
|
+
} finally {
|
56435
|
+
storage.removeItem(keyZ);
|
56436
|
+
if (storage.getItem(keyY) === i2) {
|
56437
|
+
storage.removeItem(keyY);
|
56438
|
+
}
|
56439
|
+
if (storage.getItem(keyX) === i2) {
|
56440
|
+
storage.removeItem(keyX);
|
56441
|
+
}
|
56442
|
+
}
|
56443
|
+
};
|
56444
|
+
try {
|
56445
|
+
if (localStorageSupported(storage, true)) {
|
56446
|
+
loop();
|
56447
|
+
} else {
|
56448
|
+
throw new Error("localStorage support check failed");
|
56449
|
+
}
|
56450
|
+
} catch (err) {
|
56451
|
+
reportError(err);
|
56452
|
+
}
|
56453
|
+
};
|
56454
|
+
var logger$1 = console_with_prefix("batch");
|
56455
|
+
var RequestQueue = function(storageKey, options) {
|
56456
|
+
options = options || {};
|
56457
|
+
this.storageKey = storageKey;
|
56458
|
+
this.storage = options.storage || window.localStorage;
|
56459
|
+
this.reportError = options.errorReporter || _$1.bind(logger$1.error, logger$1);
|
56460
|
+
this.lock = new SharedLock(storageKey, { storage: this.storage });
|
56461
|
+
this.pid = options.pid || null;
|
56462
|
+
this.memQueue = [];
|
56463
|
+
};
|
56464
|
+
RequestQueue.prototype.enqueue = function(item, flushInterval, cb) {
|
56465
|
+
var queueEntry = {
|
56466
|
+
"id": cheap_guid(),
|
56467
|
+
"flushAfter": new Date().getTime() + flushInterval * 2,
|
56468
|
+
"payload": item
|
56469
|
+
};
|
56470
|
+
this.lock.withLock(_$1.bind(function lockAcquired() {
|
56471
|
+
var succeeded;
|
56472
|
+
try {
|
56473
|
+
var storedQueue = this.readFromStorage();
|
56474
|
+
storedQueue.push(queueEntry);
|
56475
|
+
succeeded = this.saveToStorage(storedQueue);
|
56476
|
+
if (succeeded) {
|
56477
|
+
this.memQueue.push(queueEntry);
|
56478
|
+
}
|
56479
|
+
} catch (err) {
|
56480
|
+
this.reportError("Error enqueueing item", item);
|
56481
|
+
succeeded = false;
|
56482
|
+
}
|
56483
|
+
if (cb) {
|
56484
|
+
cb(succeeded);
|
56485
|
+
}
|
56486
|
+
}, this), _$1.bind(function lockFailure(err) {
|
56487
|
+
this.reportError("Error acquiring storage lock", err);
|
56488
|
+
if (cb) {
|
56489
|
+
cb(false);
|
56490
|
+
}
|
56491
|
+
}, this), this.pid);
|
56492
|
+
};
|
56493
|
+
RequestQueue.prototype.fillBatch = function(batchSize) {
|
56494
|
+
var batch = this.memQueue.slice(0, batchSize);
|
56495
|
+
if (batch.length < batchSize) {
|
56496
|
+
var storedQueue = this.readFromStorage();
|
56497
|
+
if (storedQueue.length) {
|
56498
|
+
var idsInBatch = {};
|
56499
|
+
_$1.each(batch, function(item2) {
|
56500
|
+
idsInBatch[item2["id"]] = true;
|
56501
|
+
});
|
56502
|
+
for (var i2 = 0; i2 < storedQueue.length; i2++) {
|
56503
|
+
var item = storedQueue[i2];
|
56504
|
+
if (new Date().getTime() > item["flushAfter"] && !idsInBatch[item["id"]]) {
|
56505
|
+
item.orphaned = true;
|
56506
|
+
batch.push(item);
|
56507
|
+
if (batch.length >= batchSize) {
|
56508
|
+
break;
|
56509
|
+
}
|
56510
|
+
}
|
56511
|
+
}
|
56512
|
+
}
|
56513
|
+
}
|
56514
|
+
return batch;
|
56515
|
+
};
|
56516
|
+
var filterOutIDsAndInvalid = function(items, idSet) {
|
56517
|
+
var filteredItems = [];
|
56518
|
+
_$1.each(items, function(item) {
|
56519
|
+
if (item["id"] && !idSet[item["id"]]) {
|
56520
|
+
filteredItems.push(item);
|
56521
|
+
}
|
56522
|
+
});
|
56523
|
+
return filteredItems;
|
56524
|
+
};
|
56525
|
+
RequestQueue.prototype.removeItemsByID = function(ids, cb) {
|
56526
|
+
var idSet = {};
|
56527
|
+
_$1.each(ids, function(id) {
|
56528
|
+
idSet[id] = true;
|
56529
|
+
});
|
56530
|
+
this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
|
56531
|
+
var removeFromStorage = _$1.bind(function() {
|
56532
|
+
var succeeded;
|
56533
|
+
try {
|
56534
|
+
var storedQueue = this.readFromStorage();
|
56535
|
+
storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
|
56536
|
+
succeeded = this.saveToStorage(storedQueue);
|
56537
|
+
if (succeeded) {
|
56538
|
+
storedQueue = this.readFromStorage();
|
56539
|
+
for (var i2 = 0; i2 < storedQueue.length; i2++) {
|
56540
|
+
var item = storedQueue[i2];
|
56541
|
+
if (item["id"] && !!idSet[item["id"]]) {
|
56542
|
+
this.reportError("Item not removed from storage");
|
56543
|
+
return false;
|
56544
|
+
}
|
56545
|
+
}
|
56546
|
+
}
|
56547
|
+
} catch (err) {
|
56548
|
+
this.reportError("Error removing items", ids);
|
56549
|
+
succeeded = false;
|
56550
|
+
}
|
56551
|
+
return succeeded;
|
56552
|
+
}, this);
|
56553
|
+
this.lock.withLock(function lockAcquired() {
|
56554
|
+
var succeeded = removeFromStorage();
|
56555
|
+
if (cb) {
|
56556
|
+
cb(succeeded);
|
56557
|
+
}
|
56558
|
+
}, _$1.bind(function lockFailure(err) {
|
56559
|
+
var succeeded = false;
|
56560
|
+
this.reportError("Error acquiring storage lock", err);
|
56561
|
+
if (!localStorageSupported(this.storage, true)) {
|
56562
|
+
succeeded = removeFromStorage();
|
56563
|
+
if (!succeeded) {
|
56564
|
+
try {
|
56565
|
+
this.storage.removeItem(this.storageKey);
|
56566
|
+
} catch (err2) {
|
56567
|
+
this.reportError("Error clearing queue", err2);
|
56568
|
+
}
|
56569
|
+
}
|
56570
|
+
}
|
56571
|
+
if (cb) {
|
56572
|
+
cb(succeeded);
|
56573
|
+
}
|
56574
|
+
}, this), this.pid);
|
56575
|
+
};
|
56576
|
+
var updatePayloads = function(existingItems, itemsToUpdate) {
|
56577
|
+
var newItems = [];
|
56578
|
+
_$1.each(existingItems, function(item) {
|
56579
|
+
var id = item["id"];
|
56580
|
+
if (id in itemsToUpdate) {
|
56581
|
+
var newPayload = itemsToUpdate[id];
|
56582
|
+
if (newPayload !== null) {
|
56583
|
+
item["payload"] = newPayload;
|
56584
|
+
newItems.push(item);
|
56585
|
+
}
|
56586
|
+
} else {
|
56587
|
+
newItems.push(item);
|
56588
|
+
}
|
56589
|
+
});
|
56590
|
+
return newItems;
|
56591
|
+
};
|
56592
|
+
RequestQueue.prototype.updatePayloads = function(itemsToUpdate, cb) {
|
56593
|
+
this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
|
56594
|
+
this.lock.withLock(_$1.bind(function lockAcquired() {
|
56595
|
+
var succeeded;
|
56596
|
+
try {
|
56597
|
+
var storedQueue = this.readFromStorage();
|
56598
|
+
storedQueue = updatePayloads(storedQueue, itemsToUpdate);
|
56599
|
+
succeeded = this.saveToStorage(storedQueue);
|
56600
|
+
} catch (err) {
|
56601
|
+
this.reportError("Error updating items", itemsToUpdate);
|
56602
|
+
succeeded = false;
|
56603
|
+
}
|
56604
|
+
if (cb) {
|
56605
|
+
cb(succeeded);
|
56606
|
+
}
|
56607
|
+
}, this), _$1.bind(function lockFailure(err) {
|
56608
|
+
this.reportError("Error acquiring storage lock", err);
|
56609
|
+
if (cb) {
|
56610
|
+
cb(false);
|
56611
|
+
}
|
56612
|
+
}, this), this.pid);
|
56613
|
+
};
|
56614
|
+
RequestQueue.prototype.readFromStorage = function() {
|
56615
|
+
var storageEntry;
|
56616
|
+
try {
|
56617
|
+
storageEntry = this.storage.getItem(this.storageKey);
|
56618
|
+
if (storageEntry) {
|
56619
|
+
storageEntry = JSONParse(storageEntry);
|
56620
|
+
if (!_$1.isArray(storageEntry)) {
|
56621
|
+
this.reportError("Invalid storage entry:", storageEntry);
|
56622
|
+
storageEntry = null;
|
56623
|
+
}
|
56624
|
+
}
|
56625
|
+
} catch (err) {
|
56626
|
+
this.reportError("Error retrieving queue", err);
|
56627
|
+
storageEntry = null;
|
56628
|
+
}
|
56629
|
+
return storageEntry || [];
|
56630
|
+
};
|
56631
|
+
RequestQueue.prototype.saveToStorage = function(queue) {
|
56632
|
+
try {
|
56633
|
+
this.storage.setItem(this.storageKey, JSONStringify(queue));
|
56634
|
+
return true;
|
56635
|
+
} catch (err) {
|
56636
|
+
this.reportError("Error saving queue", err);
|
56637
|
+
return false;
|
56638
|
+
}
|
56639
|
+
};
|
56640
|
+
RequestQueue.prototype.clear = function() {
|
56641
|
+
this.memQueue = [];
|
56642
|
+
this.storage.removeItem(this.storageKey);
|
56643
|
+
};
|
56644
|
+
var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1e3;
|
56645
|
+
var logger = console_with_prefix("batch");
|
56646
|
+
var RequestBatcher = function(storageKey, options) {
|
56647
|
+
this.errorReporter = options.errorReporter;
|
56648
|
+
this.queue = new RequestQueue(storageKey, {
|
56649
|
+
errorReporter: _$1.bind(this.reportError, this),
|
56650
|
+
storage: options.storage
|
56651
|
+
});
|
56652
|
+
this.libConfig = options.libConfig;
|
56653
|
+
this.sendRequest = options.sendRequestFunc;
|
56654
|
+
this.beforeSendHook = options.beforeSendHook;
|
56655
|
+
this.stopAllBatching = options.stopAllBatchingFunc;
|
56656
|
+
this.batchSize = this.libConfig["batch_size"];
|
56657
|
+
this.flushInterval = this.libConfig["batch_flush_interval_ms"];
|
56658
|
+
this.stopped = !this.libConfig["batch_autostart"];
|
56659
|
+
this.consecutiveRemovalFailures = 0;
|
56660
|
+
this.itemIdsSentSuccessfully = {};
|
56661
|
+
};
|
56662
|
+
RequestBatcher.prototype.enqueue = function(item, cb) {
|
56663
|
+
this.queue.enqueue(item, this.flushInterval, cb);
|
56664
|
+
};
|
56665
|
+
RequestBatcher.prototype.start = function() {
|
56666
|
+
this.stopped = false;
|
56667
|
+
this.consecutiveRemovalFailures = 0;
|
56668
|
+
this.flush();
|
56669
|
+
};
|
56670
|
+
RequestBatcher.prototype.stop = function() {
|
56671
|
+
this.stopped = true;
|
56672
|
+
if (this.timeoutID) {
|
56673
|
+
clearTimeout(this.timeoutID);
|
56674
|
+
this.timeoutID = null;
|
56675
|
+
}
|
56676
|
+
};
|
56677
|
+
RequestBatcher.prototype.clear = function() {
|
56678
|
+
this.queue.clear();
|
56679
|
+
};
|
56680
|
+
RequestBatcher.prototype.resetBatchSize = function() {
|
56681
|
+
this.batchSize = this.libConfig["batch_size"];
|
56682
|
+
};
|
56683
|
+
RequestBatcher.prototype.resetFlush = function() {
|
56684
|
+
this.scheduleFlush(this.libConfig["batch_flush_interval_ms"]);
|
56685
|
+
};
|
56686
|
+
RequestBatcher.prototype.scheduleFlush = function(flushMS) {
|
56687
|
+
this.flushInterval = flushMS;
|
56688
|
+
if (!this.stopped) {
|
56689
|
+
this.timeoutID = setTimeout(_$1.bind(this.flush, this), this.flushInterval);
|
56690
|
+
}
|
56691
|
+
};
|
56692
|
+
RequestBatcher.prototype.flush = function(options) {
|
56693
|
+
try {
|
56694
|
+
if (this.requestInProgress) {
|
56695
|
+
logger.log("Flush: Request already in progress");
|
56696
|
+
return;
|
56697
|
+
}
|
56698
|
+
options = options || {};
|
56699
|
+
var timeoutMS = this.libConfig["batch_request_timeout_ms"];
|
56700
|
+
var startTime2 = new Date().getTime();
|
56701
|
+
var currentBatchSize = this.batchSize;
|
56702
|
+
var batch = this.queue.fillBatch(currentBatchSize);
|
56703
|
+
var dataForRequest = [];
|
56704
|
+
var transformedItems = {};
|
56705
|
+
_$1.each(batch, function(item) {
|
56706
|
+
var payload = item["payload"];
|
56707
|
+
if (this.beforeSendHook && !item.orphaned) {
|
56708
|
+
payload = this.beforeSendHook(payload);
|
56709
|
+
}
|
56710
|
+
if (payload) {
|
56711
|
+
if (payload["event"] && payload["properties"]) {
|
56712
|
+
payload["properties"] = _$1.extend(
|
56713
|
+
{},
|
56714
|
+
payload["properties"],
|
56715
|
+
{ "mp_sent_by_lib_version": Config.LIB_VERSION }
|
56716
|
+
);
|
56717
|
+
}
|
56718
|
+
var addPayload = true;
|
56719
|
+
var itemId = item["id"];
|
56720
|
+
if (itemId) {
|
56721
|
+
if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
|
56722
|
+
this.reportError("[dupe] item ID sent too many times, not sending", {
|
56723
|
+
item,
|
56724
|
+
batchSize: batch.length,
|
56725
|
+
timesSent: this.itemIdsSentSuccessfully[itemId]
|
56726
|
+
});
|
56727
|
+
addPayload = false;
|
56728
|
+
}
|
56729
|
+
} else {
|
56730
|
+
this.reportError("[dupe] found item with no ID", { item });
|
56731
|
+
}
|
56732
|
+
if (addPayload) {
|
56733
|
+
dataForRequest.push(payload);
|
56734
|
+
}
|
56735
|
+
}
|
56736
|
+
transformedItems[item["id"]] = payload;
|
56737
|
+
}, this);
|
56738
|
+
if (dataForRequest.length < 1) {
|
56739
|
+
this.resetFlush();
|
56740
|
+
return;
|
56741
|
+
}
|
56742
|
+
this.requestInProgress = true;
|
56743
|
+
var batchSendCallback = _$1.bind(function(res) {
|
56744
|
+
this.requestInProgress = false;
|
56745
|
+
try {
|
56746
|
+
var removeItemsFromQueue = false;
|
56747
|
+
if (options.unloading) {
|
56748
|
+
this.queue.updatePayloads(transformedItems);
|
56749
|
+
} else if (_$1.isObject(res) && res.error === "timeout" && new Date().getTime() - startTime2 >= timeoutMS) {
|
56750
|
+
this.reportError("Network timeout; retrying");
|
56751
|
+
this.flush();
|
56752
|
+
} else if (_$1.isObject(res) && res.xhr_req && (res.xhr_req["status"] >= 500 || res.xhr_req["status"] === 429 || res.error === "timeout")) {
|
56753
|
+
var retryMS = this.flushInterval * 2;
|
56754
|
+
var headers = res.xhr_req["responseHeaders"];
|
56755
|
+
if (headers) {
|
56756
|
+
var retryAfter = headers["Retry-After"];
|
56757
|
+
if (retryAfter) {
|
56758
|
+
retryMS = parseInt(retryAfter, 10) * 1e3 || retryMS;
|
56759
|
+
}
|
56760
|
+
}
|
56761
|
+
retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
|
56762
|
+
this.reportError("Error; retry in " + retryMS + " ms");
|
56763
|
+
this.scheduleFlush(retryMS);
|
56764
|
+
} else if (_$1.isObject(res) && res.xhr_req && res.xhr_req["status"] === 413) {
|
56765
|
+
if (batch.length > 1) {
|
56766
|
+
var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
|
56767
|
+
this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
|
56768
|
+
this.reportError("413 response; reducing batch size to " + this.batchSize);
|
56769
|
+
this.resetFlush();
|
56770
|
+
} else {
|
56771
|
+
this.reportError("Single-event request too large; dropping", batch);
|
56772
|
+
this.resetBatchSize();
|
56773
|
+
removeItemsFromQueue = true;
|
56774
|
+
}
|
56775
|
+
} else {
|
56776
|
+
removeItemsFromQueue = true;
|
56777
|
+
}
|
56778
|
+
if (removeItemsFromQueue) {
|
56779
|
+
this.queue.removeItemsByID(
|
56780
|
+
_$1.map(batch, function(item) {
|
56781
|
+
return item["id"];
|
56782
|
+
}),
|
56783
|
+
_$1.bind(function(succeeded) {
|
56784
|
+
if (succeeded) {
|
56785
|
+
this.consecutiveRemovalFailures = 0;
|
56786
|
+
this.flush();
|
56787
|
+
} else {
|
56788
|
+
this.reportError("Failed to remove items from queue");
|
56789
|
+
if (++this.consecutiveRemovalFailures > 5) {
|
56790
|
+
this.reportError("Too many queue failures; disabling batching system.");
|
56791
|
+
this.stopAllBatching();
|
56792
|
+
} else {
|
56793
|
+
this.resetFlush();
|
56794
|
+
}
|
56795
|
+
}
|
56796
|
+
}, this)
|
56797
|
+
);
|
56798
|
+
_$1.each(batch, _$1.bind(function(item) {
|
56799
|
+
var itemId = item["id"];
|
56800
|
+
if (itemId) {
|
56801
|
+
this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
|
56802
|
+
this.itemIdsSentSuccessfully[itemId]++;
|
56803
|
+
if (this.itemIdsSentSuccessfully[itemId] > 5) {
|
56804
|
+
this.reportError("[dupe] item ID sent too many times", {
|
56805
|
+
item,
|
56806
|
+
batchSize: batch.length,
|
56807
|
+
timesSent: this.itemIdsSentSuccessfully[itemId]
|
56808
|
+
});
|
56809
|
+
}
|
56810
|
+
} else {
|
56811
|
+
this.reportError("[dupe] found item with no ID while removing", { item });
|
56812
|
+
}
|
56813
|
+
}, this));
|
56814
|
+
}
|
56815
|
+
} catch (err) {
|
56816
|
+
this.reportError("Error handling API response", err);
|
56817
|
+
this.resetFlush();
|
56818
|
+
}
|
56819
|
+
}, this);
|
56820
|
+
var requestOptions = {
|
56821
|
+
method: "POST",
|
56822
|
+
verbose: true,
|
56823
|
+
ignore_json_errors: true,
|
56824
|
+
timeout_ms: timeoutMS
|
56825
|
+
};
|
56826
|
+
if (options.unloading) {
|
56827
|
+
requestOptions.transport = "sendBeacon";
|
56828
|
+
}
|
56829
|
+
logger.log("MIXPANEL REQUEST:", dataForRequest);
|
56830
|
+
this.sendRequest(dataForRequest, requestOptions, batchSendCallback);
|
56831
|
+
} catch (err) {
|
56832
|
+
this.reportError("Error flushing request queue", err);
|
56833
|
+
this.resetFlush();
|
56834
|
+
}
|
56835
|
+
};
|
56836
|
+
RequestBatcher.prototype.reportError = function(msg, err) {
|
56837
|
+
logger.error.apply(logger.error, arguments);
|
56838
|
+
if (this.errorReporter) {
|
56839
|
+
try {
|
56840
|
+
if (!(err instanceof Error)) {
|
56841
|
+
err = new Error(msg);
|
56842
|
+
}
|
56843
|
+
this.errorReporter(msg, err);
|
56844
|
+
} catch (err2) {
|
56845
|
+
logger.error(err2);
|
56846
|
+
}
|
56847
|
+
}
|
56848
|
+
};
|
56849
|
+
var GDPR_DEFAULT_PERSISTENCE_PREFIX = "__mp_opt_in_out_";
|
56850
|
+
function optIn(token, options) {
|
56851
|
+
_optInOut(true, token, options);
|
56852
|
+
}
|
56853
|
+
function optOut(token, options) {
|
56854
|
+
_optInOut(false, token, options);
|
56855
|
+
}
|
56856
|
+
function hasOptedIn(token, options) {
|
56857
|
+
return _getStorageValue(token, options) === "1";
|
56858
|
+
}
|
56859
|
+
function hasOptedOut(token, options) {
|
56860
|
+
if (_hasDoNotTrackFlagOn(options)) {
|
56861
|
+
console$1.warn('This browser has "Do Not Track" enabled. This will prevent the Mixpanel SDK from sending any data. To ignore the "Do Not Track" browser setting, initialize the Mixpanel instance with the config "ignore_dnt: true"');
|
56862
|
+
return true;
|
56863
|
+
}
|
56864
|
+
var optedOut = _getStorageValue(token, options) === "0";
|
56865
|
+
if (optedOut) {
|
56866
|
+
console$1.warn("You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.");
|
56867
|
+
}
|
56868
|
+
return optedOut;
|
56869
|
+
}
|
56870
|
+
function addOptOutCheckMixpanelLib(method) {
|
56871
|
+
return _addOptOutCheck(method, function(name2) {
|
56872
|
+
return this.get_config(name2);
|
56873
|
+
});
|
56874
|
+
}
|
56875
|
+
function addOptOutCheckMixpanelPeople(method) {
|
56876
|
+
return _addOptOutCheck(method, function(name2) {
|
56877
|
+
return this._get_config(name2);
|
56878
|
+
});
|
56879
|
+
}
|
56880
|
+
function addOptOutCheckMixpanelGroup(method) {
|
56881
|
+
return _addOptOutCheck(method, function(name2) {
|
56882
|
+
return this._get_config(name2);
|
56883
|
+
});
|
56884
|
+
}
|
56885
|
+
function clearOptInOut(token, options) {
|
56886
|
+
options = options || {};
|
56887
|
+
_getStorage(options).remove(
|
56888
|
+
_getStorageKey(token, options),
|
56889
|
+
!!options.crossSubdomainCookie,
|
56890
|
+
options.cookieDomain
|
56891
|
+
);
|
56892
|
+
}
|
56893
|
+
function _getStorage(options) {
|
56894
|
+
options = options || {};
|
56895
|
+
return options.persistenceType === "localStorage" ? _$1.localStorage : _$1.cookie;
|
56896
|
+
}
|
56897
|
+
function _getStorageKey(token, options) {
|
56898
|
+
options = options || {};
|
56899
|
+
return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
|
56900
|
+
}
|
56901
|
+
function _getStorageValue(token, options) {
|
56902
|
+
return _getStorage(options).get(_getStorageKey(token, options));
|
56903
|
+
}
|
56904
|
+
function _hasDoNotTrackFlagOn(options) {
|
56905
|
+
if (options && options.ignoreDnt) {
|
56906
|
+
return false;
|
56907
|
+
}
|
56908
|
+
var win$12 = options && options.window || win;
|
56909
|
+
var nav = win$12["navigator"] || {};
|
56910
|
+
var hasDntOn = false;
|
56911
|
+
_$1.each([
|
56912
|
+
nav["doNotTrack"],
|
56913
|
+
nav["msDoNotTrack"],
|
56914
|
+
win$12["doNotTrack"]
|
56915
|
+
], function(dntValue) {
|
56916
|
+
if (_$1.includes([true, 1, "1", "yes"], dntValue)) {
|
56917
|
+
hasDntOn = true;
|
56918
|
+
}
|
56919
|
+
});
|
56920
|
+
return hasDntOn;
|
56921
|
+
}
|
56922
|
+
function _optInOut(optValue, token, options) {
|
56923
|
+
if (!_$1.isString(token) || !token.length) {
|
56924
|
+
console$1.error("gdpr." + (optValue ? "optIn" : "optOut") + " called with an invalid token");
|
56925
|
+
return;
|
56926
|
+
}
|
56927
|
+
options = options || {};
|
56928
|
+
_getStorage(options).set(
|
56929
|
+
_getStorageKey(token, options),
|
56930
|
+
optValue ? 1 : 0,
|
56931
|
+
_$1.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
|
56932
|
+
!!options.crossSubdomainCookie,
|
56933
|
+
!!options.secureCookie,
|
56934
|
+
!!options.crossSiteCookie,
|
56935
|
+
options.cookieDomain
|
56936
|
+
);
|
56937
|
+
if (options.track && optValue) {
|
56938
|
+
options.track(options.trackEventName || "$opt_in", options.trackProperties, {
|
56939
|
+
"send_immediately": true
|
56940
|
+
});
|
56941
|
+
}
|
56942
|
+
}
|
56943
|
+
function _addOptOutCheck(method, getConfigValue) {
|
56944
|
+
return function() {
|
56945
|
+
var optedOut = false;
|
56946
|
+
try {
|
56947
|
+
var token = getConfigValue.call(this, "token");
|
56948
|
+
var ignoreDnt = getConfigValue.call(this, "ignore_dnt");
|
56949
|
+
var persistenceType = getConfigValue.call(this, "opt_out_tracking_persistence_type");
|
56950
|
+
var persistencePrefix = getConfigValue.call(this, "opt_out_tracking_cookie_prefix");
|
56951
|
+
var win2 = getConfigValue.call(this, "window");
|
56952
|
+
if (token) {
|
56953
|
+
optedOut = hasOptedOut(token, {
|
56954
|
+
ignoreDnt,
|
56955
|
+
persistenceType,
|
56956
|
+
persistencePrefix,
|
56957
|
+
window: win2
|
56958
|
+
});
|
56959
|
+
}
|
56960
|
+
} catch (err) {
|
56961
|
+
console$1.error("Unexpected error when checking tracking opt-out status: " + err);
|
56962
|
+
}
|
56963
|
+
if (!optedOut) {
|
56964
|
+
return method.apply(this, arguments);
|
56965
|
+
}
|
56966
|
+
var callback = arguments[arguments.length - 1];
|
56967
|
+
if (typeof callback === "function") {
|
56968
|
+
callback(0);
|
56969
|
+
}
|
56970
|
+
return;
|
56971
|
+
};
|
56972
|
+
}
|
56973
|
+
var SET_ACTION = "$set";
|
56974
|
+
var SET_ONCE_ACTION = "$set_once";
|
56975
|
+
var UNSET_ACTION = "$unset";
|
56976
|
+
var ADD_ACTION = "$add";
|
56977
|
+
var APPEND_ACTION = "$append";
|
56978
|
+
var UNION_ACTION = "$union";
|
56979
|
+
var REMOVE_ACTION = "$remove";
|
56980
|
+
var DELETE_ACTION = "$delete";
|
56981
|
+
var apiActions = {
|
56982
|
+
set_action: function(prop, to) {
|
56983
|
+
var data = {};
|
56984
|
+
var $set = {};
|
56985
|
+
if (_$1.isObject(prop)) {
|
56986
|
+
_$1.each(prop, function(v, k) {
|
56987
|
+
if (!this._is_reserved_property(k)) {
|
56988
|
+
$set[k] = v;
|
56989
|
+
}
|
56990
|
+
}, this);
|
56991
|
+
} else {
|
56992
|
+
$set[prop] = to;
|
56993
|
+
}
|
56994
|
+
data[SET_ACTION] = $set;
|
56995
|
+
return data;
|
56996
|
+
},
|
56997
|
+
unset_action: function(prop) {
|
56998
|
+
var data = {};
|
56999
|
+
var $unset = [];
|
57000
|
+
if (!_$1.isArray(prop)) {
|
57001
|
+
prop = [prop];
|
57002
|
+
}
|
57003
|
+
_$1.each(prop, function(k) {
|
57004
|
+
if (!this._is_reserved_property(k)) {
|
57005
|
+
$unset.push(k);
|
57006
|
+
}
|
57007
|
+
}, this);
|
57008
|
+
data[UNSET_ACTION] = $unset;
|
57009
|
+
return data;
|
57010
|
+
},
|
57011
|
+
set_once_action: function(prop, to) {
|
57012
|
+
var data = {};
|
57013
|
+
var $set_once = {};
|
57014
|
+
if (_$1.isObject(prop)) {
|
57015
|
+
_$1.each(prop, function(v, k) {
|
57016
|
+
if (!this._is_reserved_property(k)) {
|
57017
|
+
$set_once[k] = v;
|
57018
|
+
}
|
57019
|
+
}, this);
|
57020
|
+
} else {
|
57021
|
+
$set_once[prop] = to;
|
57022
|
+
}
|
57023
|
+
data[SET_ONCE_ACTION] = $set_once;
|
57024
|
+
return data;
|
57025
|
+
},
|
57026
|
+
union_action: function(list_name, values2) {
|
57027
|
+
var data = {};
|
57028
|
+
var $union = {};
|
57029
|
+
if (_$1.isObject(list_name)) {
|
57030
|
+
_$1.each(list_name, function(v, k) {
|
57031
|
+
if (!this._is_reserved_property(k)) {
|
57032
|
+
$union[k] = _$1.isArray(v) ? v : [v];
|
57033
|
+
}
|
57034
|
+
}, this);
|
57035
|
+
} else {
|
57036
|
+
$union[list_name] = _$1.isArray(values2) ? values2 : [values2];
|
57037
|
+
}
|
57038
|
+
data[UNION_ACTION] = $union;
|
57039
|
+
return data;
|
57040
|
+
},
|
57041
|
+
append_action: function(list_name, value) {
|
57042
|
+
var data = {};
|
57043
|
+
var $append = {};
|
57044
|
+
if (_$1.isObject(list_name)) {
|
57045
|
+
_$1.each(list_name, function(v, k) {
|
57046
|
+
if (!this._is_reserved_property(k)) {
|
57047
|
+
$append[k] = v;
|
57048
|
+
}
|
57049
|
+
}, this);
|
57050
|
+
} else {
|
57051
|
+
$append[list_name] = value;
|
57052
|
+
}
|
57053
|
+
data[APPEND_ACTION] = $append;
|
57054
|
+
return data;
|
57055
|
+
},
|
57056
|
+
remove_action: function(list_name, value) {
|
57057
|
+
var data = {};
|
57058
|
+
var $remove = {};
|
57059
|
+
if (_$1.isObject(list_name)) {
|
57060
|
+
_$1.each(list_name, function(v, k) {
|
57061
|
+
if (!this._is_reserved_property(k)) {
|
57062
|
+
$remove[k] = v;
|
57063
|
+
}
|
57064
|
+
}, this);
|
57065
|
+
} else {
|
57066
|
+
$remove[list_name] = value;
|
57067
|
+
}
|
57068
|
+
data[REMOVE_ACTION] = $remove;
|
57069
|
+
return data;
|
57070
|
+
},
|
57071
|
+
delete_action: function() {
|
57072
|
+
var data = {};
|
57073
|
+
data[DELETE_ACTION] = "";
|
57074
|
+
return data;
|
57075
|
+
}
|
57076
|
+
};
|
57077
|
+
var MixpanelGroup = function() {
|
57078
|
+
};
|
57079
|
+
_$1.extend(MixpanelGroup.prototype, apiActions);
|
57080
|
+
MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
|
57081
|
+
this._mixpanel = mixpanel_instance;
|
57082
|
+
this._group_key = group_key;
|
57083
|
+
this._group_id = group_id;
|
57084
|
+
};
|
57085
|
+
MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
|
57086
|
+
var data = this.set_action(prop, to);
|
57087
|
+
if (_$1.isObject(prop)) {
|
57088
|
+
callback = to;
|
57089
|
+
}
|
57090
|
+
return this._send_request(data, callback);
|
57091
|
+
});
|
57092
|
+
MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
|
57093
|
+
var data = this.set_once_action(prop, to);
|
57094
|
+
if (_$1.isObject(prop)) {
|
57095
|
+
callback = to;
|
57096
|
+
}
|
57097
|
+
return this._send_request(data, callback);
|
57098
|
+
});
|
57099
|
+
MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
|
57100
|
+
var data = this.unset_action(prop);
|
57101
|
+
return this._send_request(data, callback);
|
57102
|
+
});
|
57103
|
+
MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values2, callback) {
|
57104
|
+
if (_$1.isObject(list_name)) {
|
57105
|
+
callback = values2;
|
57106
|
+
}
|
57107
|
+
var data = this.union_action(list_name, values2);
|
57108
|
+
return this._send_request(data, callback);
|
57109
|
+
});
|
57110
|
+
MixpanelGroup.prototype["delete"] = addOptOutCheckMixpanelGroup(function(callback) {
|
57111
|
+
var data = this.delete_action();
|
57112
|
+
return this._send_request(data, callback);
|
57113
|
+
});
|
57114
|
+
MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
|
57115
|
+
var data = this.remove_action(list_name, value);
|
57116
|
+
return this._send_request(data, callback);
|
57117
|
+
});
|
57118
|
+
MixpanelGroup.prototype._send_request = function(data, callback) {
|
57119
|
+
data["$group_key"] = this._group_key;
|
57120
|
+
data["$group_id"] = this._group_id;
|
57121
|
+
data["$token"] = this._get_config("token");
|
57122
|
+
var date_encoded_data = _$1.encodeDates(data);
|
57123
|
+
return this._mixpanel._track_or_batch({
|
57124
|
+
type: "groups",
|
57125
|
+
data: date_encoded_data,
|
57126
|
+
endpoint: this._get_config("api_host") + "/" + this._get_config("api_routes")["groups"],
|
57127
|
+
batcher: this._mixpanel.request_batchers.groups
|
57128
|
+
}, callback);
|
57129
|
+
};
|
57130
|
+
MixpanelGroup.prototype._is_reserved_property = function(prop) {
|
57131
|
+
return prop === "$group_key" || prop === "$group_id";
|
57132
|
+
};
|
57133
|
+
MixpanelGroup.prototype._get_config = function(conf) {
|
57134
|
+
return this._mixpanel.get_config(conf);
|
57135
|
+
};
|
57136
|
+
MixpanelGroup.prototype.toString = function() {
|
57137
|
+
return this._mixpanel.toString() + ".group." + this._group_key + "." + this._group_id;
|
57138
|
+
};
|
57139
|
+
MixpanelGroup.prototype["remove"] = MixpanelGroup.prototype.remove;
|
57140
|
+
MixpanelGroup.prototype["set"] = MixpanelGroup.prototype.set;
|
57141
|
+
MixpanelGroup.prototype["set_once"] = MixpanelGroup.prototype.set_once;
|
57142
|
+
MixpanelGroup.prototype["union"] = MixpanelGroup.prototype.union;
|
57143
|
+
MixpanelGroup.prototype["unset"] = MixpanelGroup.prototype.unset;
|
57144
|
+
MixpanelGroup.prototype["toString"] = MixpanelGroup.prototype.toString;
|
57145
|
+
var MixpanelPeople = function() {
|
57146
|
+
};
|
57147
|
+
_$1.extend(MixpanelPeople.prototype, apiActions);
|
57148
|
+
MixpanelPeople.prototype._init = function(mixpanel_instance) {
|
57149
|
+
this._mixpanel = mixpanel_instance;
|
57150
|
+
};
|
57151
|
+
MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
|
57152
|
+
var data = this.set_action(prop, to);
|
57153
|
+
if (_$1.isObject(prop)) {
|
57154
|
+
callback = to;
|
57155
|
+
}
|
57156
|
+
if (this._get_config("save_referrer")) {
|
57157
|
+
this._mixpanel["persistence"].update_referrer_info(document.referrer);
|
57158
|
+
}
|
57159
|
+
data[SET_ACTION] = _$1.extend(
|
57160
|
+
{},
|
57161
|
+
_$1.info.people_properties(),
|
57162
|
+
data[SET_ACTION]
|
57163
|
+
);
|
57164
|
+
return this._send_request(data, callback);
|
57165
|
+
});
|
57166
|
+
MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
|
57167
|
+
var data = this.set_once_action(prop, to);
|
57168
|
+
if (_$1.isObject(prop)) {
|
57169
|
+
callback = to;
|
57170
|
+
}
|
57171
|
+
return this._send_request(data, callback);
|
57172
|
+
});
|
57173
|
+
MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
|
57174
|
+
var data = this.unset_action(prop);
|
57175
|
+
return this._send_request(data, callback);
|
57176
|
+
});
|
57177
|
+
MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
|
57178
|
+
var data = {};
|
57179
|
+
var $add = {};
|
57180
|
+
if (_$1.isObject(prop)) {
|
57181
|
+
_$1.each(prop, function(v, k) {
|
57182
|
+
if (!this._is_reserved_property(k)) {
|
57183
|
+
if (isNaN(parseFloat(v))) {
|
57184
|
+
console$1.error("Invalid increment value passed to mixpanel.people.increment - must be a number");
|
57185
|
+
return;
|
57186
|
+
} else {
|
57187
|
+
$add[k] = v;
|
57188
|
+
}
|
57189
|
+
}
|
57190
|
+
}, this);
|
57191
|
+
callback = by;
|
57192
|
+
} else {
|
57193
|
+
if (_$1.isUndefined(by)) {
|
57194
|
+
by = 1;
|
57195
|
+
}
|
57196
|
+
$add[prop] = by;
|
57197
|
+
}
|
57198
|
+
data[ADD_ACTION] = $add;
|
57199
|
+
return this._send_request(data, callback);
|
57200
|
+
});
|
57201
|
+
MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
|
57202
|
+
if (_$1.isObject(list_name)) {
|
57203
|
+
callback = value;
|
57204
|
+
}
|
57205
|
+
var data = this.append_action(list_name, value);
|
57206
|
+
return this._send_request(data, callback);
|
57207
|
+
});
|
57208
|
+
MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
|
57209
|
+
if (_$1.isObject(list_name)) {
|
57210
|
+
callback = value;
|
57211
|
+
}
|
57212
|
+
var data = this.remove_action(list_name, value);
|
57213
|
+
return this._send_request(data, callback);
|
57214
|
+
});
|
57215
|
+
MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values2, callback) {
|
57216
|
+
if (_$1.isObject(list_name)) {
|
57217
|
+
callback = values2;
|
57218
|
+
}
|
57219
|
+
var data = this.union_action(list_name, values2);
|
57220
|
+
return this._send_request(data, callback);
|
57221
|
+
});
|
57222
|
+
MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function(amount, properties, callback) {
|
57223
|
+
if (!_$1.isNumber(amount)) {
|
57224
|
+
amount = parseFloat(amount);
|
57225
|
+
if (isNaN(amount)) {
|
57226
|
+
console$1.error("Invalid value passed to mixpanel.people.track_charge - must be a number");
|
57227
|
+
return;
|
57228
|
+
}
|
57229
|
+
}
|
57230
|
+
return this.append("$transactions", _$1.extend({
|
57231
|
+
"$amount": amount
|
57232
|
+
}, properties), callback);
|
57233
|
+
});
|
57234
|
+
MixpanelPeople.prototype.clear_charges = function(callback) {
|
57235
|
+
return this.set("$transactions", [], callback);
|
57236
|
+
};
|
57237
|
+
MixpanelPeople.prototype.delete_user = function() {
|
57238
|
+
if (!this._identify_called()) {
|
57239
|
+
console$1.error("mixpanel.people.delete_user() requires you to call identify() first");
|
57240
|
+
return;
|
57241
|
+
}
|
57242
|
+
var data = { "$delete": this._mixpanel.get_distinct_id() };
|
57243
|
+
return this._send_request(data);
|
57244
|
+
};
|
57245
|
+
MixpanelPeople.prototype.toString = function() {
|
57246
|
+
return this._mixpanel.toString() + ".people";
|
57247
|
+
};
|
57248
|
+
MixpanelPeople.prototype._send_request = function(data, callback) {
|
57249
|
+
data["$token"] = this._get_config("token");
|
57250
|
+
data["$distinct_id"] = this._mixpanel.get_distinct_id();
|
57251
|
+
var device_id = this._mixpanel.get_property("$device_id");
|
57252
|
+
var user_id = this._mixpanel.get_property("$user_id");
|
57253
|
+
var had_persisted_distinct_id = this._mixpanel.get_property("$had_persisted_distinct_id");
|
57254
|
+
if (device_id) {
|
57255
|
+
data["$device_id"] = device_id;
|
57256
|
+
}
|
57257
|
+
if (user_id) {
|
57258
|
+
data["$user_id"] = user_id;
|
57259
|
+
}
|
57260
|
+
if (had_persisted_distinct_id) {
|
57261
|
+
data["$had_persisted_distinct_id"] = had_persisted_distinct_id;
|
57262
|
+
}
|
57263
|
+
var date_encoded_data = _$1.encodeDates(data);
|
57264
|
+
if (!this._identify_called()) {
|
57265
|
+
this._enqueue(data);
|
57266
|
+
if (!_$1.isUndefined(callback)) {
|
57267
|
+
if (this._get_config("verbose")) {
|
57268
|
+
callback({ status: -1, error: null });
|
57269
|
+
} else {
|
57270
|
+
callback(-1);
|
57271
|
+
}
|
57272
|
+
}
|
57273
|
+
return _$1.truncate(date_encoded_data, 255);
|
57274
|
+
}
|
57275
|
+
return this._mixpanel._track_or_batch({
|
57276
|
+
type: "people",
|
57277
|
+
data: date_encoded_data,
|
57278
|
+
endpoint: this._get_config("api_host") + "/" + this._get_config("api_routes")["engage"],
|
57279
|
+
batcher: this._mixpanel.request_batchers.people
|
57280
|
+
}, callback);
|
57281
|
+
};
|
57282
|
+
MixpanelPeople.prototype._get_config = function(conf_var) {
|
57283
|
+
return this._mixpanel.get_config(conf_var);
|
57284
|
+
};
|
57285
|
+
MixpanelPeople.prototype._identify_called = function() {
|
57286
|
+
return this._mixpanel._flags.identify_called === true;
|
57287
|
+
};
|
57288
|
+
MixpanelPeople.prototype._enqueue = function(data) {
|
57289
|
+
if (SET_ACTION in data) {
|
57290
|
+
this._mixpanel["persistence"]._add_to_people_queue(SET_ACTION, data);
|
57291
|
+
} else if (SET_ONCE_ACTION in data) {
|
57292
|
+
this._mixpanel["persistence"]._add_to_people_queue(SET_ONCE_ACTION, data);
|
57293
|
+
} else if (UNSET_ACTION in data) {
|
57294
|
+
this._mixpanel["persistence"]._add_to_people_queue(UNSET_ACTION, data);
|
57295
|
+
} else if (ADD_ACTION in data) {
|
57296
|
+
this._mixpanel["persistence"]._add_to_people_queue(ADD_ACTION, data);
|
57297
|
+
} else if (APPEND_ACTION in data) {
|
57298
|
+
this._mixpanel["persistence"]._add_to_people_queue(APPEND_ACTION, data);
|
57299
|
+
} else if (REMOVE_ACTION in data) {
|
57300
|
+
this._mixpanel["persistence"]._add_to_people_queue(REMOVE_ACTION, data);
|
57301
|
+
} else if (UNION_ACTION in data) {
|
57302
|
+
this._mixpanel["persistence"]._add_to_people_queue(UNION_ACTION, data);
|
57303
|
+
} else {
|
57304
|
+
console$1.error("Invalid call to _enqueue():", data);
|
57305
|
+
}
|
57306
|
+
};
|
57307
|
+
MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
|
57308
|
+
var _this = this;
|
57309
|
+
var queued_data = _$1.extend({}, this._mixpanel["persistence"].load_queue(action));
|
57310
|
+
var action_params = queued_data;
|
57311
|
+
if (!_$1.isUndefined(queued_data) && _$1.isObject(queued_data) && !_$1.isEmptyObject(queued_data)) {
|
57312
|
+
_this._mixpanel["persistence"]._pop_from_people_queue(action, queued_data);
|
57313
|
+
_this._mixpanel["persistence"].save();
|
57314
|
+
if (queue_to_params_fn) {
|
57315
|
+
action_params = queue_to_params_fn(queued_data);
|
57316
|
+
}
|
57317
|
+
action_method.call(_this, action_params, function(response, data) {
|
57318
|
+
if (response === 0) {
|
57319
|
+
_this._mixpanel["persistence"]._add_to_people_queue(action, queued_data);
|
57320
|
+
}
|
57321
|
+
if (!_$1.isUndefined(callback)) {
|
57322
|
+
callback(response, data);
|
57323
|
+
}
|
57324
|
+
});
|
57325
|
+
}
|
57326
|
+
};
|
57327
|
+
MixpanelPeople.prototype._flush = function(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback) {
|
57328
|
+
var _this = this;
|
57329
|
+
this._flush_one_queue(SET_ACTION, this.set, _set_callback);
|
57330
|
+
this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
|
57331
|
+
this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) {
|
57332
|
+
return _$1.keys(queue);
|
57333
|
+
});
|
57334
|
+
this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
|
57335
|
+
this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
|
57336
|
+
var $append_queue = this._mixpanel["persistence"].load_queue(APPEND_ACTION);
|
57337
|
+
if (!_$1.isUndefined($append_queue) && _$1.isArray($append_queue) && $append_queue.length) {
|
57338
|
+
var $append_item;
|
57339
|
+
var append_callback = function(response, data) {
|
57340
|
+
if (response === 0) {
|
57341
|
+
_this._mixpanel["persistence"]._add_to_people_queue(APPEND_ACTION, $append_item);
|
57342
|
+
}
|
57343
|
+
if (!_$1.isUndefined(_append_callback)) {
|
57344
|
+
_append_callback(response, data);
|
57345
|
+
}
|
57346
|
+
};
|
57347
|
+
for (var i2 = $append_queue.length - 1; i2 >= 0; i2--) {
|
57348
|
+
$append_queue = this._mixpanel["persistence"].load_queue(APPEND_ACTION);
|
57349
|
+
$append_item = $append_queue.pop();
|
57350
|
+
_this._mixpanel["persistence"].save();
|
57351
|
+
if (!_$1.isEmptyObject($append_item)) {
|
57352
|
+
_this.append($append_item, append_callback);
|
57353
|
+
}
|
57354
|
+
}
|
57355
|
+
}
|
57356
|
+
var $remove_queue = this._mixpanel["persistence"].load_queue(REMOVE_ACTION);
|
57357
|
+
if (!_$1.isUndefined($remove_queue) && _$1.isArray($remove_queue) && $remove_queue.length) {
|
57358
|
+
var $remove_item;
|
57359
|
+
var remove_callback = function(response, data) {
|
57360
|
+
if (response === 0) {
|
57361
|
+
_this._mixpanel["persistence"]._add_to_people_queue(REMOVE_ACTION, $remove_item);
|
57362
|
+
}
|
57363
|
+
if (!_$1.isUndefined(_remove_callback)) {
|
57364
|
+
_remove_callback(response, data);
|
57365
|
+
}
|
57366
|
+
};
|
57367
|
+
for (var j = $remove_queue.length - 1; j >= 0; j--) {
|
57368
|
+
$remove_queue = this._mixpanel["persistence"].load_queue(REMOVE_ACTION);
|
57369
|
+
$remove_item = $remove_queue.pop();
|
57370
|
+
_this._mixpanel["persistence"].save();
|
57371
|
+
if (!_$1.isEmptyObject($remove_item)) {
|
57372
|
+
_this.remove($remove_item, remove_callback);
|
57373
|
+
}
|
57374
|
+
}
|
57375
|
+
}
|
57376
|
+
};
|
57377
|
+
MixpanelPeople.prototype._is_reserved_property = function(prop) {
|
57378
|
+
return prop === "$distinct_id" || prop === "$token" || prop === "$device_id" || prop === "$user_id" || prop === "$had_persisted_distinct_id";
|
57379
|
+
};
|
57380
|
+
MixpanelPeople.prototype["set"] = MixpanelPeople.prototype.set;
|
57381
|
+
MixpanelPeople.prototype["set_once"] = MixpanelPeople.prototype.set_once;
|
57382
|
+
MixpanelPeople.prototype["unset"] = MixpanelPeople.prototype.unset;
|
57383
|
+
MixpanelPeople.prototype["increment"] = MixpanelPeople.prototype.increment;
|
57384
|
+
MixpanelPeople.prototype["append"] = MixpanelPeople.prototype.append;
|
57385
|
+
MixpanelPeople.prototype["remove"] = MixpanelPeople.prototype.remove;
|
57386
|
+
MixpanelPeople.prototype["union"] = MixpanelPeople.prototype.union;
|
57387
|
+
MixpanelPeople.prototype["track_charge"] = MixpanelPeople.prototype.track_charge;
|
57388
|
+
MixpanelPeople.prototype["clear_charges"] = MixpanelPeople.prototype.clear_charges;
|
57389
|
+
MixpanelPeople.prototype["delete_user"] = MixpanelPeople.prototype.delete_user;
|
57390
|
+
MixpanelPeople.prototype["toString"] = MixpanelPeople.prototype.toString;
|
57391
|
+
var SET_QUEUE_KEY = "__mps";
|
57392
|
+
var SET_ONCE_QUEUE_KEY = "__mpso";
|
57393
|
+
var UNSET_QUEUE_KEY = "__mpus";
|
57394
|
+
var ADD_QUEUE_KEY = "__mpa";
|
57395
|
+
var APPEND_QUEUE_KEY = "__mpap";
|
57396
|
+
var REMOVE_QUEUE_KEY = "__mpr";
|
57397
|
+
var UNION_QUEUE_KEY = "__mpu";
|
57398
|
+
var PEOPLE_DISTINCT_ID_KEY = "$people_distinct_id";
|
57399
|
+
var ALIAS_ID_KEY = "__alias";
|
57400
|
+
var EVENT_TIMERS_KEY = "__timers";
|
57401
|
+
var RESERVED_PROPERTIES = [
|
57402
|
+
SET_QUEUE_KEY,
|
57403
|
+
SET_ONCE_QUEUE_KEY,
|
57404
|
+
UNSET_QUEUE_KEY,
|
57405
|
+
ADD_QUEUE_KEY,
|
57406
|
+
APPEND_QUEUE_KEY,
|
57407
|
+
REMOVE_QUEUE_KEY,
|
57408
|
+
UNION_QUEUE_KEY,
|
57409
|
+
PEOPLE_DISTINCT_ID_KEY,
|
57410
|
+
ALIAS_ID_KEY,
|
57411
|
+
EVENT_TIMERS_KEY
|
57412
|
+
];
|
57413
|
+
var MixpanelPersistence = function(config) {
|
57414
|
+
this["props"] = {};
|
57415
|
+
this.campaign_params_saved = false;
|
57416
|
+
if (config["persistence_name"]) {
|
57417
|
+
this.name = "mp_" + config["persistence_name"];
|
57418
|
+
} else {
|
57419
|
+
this.name = "mp_" + config["token"] + "_mixpanel";
|
57420
|
+
}
|
57421
|
+
var storage_type = config["persistence"];
|
57422
|
+
if (storage_type !== "cookie" && storage_type !== "localStorage") {
|
57423
|
+
console$1.critical("Unknown persistence type " + storage_type + "; falling back to cookie");
|
57424
|
+
storage_type = config["persistence"] = "cookie";
|
57425
|
+
}
|
57426
|
+
if (storage_type === "localStorage" && _$1.localStorage.is_supported()) {
|
57427
|
+
this.storage = _$1.localStorage;
|
57428
|
+
} else {
|
57429
|
+
this.storage = _$1.cookie;
|
57430
|
+
}
|
57431
|
+
this.load();
|
57432
|
+
this.update_config(config);
|
57433
|
+
this.upgrade();
|
57434
|
+
this.save();
|
57435
|
+
};
|
57436
|
+
MixpanelPersistence.prototype.properties = function() {
|
57437
|
+
var p = {};
|
57438
|
+
this.load();
|
57439
|
+
_$1.each(this["props"], function(v, k) {
|
57440
|
+
if (!_$1.include(RESERVED_PROPERTIES, k)) {
|
57441
|
+
p[k] = v;
|
57442
|
+
}
|
57443
|
+
});
|
57444
|
+
return p;
|
57445
|
+
};
|
57446
|
+
MixpanelPersistence.prototype.load = function() {
|
57447
|
+
if (this.disabled) {
|
57448
|
+
return;
|
57449
|
+
}
|
57450
|
+
var entry = this.storage.parse(this.name);
|
57451
|
+
if (entry) {
|
57452
|
+
this["props"] = _$1.extend({}, entry);
|
57453
|
+
}
|
57454
|
+
};
|
57455
|
+
MixpanelPersistence.prototype.upgrade = function() {
|
57456
|
+
var old_cookie, old_localstorage;
|
57457
|
+
if (this.storage === _$1.localStorage) {
|
57458
|
+
old_cookie = _$1.cookie.parse(this.name);
|
57459
|
+
_$1.cookie.remove(this.name);
|
57460
|
+
_$1.cookie.remove(this.name, true);
|
57461
|
+
if (old_cookie) {
|
57462
|
+
this.register_once(old_cookie);
|
57463
|
+
}
|
57464
|
+
} else if (this.storage === _$1.cookie) {
|
57465
|
+
old_localstorage = _$1.localStorage.parse(this.name);
|
57466
|
+
_$1.localStorage.remove(this.name);
|
57467
|
+
if (old_localstorage) {
|
57468
|
+
this.register_once(old_localstorage);
|
57469
|
+
}
|
57470
|
+
}
|
57471
|
+
};
|
57472
|
+
MixpanelPersistence.prototype.save = function() {
|
57473
|
+
if (this.disabled) {
|
57474
|
+
return;
|
57475
|
+
}
|
57476
|
+
this.storage.set(
|
57477
|
+
this.name,
|
57478
|
+
_$1.JSONEncode(this["props"]),
|
57479
|
+
this.expire_days,
|
57480
|
+
this.cross_subdomain,
|
57481
|
+
this.secure,
|
57482
|
+
this.cross_site,
|
57483
|
+
this.cookie_domain
|
57484
|
+
);
|
57485
|
+
};
|
57486
|
+
MixpanelPersistence.prototype.load_prop = function(key) {
|
57487
|
+
this.load();
|
57488
|
+
return this["props"][key];
|
57489
|
+
};
|
57490
|
+
MixpanelPersistence.prototype.remove = function() {
|
57491
|
+
this.storage.remove(this.name, false, this.cookie_domain);
|
57492
|
+
this.storage.remove(this.name, true, this.cookie_domain);
|
57493
|
+
};
|
57494
|
+
MixpanelPersistence.prototype.clear = function() {
|
57495
|
+
this.remove();
|
57496
|
+
this["props"] = {};
|
57497
|
+
};
|
57498
|
+
MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
|
57499
|
+
if (_$1.isObject(props)) {
|
57500
|
+
if (typeof default_value === "undefined") {
|
57501
|
+
default_value = "None";
|
57502
|
+
}
|
57503
|
+
this.expire_days = typeof days === "undefined" ? this.default_expiry : days;
|
57504
|
+
this.load();
|
57505
|
+
_$1.each(props, function(val, prop) {
|
57506
|
+
if (!this["props"].hasOwnProperty(prop) || this["props"][prop] === default_value) {
|
57507
|
+
this["props"][prop] = val;
|
57508
|
+
}
|
57509
|
+
}, this);
|
57510
|
+
this.save();
|
57511
|
+
return true;
|
57512
|
+
}
|
57513
|
+
return false;
|
57514
|
+
};
|
57515
|
+
MixpanelPersistence.prototype.register = function(props, days) {
|
57516
|
+
if (_$1.isObject(props)) {
|
57517
|
+
this.expire_days = typeof days === "undefined" ? this.default_expiry : days;
|
57518
|
+
this.load();
|
57519
|
+
_$1.extend(this["props"], props);
|
57520
|
+
this.save();
|
57521
|
+
return true;
|
57522
|
+
}
|
57523
|
+
return false;
|
57524
|
+
};
|
57525
|
+
MixpanelPersistence.prototype.unregister = function(prop) {
|
57526
|
+
this.load();
|
57527
|
+
if (prop in this["props"]) {
|
57528
|
+
delete this["props"][prop];
|
57529
|
+
this.save();
|
57530
|
+
}
|
57531
|
+
};
|
57532
|
+
MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
|
57533
|
+
this.register(_$1.info.searchInfo(referrer));
|
57534
|
+
};
|
57535
|
+
MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
|
57536
|
+
this.register_once({
|
57537
|
+
"$initial_referrer": referrer || "$direct",
|
57538
|
+
"$initial_referring_domain": _$1.info.referringDomain(referrer) || "$direct"
|
57539
|
+
}, "");
|
57540
|
+
};
|
57541
|
+
MixpanelPersistence.prototype.get_referrer_info = function() {
|
57542
|
+
return _$1.strip_empty_properties({
|
57543
|
+
"$initial_referrer": this["props"]["$initial_referrer"],
|
57544
|
+
"$initial_referring_domain": this["props"]["$initial_referring_domain"]
|
57545
|
+
});
|
57546
|
+
};
|
57547
|
+
MixpanelPersistence.prototype.update_config = function(config) {
|
57548
|
+
this.default_expiry = this.expire_days = config["cookie_expiration"];
|
57549
|
+
this.set_disabled(config["disable_persistence"]);
|
57550
|
+
this.set_cookie_domain(config["cookie_domain"]);
|
57551
|
+
this.set_cross_site(config["cross_site_cookie"]);
|
57552
|
+
this.set_cross_subdomain(config["cross_subdomain_cookie"]);
|
57553
|
+
this.set_secure(config["secure_cookie"]);
|
57554
|
+
};
|
57555
|
+
MixpanelPersistence.prototype.set_disabled = function(disabled) {
|
57556
|
+
this.disabled = disabled;
|
57557
|
+
if (this.disabled) {
|
57558
|
+
this.remove();
|
57559
|
+
} else {
|
57560
|
+
this.save();
|
57561
|
+
}
|
57562
|
+
};
|
57563
|
+
MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
|
57564
|
+
if (cookie_domain !== this.cookie_domain) {
|
57565
|
+
this.remove();
|
57566
|
+
this.cookie_domain = cookie_domain;
|
57567
|
+
this.save();
|
57568
|
+
}
|
57569
|
+
};
|
57570
|
+
MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
|
57571
|
+
if (cross_site !== this.cross_site) {
|
57572
|
+
this.cross_site = cross_site;
|
57573
|
+
this.remove();
|
57574
|
+
this.save();
|
57575
|
+
}
|
57576
|
+
};
|
57577
|
+
MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
|
57578
|
+
if (cross_subdomain !== this.cross_subdomain) {
|
57579
|
+
this.cross_subdomain = cross_subdomain;
|
57580
|
+
this.remove();
|
57581
|
+
this.save();
|
57582
|
+
}
|
57583
|
+
};
|
57584
|
+
MixpanelPersistence.prototype.get_cross_subdomain = function() {
|
57585
|
+
return this.cross_subdomain;
|
57586
|
+
};
|
57587
|
+
MixpanelPersistence.prototype.set_secure = function(secure) {
|
57588
|
+
if (secure !== this.secure) {
|
57589
|
+
this.secure = secure ? true : false;
|
57590
|
+
this.remove();
|
57591
|
+
this.save();
|
57592
|
+
}
|
57593
|
+
};
|
57594
|
+
MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
|
57595
|
+
var q_key = this._get_queue_key(queue), q_data = data[queue], set_q = this._get_or_create_queue(SET_ACTION), set_once_q = this._get_or_create_queue(SET_ONCE_ACTION), unset_q = this._get_or_create_queue(UNSET_ACTION), add_q = this._get_or_create_queue(ADD_ACTION), union_q = this._get_or_create_queue(UNION_ACTION), remove_q = this._get_or_create_queue(REMOVE_ACTION, []), append_q = this._get_or_create_queue(APPEND_ACTION, []);
|
57596
|
+
if (q_key === SET_QUEUE_KEY) {
|
57597
|
+
_$1.extend(set_q, q_data);
|
57598
|
+
this._pop_from_people_queue(ADD_ACTION, q_data);
|
57599
|
+
this._pop_from_people_queue(UNION_ACTION, q_data);
|
57600
|
+
this._pop_from_people_queue(UNSET_ACTION, q_data);
|
57601
|
+
} else if (q_key === SET_ONCE_QUEUE_KEY) {
|
57602
|
+
_$1.each(q_data, function(v, k) {
|
57603
|
+
if (!(k in set_once_q)) {
|
57604
|
+
set_once_q[k] = v;
|
57605
|
+
}
|
57606
|
+
});
|
57607
|
+
this._pop_from_people_queue(UNSET_ACTION, q_data);
|
57608
|
+
} else if (q_key === UNSET_QUEUE_KEY) {
|
57609
|
+
_$1.each(q_data, function(prop) {
|
57610
|
+
_$1.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
|
57611
|
+
if (prop in enqueued_obj) {
|
57612
|
+
delete enqueued_obj[prop];
|
57613
|
+
}
|
57614
|
+
});
|
57615
|
+
_$1.each(append_q, function(append_obj) {
|
57616
|
+
if (prop in append_obj) {
|
57617
|
+
delete append_obj[prop];
|
57618
|
+
}
|
57619
|
+
});
|
57620
|
+
unset_q[prop] = true;
|
57621
|
+
});
|
57622
|
+
} else if (q_key === ADD_QUEUE_KEY) {
|
57623
|
+
_$1.each(q_data, function(v, k) {
|
57624
|
+
if (k in set_q) {
|
57625
|
+
set_q[k] += v;
|
57626
|
+
} else {
|
57627
|
+
if (!(k in add_q)) {
|
57628
|
+
add_q[k] = 0;
|
57629
|
+
}
|
57630
|
+
add_q[k] += v;
|
57631
|
+
}
|
57632
|
+
}, this);
|
57633
|
+
this._pop_from_people_queue(UNSET_ACTION, q_data);
|
57634
|
+
} else if (q_key === UNION_QUEUE_KEY) {
|
57635
|
+
_$1.each(q_data, function(v, k) {
|
57636
|
+
if (_$1.isArray(v)) {
|
57637
|
+
if (!(k in union_q)) {
|
57638
|
+
union_q[k] = [];
|
57639
|
+
}
|
57640
|
+
union_q[k] = union_q[k].concat(v);
|
57641
|
+
}
|
57642
|
+
});
|
57643
|
+
this._pop_from_people_queue(UNSET_ACTION, q_data);
|
57644
|
+
} else if (q_key === REMOVE_QUEUE_KEY) {
|
57645
|
+
remove_q.push(q_data);
|
57646
|
+
this._pop_from_people_queue(APPEND_ACTION, q_data);
|
57647
|
+
} else if (q_key === APPEND_QUEUE_KEY) {
|
57648
|
+
append_q.push(q_data);
|
57649
|
+
this._pop_from_people_queue(UNSET_ACTION, q_data);
|
57650
|
+
}
|
57651
|
+
console$1.log("MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):");
|
57652
|
+
console$1.log(data);
|
57653
|
+
this.save();
|
57654
|
+
};
|
57655
|
+
MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
|
57656
|
+
var q = this["props"][this._get_queue_key(queue)];
|
57657
|
+
if (!_$1.isUndefined(q)) {
|
57658
|
+
_$1.each(data, function(v, k) {
|
57659
|
+
if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
|
57660
|
+
_$1.each(q, function(queued_action) {
|
57661
|
+
if (queued_action[k] === v) {
|
57662
|
+
delete queued_action[k];
|
57663
|
+
}
|
57664
|
+
});
|
57665
|
+
} else {
|
57666
|
+
delete q[k];
|
57667
|
+
}
|
57668
|
+
}, this);
|
57669
|
+
}
|
57670
|
+
};
|
57671
|
+
MixpanelPersistence.prototype.load_queue = function(queue) {
|
57672
|
+
return this.load_prop(this._get_queue_key(queue));
|
57673
|
+
};
|
57674
|
+
MixpanelPersistence.prototype._get_queue_key = function(queue) {
|
57675
|
+
if (queue === SET_ACTION) {
|
57676
|
+
return SET_QUEUE_KEY;
|
57677
|
+
} else if (queue === SET_ONCE_ACTION) {
|
57678
|
+
return SET_ONCE_QUEUE_KEY;
|
57679
|
+
} else if (queue === UNSET_ACTION) {
|
57680
|
+
return UNSET_QUEUE_KEY;
|
57681
|
+
} else if (queue === ADD_ACTION) {
|
57682
|
+
return ADD_QUEUE_KEY;
|
57683
|
+
} else if (queue === APPEND_ACTION) {
|
57684
|
+
return APPEND_QUEUE_KEY;
|
57685
|
+
} else if (queue === REMOVE_ACTION) {
|
57686
|
+
return REMOVE_QUEUE_KEY;
|
57687
|
+
} else if (queue === UNION_ACTION) {
|
57688
|
+
return UNION_QUEUE_KEY;
|
57689
|
+
} else {
|
57690
|
+
console$1.error("Invalid queue:", queue);
|
57691
|
+
}
|
57692
|
+
};
|
57693
|
+
MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
|
57694
|
+
var key = this._get_queue_key(queue);
|
57695
|
+
default_val = _$1.isUndefined(default_val) ? {} : default_val;
|
57696
|
+
return this["props"][key] || (this["props"][key] = default_val);
|
57697
|
+
};
|
57698
|
+
MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
|
57699
|
+
var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
|
57700
|
+
timers[event_name] = timestamp;
|
57701
|
+
this["props"][EVENT_TIMERS_KEY] = timers;
|
57702
|
+
this.save();
|
57703
|
+
};
|
57704
|
+
MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
|
57705
|
+
var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
|
57706
|
+
var timestamp = timers[event_name];
|
57707
|
+
if (!_$1.isUndefined(timestamp)) {
|
57708
|
+
delete this["props"][EVENT_TIMERS_KEY][event_name];
|
57709
|
+
this.save();
|
57710
|
+
}
|
57711
|
+
return timestamp;
|
57712
|
+
};
|
57713
|
+
var init_type;
|
57714
|
+
var mixpanel_master;
|
57715
|
+
var INIT_MODULE = 0;
|
57716
|
+
var INIT_SNIPPET = 1;
|
57717
|
+
var IDENTITY_FUNC = function(x) {
|
57718
|
+
return x;
|
57719
|
+
};
|
57720
|
+
var NOOP_FUNC = function() {
|
57721
|
+
};
|
57722
|
+
var PRIMARY_INSTANCE_NAME = "mixpanel";
|
57723
|
+
var PAYLOAD_TYPE_BASE64 = "base64";
|
57724
|
+
var PAYLOAD_TYPE_JSON = "json";
|
57725
|
+
var DEVICE_ID_PREFIX = "$device:";
|
57726
|
+
var USE_XHR = win.XMLHttpRequest && "withCredentials" in new XMLHttpRequest();
|
57727
|
+
var ENQUEUE_REQUESTS = !USE_XHR && userAgent.indexOf("MSIE") === -1 && userAgent.indexOf("Mozilla") === -1;
|
57728
|
+
var sendBeacon = null;
|
57729
|
+
if (navigator$1["sendBeacon"]) {
|
57730
|
+
sendBeacon = function() {
|
57731
|
+
return navigator$1["sendBeacon"].apply(navigator$1, arguments);
|
57732
|
+
};
|
57733
|
+
}
|
57734
|
+
var DEFAULT_API_ROUTES = {
|
57735
|
+
"track": "track/",
|
57736
|
+
"engage": "engage/",
|
57737
|
+
"groups": "groups/",
|
57738
|
+
"record": "record/"
|
57739
|
+
};
|
57740
|
+
var DEFAULT_CONFIG = {
|
57741
|
+
"api_host": "https://api-js.mixpanel.com",
|
57742
|
+
"api_routes": DEFAULT_API_ROUTES,
|
57743
|
+
"api_method": "POST",
|
57744
|
+
"api_transport": "XHR",
|
57745
|
+
"api_payload_format": PAYLOAD_TYPE_BASE64,
|
57746
|
+
"app_host": "https://mixpanel.com",
|
57747
|
+
"cdn": "https://cdn.mxpnl.com",
|
57748
|
+
"cross_site_cookie": false,
|
57749
|
+
"cross_subdomain_cookie": true,
|
57750
|
+
"error_reporter": NOOP_FUNC,
|
57751
|
+
"persistence": "cookie",
|
57752
|
+
"persistence_name": "",
|
57753
|
+
"cookie_domain": "",
|
57754
|
+
"cookie_name": "",
|
57755
|
+
"loaded": NOOP_FUNC,
|
57756
|
+
"mp_loader": null,
|
57757
|
+
"track_marketing": true,
|
57758
|
+
"track_pageview": false,
|
57759
|
+
"skip_first_touch_marketing": false,
|
57760
|
+
"store_google": true,
|
57761
|
+
"stop_utm_persistence": false,
|
57762
|
+
"save_referrer": true,
|
57763
|
+
"test": false,
|
57764
|
+
"verbose": false,
|
57765
|
+
"img": false,
|
57766
|
+
"debug": false,
|
57767
|
+
"track_links_timeout": 300,
|
57768
|
+
"cookie_expiration": 365,
|
57769
|
+
"upgrade": false,
|
57770
|
+
"disable_persistence": false,
|
57771
|
+
"disable_cookie": false,
|
57772
|
+
"secure_cookie": false,
|
57773
|
+
"ip": true,
|
57774
|
+
"opt_out_tracking_by_default": false,
|
57775
|
+
"opt_out_persistence_by_default": false,
|
57776
|
+
"opt_out_tracking_persistence_type": "localStorage",
|
57777
|
+
"opt_out_tracking_cookie_prefix": null,
|
57778
|
+
"property_blacklist": [],
|
57779
|
+
"xhr_headers": {},
|
57780
|
+
"ignore_dnt": false,
|
57781
|
+
"batch_requests": true,
|
57782
|
+
"batch_size": 50,
|
57783
|
+
"batch_flush_interval_ms": 5e3,
|
57784
|
+
"batch_request_timeout_ms": 9e4,
|
57785
|
+
"batch_autostart": true,
|
57786
|
+
"hooks": {},
|
57787
|
+
"record_block_class": new RegExp("^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$"),
|
57788
|
+
"record_block_selector": "img, video",
|
57789
|
+
"record_idle_timeout_ms": 30 * 60 * 1e3,
|
57790
|
+
"record_mask_text_class": new RegExp("^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$"),
|
57791
|
+
"record_mask_text_selector": "*",
|
57792
|
+
"record_max_ms": MAX_RECORDING_MS,
|
57793
|
+
"record_sessions_percent": 0,
|
57794
|
+
"recorder_src": "https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js"
|
57795
|
+
};
|
57796
|
+
var DOM_LOADED = false;
|
57797
|
+
var MixpanelLib = function() {
|
57798
|
+
};
|
57799
|
+
var create_mplib = function(token, config, name2) {
|
57800
|
+
var instance, target = name2 === PRIMARY_INSTANCE_NAME ? mixpanel_master : mixpanel_master[name2];
|
57801
|
+
if (target && init_type === INIT_MODULE) {
|
57802
|
+
instance = target;
|
57803
|
+
} else {
|
57804
|
+
if (target && !_$1.isArray(target)) {
|
57805
|
+
console$1.error("You have already initialized " + name2);
|
57806
|
+
return;
|
57807
|
+
}
|
57808
|
+
instance = new MixpanelLib();
|
57809
|
+
}
|
57810
|
+
instance._cached_groups = {};
|
57811
|
+
instance._init(token, config, name2);
|
57812
|
+
instance["people"] = new MixpanelPeople();
|
57813
|
+
instance["people"]._init(instance);
|
57814
|
+
if (!instance.get_config("skip_first_touch_marketing")) {
|
57815
|
+
var utm_params = _$1.info.campaignParams(null);
|
57816
|
+
var initial_utm_params = {};
|
57817
|
+
var has_utm = false;
|
57818
|
+
_$1.each(utm_params, function(utm_value, utm_key) {
|
57819
|
+
initial_utm_params["initial_" + utm_key] = utm_value;
|
57820
|
+
if (utm_value) {
|
57821
|
+
has_utm = true;
|
57822
|
+
}
|
57823
|
+
});
|
57824
|
+
if (has_utm) {
|
57825
|
+
instance["people"].set_once(initial_utm_params);
|
57826
|
+
}
|
57827
|
+
}
|
57828
|
+
Config.DEBUG = Config.DEBUG || instance.get_config("debug");
|
57829
|
+
if (!_$1.isUndefined(target) && _$1.isArray(target)) {
|
57830
|
+
instance._execute_array.call(instance["people"], target["people"]);
|
57831
|
+
instance._execute_array(target);
|
57832
|
+
}
|
57833
|
+
return instance;
|
57834
|
+
};
|
57835
|
+
MixpanelLib.prototype.init = function(token, config, name2) {
|
57836
|
+
if (_$1.isUndefined(name2)) {
|
57837
|
+
this.report_error("You must name your new library: init(token, config, name)");
|
57838
|
+
return;
|
57839
|
+
}
|
57840
|
+
if (name2 === PRIMARY_INSTANCE_NAME) {
|
57841
|
+
this.report_error("You must initialize the main mixpanel object right after you include the Mixpanel js snippet");
|
57842
|
+
return;
|
57843
|
+
}
|
57844
|
+
var instance = create_mplib(token, config, name2);
|
57845
|
+
mixpanel_master[name2] = instance;
|
57846
|
+
instance._loaded();
|
57847
|
+
return instance;
|
57848
|
+
};
|
57849
|
+
MixpanelLib.prototype._init = function(token, config, name2) {
|
57850
|
+
config = config || {};
|
57851
|
+
this["__loaded"] = true;
|
57852
|
+
this["config"] = {};
|
57853
|
+
var variable_features = {};
|
57854
|
+
if (!("api_payload_format" in config)) {
|
57855
|
+
var api_host = config["api_host"] || DEFAULT_CONFIG["api_host"];
|
57856
|
+
if (api_host.match(/\.mixpanel\.com/)) {
|
57857
|
+
variable_features["api_payload_format"] = PAYLOAD_TYPE_JSON;
|
57858
|
+
}
|
57859
|
+
}
|
57860
|
+
this.set_config(_$1.extend({}, DEFAULT_CONFIG, variable_features, config, {
|
57861
|
+
"name": name2,
|
57862
|
+
"token": token,
|
57863
|
+
"callback_fn": (name2 === PRIMARY_INSTANCE_NAME ? name2 : PRIMARY_INSTANCE_NAME + "." + name2) + "._jsc"
|
57864
|
+
}));
|
57865
|
+
this["_jsc"] = NOOP_FUNC;
|
57866
|
+
this.__dom_loaded_queue = [];
|
57867
|
+
this.__request_queue = [];
|
57868
|
+
this.__disabled_events = [];
|
57869
|
+
this._flags = {
|
57870
|
+
"disable_all_events": false,
|
57871
|
+
"identify_called": false
|
57872
|
+
};
|
57873
|
+
this.request_batchers = {};
|
57874
|
+
this._batch_requests = this.get_config("batch_requests");
|
57875
|
+
if (this._batch_requests) {
|
57876
|
+
if (!_$1.localStorage.is_supported(true) || !USE_XHR) {
|
57877
|
+
this._batch_requests = false;
|
57878
|
+
console$1.log("Turning off Mixpanel request-queueing; needs XHR and localStorage support");
|
57879
|
+
_$1.each(this.get_batcher_configs(), function(batcher_config) {
|
57880
|
+
console$1.log("Clearing batch queue " + batcher_config.queue_key);
|
57881
|
+
_$1.localStorage.remove(batcher_config.queue_key);
|
57882
|
+
});
|
57883
|
+
} else {
|
57884
|
+
this.init_batchers();
|
57885
|
+
if (sendBeacon && win.addEventListener) {
|
57886
|
+
var flush_on_unload = _$1.bind(function() {
|
57887
|
+
if (!this.request_batchers.events.stopped) {
|
57888
|
+
this.request_batchers.events.flush({ unloading: true });
|
57889
|
+
}
|
57890
|
+
}, this);
|
57891
|
+
win.addEventListener("pagehide", function(ev) {
|
57892
|
+
if (ev["persisted"]) {
|
57893
|
+
flush_on_unload();
|
57894
|
+
}
|
57895
|
+
});
|
57896
|
+
win.addEventListener("visibilitychange", function() {
|
57897
|
+
if (document$1["visibilityState"] === "hidden") {
|
57898
|
+
flush_on_unload();
|
57899
|
+
}
|
57900
|
+
});
|
57901
|
+
}
|
57902
|
+
}
|
57903
|
+
}
|
57904
|
+
this["persistence"] = this["cookie"] = new MixpanelPersistence(this["config"]);
|
57905
|
+
this.unpersisted_superprops = {};
|
57906
|
+
this._gdpr_init();
|
57907
|
+
var uuid2 = _$1.UUID();
|
57908
|
+
if (!this.get_distinct_id()) {
|
57909
|
+
this.register_once({
|
57910
|
+
"distinct_id": DEVICE_ID_PREFIX + uuid2,
|
57911
|
+
"$device_id": uuid2
|
57912
|
+
}, "");
|
57913
|
+
}
|
57914
|
+
var track_pageview_option = this.get_config("track_pageview");
|
57915
|
+
if (track_pageview_option) {
|
57916
|
+
this._init_url_change_tracking(track_pageview_option);
|
57917
|
+
}
|
57918
|
+
if (this.get_config("record_sessions_percent") > 0 && Math.random() * 100 <= this.get_config("record_sessions_percent")) {
|
57919
|
+
this.start_session_recording();
|
57920
|
+
}
|
57921
|
+
};
|
57922
|
+
MixpanelLib.prototype.start_session_recording = addOptOutCheckMixpanelLib(function() {
|
57923
|
+
if (!win["MutationObserver"]) {
|
57924
|
+
console$1.critical("Browser does not support MutationObserver; skipping session recording");
|
57925
|
+
return;
|
57926
|
+
}
|
57927
|
+
var handleLoadedRecorder = _$1.bind(function() {
|
57928
|
+
this._recorder = this._recorder || new win["__mp_recorder"](this);
|
57929
|
+
this._recorder["startRecording"]();
|
57930
|
+
}, this);
|
57931
|
+
if (_$1.isUndefined(win["__mp_recorder"])) {
|
57932
|
+
var scriptEl = document$1.createElement("script");
|
57933
|
+
scriptEl.type = "text/javascript";
|
57934
|
+
scriptEl.async = true;
|
57935
|
+
scriptEl.onload = handleLoadedRecorder;
|
57936
|
+
scriptEl.src = this.get_config("recorder_src");
|
57937
|
+
document$1.head.appendChild(scriptEl);
|
57938
|
+
} else {
|
57939
|
+
handleLoadedRecorder();
|
57940
|
+
}
|
57941
|
+
});
|
57942
|
+
MixpanelLib.prototype.stop_session_recording = function() {
|
57943
|
+
if (this._recorder) {
|
57944
|
+
this._recorder["stopRecording"]();
|
57945
|
+
} else {
|
57946
|
+
console$1.critical("Session recorder module not loaded");
|
57947
|
+
}
|
57948
|
+
};
|
57949
|
+
MixpanelLib.prototype.get_session_recording_properties = function() {
|
57950
|
+
var props = {};
|
57951
|
+
if (this._recorder) {
|
57952
|
+
var replay_id = this._recorder["replayId"];
|
57953
|
+
if (replay_id) {
|
57954
|
+
props["$mp_replay_id"] = replay_id;
|
57955
|
+
}
|
57956
|
+
}
|
57957
|
+
return props;
|
57958
|
+
};
|
57959
|
+
MixpanelLib.prototype._loaded = function() {
|
57960
|
+
this.get_config("loaded")(this);
|
57961
|
+
this._set_default_superprops();
|
57962
|
+
this["people"].set_once(this["persistence"].get_referrer_info());
|
57963
|
+
if (this.get_config("store_google") && this.get_config("stop_utm_persistence")) {
|
57964
|
+
var utm_params = _$1.info.campaignParams(null);
|
57965
|
+
_$1.each(utm_params, function(_utm_value, utm_key) {
|
57966
|
+
this.unregister(utm_key);
|
57967
|
+
}.bind(this));
|
57968
|
+
}
|
57969
|
+
};
|
57970
|
+
MixpanelLib.prototype._set_default_superprops = function() {
|
57971
|
+
this["persistence"].update_search_keyword(document$1.referrer);
|
57972
|
+
if (this.get_config("store_google") && !this.get_config("stop_utm_persistence")) {
|
57973
|
+
this.register(_$1.info.campaignParams());
|
57974
|
+
}
|
57975
|
+
if (this.get_config("save_referrer")) {
|
57976
|
+
this["persistence"].update_referrer_info(document$1.referrer);
|
57977
|
+
}
|
57978
|
+
};
|
57979
|
+
MixpanelLib.prototype._dom_loaded = function() {
|
57980
|
+
_$1.each(this.__dom_loaded_queue, function(item) {
|
57981
|
+
this._track_dom.apply(this, item);
|
57982
|
+
}, this);
|
57983
|
+
if (!this.has_opted_out_tracking()) {
|
57984
|
+
_$1.each(this.__request_queue, function(item) {
|
57985
|
+
this._send_request.apply(this, item);
|
57986
|
+
}, this);
|
57987
|
+
}
|
57988
|
+
delete this.__dom_loaded_queue;
|
57989
|
+
delete this.__request_queue;
|
57990
|
+
};
|
57991
|
+
MixpanelLib.prototype._track_dom = function(DomClass, args) {
|
57992
|
+
if (this.get_config("img")) {
|
57993
|
+
this.report_error("You can't use DOM tracking functions with img = true.");
|
57994
|
+
return false;
|
57995
|
+
}
|
57996
|
+
if (!DOM_LOADED) {
|
57997
|
+
this.__dom_loaded_queue.push([DomClass, args]);
|
57998
|
+
return false;
|
57999
|
+
}
|
58000
|
+
var dt = new DomClass().init(this);
|
58001
|
+
return dt.track.apply(dt, args);
|
58002
|
+
};
|
58003
|
+
MixpanelLib.prototype._init_url_change_tracking = function(track_pageview_option) {
|
58004
|
+
var previous_tracked_url = "";
|
58005
|
+
var tracked = this.track_pageview();
|
58006
|
+
if (tracked) {
|
58007
|
+
previous_tracked_url = _$1.info.currentUrl();
|
58008
|
+
}
|
58009
|
+
if (_$1.include(["full-url", "url-with-path-and-query-string", "url-with-path"], track_pageview_option)) {
|
58010
|
+
win.addEventListener("popstate", function() {
|
58011
|
+
win.dispatchEvent(new Event("mp_locationchange"));
|
58012
|
+
});
|
58013
|
+
win.addEventListener("hashchange", function() {
|
58014
|
+
win.dispatchEvent(new Event("mp_locationchange"));
|
58015
|
+
});
|
58016
|
+
var nativePushState = win.history.pushState;
|
58017
|
+
if (typeof nativePushState === "function") {
|
58018
|
+
win.history.pushState = function(state, unused, url) {
|
58019
|
+
nativePushState.call(win.history, state, unused, url);
|
58020
|
+
win.dispatchEvent(new Event("mp_locationchange"));
|
58021
|
+
};
|
58022
|
+
}
|
58023
|
+
var nativeReplaceState = win.history.replaceState;
|
58024
|
+
if (typeof nativeReplaceState === "function") {
|
58025
|
+
win.history.replaceState = function(state, unused, url) {
|
58026
|
+
nativeReplaceState.call(win.history, state, unused, url);
|
58027
|
+
win.dispatchEvent(new Event("mp_locationchange"));
|
58028
|
+
};
|
58029
|
+
}
|
58030
|
+
win.addEventListener("mp_locationchange", function() {
|
58031
|
+
var current_url = _$1.info.currentUrl();
|
58032
|
+
var should_track = false;
|
58033
|
+
if (track_pageview_option === "full-url") {
|
58034
|
+
should_track = current_url !== previous_tracked_url;
|
58035
|
+
} else if (track_pageview_option === "url-with-path-and-query-string") {
|
58036
|
+
should_track = current_url.split("#")[0] !== previous_tracked_url.split("#")[0];
|
58037
|
+
} else if (track_pageview_option === "url-with-path") {
|
58038
|
+
should_track = current_url.split("#")[0].split("?")[0] !== previous_tracked_url.split("#")[0].split("?")[0];
|
58039
|
+
}
|
58040
|
+
if (should_track) {
|
58041
|
+
var tracked2 = this.track_pageview();
|
58042
|
+
if (tracked2) {
|
58043
|
+
previous_tracked_url = current_url;
|
58044
|
+
}
|
58045
|
+
}
|
58046
|
+
}.bind(this));
|
58047
|
+
}
|
58048
|
+
};
|
58049
|
+
MixpanelLib.prototype._prepare_callback = function(callback, data) {
|
58050
|
+
if (_$1.isUndefined(callback)) {
|
58051
|
+
return null;
|
58052
|
+
}
|
58053
|
+
if (USE_XHR) {
|
58054
|
+
var callback_function = function(response) {
|
58055
|
+
callback(response, data);
|
58056
|
+
};
|
58057
|
+
return callback_function;
|
58058
|
+
} else {
|
58059
|
+
var jsc = this["_jsc"];
|
58060
|
+
var randomized_cb = "" + Math.floor(Math.random() * 1e8);
|
58061
|
+
var callback_string = this.get_config("callback_fn") + "[" + randomized_cb + "]";
|
58062
|
+
jsc[randomized_cb] = function(response) {
|
58063
|
+
delete jsc[randomized_cb];
|
58064
|
+
callback(response, data);
|
58065
|
+
};
|
58066
|
+
return callback_string;
|
58067
|
+
}
|
58068
|
+
};
|
58069
|
+
MixpanelLib.prototype._send_request = function(url, data, options, callback) {
|
58070
|
+
var succeeded = true;
|
58071
|
+
if (ENQUEUE_REQUESTS) {
|
58072
|
+
this.__request_queue.push(arguments);
|
58073
|
+
return succeeded;
|
58074
|
+
}
|
58075
|
+
var DEFAULT_OPTIONS = {
|
58076
|
+
method: this.get_config("api_method"),
|
58077
|
+
transport: this.get_config("api_transport"),
|
58078
|
+
verbose: this.get_config("verbose")
|
58079
|
+
};
|
58080
|
+
var body_data = null;
|
58081
|
+
if (!callback && (_$1.isFunction(options) || typeof options === "string")) {
|
58082
|
+
callback = options;
|
58083
|
+
options = null;
|
58084
|
+
}
|
58085
|
+
options = _$1.extend(DEFAULT_OPTIONS, options || {});
|
58086
|
+
if (!USE_XHR) {
|
58087
|
+
options.method = "GET";
|
58088
|
+
}
|
58089
|
+
var use_post = options.method === "POST";
|
58090
|
+
var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === "sendbeacon";
|
58091
|
+
var verbose_mode = options.verbose;
|
58092
|
+
if (data["verbose"]) {
|
58093
|
+
verbose_mode = true;
|
58094
|
+
}
|
58095
|
+
if (this.get_config("test")) {
|
58096
|
+
data["test"] = 1;
|
58097
|
+
}
|
58098
|
+
if (verbose_mode) {
|
58099
|
+
data["verbose"] = 1;
|
58100
|
+
}
|
58101
|
+
if (this.get_config("img")) {
|
58102
|
+
data["img"] = 1;
|
58103
|
+
}
|
58104
|
+
if (!USE_XHR) {
|
58105
|
+
if (callback) {
|
58106
|
+
data["callback"] = callback;
|
58107
|
+
} else if (verbose_mode || this.get_config("test")) {
|
58108
|
+
data["callback"] = "(function(){})";
|
58109
|
+
}
|
58110
|
+
}
|
58111
|
+
data["ip"] = this.get_config("ip") ? 1 : 0;
|
58112
|
+
data["_"] = new Date().getTime().toString();
|
58113
|
+
if (use_post) {
|
58114
|
+
body_data = "data=" + encodeURIComponent(data["data"]);
|
58115
|
+
delete data["data"];
|
58116
|
+
}
|
58117
|
+
url += "?" + _$1.HTTPBuildQuery(data);
|
58118
|
+
var lib = this;
|
58119
|
+
if ("img" in data) {
|
58120
|
+
var img = document$1.createElement("img");
|
58121
|
+
img.src = url;
|
58122
|
+
document$1.body.appendChild(img);
|
58123
|
+
} else if (use_sendBeacon) {
|
58124
|
+
try {
|
58125
|
+
succeeded = sendBeacon(url, body_data);
|
58126
|
+
} catch (e) {
|
58127
|
+
lib.report_error(e);
|
58128
|
+
succeeded = false;
|
58129
|
+
}
|
58130
|
+
try {
|
58131
|
+
if (callback) {
|
58132
|
+
callback(succeeded ? 1 : 0);
|
58133
|
+
}
|
58134
|
+
} catch (e) {
|
58135
|
+
lib.report_error(e);
|
58136
|
+
}
|
58137
|
+
} else if (USE_XHR) {
|
58138
|
+
try {
|
58139
|
+
var req = new XMLHttpRequest();
|
58140
|
+
req.open(options.method, url, true);
|
58141
|
+
var headers = this.get_config("xhr_headers");
|
58142
|
+
if (use_post) {
|
58143
|
+
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
58144
|
+
}
|
58145
|
+
_$1.each(headers, function(headerValue, headerName) {
|
58146
|
+
req.setRequestHeader(headerName, headerValue);
|
58147
|
+
});
|
58148
|
+
if (options.timeout_ms && typeof req.timeout !== "undefined") {
|
58149
|
+
req.timeout = options.timeout_ms;
|
58150
|
+
var start_time = new Date().getTime();
|
58151
|
+
}
|
58152
|
+
req.withCredentials = true;
|
58153
|
+
req.onreadystatechange = function() {
|
58154
|
+
if (req.readyState === 4) {
|
58155
|
+
if (req.status === 200) {
|
58156
|
+
if (callback) {
|
58157
|
+
if (verbose_mode) {
|
58158
|
+
var response;
|
58159
|
+
try {
|
58160
|
+
response = _$1.JSONDecode(req.responseText);
|
58161
|
+
} catch (e) {
|
58162
|
+
lib.report_error(e);
|
58163
|
+
if (options.ignore_json_errors) {
|
58164
|
+
response = req.responseText;
|
58165
|
+
} else {
|
58166
|
+
return;
|
58167
|
+
}
|
58168
|
+
}
|
58169
|
+
callback(response);
|
58170
|
+
} else {
|
58171
|
+
callback(Number(req.responseText));
|
58172
|
+
}
|
58173
|
+
}
|
58174
|
+
} else {
|
58175
|
+
var error;
|
58176
|
+
if (req.timeout && !req.status && new Date().getTime() - start_time >= req.timeout) {
|
58177
|
+
error = "timeout";
|
58178
|
+
} else {
|
58179
|
+
error = "Bad HTTP status: " + req.status + " " + req.statusText;
|
58180
|
+
}
|
58181
|
+
lib.report_error(error);
|
58182
|
+
if (callback) {
|
58183
|
+
if (verbose_mode) {
|
58184
|
+
callback({ status: 0, error, xhr_req: req });
|
58185
|
+
} else {
|
58186
|
+
callback(0);
|
58187
|
+
}
|
58188
|
+
}
|
58189
|
+
}
|
58190
|
+
}
|
58191
|
+
};
|
58192
|
+
req.send(body_data);
|
58193
|
+
} catch (e) {
|
58194
|
+
lib.report_error(e);
|
58195
|
+
succeeded = false;
|
58196
|
+
}
|
58197
|
+
} else {
|
58198
|
+
var script = document$1.createElement("script");
|
58199
|
+
script.type = "text/javascript";
|
58200
|
+
script.async = true;
|
58201
|
+
script.defer = true;
|
58202
|
+
script.src = url;
|
58203
|
+
var s = document$1.getElementsByTagName("script")[0];
|
58204
|
+
s.parentNode.insertBefore(script, s);
|
58205
|
+
}
|
58206
|
+
return succeeded;
|
58207
|
+
};
|
58208
|
+
MixpanelLib.prototype._execute_array = function(array) {
|
58209
|
+
var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
|
58210
|
+
_$1.each(array, function(item) {
|
58211
|
+
if (item) {
|
58212
|
+
fn_name = item[0];
|
58213
|
+
if (_$1.isArray(fn_name)) {
|
58214
|
+
tracking_calls.push(item);
|
58215
|
+
} else if (typeof item === "function") {
|
58216
|
+
item.call(this);
|
58217
|
+
} else if (_$1.isArray(item) && fn_name === "alias") {
|
58218
|
+
alias_calls.push(item);
|
58219
|
+
} else if (_$1.isArray(item) && fn_name.indexOf("track") !== -1 && typeof this[fn_name] === "function") {
|
58220
|
+
tracking_calls.push(item);
|
58221
|
+
} else {
|
58222
|
+
other_calls.push(item);
|
58223
|
+
}
|
58224
|
+
}
|
58225
|
+
}, this);
|
58226
|
+
var execute = function(calls, context) {
|
58227
|
+
_$1.each(calls, function(item) {
|
58228
|
+
if (_$1.isArray(item[0])) {
|
58229
|
+
var caller = context;
|
58230
|
+
_$1.each(item, function(call) {
|
58231
|
+
caller = caller[call[0]].apply(caller, call.slice(1));
|
58232
|
+
});
|
58233
|
+
} else {
|
58234
|
+
this[item[0]].apply(this, item.slice(1));
|
58235
|
+
}
|
58236
|
+
}, context);
|
58237
|
+
};
|
58238
|
+
execute(alias_calls, this);
|
58239
|
+
execute(other_calls, this);
|
58240
|
+
execute(tracking_calls, this);
|
58241
|
+
};
|
58242
|
+
MixpanelLib.prototype.are_batchers_initialized = function() {
|
58243
|
+
return !!this.request_batchers.events;
|
58244
|
+
};
|
58245
|
+
MixpanelLib.prototype.get_batcher_configs = function() {
|
58246
|
+
var queue_prefix = "__mpq_" + this.get_config("token");
|
58247
|
+
var api_routes = this.get_config("api_routes");
|
58248
|
+
this._batcher_configs = this._batcher_configs || {
|
58249
|
+
events: { type: "events", endpoint: "/" + api_routes["track"], queue_key: queue_prefix + "_ev" },
|
58250
|
+
people: { type: "people", endpoint: "/" + api_routes["engage"], queue_key: queue_prefix + "_pp" },
|
58251
|
+
groups: { type: "groups", endpoint: "/" + api_routes["groups"], queue_key: queue_prefix + "_gr" }
|
58252
|
+
};
|
58253
|
+
return this._batcher_configs;
|
58254
|
+
};
|
58255
|
+
MixpanelLib.prototype.init_batchers = function() {
|
58256
|
+
if (!this.are_batchers_initialized()) {
|
58257
|
+
var batcher_for = _$1.bind(function(attrs) {
|
58258
|
+
return new RequestBatcher(
|
58259
|
+
attrs.queue_key,
|
58260
|
+
{
|
58261
|
+
libConfig: this["config"],
|
58262
|
+
sendRequestFunc: _$1.bind(function(data, options, cb) {
|
58263
|
+
this._send_request(
|
58264
|
+
this.get_config("api_host") + attrs.endpoint,
|
58265
|
+
this._encode_data_for_request(data),
|
58266
|
+
options,
|
58267
|
+
this._prepare_callback(cb, data)
|
58268
|
+
);
|
58269
|
+
}, this),
|
58270
|
+
beforeSendHook: _$1.bind(function(item) {
|
58271
|
+
return this._run_hook("before_send_" + attrs.type, item);
|
58272
|
+
}, this),
|
58273
|
+
errorReporter: this.get_config("error_reporter"),
|
58274
|
+
stopAllBatchingFunc: _$1.bind(this.stop_batch_senders, this)
|
58275
|
+
}
|
58276
|
+
);
|
58277
|
+
}, this);
|
58278
|
+
var batcher_configs = this.get_batcher_configs();
|
58279
|
+
this.request_batchers = {
|
58280
|
+
events: batcher_for(batcher_configs.events),
|
58281
|
+
people: batcher_for(batcher_configs.people),
|
58282
|
+
groups: batcher_for(batcher_configs.groups)
|
58283
|
+
};
|
58284
|
+
}
|
58285
|
+
if (this.get_config("batch_autostart")) {
|
58286
|
+
this.start_batch_senders();
|
58287
|
+
}
|
58288
|
+
};
|
58289
|
+
MixpanelLib.prototype.start_batch_senders = function() {
|
58290
|
+
this._batchers_were_started = true;
|
58291
|
+
if (this.are_batchers_initialized()) {
|
58292
|
+
this._batch_requests = true;
|
58293
|
+
_$1.each(this.request_batchers, function(batcher) {
|
58294
|
+
batcher.start();
|
58295
|
+
});
|
58296
|
+
}
|
58297
|
+
};
|
58298
|
+
MixpanelLib.prototype.stop_batch_senders = function() {
|
58299
|
+
this._batch_requests = false;
|
58300
|
+
_$1.each(this.request_batchers, function(batcher) {
|
58301
|
+
batcher.stop();
|
58302
|
+
batcher.clear();
|
58303
|
+
});
|
58304
|
+
};
|
58305
|
+
MixpanelLib.prototype.push = function(item) {
|
58306
|
+
this._execute_array([item]);
|
58307
|
+
};
|
58308
|
+
MixpanelLib.prototype.disable = function(events) {
|
58309
|
+
if (typeof events === "undefined") {
|
58310
|
+
this._flags.disable_all_events = true;
|
58311
|
+
} else {
|
58312
|
+
this.__disabled_events = this.__disabled_events.concat(events);
|
58313
|
+
}
|
58314
|
+
};
|
58315
|
+
MixpanelLib.prototype._encode_data_for_request = function(data) {
|
58316
|
+
var encoded_data = _$1.JSONEncode(data);
|
58317
|
+
if (this.get_config("api_payload_format") === PAYLOAD_TYPE_BASE64) {
|
58318
|
+
encoded_data = _$1.base64Encode(encoded_data);
|
58319
|
+
}
|
58320
|
+
return { "data": encoded_data };
|
58321
|
+
};
|
58322
|
+
MixpanelLib.prototype._track_or_batch = function(options, callback) {
|
58323
|
+
var truncated_data = _$1.truncate(options.data, 255);
|
58324
|
+
var endpoint = options.endpoint;
|
58325
|
+
var batcher = options.batcher;
|
58326
|
+
var should_send_immediately = options.should_send_immediately;
|
58327
|
+
var send_request_options = options.send_request_options || {};
|
58328
|
+
callback = callback || NOOP_FUNC;
|
58329
|
+
var request_enqueued_or_initiated = true;
|
58330
|
+
var send_request_immediately = _$1.bind(function() {
|
58331
|
+
if (!send_request_options.skip_hooks) {
|
58332
|
+
truncated_data = this._run_hook("before_send_" + options.type, truncated_data);
|
58333
|
+
}
|
58334
|
+
if (truncated_data) {
|
58335
|
+
console$1.log("MIXPANEL REQUEST:");
|
58336
|
+
console$1.log(truncated_data);
|
58337
|
+
return this._send_request(
|
58338
|
+
endpoint,
|
58339
|
+
this._encode_data_for_request(truncated_data),
|
58340
|
+
send_request_options,
|
58341
|
+
this._prepare_callback(callback, truncated_data)
|
58342
|
+
);
|
58343
|
+
} else {
|
58344
|
+
return null;
|
58345
|
+
}
|
58346
|
+
}, this);
|
58347
|
+
if (this._batch_requests && !should_send_immediately) {
|
58348
|
+
batcher.enqueue(truncated_data, function(succeeded) {
|
58349
|
+
if (succeeded) {
|
58350
|
+
callback(1, truncated_data);
|
58351
|
+
} else {
|
58352
|
+
send_request_immediately();
|
58353
|
+
}
|
58354
|
+
});
|
58355
|
+
} else {
|
58356
|
+
request_enqueued_or_initiated = send_request_immediately();
|
58357
|
+
}
|
58358
|
+
return request_enqueued_or_initiated && truncated_data;
|
58359
|
+
};
|
58360
|
+
MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
|
58361
|
+
if (!callback && typeof options === "function") {
|
58362
|
+
callback = options;
|
58363
|
+
options = null;
|
58364
|
+
}
|
58365
|
+
options = options || {};
|
58366
|
+
var transport = options["transport"];
|
58367
|
+
if (transport) {
|
58368
|
+
options.transport = transport;
|
58369
|
+
}
|
58370
|
+
var should_send_immediately = options["send_immediately"];
|
58371
|
+
if (typeof callback !== "function") {
|
58372
|
+
callback = NOOP_FUNC;
|
58373
|
+
}
|
58374
|
+
if (_$1.isUndefined(event_name)) {
|
58375
|
+
this.report_error("No event name provided to mixpanel.track");
|
58376
|
+
return;
|
58377
|
+
}
|
58378
|
+
if (this._event_is_disabled(event_name)) {
|
58379
|
+
callback(0);
|
58380
|
+
return;
|
58381
|
+
}
|
58382
|
+
properties = _$1.extend({}, properties);
|
58383
|
+
properties["token"] = this.get_config("token");
|
58384
|
+
var start_timestamp = this["persistence"].remove_event_timer(event_name);
|
58385
|
+
if (!_$1.isUndefined(start_timestamp)) {
|
58386
|
+
var duration_in_ms = new Date().getTime() - start_timestamp;
|
58387
|
+
properties["$duration"] = parseFloat((duration_in_ms / 1e3).toFixed(3));
|
58388
|
+
}
|
58389
|
+
this._set_default_superprops();
|
58390
|
+
var marketing_properties = this.get_config("track_marketing") ? _$1.info.marketingParams() : {};
|
58391
|
+
properties = _$1.extend(
|
58392
|
+
{},
|
58393
|
+
_$1.info.properties({ "mp_loader": this.get_config("mp_loader") }),
|
58394
|
+
marketing_properties,
|
58395
|
+
this["persistence"].properties(),
|
58396
|
+
this.unpersisted_superprops,
|
58397
|
+
this.get_session_recording_properties(),
|
58398
|
+
properties
|
58399
|
+
);
|
58400
|
+
var property_blacklist = this.get_config("property_blacklist");
|
58401
|
+
if (_$1.isArray(property_blacklist)) {
|
58402
|
+
_$1.each(property_blacklist, function(blacklisted_prop) {
|
58403
|
+
delete properties[blacklisted_prop];
|
58404
|
+
});
|
58405
|
+
} else {
|
58406
|
+
this.report_error("Invalid value for property_blacklist config: " + property_blacklist);
|
58407
|
+
}
|
58408
|
+
var data = {
|
58409
|
+
"event": event_name,
|
58410
|
+
"properties": properties
|
58411
|
+
};
|
58412
|
+
var ret = this._track_or_batch({
|
58413
|
+
type: "events",
|
58414
|
+
data,
|
58415
|
+
endpoint: this.get_config("api_host") + "/" + this.get_config("api_routes")["track"],
|
58416
|
+
batcher: this.request_batchers.events,
|
58417
|
+
should_send_immediately,
|
58418
|
+
send_request_options: options
|
58419
|
+
}, callback);
|
58420
|
+
return ret;
|
58421
|
+
});
|
58422
|
+
MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
|
58423
|
+
if (!_$1.isArray(group_ids)) {
|
58424
|
+
group_ids = [group_ids];
|
58425
|
+
}
|
58426
|
+
var prop = {};
|
58427
|
+
prop[group_key] = group_ids;
|
58428
|
+
this.register(prop);
|
58429
|
+
return this["people"].set(group_key, group_ids, callback);
|
58430
|
+
});
|
58431
|
+
MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
|
58432
|
+
var old_values = this.get_property(group_key);
|
58433
|
+
var prop = {};
|
58434
|
+
if (old_values === void 0) {
|
58435
|
+
prop[group_key] = [group_id];
|
58436
|
+
this.register(prop);
|
58437
|
+
} else {
|
58438
|
+
if (old_values.indexOf(group_id) === -1) {
|
58439
|
+
old_values.push(group_id);
|
58440
|
+
prop[group_key] = old_values;
|
58441
|
+
this.register(prop);
|
58442
|
+
}
|
58443
|
+
}
|
58444
|
+
return this["people"].union(group_key, group_id, callback);
|
58445
|
+
});
|
58446
|
+
MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
|
58447
|
+
var old_value = this.get_property(group_key);
|
58448
|
+
if (old_value !== void 0) {
|
58449
|
+
var idx = old_value.indexOf(group_id);
|
58450
|
+
if (idx > -1) {
|
58451
|
+
old_value.splice(idx, 1);
|
58452
|
+
this.register({ group_key: old_value });
|
58453
|
+
}
|
58454
|
+
if (old_value.length === 0) {
|
58455
|
+
this.unregister(group_key);
|
58456
|
+
}
|
58457
|
+
}
|
58458
|
+
return this["people"].remove(group_key, group_id, callback);
|
58459
|
+
});
|
58460
|
+
MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
|
58461
|
+
var tracking_props = _$1.extend({}, properties || {});
|
58462
|
+
_$1.each(groups, function(v, k) {
|
58463
|
+
if (v !== null && v !== void 0) {
|
58464
|
+
tracking_props[k] = v;
|
58465
|
+
}
|
58466
|
+
});
|
58467
|
+
return this.track(event_name, tracking_props, callback);
|
58468
|
+
});
|
58469
|
+
MixpanelLib.prototype._create_map_key = function(group_key, group_id) {
|
58470
|
+
return group_key + "_" + JSON.stringify(group_id);
|
58471
|
+
};
|
58472
|
+
MixpanelLib.prototype._remove_group_from_cache = function(group_key, group_id) {
|
58473
|
+
delete this._cached_groups[this._create_map_key(group_key, group_id)];
|
58474
|
+
};
|
58475
|
+
MixpanelLib.prototype.get_group = function(group_key, group_id) {
|
58476
|
+
var map_key = this._create_map_key(group_key, group_id);
|
58477
|
+
var group = this._cached_groups[map_key];
|
58478
|
+
if (group === void 0 || group._group_key !== group_key || group._group_id !== group_id) {
|
58479
|
+
group = new MixpanelGroup();
|
58480
|
+
group._init(this, group_key, group_id);
|
58481
|
+
this._cached_groups[map_key] = group;
|
58482
|
+
}
|
58483
|
+
return group;
|
58484
|
+
};
|
58485
|
+
MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
|
58486
|
+
if (typeof properties !== "object") {
|
58487
|
+
properties = {};
|
58488
|
+
}
|
58489
|
+
options = options || {};
|
58490
|
+
var event_name = options["event_name"] || "$mp_web_page_view";
|
58491
|
+
var default_page_properties = _$1.extend(
|
58492
|
+
_$1.info.mpPageViewProperties(),
|
58493
|
+
_$1.info.campaignParams(),
|
58494
|
+
_$1.info.clickParams()
|
58495
|
+
);
|
58496
|
+
var event_properties = _$1.extend(
|
58497
|
+
{},
|
58498
|
+
default_page_properties,
|
58499
|
+
properties
|
58500
|
+
);
|
58501
|
+
return this.track(event_name, event_properties);
|
58502
|
+
});
|
58503
|
+
MixpanelLib.prototype.track_links = function() {
|
58504
|
+
return this._track_dom.call(this, LinkTracker, arguments);
|
58505
|
+
};
|
58506
|
+
MixpanelLib.prototype.track_forms = function() {
|
58507
|
+
return this._track_dom.call(this, FormTracker, arguments);
|
58508
|
+
};
|
58509
|
+
MixpanelLib.prototype.time_event = function(event_name) {
|
58510
|
+
if (_$1.isUndefined(event_name)) {
|
58511
|
+
this.report_error("No event name provided to mixpanel.time_event");
|
58512
|
+
return;
|
58513
|
+
}
|
58514
|
+
if (this._event_is_disabled(event_name)) {
|
58515
|
+
return;
|
58516
|
+
}
|
58517
|
+
this["persistence"].set_event_timer(event_name, new Date().getTime());
|
58518
|
+
};
|
58519
|
+
var REGISTER_DEFAULTS = {
|
58520
|
+
"persistent": true
|
58521
|
+
};
|
58522
|
+
var options_for_register = function(days_or_options) {
|
58523
|
+
var options;
|
58524
|
+
if (_$1.isObject(days_or_options)) {
|
58525
|
+
options = days_or_options;
|
58526
|
+
} else if (!_$1.isUndefined(days_or_options)) {
|
58527
|
+
options = { "days": days_or_options };
|
58528
|
+
} else {
|
58529
|
+
options = {};
|
58530
|
+
}
|
58531
|
+
return _$1.extend({}, REGISTER_DEFAULTS, options);
|
58532
|
+
};
|
58533
|
+
MixpanelLib.prototype.register = function(props, days_or_options) {
|
58534
|
+
var options = options_for_register(days_or_options);
|
58535
|
+
if (options["persistent"]) {
|
58536
|
+
this["persistence"].register(props, options["days"]);
|
58537
|
+
} else {
|
58538
|
+
_$1.extend(this.unpersisted_superprops, props);
|
58539
|
+
}
|
58540
|
+
};
|
58541
|
+
MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
|
58542
|
+
var options = options_for_register(days_or_options);
|
58543
|
+
if (options["persistent"]) {
|
58544
|
+
this["persistence"].register_once(props, default_value, options["days"]);
|
58545
|
+
} else {
|
58546
|
+
if (typeof default_value === "undefined") {
|
58547
|
+
default_value = "None";
|
58548
|
+
}
|
58549
|
+
_$1.each(props, function(val, prop) {
|
58550
|
+
if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
|
58551
|
+
this.unpersisted_superprops[prop] = val;
|
58552
|
+
}
|
58553
|
+
}, this);
|
58554
|
+
}
|
58555
|
+
};
|
58556
|
+
MixpanelLib.prototype.unregister = function(property, options) {
|
58557
|
+
options = options_for_register(options);
|
58558
|
+
if (options["persistent"]) {
|
58559
|
+
this["persistence"].unregister(property);
|
58560
|
+
} else {
|
58561
|
+
delete this.unpersisted_superprops[property];
|
58562
|
+
}
|
58563
|
+
};
|
58564
|
+
MixpanelLib.prototype._register_single = function(prop, value) {
|
58565
|
+
var props = {};
|
58566
|
+
props[prop] = value;
|
58567
|
+
this.register(props);
|
58568
|
+
};
|
58569
|
+
MixpanelLib.prototype.identify = function(new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback) {
|
58570
|
+
var previous_distinct_id = this.get_distinct_id();
|
58571
|
+
if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
|
58572
|
+
if (typeof new_distinct_id === "string" && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
|
58573
|
+
this.report_error("distinct_id cannot have $device: prefix");
|
58574
|
+
return -1;
|
58575
|
+
}
|
58576
|
+
this.register({ "$user_id": new_distinct_id });
|
58577
|
+
}
|
58578
|
+
if (!this.get_property("$device_id")) {
|
58579
|
+
var device_id = previous_distinct_id;
|
58580
|
+
this.register_once({
|
58581
|
+
"$had_persisted_distinct_id": true,
|
58582
|
+
"$device_id": device_id
|
58583
|
+
}, "");
|
58584
|
+
}
|
58585
|
+
if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
|
58586
|
+
this.unregister(ALIAS_ID_KEY);
|
58587
|
+
this.register({ "distinct_id": new_distinct_id });
|
58588
|
+
}
|
58589
|
+
this._flags.identify_called = true;
|
58590
|
+
this["people"]._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
|
58591
|
+
if (new_distinct_id !== previous_distinct_id) {
|
58592
|
+
this.track("$identify", {
|
58593
|
+
"distinct_id": new_distinct_id,
|
58594
|
+
"$anon_distinct_id": previous_distinct_id
|
58595
|
+
}, { skip_hooks: true });
|
58596
|
+
}
|
58597
|
+
};
|
58598
|
+
MixpanelLib.prototype.reset = function() {
|
58599
|
+
this["persistence"].clear();
|
58600
|
+
this._flags.identify_called = false;
|
58601
|
+
var uuid2 = _$1.UUID();
|
58602
|
+
this.register_once({
|
58603
|
+
"distinct_id": DEVICE_ID_PREFIX + uuid2,
|
58604
|
+
"$device_id": uuid2
|
58605
|
+
}, "");
|
58606
|
+
};
|
58607
|
+
MixpanelLib.prototype.get_distinct_id = function() {
|
58608
|
+
return this.get_property("distinct_id");
|
58609
|
+
};
|
58610
|
+
MixpanelLib.prototype.alias = function(alias, original) {
|
58611
|
+
if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
|
58612
|
+
this.report_error("Attempting to create alias for existing People user - aborting.");
|
58613
|
+
return -2;
|
58614
|
+
}
|
58615
|
+
var _this = this;
|
58616
|
+
if (_$1.isUndefined(original)) {
|
58617
|
+
original = this.get_distinct_id();
|
58618
|
+
}
|
58619
|
+
if (alias !== original) {
|
58620
|
+
this._register_single(ALIAS_ID_KEY, alias);
|
58621
|
+
return this.track("$create_alias", {
|
58622
|
+
"alias": alias,
|
58623
|
+
"distinct_id": original
|
58624
|
+
}, {
|
58625
|
+
skip_hooks: true
|
58626
|
+
}, function() {
|
58627
|
+
_this.identify(alias);
|
58628
|
+
});
|
58629
|
+
} else {
|
58630
|
+
this.report_error("alias matches current distinct_id - skipping api call.");
|
58631
|
+
this.identify(alias);
|
58632
|
+
return -1;
|
58633
|
+
}
|
58634
|
+
};
|
58635
|
+
MixpanelLib.prototype.name_tag = function(name_tag) {
|
58636
|
+
this._register_single("mp_name_tag", name_tag);
|
58637
|
+
};
|
58638
|
+
MixpanelLib.prototype.set_config = function(config) {
|
58639
|
+
if (_$1.isObject(config)) {
|
58640
|
+
_$1.extend(this["config"], config);
|
58641
|
+
var new_batch_size = config["batch_size"];
|
58642
|
+
if (new_batch_size) {
|
58643
|
+
_$1.each(this.request_batchers, function(batcher) {
|
58644
|
+
batcher.resetBatchSize();
|
58645
|
+
});
|
58646
|
+
}
|
58647
|
+
if (!this.get_config("persistence_name")) {
|
58648
|
+
this["config"]["persistence_name"] = this["config"]["cookie_name"];
|
58649
|
+
}
|
58650
|
+
if (!this.get_config("disable_persistence")) {
|
58651
|
+
this["config"]["disable_persistence"] = this["config"]["disable_cookie"];
|
58652
|
+
}
|
58653
|
+
if (this["persistence"]) {
|
58654
|
+
this["persistence"].update_config(this["config"]);
|
58655
|
+
}
|
58656
|
+
Config.DEBUG = Config.DEBUG || this.get_config("debug");
|
58657
|
+
}
|
58658
|
+
};
|
58659
|
+
MixpanelLib.prototype.get_config = function(prop_name) {
|
58660
|
+
return this["config"][prop_name];
|
58661
|
+
};
|
58662
|
+
MixpanelLib.prototype._run_hook = function(hook_name) {
|
58663
|
+
var ret = (this["config"]["hooks"][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
|
58664
|
+
if (typeof ret === "undefined") {
|
58665
|
+
this.report_error(hook_name + " hook did not return a value");
|
58666
|
+
ret = null;
|
58667
|
+
}
|
58668
|
+
return ret;
|
58669
|
+
};
|
58670
|
+
MixpanelLib.prototype.get_property = function(property_name) {
|
58671
|
+
return this["persistence"].load_prop([property_name]);
|
58672
|
+
};
|
58673
|
+
MixpanelLib.prototype.toString = function() {
|
58674
|
+
var name2 = this.get_config("name");
|
58675
|
+
if (name2 !== PRIMARY_INSTANCE_NAME) {
|
58676
|
+
name2 = PRIMARY_INSTANCE_NAME + "." + name2;
|
58677
|
+
}
|
58678
|
+
return name2;
|
58679
|
+
};
|
58680
|
+
MixpanelLib.prototype._event_is_disabled = function(event_name) {
|
58681
|
+
return _$1.isBlockedUA(userAgent) || this._flags.disable_all_events || _$1.include(this.__disabled_events, event_name);
|
58682
|
+
};
|
58683
|
+
MixpanelLib.prototype._gdpr_init = function() {
|
58684
|
+
var is_localStorage_requested = this.get_config("opt_out_tracking_persistence_type") === "localStorage";
|
58685
|
+
if (is_localStorage_requested && _$1.localStorage.is_supported()) {
|
58686
|
+
if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({ "persistence_type": "cookie" })) {
|
58687
|
+
this.opt_in_tracking({ "enable_persistence": false });
|
58688
|
+
}
|
58689
|
+
if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({ "persistence_type": "cookie" })) {
|
58690
|
+
this.opt_out_tracking({ "clear_persistence": false });
|
58691
|
+
}
|
58692
|
+
this.clear_opt_in_out_tracking({
|
58693
|
+
"persistence_type": "cookie",
|
58694
|
+
"enable_persistence": false
|
58695
|
+
});
|
58696
|
+
}
|
58697
|
+
if (this.has_opted_out_tracking()) {
|
58698
|
+
this._gdpr_update_persistence({ "clear_persistence": true });
|
58699
|
+
} else if (!this.has_opted_in_tracking() && (this.get_config("opt_out_tracking_by_default") || _$1.cookie.get("mp_optout"))) {
|
58700
|
+
_$1.cookie.remove("mp_optout");
|
58701
|
+
this.opt_out_tracking({
|
58702
|
+
"clear_persistence": this.get_config("opt_out_persistence_by_default")
|
58703
|
+
});
|
58704
|
+
}
|
58705
|
+
};
|
58706
|
+
MixpanelLib.prototype._gdpr_update_persistence = function(options) {
|
58707
|
+
var disabled;
|
58708
|
+
if (options && options["clear_persistence"]) {
|
58709
|
+
disabled = true;
|
58710
|
+
} else if (options && options["enable_persistence"]) {
|
58711
|
+
disabled = false;
|
58712
|
+
} else {
|
58713
|
+
return;
|
58714
|
+
}
|
58715
|
+
if (!this.get_config("disable_persistence") && this["persistence"].disabled !== disabled) {
|
58716
|
+
this["persistence"].set_disabled(disabled);
|
58717
|
+
}
|
58718
|
+
if (disabled) {
|
58719
|
+
this.stop_batch_senders();
|
58720
|
+
} else {
|
58721
|
+
if (this._batchers_were_started) {
|
58722
|
+
this.start_batch_senders();
|
58723
|
+
}
|
58724
|
+
}
|
58725
|
+
};
|
58726
|
+
MixpanelLib.prototype._gdpr_call_func = function(func, options) {
|
58727
|
+
options = _$1.extend({
|
58728
|
+
"track": _$1.bind(this.track, this),
|
58729
|
+
"persistence_type": this.get_config("opt_out_tracking_persistence_type"),
|
58730
|
+
"cookie_prefix": this.get_config("opt_out_tracking_cookie_prefix"),
|
58731
|
+
"cookie_expiration": this.get_config("cookie_expiration"),
|
58732
|
+
"cross_site_cookie": this.get_config("cross_site_cookie"),
|
58733
|
+
"cross_subdomain_cookie": this.get_config("cross_subdomain_cookie"),
|
58734
|
+
"cookie_domain": this.get_config("cookie_domain"),
|
58735
|
+
"secure_cookie": this.get_config("secure_cookie"),
|
58736
|
+
"ignore_dnt": this.get_config("ignore_dnt")
|
58737
|
+
}, options);
|
58738
|
+
if (!_$1.localStorage.is_supported()) {
|
58739
|
+
options["persistence_type"] = "cookie";
|
58740
|
+
}
|
58741
|
+
return func(this.get_config("token"), {
|
58742
|
+
track: options["track"],
|
58743
|
+
trackEventName: options["track_event_name"],
|
58744
|
+
trackProperties: options["track_properties"],
|
58745
|
+
persistenceType: options["persistence_type"],
|
58746
|
+
persistencePrefix: options["cookie_prefix"],
|
58747
|
+
cookieDomain: options["cookie_domain"],
|
58748
|
+
cookieExpiration: options["cookie_expiration"],
|
58749
|
+
crossSiteCookie: options["cross_site_cookie"],
|
58750
|
+
crossSubdomainCookie: options["cross_subdomain_cookie"],
|
58751
|
+
secureCookie: options["secure_cookie"],
|
58752
|
+
ignoreDnt: options["ignore_dnt"]
|
58753
|
+
});
|
58754
|
+
};
|
58755
|
+
MixpanelLib.prototype.opt_in_tracking = function(options) {
|
58756
|
+
options = _$1.extend({
|
58757
|
+
"enable_persistence": true
|
58758
|
+
}, options);
|
58759
|
+
this._gdpr_call_func(optIn, options);
|
58760
|
+
this._gdpr_update_persistence(options);
|
58761
|
+
};
|
58762
|
+
MixpanelLib.prototype.opt_out_tracking = function(options) {
|
58763
|
+
options = _$1.extend({
|
58764
|
+
"clear_persistence": true,
|
58765
|
+
"delete_user": true
|
58766
|
+
}, options);
|
58767
|
+
if (options["delete_user"] && this["people"] && this["people"]._identify_called()) {
|
58768
|
+
this["people"].delete_user();
|
58769
|
+
this["people"].clear_charges();
|
58770
|
+
}
|
58771
|
+
this._gdpr_call_func(optOut, options);
|
58772
|
+
this._gdpr_update_persistence(options);
|
58773
|
+
};
|
58774
|
+
MixpanelLib.prototype.has_opted_in_tracking = function(options) {
|
58775
|
+
return this._gdpr_call_func(hasOptedIn, options);
|
58776
|
+
};
|
58777
|
+
MixpanelLib.prototype.has_opted_out_tracking = function(options) {
|
58778
|
+
return this._gdpr_call_func(hasOptedOut, options);
|
58779
|
+
};
|
58780
|
+
MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
|
58781
|
+
options = _$1.extend({
|
58782
|
+
"enable_persistence": true
|
58783
|
+
}, options);
|
58784
|
+
this._gdpr_call_func(clearOptInOut, options);
|
58785
|
+
this._gdpr_update_persistence(options);
|
58786
|
+
};
|
58787
|
+
MixpanelLib.prototype.report_error = function(msg, err) {
|
58788
|
+
console$1.error.apply(console$1.error, arguments);
|
58789
|
+
try {
|
58790
|
+
if (!err && !(msg instanceof Error)) {
|
58791
|
+
msg = new Error(msg);
|
58792
|
+
}
|
58793
|
+
this.get_config("error_reporter")(msg, err);
|
58794
|
+
} catch (err2) {
|
58795
|
+
console$1.error(err2);
|
58796
|
+
}
|
58797
|
+
};
|
58798
|
+
MixpanelLib.prototype["init"] = MixpanelLib.prototype.init;
|
58799
|
+
MixpanelLib.prototype["reset"] = MixpanelLib.prototype.reset;
|
58800
|
+
MixpanelLib.prototype["disable"] = MixpanelLib.prototype.disable;
|
58801
|
+
MixpanelLib.prototype["time_event"] = MixpanelLib.prototype.time_event;
|
58802
|
+
MixpanelLib.prototype["track"] = MixpanelLib.prototype.track;
|
58803
|
+
MixpanelLib.prototype["track_links"] = MixpanelLib.prototype.track_links;
|
58804
|
+
MixpanelLib.prototype["track_forms"] = MixpanelLib.prototype.track_forms;
|
58805
|
+
MixpanelLib.prototype["track_pageview"] = MixpanelLib.prototype.track_pageview;
|
58806
|
+
MixpanelLib.prototype["register"] = MixpanelLib.prototype.register;
|
58807
|
+
MixpanelLib.prototype["register_once"] = MixpanelLib.prototype.register_once;
|
58808
|
+
MixpanelLib.prototype["unregister"] = MixpanelLib.prototype.unregister;
|
58809
|
+
MixpanelLib.prototype["identify"] = MixpanelLib.prototype.identify;
|
58810
|
+
MixpanelLib.prototype["alias"] = MixpanelLib.prototype.alias;
|
58811
|
+
MixpanelLib.prototype["name_tag"] = MixpanelLib.prototype.name_tag;
|
58812
|
+
MixpanelLib.prototype["set_config"] = MixpanelLib.prototype.set_config;
|
58813
|
+
MixpanelLib.prototype["get_config"] = MixpanelLib.prototype.get_config;
|
58814
|
+
MixpanelLib.prototype["get_property"] = MixpanelLib.prototype.get_property;
|
58815
|
+
MixpanelLib.prototype["get_distinct_id"] = MixpanelLib.prototype.get_distinct_id;
|
58816
|
+
MixpanelLib.prototype["toString"] = MixpanelLib.prototype.toString;
|
58817
|
+
MixpanelLib.prototype["opt_out_tracking"] = MixpanelLib.prototype.opt_out_tracking;
|
58818
|
+
MixpanelLib.prototype["opt_in_tracking"] = MixpanelLib.prototype.opt_in_tracking;
|
58819
|
+
MixpanelLib.prototype["has_opted_out_tracking"] = MixpanelLib.prototype.has_opted_out_tracking;
|
58820
|
+
MixpanelLib.prototype["has_opted_in_tracking"] = MixpanelLib.prototype.has_opted_in_tracking;
|
58821
|
+
MixpanelLib.prototype["clear_opt_in_out_tracking"] = MixpanelLib.prototype.clear_opt_in_out_tracking;
|
58822
|
+
MixpanelLib.prototype["get_group"] = MixpanelLib.prototype.get_group;
|
58823
|
+
MixpanelLib.prototype["set_group"] = MixpanelLib.prototype.set_group;
|
58824
|
+
MixpanelLib.prototype["add_group"] = MixpanelLib.prototype.add_group;
|
58825
|
+
MixpanelLib.prototype["remove_group"] = MixpanelLib.prototype.remove_group;
|
58826
|
+
MixpanelLib.prototype["track_with_groups"] = MixpanelLib.prototype.track_with_groups;
|
58827
|
+
MixpanelLib.prototype["start_batch_senders"] = MixpanelLib.prototype.start_batch_senders;
|
58828
|
+
MixpanelLib.prototype["stop_batch_senders"] = MixpanelLib.prototype.stop_batch_senders;
|
58829
|
+
MixpanelLib.prototype["start_session_recording"] = MixpanelLib.prototype.start_session_recording;
|
58830
|
+
MixpanelLib.prototype["stop_session_recording"] = MixpanelLib.prototype.stop_session_recording;
|
58831
|
+
MixpanelLib.prototype["get_session_recording_properties"] = MixpanelLib.prototype.get_session_recording_properties;
|
58832
|
+
MixpanelLib.prototype["DEFAULT_API_ROUTES"] = DEFAULT_API_ROUTES;
|
58833
|
+
MixpanelPersistence.prototype["properties"] = MixpanelPersistence.prototype.properties;
|
58834
|
+
MixpanelPersistence.prototype["update_search_keyword"] = MixpanelPersistence.prototype.update_search_keyword;
|
58835
|
+
MixpanelPersistence.prototype["update_referrer_info"] = MixpanelPersistence.prototype.update_referrer_info;
|
58836
|
+
MixpanelPersistence.prototype["get_cross_subdomain"] = MixpanelPersistence.prototype.get_cross_subdomain;
|
58837
|
+
MixpanelPersistence.prototype["clear"] = MixpanelPersistence.prototype.clear;
|
58838
|
+
var instances = {};
|
58839
|
+
var extend_mp = function() {
|
58840
|
+
_$1.each(instances, function(instance, name2) {
|
58841
|
+
if (name2 !== PRIMARY_INSTANCE_NAME) {
|
58842
|
+
mixpanel_master[name2] = instance;
|
58843
|
+
}
|
58844
|
+
});
|
58845
|
+
mixpanel_master["_"] = _$1;
|
58846
|
+
};
|
58847
|
+
var override_mp_init_func = function() {
|
58848
|
+
mixpanel_master["init"] = function(token, config, name2) {
|
58849
|
+
if (name2) {
|
58850
|
+
if (!mixpanel_master[name2]) {
|
58851
|
+
mixpanel_master[name2] = instances[name2] = create_mplib(token, config, name2);
|
58852
|
+
mixpanel_master[name2]._loaded();
|
58853
|
+
}
|
58854
|
+
return mixpanel_master[name2];
|
58855
|
+
} else {
|
58856
|
+
var instance = mixpanel_master;
|
58857
|
+
if (instances[PRIMARY_INSTANCE_NAME]) {
|
58858
|
+
instance = instances[PRIMARY_INSTANCE_NAME];
|
58859
|
+
} else if (token) {
|
58860
|
+
instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
|
58861
|
+
instance._loaded();
|
58862
|
+
instances[PRIMARY_INSTANCE_NAME] = instance;
|
58863
|
+
}
|
58864
|
+
mixpanel_master = instance;
|
58865
|
+
if (init_type === INIT_SNIPPET) {
|
58866
|
+
win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
|
58867
|
+
}
|
58868
|
+
extend_mp();
|
58869
|
+
}
|
58870
|
+
};
|
58871
|
+
};
|
58872
|
+
var add_dom_loaded_handler = function() {
|
58873
|
+
function dom_loaded_handler() {
|
58874
|
+
if (dom_loaded_handler.done) {
|
58875
|
+
return;
|
58876
|
+
}
|
58877
|
+
dom_loaded_handler.done = true;
|
58878
|
+
DOM_LOADED = true;
|
58879
|
+
ENQUEUE_REQUESTS = false;
|
58880
|
+
_$1.each(instances, function(inst) {
|
58881
|
+
inst._dom_loaded();
|
58882
|
+
});
|
58883
|
+
}
|
58884
|
+
function do_scroll_check() {
|
58885
|
+
try {
|
58886
|
+
document$1.documentElement.doScroll("left");
|
58887
|
+
} catch (e) {
|
58888
|
+
setTimeout(do_scroll_check, 1);
|
58889
|
+
return;
|
58890
|
+
}
|
58891
|
+
dom_loaded_handler();
|
58892
|
+
}
|
58893
|
+
if (document$1.addEventListener) {
|
58894
|
+
if (document$1.readyState === "complete") {
|
58895
|
+
dom_loaded_handler();
|
58896
|
+
} else {
|
58897
|
+
document$1.addEventListener("DOMContentLoaded", dom_loaded_handler, false);
|
58898
|
+
}
|
58899
|
+
} else if (document$1.attachEvent) {
|
58900
|
+
document$1.attachEvent("onreadystatechange", dom_loaded_handler);
|
58901
|
+
var toplevel = false;
|
58902
|
+
try {
|
58903
|
+
toplevel = win.frameElement === null;
|
58904
|
+
} catch (e) {
|
58905
|
+
}
|
58906
|
+
if (document$1.documentElement.doScroll && toplevel) {
|
58907
|
+
do_scroll_check();
|
58908
|
+
}
|
58909
|
+
}
|
58910
|
+
_$1.register_event(win, "load", dom_loaded_handler, true);
|
58911
|
+
};
|
58912
|
+
function init_as_module() {
|
58913
|
+
init_type = INIT_MODULE;
|
58914
|
+
mixpanel_master = new MixpanelLib();
|
58915
|
+
override_mp_init_func();
|
58916
|
+
mixpanel_master["init"]();
|
58917
|
+
add_dom_loaded_handler();
|
58918
|
+
return mixpanel_master;
|
58919
|
+
}
|
58920
|
+
var mixpanel = init_as_module();
|
58921
|
+
var mixpanel_cjs = mixpanel;
|
58922
|
+
module$2.factory("MixpanelService", [function() {
|
58923
|
+
const service = {};
|
58924
|
+
const mixpanelTimescaleProxyDEV = "https://d3ige8rf4hrn8x.cloudfront.net/dev";
|
58925
|
+
mixpanel_cjs.init("some_token");
|
58926
|
+
mixpanel_cjs.init("", { api_host: mixpanelTimescaleProxyDEV }, "proxy");
|
58927
|
+
service.sendProxyEvent = (event2, properties) => {
|
58928
|
+
try {
|
58929
|
+
event2 = event2.toLowerCase();
|
58930
|
+
properties = properties || {};
|
58931
|
+
if (properties.user_id) {
|
58932
|
+
mixpanel_cjs.proxy.identify(properties.user_id);
|
58933
|
+
}
|
58934
|
+
mixpanel_cjs.proxy.track(event2, properties);
|
58935
|
+
} catch (err) {
|
58936
|
+
console.log("Failed to send MX event");
|
58937
|
+
}
|
58938
|
+
};
|
58939
|
+
return service;
|
58940
|
+
}]);
|
58941
|
+
module$2.service("PlayerTrackerService", ["MixpanelService", function(MixpanelService) {
|
58942
|
+
this.track = function(event2, properties) {
|
58943
|
+
properties.__table = "video_events";
|
58944
|
+
MixpanelService.sendProxyEvent(event2, properties);
|
58945
|
+
};
|
58946
|
+
try {
|
58947
|
+
const broadCastChannel = new BroadcastChannel("chunk_loaded");
|
58948
|
+
const origOpen = XMLHttpRequest.prototype.open;
|
58949
|
+
XMLHttpRequest.prototype.open = function() {
|
58950
|
+
this.addEventListener("load", function() {
|
58951
|
+
let url;
|
58952
|
+
try {
|
58953
|
+
url = new URL(this.responseURL);
|
58954
|
+
if (this.status === 200 && url && ["stream.videoflow.io", "dflsjqznkm1lx.cloudfront.net", "a6f45de6e044.us-west-2.playback.live-video.net", "live.videoflow.io"].includes(url.hostname) && url.pathname.match(/.(ts|cmfv|cmfa)$/)) {
|
58955
|
+
broadCastChannel.postMessage(JSON.stringify({ size: parseInt(this.getResponseHeader("content-length")) }));
|
58956
|
+
}
|
58957
|
+
} catch (err) {
|
58958
|
+
}
|
58959
|
+
});
|
58960
|
+
origOpen.apply(this, arguments);
|
58961
|
+
};
|
58962
|
+
} catch (err) {
|
58963
|
+
}
|
58964
|
+
return this;
|
58965
|
+
}]).factory("PlayerTracker", ["PlayerTrackerService", function(PlayerTrackerService) {
|
58966
|
+
const watchTimeEvent = "video_watched_time";
|
58967
|
+
const TrackedEvents = {
|
58968
|
+
impression: true,
|
58969
|
+
play: false,
|
58970
|
+
pause: false,
|
58971
|
+
ended: false,
|
58972
|
+
"section watched": true,
|
58973
|
+
"ad started": true,
|
58974
|
+
"ad impression": false,
|
58975
|
+
"ad skipped": true,
|
58976
|
+
"ad completed": true,
|
58977
|
+
"chunk": true
|
58978
|
+
};
|
58979
|
+
const tracker2 = function Tracker(player, metadata) {
|
58980
|
+
this.player = player;
|
58981
|
+
this.metadata = metadata;
|
58982
|
+
this.player.one("play", () => {
|
58983
|
+
try {
|
58984
|
+
const props = this._getProps();
|
58985
|
+
props.event = "impression";
|
58986
|
+
if (TrackedEvents[props.event])
|
58987
|
+
PlayerTrackerService.track("video", props);
|
58988
|
+
this.sendSectionWatchedEvent();
|
58989
|
+
} catch (err) {
|
58990
|
+
}
|
58991
|
+
});
|
58992
|
+
this.on("play");
|
58993
|
+
this.on("pause");
|
58994
|
+
this.on("ended");
|
58995
|
+
const prop = {};
|
58996
|
+
prop[watchTimeEvent] = 0;
|
58997
|
+
mixpanel_cjs.register_once(prop);
|
58998
|
+
this.lastTimeUpdate = 0;
|
58999
|
+
this.watchTime = 0;
|
59000
|
+
let sectionWatchSent = 0;
|
59001
|
+
const sectionDuration = 30;
|
59002
|
+
let self2 = this;
|
59003
|
+
this.chunkListener = function(event2) {
|
59004
|
+
try {
|
59005
|
+
let data = JSON.parse(event2.data);
|
59006
|
+
const props = self2._getProps();
|
59007
|
+
props.event = "chunk";
|
59008
|
+
Object.assign(props, self2._getHLSProps());
|
59009
|
+
props.stream_bitrate = data.size;
|
59010
|
+
if (TrackedEvents[props.event])
|
59011
|
+
PlayerTrackerService.track("video", props);
|
59012
|
+
} catch (err) {
|
59013
|
+
}
|
59014
|
+
};
|
59015
|
+
this.sendSectionWatchedEvent = function() {
|
59016
|
+
const props = this._getProps();
|
59017
|
+
props.event = "section watched";
|
59018
|
+
props.section_duration = sectionDuration;
|
59019
|
+
props.measure = sectionDuration;
|
59020
|
+
Object.assign(props, this._getHLSProps());
|
59021
|
+
if (TrackedEvents[props.event])
|
59022
|
+
PlayerTrackerService.track("video", props);
|
59023
|
+
};
|
59024
|
+
try {
|
59025
|
+
this.broadcastChannel = new BroadcastChannel("chunk_loaded");
|
59026
|
+
this.broadcastChannel.addEventListener("message", this.chunkListener);
|
59027
|
+
} catch (err) {
|
59028
|
+
}
|
59029
|
+
this.player.on("frag_loaded", (event2, data) => {
|
59030
|
+
try {
|
59031
|
+
const props = this._getProps();
|
59032
|
+
props.event = "chunk";
|
59033
|
+
props.stream_bitrate = data.frag.loaded;
|
59034
|
+
Object.assign(props, this._getHLSProps());
|
59035
|
+
props.stream_segment_duration = data.frag.duration;
|
59036
|
+
if (TrackedEvents[props.event])
|
59037
|
+
PlayerTrackerService.track("video", props);
|
59038
|
+
} catch (err) {
|
59039
|
+
}
|
59040
|
+
});
|
59041
|
+
this.player.on("timeupdate", (event2) => {
|
59042
|
+
if (this.lastTimeUpdate && Math.abs(this.player.currentTime() - this.lastTimeUpdate) < 1) {
|
59043
|
+
this._increment(watchTimeEvent, this.player.currentTime() - this.lastTimeUpdate);
|
59044
|
+
this.watchTime += this.player.currentTime() - this.lastTimeUpdate;
|
59045
|
+
}
|
59046
|
+
this.lastTimeUpdate = this.player.currentTime();
|
59047
|
+
if (this.watchTime - sectionWatchSent > sectionDuration) {
|
59048
|
+
try {
|
59049
|
+
this.sendSectionWatchedEvent();
|
59050
|
+
sectionWatchSent = this.watchTime;
|
59051
|
+
} catch (err) {
|
59052
|
+
}
|
59053
|
+
}
|
59054
|
+
});
|
59055
|
+
};
|
59056
|
+
tracker2.prototype = {
|
59057
|
+
_getInputType: function(input) {
|
59058
|
+
if (input.type === "live")
|
59059
|
+
return input.live_type;
|
59060
|
+
if (input.type === "normal") {
|
59061
|
+
return "custom";
|
59062
|
+
}
|
59063
|
+
return input.type;
|
59064
|
+
},
|
59065
|
+
_getProps: function() {
|
59066
|
+
let props = {
|
59067
|
+
input_src: this.player.src(),
|
59068
|
+
input_name: this.metadata.videoTitle,
|
59069
|
+
input_token: this.metadata.videoId,
|
59070
|
+
input_tags: this.metadata.videoTags,
|
59071
|
+
input_parent_id: this.metadata.videoParentId,
|
59072
|
+
input_parent_token: this.metadata.videoParentId,
|
59073
|
+
organization_owner: this.metadata.workspaceOwner,
|
59074
|
+
organization_name: this.metadata.workspaceName,
|
59075
|
+
organization_token: this.metadata.workspaceToken,
|
59076
|
+
organization_id: this.metadata.workspaceId,
|
59077
|
+
channel_name: this.metadata.channelTitle,
|
59078
|
+
channel_token: this.metadata.channelId,
|
59079
|
+
video_current_watch_time: parseFloat(this.watchTime.toFixed(2)),
|
59080
|
+
video_duration: parseFloat(this.player.duration().toFixed(2)),
|
59081
|
+
video_current_time: parseFloat(this.player.currentTime().toFixed(2)),
|
59082
|
+
is_recording: !!this.metadata.isRecording,
|
59083
|
+
is_external: !!this.metadata.isExternal,
|
59084
|
+
input_stream_state: this.metadata.videoState,
|
59085
|
+
input_type: this.metadata.videoType,
|
59086
|
+
user_id: this.metadata.viewerId
|
59087
|
+
};
|
59088
|
+
return props;
|
59089
|
+
},
|
59090
|
+
_aproxEq: function(val1, val2, delta) {
|
59091
|
+
return val1 >= val2 - delta && val1 <= val2 + delta;
|
59092
|
+
},
|
59093
|
+
_getHLSProps: function() {
|
59094
|
+
try {
|
59095
|
+
if (this.player.vfhls.currentLevel) {
|
59096
|
+
return {
|
59097
|
+
stream_width: this.player.vfhls.currentLevel.width,
|
59098
|
+
stream_height: this.player.vfhls.currentLevel.height,
|
59099
|
+
stream_bitrate: this.player.vfhls.currentLevel.bitrate,
|
59100
|
+
stream_video_codec: this.player.vfhls.currentLevel.videoCodec,
|
59101
|
+
stream_audio_codec: this.player.vfhls.currentLevel.audioCodec,
|
59102
|
+
stream_level: `${this.player.vfhls.currentLevel.level + 1}/${this.player.vfhls.currentLevel.totalLevels}`,
|
59103
|
+
stream_level_index: this.player.vfhls.currentLevel.level,
|
59104
|
+
stream_total_levels: this.player.vfhls.currentLevel.totalLevels,
|
59105
|
+
stream_resolutions: this.player.vfhls.currentLevel.availableResolutions,
|
59106
|
+
stream_is_live: !!this.player.vfhls.isLive,
|
59107
|
+
stream_segment_duration: this.player.vfhls.manifest ? this.player.vfhls.manifest._segmentDuration : void 0
|
59108
|
+
};
|
59109
|
+
} else if (this.player.vfhls.manifest && this.player.vfhls.manifest.playlists) {
|
59110
|
+
const width = this.player.videoWidth();
|
59111
|
+
const height = this.player.videoHeight();
|
59112
|
+
let playlists = this.player.vfhls.manifest.playlists;
|
59113
|
+
const subManifestIndex = playlists.findIndex((playlist) => {
|
59114
|
+
return playlist.attributes && playlist.attributes.RESOLUTION && this._aproxEq(playlist.attributes.RESOLUTION.width, width, 10) && this._aproxEq(playlist.attributes.RESOLUTION.height, height, 10);
|
59115
|
+
});
|
59116
|
+
if (subManifestIndex < 0)
|
59117
|
+
return {};
|
59118
|
+
const subManifest = playlists[subManifestIndex];
|
59119
|
+
if (!subManifest || !subManifest.attributes)
|
59120
|
+
return {};
|
59121
|
+
const codecs = subManifest.attributes.CODECS ? subManifest.attributes.CODECS.split(",") : [];
|
59122
|
+
return {
|
59123
|
+
stream_total_levels: playlists.length,
|
59124
|
+
stream_level: `${subManifestIndex + 1}/${playlists.length}`,
|
59125
|
+
stream_level_index: subManifestIndex,
|
59126
|
+
stream_is_live: this.player.vfhls.manifest._live,
|
59127
|
+
stream_segment_duration: this.player.vfhls.manifest._segmentDuration,
|
59128
|
+
stream_bitrate: subManifest.attributes.BANDWIDTH,
|
59129
|
+
stream_width: subManifest.attributes.RESOLUTION ? subManifest.attributes.RESOLUTION.width : void 0,
|
59130
|
+
stream_height: subManifest.attributes.RESOLUTION ? subManifest.attributes.RESOLUTION.height : void 0,
|
59131
|
+
stream_video_codec: codecs.length > 1 ? codecs[0].trim() : "unknown",
|
59132
|
+
stream_audio_codec: codecs.length > 2 ? codecs[1].trim() : "unknown"
|
59133
|
+
};
|
59134
|
+
} else {
|
59135
|
+
return {};
|
59136
|
+
}
|
59137
|
+
} catch (err) {
|
59138
|
+
return {};
|
59139
|
+
}
|
59140
|
+
},
|
59141
|
+
one: function(playerEvent, mxEvent) {
|
59142
|
+
this.player.one(playerEvent, () => {
|
59143
|
+
const props = this._getProps();
|
59144
|
+
props.event = playerEvent;
|
59145
|
+
PlayerTrackerService.track(mxEvent, props);
|
59146
|
+
});
|
59147
|
+
},
|
59148
|
+
on: function(playerEvent, alternateName) {
|
59149
|
+
this.player.on(playerEvent, () => {
|
59150
|
+
try {
|
59151
|
+
const props = this._getProps();
|
59152
|
+
props.event = alternateName || playerEvent;
|
59153
|
+
if (TrackedEvents[props.event])
|
59154
|
+
PlayerTrackerService.track("video", props);
|
59155
|
+
} catch (err) {
|
59156
|
+
}
|
59157
|
+
});
|
59158
|
+
},
|
59159
|
+
onAd: function(adEvent, alternateName) {
|
59160
|
+
try {
|
59161
|
+
this.player.ima.addEventListener(adEvent, (e) => {
|
59162
|
+
try {
|
59163
|
+
const props = this._getProps();
|
59164
|
+
props.event = alternateName || adEvent;
|
59165
|
+
if (TrackedEvents[props.event])
|
59166
|
+
PlayerTrackerService.track("video", props);
|
59167
|
+
} catch (err) {
|
59168
|
+
}
|
59169
|
+
});
|
59170
|
+
} catch (err) {
|
59171
|
+
}
|
59172
|
+
},
|
59173
|
+
debug: function(playerEvent) {
|
59174
|
+
this.player.on(playerEvent, () => {
|
59175
|
+
console.log(playerEvent);
|
59176
|
+
});
|
59177
|
+
},
|
59178
|
+
off: function(event2) {
|
59179
|
+
this.player.off(event2);
|
59180
|
+
},
|
59181
|
+
trackAds: function() {
|
59182
|
+
this.onAd("start", "ad started");
|
59183
|
+
this.onAd("impression", "ad impression");
|
59184
|
+
this.onAd("skip", "ad skipped");
|
59185
|
+
this.onAd("allAdsCompleted", "ad completed");
|
59186
|
+
},
|
59187
|
+
destroy: function(event2) {
|
59188
|
+
this.off("play");
|
59189
|
+
this.off("pause");
|
59190
|
+
this.off("ended");
|
59191
|
+
this.off("timeupdate");
|
59192
|
+
try {
|
59193
|
+
this.broadcastChannel.removeEventListener("message", this.chunkListener);
|
59194
|
+
} catch (err) {
|
59195
|
+
}
|
59196
|
+
},
|
59197
|
+
_increment: function(property, value) {
|
59198
|
+
const prop = {};
|
59199
|
+
prop[property] = parseFloat((mixpanel_cjs.get_property(property) + value).toFixed(2));
|
59200
|
+
mixpanel_cjs.register(prop);
|
59201
|
+
}
|
59202
|
+
};
|
59203
|
+
return tracker2;
|
59204
|
+
}]);
|
59205
|
+
function initMux(player, options) {
|
59206
|
+
var _a;
|
59207
|
+
const muxSettings = {
|
59208
|
+
debug: false,
|
59209
|
+
data: {
|
59210
|
+
env_key: options.muxKey,
|
59211
|
+
player_name: options.playerName || "Stream Engine Player",
|
59212
|
+
viewer_user_id: options.viewerId || "",
|
59213
|
+
player_version: "1.0.0",
|
59214
|
+
video_id: options.videoId,
|
59215
|
+
video_title: options.videoTitle,
|
59216
|
+
video_series: "",
|
59217
|
+
video_duration: (parseFloat(player.duration().toFixed(2)) || 0) * 1e3,
|
59218
|
+
video_stream_type: (_a = options.videoState) == null ? void 0 : _a.toUpperCase(),
|
59219
|
+
video_cdn: "CloudFront",
|
59220
|
+
custom_1: options.channelTitle,
|
59221
|
+
custom_2: window.location.host
|
59222
|
+
}
|
59223
|
+
};
|
59224
|
+
player.mux(muxSettings);
|
59225
|
+
}
|
59226
|
+
module$2.service("VJSAnalyticsPlugin", ["PlayerTracker", function(PlayerTracker) {
|
59227
|
+
const Plugin2 = videojs$1.getPlugin("plugin");
|
59228
|
+
const plugin = videojs$1.extend(Plugin2, {
|
59229
|
+
constructor: function(player, options) {
|
59230
|
+
Plugin2.call(this, player, options);
|
59231
|
+
if (options.muxKey && player.mux) {
|
59232
|
+
initMux(player, options);
|
59233
|
+
}
|
59234
|
+
new PlayerTracker(player, options);
|
54939
59235
|
}
|
54940
59236
|
});
|
54941
59237
|
plugin.pluginName = "analytics";
|
@@ -61821,6 +66117,7 @@ var require_stream_engine_player = __commonJS({
|
|
61821
66117
|
player.info = {};
|
61822
66118
|
player.vfhls = {};
|
61823
66119
|
player.transparent = !!scope.options.transparent;
|
66120
|
+
player.analytics(scope.options.analytics);
|
61824
66121
|
let imaOptions = {
|
61825
66122
|
adTagUrl: scope.options.adTagUrl,
|
61826
66123
|
adsManagerLoadedCallback
|
@@ -62279,7 +66576,8 @@ var require_stream_engine_player = __commonJS({
|
|
62279
66576
|
logger: "=",
|
62280
66577
|
title: "@",
|
62281
66578
|
dvr: "=",
|
62282
|
-
captions: "="
|
66579
|
+
captions: "=",
|
66580
|
+
analytics: "="
|
62283
66581
|
},
|
62284
66582
|
controller: ["$scope", ($scope) => {
|
62285
66583
|
$scope.api = new Player2();
|
@@ -62331,6 +66629,7 @@ var require_stream_engine_player = __commonJS({
|
|
62331
66629
|
style: $scope.style || {},
|
62332
66630
|
metadata: {},
|
62333
66631
|
captions: $scope.captions,
|
66632
|
+
analytics: $scope.analytics,
|
62334
66633
|
title: "",
|
62335
66634
|
description: ""
|
62336
66635
|
};
|