mixpanel-browser 2.65.0 → 2.66.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 +5 -0
- package/README.md +1 -1
- package/dist/mixpanel-core.cjs.js +47 -16
- package/dist/mixpanel-recorder.js +18 -10
- package/dist/mixpanel-recorder.min.js +1 -1
- package/dist/mixpanel-recorder.min.js.map +1 -1
- package/dist/mixpanel-with-async-recorder.cjs.js +47 -16
- package/dist/mixpanel-with-recorder.js +64 -25
- package/dist/mixpanel-with-recorder.min.js +1 -1
- package/dist/mixpanel.amd.js +64 -25
- package/dist/mixpanel.cjs.js +64 -25
- package/dist/mixpanel.globals.js +47 -16
- package/dist/mixpanel.min.js +130 -129
- package/dist/mixpanel.module.js +64 -25
- package/dist/mixpanel.umd.js +64 -25
- package/package.json +2 -1
- package/src/config.js +1 -1
- package/src/index.d.ts +408 -0
- package/src/mixpanel-core.js +44 -13
- package/src/mixpanel-group.js +1 -1
- package/src/mixpanel-people.js +1 -1
- package/src/recorder/recorder.js +15 -7
- package/src/recorder/session-recording.js +2 -2
- package/tunnel.log +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var Config = {
|
|
4
4
|
DEBUG: false,
|
|
5
|
-
LIB_VERSION: '2.
|
|
5
|
+
LIB_VERSION: '2.66.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
|
|
@@ -4789,7 +4789,7 @@ MixpanelGroup.prototype._send_request = function(data, callback) {
|
|
|
4789
4789
|
return this._mixpanel._track_or_batch({
|
|
4790
4790
|
type: 'groups',
|
|
4791
4791
|
data: date_encoded_data,
|
|
4792
|
-
endpoint: this.
|
|
4792
|
+
endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
|
|
4793
4793
|
batcher: this._mixpanel.request_batchers.groups
|
|
4794
4794
|
}, callback);
|
|
4795
4795
|
};
|
|
@@ -5141,7 +5141,7 @@ MixpanelPeople.prototype._send_request = function(data, callback) {
|
|
|
5141
5141
|
return this._mixpanel._track_or_batch({
|
|
5142
5142
|
type: 'people',
|
|
5143
5143
|
data: date_encoded_data,
|
|
5144
|
-
endpoint: this.
|
|
5144
|
+
endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
|
|
5145
5145
|
batcher: this._mixpanel.request_batchers.people
|
|
5146
5146
|
}, callback);
|
|
5147
5147
|
};
|
|
@@ -5901,6 +5901,7 @@ var DEFAULT_API_ROUTES = {
|
|
|
5901
5901
|
*/
|
|
5902
5902
|
var DEFAULT_CONFIG = {
|
|
5903
5903
|
'api_host': 'https://api-js.mixpanel.com',
|
|
5904
|
+
'api_hosts': {},
|
|
5904
5905
|
'api_routes': DEFAULT_API_ROUTES,
|
|
5905
5906
|
'api_extra_query_params': {},
|
|
5906
5907
|
'api_method': 'POST',
|
|
@@ -6286,20 +6287,23 @@ MixpanelLib.prototype.start_session_recording = function () {
|
|
|
6286
6287
|
|
|
6287
6288
|
MixpanelLib.prototype.stop_session_recording = function () {
|
|
6288
6289
|
if (this._recorder) {
|
|
6289
|
-
this._recorder['stopRecording']();
|
|
6290
|
+
return this._recorder['stopRecording']();
|
|
6290
6291
|
}
|
|
6292
|
+
return Promise.resolve();
|
|
6291
6293
|
};
|
|
6292
6294
|
|
|
6293
6295
|
MixpanelLib.prototype.pause_session_recording = function () {
|
|
6294
6296
|
if (this._recorder) {
|
|
6295
|
-
this._recorder['pauseRecording']();
|
|
6297
|
+
return this._recorder['pauseRecording']();
|
|
6296
6298
|
}
|
|
6299
|
+
return Promise.resolve();
|
|
6297
6300
|
};
|
|
6298
6301
|
|
|
6299
6302
|
MixpanelLib.prototype.resume_session_recording = function () {
|
|
6300
6303
|
if (this._recorder) {
|
|
6301
|
-
this._recorder['resumeRecording']();
|
|
6304
|
+
return this._recorder['resumeRecording']();
|
|
6302
6305
|
}
|
|
6306
|
+
return Promise.resolve();
|
|
6303
6307
|
};
|
|
6304
6308
|
|
|
6305
6309
|
MixpanelLib.prototype.is_recording_heatmap_data = function () {
|
|
@@ -6899,7 +6903,7 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
|
|
|
6899
6903
|
var ret = this._track_or_batch({
|
|
6900
6904
|
type: 'events',
|
|
6901
6905
|
data: data,
|
|
6902
|
-
endpoint: this.
|
|
6906
|
+
endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
|
|
6903
6907
|
batcher: this.request_batchers.events,
|
|
6904
6908
|
should_send_immediately: should_send_immediately,
|
|
6905
6909
|
send_request_options: options
|
|
@@ -7401,15 +7405,31 @@ MixpanelLib.prototype.identify = function(
|
|
|
7401
7405
|
* Useful for clearing data when a user logs out.
|
|
7402
7406
|
*/
|
|
7403
7407
|
MixpanelLib.prototype.reset = function() {
|
|
7404
|
-
this
|
|
7405
|
-
|
|
7406
|
-
var
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7408
|
+
var self = this;
|
|
7409
|
+
|
|
7410
|
+
var reset = function () {
|
|
7411
|
+
self['persistence'].clear();
|
|
7412
|
+
self._flags.identify_called = false;
|
|
7413
|
+
var uuid = _.UUID();
|
|
7414
|
+
self.register_once({
|
|
7415
|
+
'distinct_id': DEVICE_ID_PREFIX + uuid,
|
|
7416
|
+
'$device_id': uuid
|
|
7417
|
+
}, '');
|
|
7418
|
+
};
|
|
7419
|
+
|
|
7420
|
+
if (self._recorder) {
|
|
7421
|
+
self.stop_session_recording()
|
|
7422
|
+
.then(function () {
|
|
7423
|
+
reset();
|
|
7424
|
+
self._check_and_start_session_recording();
|
|
7425
|
+
})
|
|
7426
|
+
.catch(_.bind(function (err) {
|
|
7427
|
+
reset();
|
|
7428
|
+
this.report_error('Error restarting recording session', err);
|
|
7429
|
+
}, this));
|
|
7430
|
+
} else {
|
|
7431
|
+
reset();
|
|
7432
|
+
}
|
|
7413
7433
|
};
|
|
7414
7434
|
|
|
7415
7435
|
/**
|
|
@@ -7720,6 +7740,16 @@ MixpanelLib.prototype.get_property = function(property_name) {
|
|
|
7720
7740
|
return this['persistence'].load_prop([property_name]);
|
|
7721
7741
|
};
|
|
7722
7742
|
|
|
7743
|
+
/**
|
|
7744
|
+
* Get the API host for a specific endpoint type, falling back to the default api_host if not specified
|
|
7745
|
+
*
|
|
7746
|
+
* @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
|
|
7747
|
+
* @returns {String} The API host to use for this endpoint
|
|
7748
|
+
*/
|
|
7749
|
+
MixpanelLib.prototype.get_api_host = function(endpoint_type) {
|
|
7750
|
+
return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
|
|
7751
|
+
};
|
|
7752
|
+
|
|
7723
7753
|
MixpanelLib.prototype.toString = function() {
|
|
7724
7754
|
var name = this.get_config('name');
|
|
7725
7755
|
if (name !== PRIMARY_INSTANCE_NAME) {
|
|
@@ -8015,6 +8045,7 @@ MixpanelLib.prototype['alias'] = MixpanelLib.protot
|
|
|
8015
8045
|
MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
|
|
8016
8046
|
MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
|
|
8017
8047
|
MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
|
|
8048
|
+
MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
|
|
8018
8049
|
MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
|
|
8019
8050
|
MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
|
|
8020
8051
|
MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
|
|
@@ -13945,7 +13945,7 @@
|
|
|
13945
13945
|
|
|
13946
13946
|
var Config = {
|
|
13947
13947
|
DEBUG: false,
|
|
13948
|
-
LIB_VERSION: '2.
|
|
13948
|
+
LIB_VERSION: '2.66.0'
|
|
13949
13949
|
};
|
|
13950
13950
|
|
|
13951
13951
|
/* eslint camelcase: "off", eqeqeq: "off" */
|
|
@@ -17352,8 +17352,8 @@
|
|
|
17352
17352
|
retryAfter: response.headers.get('Retry-After')
|
|
17353
17353
|
});
|
|
17354
17354
|
}.bind(this);
|
|
17355
|
-
|
|
17356
|
-
win['fetch'](
|
|
17355
|
+
var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
|
|
17356
|
+
win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
|
|
17357
17357
|
'method': 'POST',
|
|
17358
17358
|
'headers': {
|
|
17359
17359
|
'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
|
|
@@ -17570,6 +17570,7 @@
|
|
|
17570
17570
|
this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
|
|
17571
17571
|
|
|
17572
17572
|
this.activeRecording = null;
|
|
17573
|
+
this.stopRecordingInProgress = false;
|
|
17573
17574
|
};
|
|
17574
17575
|
|
|
17575
17576
|
MixpanelRecorder.prototype.startRecording = function(options) {
|
|
@@ -17618,19 +17619,26 @@
|
|
|
17618
17619
|
};
|
|
17619
17620
|
|
|
17620
17621
|
MixpanelRecorder.prototype.stopRecording = function() {
|
|
17621
|
-
|
|
17622
|
-
this.
|
|
17623
|
-
this.
|
|
17624
|
-
|
|
17622
|
+
// Prevents activeSerializedRecording from being reused when stopping the recording.
|
|
17623
|
+
this.stopRecordingInProgress = true;
|
|
17624
|
+
return this._stopCurrentRecording(false, true).then(function() {
|
|
17625
|
+
return this.recordingRegistry.clearActiveRecording();
|
|
17626
|
+
}.bind(this)).then(function() {
|
|
17627
|
+
this.stopRecordingInProgress = false;
|
|
17628
|
+
}.bind(this));
|
|
17625
17629
|
};
|
|
17626
17630
|
|
|
17627
17631
|
MixpanelRecorder.prototype.pauseRecording = function() {
|
|
17628
17632
|
return this._stopCurrentRecording(false);
|
|
17629
17633
|
};
|
|
17630
17634
|
|
|
17631
|
-
MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush) {
|
|
17635
|
+
MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
|
|
17632
17636
|
if (this.activeRecording) {
|
|
17633
|
-
|
|
17637
|
+
var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
|
|
17638
|
+
if (disableActiveRecording) {
|
|
17639
|
+
this.activeRecording = null;
|
|
17640
|
+
}
|
|
17641
|
+
return stopRecordingPromise;
|
|
17634
17642
|
}
|
|
17635
17643
|
return PromisePolyfill.resolve();
|
|
17636
17644
|
};
|
|
@@ -17643,7 +17651,7 @@
|
|
|
17643
17651
|
|
|
17644
17652
|
return this.recordingRegistry.getActiveRecording()
|
|
17645
17653
|
.then(function (activeSerializedRecording) {
|
|
17646
|
-
if (activeSerializedRecording) {
|
|
17654
|
+
if (activeSerializedRecording && !this.stopRecordingInProgress) {
|
|
17647
17655
|
return this.startRecording({activeSerializedRecording: activeSerializedRecording});
|
|
17648
17656
|
} else if (startNewIfInactive) {
|
|
17649
17657
|
return this.startRecording({shouldStopBatcher: false});
|
|
@@ -19145,7 +19153,7 @@
|
|
|
19145
19153
|
return this._mixpanel._track_or_batch({
|
|
19146
19154
|
type: 'groups',
|
|
19147
19155
|
data: date_encoded_data,
|
|
19148
|
-
endpoint: this.
|
|
19156
|
+
endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
|
|
19149
19157
|
batcher: this._mixpanel.request_batchers.groups
|
|
19150
19158
|
}, callback);
|
|
19151
19159
|
};
|
|
@@ -19497,7 +19505,7 @@
|
|
|
19497
19505
|
return this._mixpanel._track_or_batch({
|
|
19498
19506
|
type: 'people',
|
|
19499
19507
|
data: date_encoded_data,
|
|
19500
|
-
endpoint: this.
|
|
19508
|
+
endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
|
|
19501
19509
|
batcher: this._mixpanel.request_batchers.people
|
|
19502
19510
|
}, callback);
|
|
19503
19511
|
};
|
|
@@ -20134,6 +20142,7 @@
|
|
|
20134
20142
|
*/
|
|
20135
20143
|
var DEFAULT_CONFIG = {
|
|
20136
20144
|
'api_host': 'https://api-js.mixpanel.com',
|
|
20145
|
+
'api_hosts': {},
|
|
20137
20146
|
'api_routes': DEFAULT_API_ROUTES,
|
|
20138
20147
|
'api_extra_query_params': {},
|
|
20139
20148
|
'api_method': 'POST',
|
|
@@ -20519,20 +20528,23 @@
|
|
|
20519
20528
|
|
|
20520
20529
|
MixpanelLib.prototype.stop_session_recording = function () {
|
|
20521
20530
|
if (this._recorder) {
|
|
20522
|
-
this._recorder['stopRecording']();
|
|
20531
|
+
return this._recorder['stopRecording']();
|
|
20523
20532
|
}
|
|
20533
|
+
return Promise.resolve();
|
|
20524
20534
|
};
|
|
20525
20535
|
|
|
20526
20536
|
MixpanelLib.prototype.pause_session_recording = function () {
|
|
20527
20537
|
if (this._recorder) {
|
|
20528
|
-
this._recorder['pauseRecording']();
|
|
20538
|
+
return this._recorder['pauseRecording']();
|
|
20529
20539
|
}
|
|
20540
|
+
return Promise.resolve();
|
|
20530
20541
|
};
|
|
20531
20542
|
|
|
20532
20543
|
MixpanelLib.prototype.resume_session_recording = function () {
|
|
20533
20544
|
if (this._recorder) {
|
|
20534
|
-
this._recorder['resumeRecording']();
|
|
20545
|
+
return this._recorder['resumeRecording']();
|
|
20535
20546
|
}
|
|
20547
|
+
return Promise.resolve();
|
|
20536
20548
|
};
|
|
20537
20549
|
|
|
20538
20550
|
MixpanelLib.prototype.is_recording_heatmap_data = function () {
|
|
@@ -21132,7 +21144,7 @@
|
|
|
21132
21144
|
var ret = this._track_or_batch({
|
|
21133
21145
|
type: 'events',
|
|
21134
21146
|
data: data,
|
|
21135
|
-
endpoint: this.
|
|
21147
|
+
endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
|
|
21136
21148
|
batcher: this.request_batchers.events,
|
|
21137
21149
|
should_send_immediately: should_send_immediately,
|
|
21138
21150
|
send_request_options: options
|
|
@@ -21634,15 +21646,31 @@
|
|
|
21634
21646
|
* Useful for clearing data when a user logs out.
|
|
21635
21647
|
*/
|
|
21636
21648
|
MixpanelLib.prototype.reset = function() {
|
|
21637
|
-
this
|
|
21638
|
-
|
|
21639
|
-
var
|
|
21640
|
-
|
|
21641
|
-
|
|
21642
|
-
|
|
21643
|
-
|
|
21644
|
-
|
|
21645
|
-
|
|
21649
|
+
var self = this;
|
|
21650
|
+
|
|
21651
|
+
var reset = function () {
|
|
21652
|
+
self['persistence'].clear();
|
|
21653
|
+
self._flags.identify_called = false;
|
|
21654
|
+
var uuid = _.UUID();
|
|
21655
|
+
self.register_once({
|
|
21656
|
+
'distinct_id': DEVICE_ID_PREFIX + uuid,
|
|
21657
|
+
'$device_id': uuid
|
|
21658
|
+
}, '');
|
|
21659
|
+
};
|
|
21660
|
+
|
|
21661
|
+
if (self._recorder) {
|
|
21662
|
+
self.stop_session_recording()
|
|
21663
|
+
.then(function () {
|
|
21664
|
+
reset();
|
|
21665
|
+
self._check_and_start_session_recording();
|
|
21666
|
+
})
|
|
21667
|
+
.catch(_.bind(function (err) {
|
|
21668
|
+
reset();
|
|
21669
|
+
this.report_error('Error restarting recording session', err);
|
|
21670
|
+
}, this));
|
|
21671
|
+
} else {
|
|
21672
|
+
reset();
|
|
21673
|
+
}
|
|
21646
21674
|
};
|
|
21647
21675
|
|
|
21648
21676
|
/**
|
|
@@ -21953,6 +21981,16 @@
|
|
|
21953
21981
|
return this['persistence'].load_prop([property_name]);
|
|
21954
21982
|
};
|
|
21955
21983
|
|
|
21984
|
+
/**
|
|
21985
|
+
* Get the API host for a specific endpoint type, falling back to the default api_host if not specified
|
|
21986
|
+
*
|
|
21987
|
+
* @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
|
|
21988
|
+
* @returns {String} The API host to use for this endpoint
|
|
21989
|
+
*/
|
|
21990
|
+
MixpanelLib.prototype.get_api_host = function(endpoint_type) {
|
|
21991
|
+
return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
|
|
21992
|
+
};
|
|
21993
|
+
|
|
21956
21994
|
MixpanelLib.prototype.toString = function() {
|
|
21957
21995
|
var name = this.get_config('name');
|
|
21958
21996
|
if (name !== PRIMARY_INSTANCE_NAME) {
|
|
@@ -22248,6 +22286,7 @@
|
|
|
22248
22286
|
MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
|
|
22249
22287
|
MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
|
|
22250
22288
|
MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
|
|
22289
|
+
MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
|
|
22251
22290
|
MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
|
|
22252
22291
|
MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
|
|
22253
22292
|
MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
|