mixpanel-browser 2.61.1 → 2.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/mixpanel-core.cjs.js +23 -67
- package/dist/mixpanel-recorder.js +28 -68
- package/dist/mixpanel-recorder.min.js +10 -10
- package/dist/mixpanel-recorder.min.js.map +1 -1
- package/dist/mixpanel-with-async-recorder.cjs.js +23 -67
- package/dist/mixpanel.amd.js +29 -70
- package/dist/mixpanel.cjs.js +29 -70
- package/dist/mixpanel.globals.js +23 -67
- package/dist/mixpanel.min.js +140 -141
- package/dist/mixpanel.module.js +29 -70
- package/dist/mixpanel.umd.js +29 -70
- package/package.json +1 -1
- package/src/config.js +1 -1
- package/src/mixpanel-core.js +2 -3
- package/src/mixpanel-persistence.js +2 -2
- package/src/recorder/session-recording.js +6 -3
- package/src/utils.js +20 -64
- package/src/window.js +1 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var Config = {
|
|
4
4
|
DEBUG: false,
|
|
5
|
-
LIB_VERSION: '2.
|
|
5
|
+
LIB_VERSION: '2.62.0'
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
|
|
@@ -12,6 +12,7 @@ if (typeof(window) === 'undefined') {
|
|
|
12
12
|
hostname: ''
|
|
13
13
|
};
|
|
14
14
|
win = {
|
|
15
|
+
crypto: {randomUUID: function() {throw Error('unsupported');}},
|
|
15
16
|
navigator: { userAgent: '', onLine: true },
|
|
16
17
|
document: {
|
|
17
18
|
createElement: function() { return {}; },
|
|
@@ -1225,71 +1226,27 @@ _.utf8Encode = function(string) {
|
|
|
1225
1226
|
return utftext;
|
|
1226
1227
|
};
|
|
1227
1228
|
|
|
1228
|
-
_.UUID =
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
ticks = 0;
|
|
1239
|
-
|
|
1240
|
-
// this while loop figures how many browser ticks go by
|
|
1241
|
-
// before 1*new Date() returns a new number, ie the amount
|
|
1242
|
-
// of ticks that go by per millisecond
|
|
1243
|
-
while (time == 1 * new Date()) {
|
|
1244
|
-
ticks++;
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
return time.toString(16) + Math.floor(ticks).toString(16);
|
|
1248
|
-
};
|
|
1249
|
-
|
|
1250
|
-
// Math.Random entropy
|
|
1251
|
-
var R = function() {
|
|
1252
|
-
return Math.random().toString(16).replace('.', '');
|
|
1253
|
-
};
|
|
1254
|
-
|
|
1255
|
-
// User agent entropy
|
|
1256
|
-
// This function takes the user agent string, and then xors
|
|
1257
|
-
// together each sequence of 8 bytes. This produces a final
|
|
1258
|
-
// sequence of 8 bytes which it returns as hex.
|
|
1259
|
-
var UA = function() {
|
|
1260
|
-
var ua = userAgent,
|
|
1261
|
-
i, ch, buffer = [],
|
|
1262
|
-
ret = 0;
|
|
1263
|
-
|
|
1264
|
-
function xor(result, byte_array) {
|
|
1265
|
-
var j, tmp = 0;
|
|
1266
|
-
for (j = 0; j < byte_array.length; j++) {
|
|
1267
|
-
tmp |= (buffer[j] << j * 8);
|
|
1268
|
-
}
|
|
1269
|
-
return result ^ tmp;
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
for (i = 0; i < ua.length; i++) {
|
|
1273
|
-
ch = ua.charCodeAt(i);
|
|
1274
|
-
buffer.unshift(ch & 0xFF);
|
|
1275
|
-
if (buffer.length >= 4) {
|
|
1276
|
-
ret = xor(ret, buffer);
|
|
1277
|
-
buffer = [];
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
if (buffer.length > 0) {
|
|
1282
|
-
ret = xor(ret, buffer);
|
|
1229
|
+
_.UUID = function() {
|
|
1230
|
+
try {
|
|
1231
|
+
// use native Crypto API when available
|
|
1232
|
+
return win['crypto']['randomUUID']();
|
|
1233
|
+
} catch (err) {
|
|
1234
|
+
// fall back to generating our own UUID
|
|
1235
|
+
// based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
|
|
1236
|
+
var uuid = new Array(36);
|
|
1237
|
+
for (var i = 0; i < 36; i++) {
|
|
1238
|
+
uuid[i] = Math.floor(Math.random() * 16);
|
|
1283
1239
|
}
|
|
1240
|
+
uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
|
|
1241
|
+
uuid[19] = uuid[19] &= ~(1 << 2); // set bit 6 of clock-seq-and-reserved to zero
|
|
1242
|
+
uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
|
|
1243
|
+
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
1284
1244
|
|
|
1285
|
-
return
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
return (T() + '-' + R() + '-' + UA() + '-' + se + '-' + T());
|
|
1291
|
-
};
|
|
1292
|
-
})();
|
|
1245
|
+
return _.map(uuid, function(x) {
|
|
1246
|
+
return x.toString(16);
|
|
1247
|
+
}).join('');
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1293
1250
|
|
|
1294
1251
|
// _.isBlockedUA()
|
|
1295
1252
|
// This is to block various web spiders from executing our JS and
|
|
@@ -5231,7 +5188,7 @@ MixpanelPersistence.prototype.save = function() {
|
|
|
5231
5188
|
|
|
5232
5189
|
this.storage.set(
|
|
5233
5190
|
this.name,
|
|
5234
|
-
|
|
5191
|
+
JSONStringify(this['props']),
|
|
5235
5192
|
this.expire_days,
|
|
5236
5193
|
this.cross_subdomain,
|
|
5237
5194
|
this.secure,
|
|
@@ -6506,7 +6463,6 @@ MixpanelLib.prototype.init_batchers = function() {
|
|
|
6506
6463
|
}, this),
|
|
6507
6464
|
stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
|
|
6508
6465
|
usePersistence: true,
|
|
6509
|
-
enqueueThrottleMs: 10,
|
|
6510
6466
|
}
|
|
6511
6467
|
);
|
|
6512
6468
|
}, this);
|
|
@@ -6576,7 +6532,7 @@ MixpanelLib.prototype.disable = function(events) {
|
|
|
6576
6532
|
};
|
|
6577
6533
|
|
|
6578
6534
|
MixpanelLib.prototype._encode_data_for_request = function(data) {
|
|
6579
|
-
var encoded_data =
|
|
6535
|
+
var encoded_data = JSONStringify(data);
|
|
6580
6536
|
if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
|
|
6581
6537
|
encoded_data = _.base64Encode(encoded_data);
|
|
6582
6538
|
}
|
package/dist/mixpanel.amd.js
CHANGED
|
@@ -7,6 +7,7 @@ define((function () { 'use strict';
|
|
|
7
7
|
hostname: ''
|
|
8
8
|
};
|
|
9
9
|
win = {
|
|
10
|
+
crypto: {randomUUID: function() {throw Error('unsupported');}},
|
|
10
11
|
navigator: { userAgent: '', onLine: true },
|
|
11
12
|
document: {
|
|
12
13
|
createElement: function() { return {}; },
|
|
@@ -4893,7 +4894,7 @@ define((function () { 'use strict';
|
|
|
4893
4894
|
|
|
4894
4895
|
var Config = {
|
|
4895
4896
|
DEBUG: false,
|
|
4896
|
-
LIB_VERSION: '2.
|
|
4897
|
+
LIB_VERSION: '2.62.0'
|
|
4897
4898
|
};
|
|
4898
4899
|
|
|
4899
4900
|
/* eslint camelcase: "off", eqeqeq: "off" */
|
|
@@ -5734,71 +5735,27 @@ define((function () { 'use strict';
|
|
|
5734
5735
|
return utftext;
|
|
5735
5736
|
};
|
|
5736
5737
|
|
|
5737
|
-
_.UUID =
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
ticks = 0;
|
|
5748
|
-
|
|
5749
|
-
// this while loop figures how many browser ticks go by
|
|
5750
|
-
// before 1*new Date() returns a new number, ie the amount
|
|
5751
|
-
// of ticks that go by per millisecond
|
|
5752
|
-
while (time == 1 * new Date()) {
|
|
5753
|
-
ticks++;
|
|
5754
|
-
}
|
|
5755
|
-
}
|
|
5756
|
-
return time.toString(16) + Math.floor(ticks).toString(16);
|
|
5757
|
-
};
|
|
5758
|
-
|
|
5759
|
-
// Math.Random entropy
|
|
5760
|
-
var R = function() {
|
|
5761
|
-
return Math.random().toString(16).replace('.', '');
|
|
5762
|
-
};
|
|
5763
|
-
|
|
5764
|
-
// User agent entropy
|
|
5765
|
-
// This function takes the user agent string, and then xors
|
|
5766
|
-
// together each sequence of 8 bytes. This produces a final
|
|
5767
|
-
// sequence of 8 bytes which it returns as hex.
|
|
5768
|
-
var UA = function() {
|
|
5769
|
-
var ua = userAgent,
|
|
5770
|
-
i, ch, buffer = [],
|
|
5771
|
-
ret = 0;
|
|
5772
|
-
|
|
5773
|
-
function xor(result, byte_array) {
|
|
5774
|
-
var j, tmp = 0;
|
|
5775
|
-
for (j = 0; j < byte_array.length; j++) {
|
|
5776
|
-
tmp |= (buffer[j] << j * 8);
|
|
5777
|
-
}
|
|
5778
|
-
return result ^ tmp;
|
|
5779
|
-
}
|
|
5780
|
-
|
|
5781
|
-
for (i = 0; i < ua.length; i++) {
|
|
5782
|
-
ch = ua.charCodeAt(i);
|
|
5783
|
-
buffer.unshift(ch & 0xFF);
|
|
5784
|
-
if (buffer.length >= 4) {
|
|
5785
|
-
ret = xor(ret, buffer);
|
|
5786
|
-
buffer = [];
|
|
5787
|
-
}
|
|
5788
|
-
}
|
|
5789
|
-
|
|
5790
|
-
if (buffer.length > 0) {
|
|
5791
|
-
ret = xor(ret, buffer);
|
|
5738
|
+
_.UUID = function() {
|
|
5739
|
+
try {
|
|
5740
|
+
// use native Crypto API when available
|
|
5741
|
+
return win['crypto']['randomUUID']();
|
|
5742
|
+
} catch (err) {
|
|
5743
|
+
// fall back to generating our own UUID
|
|
5744
|
+
// based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
|
|
5745
|
+
var uuid = new Array(36);
|
|
5746
|
+
for (var i = 0; i < 36; i++) {
|
|
5747
|
+
uuid[i] = Math.floor(Math.random() * 16);
|
|
5792
5748
|
}
|
|
5749
|
+
uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
|
|
5750
|
+
uuid[19] = uuid[19] &= ~(1 << 2); // set bit 6 of clock-seq-and-reserved to zero
|
|
5751
|
+
uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
|
|
5752
|
+
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
5793
5753
|
|
|
5794
|
-
return
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
return (T() + '-' + R() + '-' + UA() + '-' + se + '-' + T());
|
|
5800
|
-
};
|
|
5801
|
-
})();
|
|
5754
|
+
return _.map(uuid, function(x) {
|
|
5755
|
+
return x.toString(16);
|
|
5756
|
+
}).join('');
|
|
5757
|
+
}
|
|
5758
|
+
};
|
|
5802
5759
|
|
|
5803
5760
|
// _.isBlockedUA()
|
|
5804
5761
|
// This is to block various web spiders from executing our JS and
|
|
@@ -8174,6 +8131,7 @@ define((function () { 'use strict';
|
|
|
8174
8131
|
this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
|
|
8175
8132
|
this.idleExpires = new Date().getTime() + idleTimeoutMs;
|
|
8176
8133
|
}.bind(this);
|
|
8134
|
+
resetIdleTimeout();
|
|
8177
8135
|
|
|
8178
8136
|
var blockSelector = this.getConfig('record_block_selector');
|
|
8179
8137
|
if (blockSelector === '' || blockSelector === null) {
|
|
@@ -8183,6 +8141,10 @@ define((function () { 'use strict';
|
|
|
8183
8141
|
try {
|
|
8184
8142
|
this._stopRecording = this._rrwebRecord({
|
|
8185
8143
|
'emit': function (ev) {
|
|
8144
|
+
if (this.idleExpires && this.idleExpires < ev.timestamp) {
|
|
8145
|
+
this._onIdleTimeout();
|
|
8146
|
+
return;
|
|
8147
|
+
}
|
|
8186
8148
|
if (isUserEvent(ev)) {
|
|
8187
8149
|
if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
|
|
8188
8150
|
// start flushing again after user activity
|
|
@@ -8219,8 +8181,6 @@ define((function () { 'use strict';
|
|
|
8219
8181
|
return;
|
|
8220
8182
|
}
|
|
8221
8183
|
|
|
8222
|
-
resetIdleTimeout();
|
|
8223
|
-
|
|
8224
8184
|
var maxTimeoutMs = this.maxExpires - new Date().getTime();
|
|
8225
8185
|
this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
|
|
8226
8186
|
};
|
|
@@ -8399,7 +8359,7 @@ define((function () { 'use strict';
|
|
|
8399
8359
|
'replay_start_url': this.replayStartUrl,
|
|
8400
8360
|
'seq': this.seqNo
|
|
8401
8361
|
};
|
|
8402
|
-
var eventsJson =
|
|
8362
|
+
var eventsJson = JSON.stringify(data);
|
|
8403
8363
|
|
|
8404
8364
|
// send ID management props if they exist
|
|
8405
8365
|
var deviceId = this._mixpanel.get_property('$device_id');
|
|
@@ -10533,7 +10493,7 @@ define((function () { 'use strict';
|
|
|
10533
10493
|
|
|
10534
10494
|
this.storage.set(
|
|
10535
10495
|
this.name,
|
|
10536
|
-
|
|
10496
|
+
JSONStringify(this['props']),
|
|
10537
10497
|
this.expire_days,
|
|
10538
10498
|
this.cross_subdomain,
|
|
10539
10499
|
this.secure,
|
|
@@ -11685,7 +11645,6 @@ define((function () { 'use strict';
|
|
|
11685
11645
|
}, this),
|
|
11686
11646
|
stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
|
|
11687
11647
|
usePersistence: true,
|
|
11688
|
-
enqueueThrottleMs: 10,
|
|
11689
11648
|
}
|
|
11690
11649
|
);
|
|
11691
11650
|
}, this);
|
|
@@ -11755,7 +11714,7 @@ define((function () { 'use strict';
|
|
|
11755
11714
|
};
|
|
11756
11715
|
|
|
11757
11716
|
MixpanelLib.prototype._encode_data_for_request = function(data) {
|
|
11758
|
-
var encoded_data =
|
|
11717
|
+
var encoded_data = JSONStringify(data);
|
|
11759
11718
|
if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
|
|
11760
11719
|
encoded_data = _.base64Encode(encoded_data);
|
|
11761
11720
|
}
|
package/dist/mixpanel.cjs.js
CHANGED
|
@@ -7,6 +7,7 @@ if (typeof(window) === 'undefined') {
|
|
|
7
7
|
hostname: ''
|
|
8
8
|
};
|
|
9
9
|
win = {
|
|
10
|
+
crypto: {randomUUID: function() {throw Error('unsupported');}},
|
|
10
11
|
navigator: { userAgent: '', onLine: true },
|
|
11
12
|
document: {
|
|
12
13
|
createElement: function() { return {}; },
|
|
@@ -4893,7 +4894,7 @@ var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {
|
|
|
4893
4894
|
|
|
4894
4895
|
var Config = {
|
|
4895
4896
|
DEBUG: false,
|
|
4896
|
-
LIB_VERSION: '2.
|
|
4897
|
+
LIB_VERSION: '2.62.0'
|
|
4897
4898
|
};
|
|
4898
4899
|
|
|
4899
4900
|
/* eslint camelcase: "off", eqeqeq: "off" */
|
|
@@ -5734,71 +5735,27 @@ _.utf8Encode = function(string) {
|
|
|
5734
5735
|
return utftext;
|
|
5735
5736
|
};
|
|
5736
5737
|
|
|
5737
|
-
_.UUID =
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
ticks = 0;
|
|
5748
|
-
|
|
5749
|
-
// this while loop figures how many browser ticks go by
|
|
5750
|
-
// before 1*new Date() returns a new number, ie the amount
|
|
5751
|
-
// of ticks that go by per millisecond
|
|
5752
|
-
while (time == 1 * new Date()) {
|
|
5753
|
-
ticks++;
|
|
5754
|
-
}
|
|
5755
|
-
}
|
|
5756
|
-
return time.toString(16) + Math.floor(ticks).toString(16);
|
|
5757
|
-
};
|
|
5758
|
-
|
|
5759
|
-
// Math.Random entropy
|
|
5760
|
-
var R = function() {
|
|
5761
|
-
return Math.random().toString(16).replace('.', '');
|
|
5762
|
-
};
|
|
5763
|
-
|
|
5764
|
-
// User agent entropy
|
|
5765
|
-
// This function takes the user agent string, and then xors
|
|
5766
|
-
// together each sequence of 8 bytes. This produces a final
|
|
5767
|
-
// sequence of 8 bytes which it returns as hex.
|
|
5768
|
-
var UA = function() {
|
|
5769
|
-
var ua = userAgent,
|
|
5770
|
-
i, ch, buffer = [],
|
|
5771
|
-
ret = 0;
|
|
5772
|
-
|
|
5773
|
-
function xor(result, byte_array) {
|
|
5774
|
-
var j, tmp = 0;
|
|
5775
|
-
for (j = 0; j < byte_array.length; j++) {
|
|
5776
|
-
tmp |= (buffer[j] << j * 8);
|
|
5777
|
-
}
|
|
5778
|
-
return result ^ tmp;
|
|
5779
|
-
}
|
|
5780
|
-
|
|
5781
|
-
for (i = 0; i < ua.length; i++) {
|
|
5782
|
-
ch = ua.charCodeAt(i);
|
|
5783
|
-
buffer.unshift(ch & 0xFF);
|
|
5784
|
-
if (buffer.length >= 4) {
|
|
5785
|
-
ret = xor(ret, buffer);
|
|
5786
|
-
buffer = [];
|
|
5787
|
-
}
|
|
5788
|
-
}
|
|
5789
|
-
|
|
5790
|
-
if (buffer.length > 0) {
|
|
5791
|
-
ret = xor(ret, buffer);
|
|
5738
|
+
_.UUID = function() {
|
|
5739
|
+
try {
|
|
5740
|
+
// use native Crypto API when available
|
|
5741
|
+
return win['crypto']['randomUUID']();
|
|
5742
|
+
} catch (err) {
|
|
5743
|
+
// fall back to generating our own UUID
|
|
5744
|
+
// based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
|
|
5745
|
+
var uuid = new Array(36);
|
|
5746
|
+
for (var i = 0; i < 36; i++) {
|
|
5747
|
+
uuid[i] = Math.floor(Math.random() * 16);
|
|
5792
5748
|
}
|
|
5749
|
+
uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
|
|
5750
|
+
uuid[19] = uuid[19] &= ~(1 << 2); // set bit 6 of clock-seq-and-reserved to zero
|
|
5751
|
+
uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
|
|
5752
|
+
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
5793
5753
|
|
|
5794
|
-
return
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
return (T() + '-' + R() + '-' + UA() + '-' + se + '-' + T());
|
|
5800
|
-
};
|
|
5801
|
-
})();
|
|
5754
|
+
return _.map(uuid, function(x) {
|
|
5755
|
+
return x.toString(16);
|
|
5756
|
+
}).join('');
|
|
5757
|
+
}
|
|
5758
|
+
};
|
|
5802
5759
|
|
|
5803
5760
|
// _.isBlockedUA()
|
|
5804
5761
|
// This is to block various web spiders from executing our JS and
|
|
@@ -8174,6 +8131,7 @@ SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
|
|
|
8174
8131
|
this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
|
|
8175
8132
|
this.idleExpires = new Date().getTime() + idleTimeoutMs;
|
|
8176
8133
|
}.bind(this);
|
|
8134
|
+
resetIdleTimeout();
|
|
8177
8135
|
|
|
8178
8136
|
var blockSelector = this.getConfig('record_block_selector');
|
|
8179
8137
|
if (blockSelector === '' || blockSelector === null) {
|
|
@@ -8183,6 +8141,10 @@ SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
|
|
|
8183
8141
|
try {
|
|
8184
8142
|
this._stopRecording = this._rrwebRecord({
|
|
8185
8143
|
'emit': function (ev) {
|
|
8144
|
+
if (this.idleExpires && this.idleExpires < ev.timestamp) {
|
|
8145
|
+
this._onIdleTimeout();
|
|
8146
|
+
return;
|
|
8147
|
+
}
|
|
8186
8148
|
if (isUserEvent(ev)) {
|
|
8187
8149
|
if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
|
|
8188
8150
|
// start flushing again after user activity
|
|
@@ -8219,8 +8181,6 @@ SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
|
|
|
8219
8181
|
return;
|
|
8220
8182
|
}
|
|
8221
8183
|
|
|
8222
|
-
resetIdleTimeout();
|
|
8223
|
-
|
|
8224
8184
|
var maxTimeoutMs = this.maxExpires - new Date().getTime();
|
|
8225
8185
|
this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
|
|
8226
8186
|
};
|
|
@@ -8399,7 +8359,7 @@ SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (da
|
|
|
8399
8359
|
'replay_start_url': this.replayStartUrl,
|
|
8400
8360
|
'seq': this.seqNo
|
|
8401
8361
|
};
|
|
8402
|
-
var eventsJson =
|
|
8362
|
+
var eventsJson = JSON.stringify(data);
|
|
8403
8363
|
|
|
8404
8364
|
// send ID management props if they exist
|
|
8405
8365
|
var deviceId = this._mixpanel.get_property('$device_id');
|
|
@@ -10533,7 +10493,7 @@ MixpanelPersistence.prototype.save = function() {
|
|
|
10533
10493
|
|
|
10534
10494
|
this.storage.set(
|
|
10535
10495
|
this.name,
|
|
10536
|
-
|
|
10496
|
+
JSONStringify(this['props']),
|
|
10537
10497
|
this.expire_days,
|
|
10538
10498
|
this.cross_subdomain,
|
|
10539
10499
|
this.secure,
|
|
@@ -11685,7 +11645,6 @@ MixpanelLib.prototype.init_batchers = function() {
|
|
|
11685
11645
|
}, this),
|
|
11686
11646
|
stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
|
|
11687
11647
|
usePersistence: true,
|
|
11688
|
-
enqueueThrottleMs: 10,
|
|
11689
11648
|
}
|
|
11690
11649
|
);
|
|
11691
11650
|
}, this);
|
|
@@ -11755,7 +11714,7 @@ MixpanelLib.prototype.disable = function(events) {
|
|
|
11755
11714
|
};
|
|
11756
11715
|
|
|
11757
11716
|
MixpanelLib.prototype._encode_data_for_request = function(data) {
|
|
11758
|
-
var encoded_data =
|
|
11717
|
+
var encoded_data = JSONStringify(data);
|
|
11759
11718
|
if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
|
|
11760
11719
|
encoded_data = _.base64Encode(encoded_data);
|
|
11761
11720
|
}
|
package/dist/mixpanel.globals.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
var Config = {
|
|
5
5
|
DEBUG: false,
|
|
6
|
-
LIB_VERSION: '2.
|
|
6
|
+
LIB_VERSION: '2.62.0'
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
hostname: ''
|
|
14
14
|
};
|
|
15
15
|
win = {
|
|
16
|
+
crypto: {randomUUID: function() {throw Error('unsupported');}},
|
|
16
17
|
navigator: { userAgent: '', onLine: true },
|
|
17
18
|
document: {
|
|
18
19
|
createElement: function() { return {}; },
|
|
@@ -1226,71 +1227,27 @@
|
|
|
1226
1227
|
return utftext;
|
|
1227
1228
|
};
|
|
1228
1229
|
|
|
1229
|
-
_.UUID =
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
ticks = 0;
|
|
1240
|
-
|
|
1241
|
-
// this while loop figures how many browser ticks go by
|
|
1242
|
-
// before 1*new Date() returns a new number, ie the amount
|
|
1243
|
-
// of ticks that go by per millisecond
|
|
1244
|
-
while (time == 1 * new Date()) {
|
|
1245
|
-
ticks++;
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
return time.toString(16) + Math.floor(ticks).toString(16);
|
|
1249
|
-
};
|
|
1250
|
-
|
|
1251
|
-
// Math.Random entropy
|
|
1252
|
-
var R = function() {
|
|
1253
|
-
return Math.random().toString(16).replace('.', '');
|
|
1254
|
-
};
|
|
1255
|
-
|
|
1256
|
-
// User agent entropy
|
|
1257
|
-
// This function takes the user agent string, and then xors
|
|
1258
|
-
// together each sequence of 8 bytes. This produces a final
|
|
1259
|
-
// sequence of 8 bytes which it returns as hex.
|
|
1260
|
-
var UA = function() {
|
|
1261
|
-
var ua = userAgent,
|
|
1262
|
-
i, ch, buffer = [],
|
|
1263
|
-
ret = 0;
|
|
1264
|
-
|
|
1265
|
-
function xor(result, byte_array) {
|
|
1266
|
-
var j, tmp = 0;
|
|
1267
|
-
for (j = 0; j < byte_array.length; j++) {
|
|
1268
|
-
tmp |= (buffer[j] << j * 8);
|
|
1269
|
-
}
|
|
1270
|
-
return result ^ tmp;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
for (i = 0; i < ua.length; i++) {
|
|
1274
|
-
ch = ua.charCodeAt(i);
|
|
1275
|
-
buffer.unshift(ch & 0xFF);
|
|
1276
|
-
if (buffer.length >= 4) {
|
|
1277
|
-
ret = xor(ret, buffer);
|
|
1278
|
-
buffer = [];
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
if (buffer.length > 0) {
|
|
1283
|
-
ret = xor(ret, buffer);
|
|
1230
|
+
_.UUID = function() {
|
|
1231
|
+
try {
|
|
1232
|
+
// use native Crypto API when available
|
|
1233
|
+
return win['crypto']['randomUUID']();
|
|
1234
|
+
} catch (err) {
|
|
1235
|
+
// fall back to generating our own UUID
|
|
1236
|
+
// based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
|
|
1237
|
+
var uuid = new Array(36);
|
|
1238
|
+
for (var i = 0; i < 36; i++) {
|
|
1239
|
+
uuid[i] = Math.floor(Math.random() * 16);
|
|
1284
1240
|
}
|
|
1241
|
+
uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
|
|
1242
|
+
uuid[19] = uuid[19] &= ~(1 << 2); // set bit 6 of clock-seq-and-reserved to zero
|
|
1243
|
+
uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
|
|
1244
|
+
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
1285
1245
|
|
|
1286
|
-
return
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
return (T() + '-' + R() + '-' + UA() + '-' + se + '-' + T());
|
|
1292
|
-
};
|
|
1293
|
-
})();
|
|
1246
|
+
return _.map(uuid, function(x) {
|
|
1247
|
+
return x.toString(16);
|
|
1248
|
+
}).join('');
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1294
1251
|
|
|
1295
1252
|
// _.isBlockedUA()
|
|
1296
1253
|
// This is to block various web spiders from executing our JS and
|
|
@@ -5232,7 +5189,7 @@
|
|
|
5232
5189
|
|
|
5233
5190
|
this.storage.set(
|
|
5234
5191
|
this.name,
|
|
5235
|
-
|
|
5192
|
+
JSONStringify(this['props']),
|
|
5236
5193
|
this.expire_days,
|
|
5237
5194
|
this.cross_subdomain,
|
|
5238
5195
|
this.secure,
|
|
@@ -6507,7 +6464,6 @@
|
|
|
6507
6464
|
}, this),
|
|
6508
6465
|
stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
|
|
6509
6466
|
usePersistence: true,
|
|
6510
|
-
enqueueThrottleMs: 10,
|
|
6511
6467
|
}
|
|
6512
6468
|
);
|
|
6513
6469
|
}, this);
|
|
@@ -6577,7 +6533,7 @@
|
|
|
6577
6533
|
};
|
|
6578
6534
|
|
|
6579
6535
|
MixpanelLib.prototype._encode_data_for_request = function(data) {
|
|
6580
|
-
var encoded_data =
|
|
6536
|
+
var encoded_data = JSONStringify(data);
|
|
6581
6537
|
if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
|
|
6582
6538
|
encoded_data = _.base64Encode(encoded_data);
|
|
6583
6539
|
}
|