mixpanel-browser 2.64.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 +13 -0
- package/README.md +1 -1
- package/dist/mixpanel-core.cjs.js +94 -53
- package/dist/mixpanel-recorder.js +23 -11
- 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 +94 -53
- package/dist/mixpanel-with-recorder.js +111 -62
- package/dist/mixpanel-with-recorder.min.js +1 -1
- package/dist/mixpanel.amd.js +111 -62
- package/dist/mixpanel.cjs.js +111 -62
- package/dist/mixpanel.globals.js +94 -53
- package/dist/mixpanel.min.js +148 -146
- package/dist/mixpanel.module.js +111 -62
- package/dist/mixpanel.umd.js +111 -62
- package/package.json +2 -1
- package/src/autocapture/utils.js +3 -1
- package/src/config.js +1 -1
- package/src/flags/index.js +34 -25
- package/src/index.d.ts +408 -0
- package/src/mixpanel-core.js +47 -11
- package/src/mixpanel-group.js +1 -1
- package/src/mixpanel-people.js +3 -13
- package/src/recorder/recorder.js +15 -7
- package/src/recorder/session-recording.js +2 -2
- package/src/utils.js +5 -1
- package/tunnel.log +0 -0
package/dist/mixpanel.umd.js
CHANGED
|
@@ -13948,7 +13948,7 @@
|
|
|
13948
13948
|
|
|
13949
13949
|
var Config = {
|
|
13950
13950
|
DEBUG: false,
|
|
13951
|
-
LIB_VERSION: '2.
|
|
13951
|
+
LIB_VERSION: '2.66.0'
|
|
13952
13952
|
};
|
|
13953
13953
|
|
|
13954
13954
|
/* eslint camelcase: "off", eqeqeq: "off" */
|
|
@@ -15433,6 +15433,9 @@
|
|
|
15433
15433
|
return 'Microsoft Edge';
|
|
15434
15434
|
} else if (_.includes(user_agent, 'FBIOS')) {
|
|
15435
15435
|
return 'Facebook Mobile';
|
|
15436
|
+
} else if (_.includes(user_agent, 'Whale/')) {
|
|
15437
|
+
// https://user-agents.net/browsers/whale-browser
|
|
15438
|
+
return 'Whale Browser';
|
|
15436
15439
|
} else if (_.includes(user_agent, 'Chrome')) {
|
|
15437
15440
|
return 'Chrome';
|
|
15438
15441
|
} else if (_.includes(user_agent, 'CriOS')) {
|
|
@@ -15484,7 +15487,8 @@
|
|
|
15484
15487
|
'Android Mobile': /android\s(\d+(\.\d+)?)/,
|
|
15485
15488
|
'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
|
|
15486
15489
|
'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
|
|
15487
|
-
'Mozilla': /rv:(\d+(\.\d+)?)
|
|
15490
|
+
'Mozilla': /rv:(\d+(\.\d+)?)/,
|
|
15491
|
+
'Whale Browser': /Whale\/(\d+(\.\d+)?)/
|
|
15488
15492
|
};
|
|
15489
15493
|
var regex = versionRegexs[browser];
|
|
15490
15494
|
if (regex === undefined) {
|
|
@@ -17351,8 +17355,8 @@
|
|
|
17351
17355
|
retryAfter: response.headers.get('Retry-After')
|
|
17352
17356
|
});
|
|
17353
17357
|
}.bind(this);
|
|
17354
|
-
|
|
17355
|
-
win['fetch'](
|
|
17358
|
+
var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
|
|
17359
|
+
win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
|
|
17356
17360
|
'method': 'POST',
|
|
17357
17361
|
'headers': {
|
|
17358
17362
|
'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
|
|
@@ -17569,6 +17573,7 @@
|
|
|
17569
17573
|
this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
|
|
17570
17574
|
|
|
17571
17575
|
this.activeRecording = null;
|
|
17576
|
+
this.stopRecordingInProgress = false;
|
|
17572
17577
|
};
|
|
17573
17578
|
|
|
17574
17579
|
MixpanelRecorder.prototype.startRecording = function(options) {
|
|
@@ -17617,19 +17622,26 @@
|
|
|
17617
17622
|
};
|
|
17618
17623
|
|
|
17619
17624
|
MixpanelRecorder.prototype.stopRecording = function() {
|
|
17620
|
-
|
|
17621
|
-
this.
|
|
17622
|
-
this.
|
|
17623
|
-
|
|
17625
|
+
// Prevents activeSerializedRecording from being reused when stopping the recording.
|
|
17626
|
+
this.stopRecordingInProgress = true;
|
|
17627
|
+
return this._stopCurrentRecording(false, true).then(function() {
|
|
17628
|
+
return this.recordingRegistry.clearActiveRecording();
|
|
17629
|
+
}.bind(this)).then(function() {
|
|
17630
|
+
this.stopRecordingInProgress = false;
|
|
17631
|
+
}.bind(this));
|
|
17624
17632
|
};
|
|
17625
17633
|
|
|
17626
17634
|
MixpanelRecorder.prototype.pauseRecording = function() {
|
|
17627
17635
|
return this._stopCurrentRecording(false);
|
|
17628
17636
|
};
|
|
17629
17637
|
|
|
17630
|
-
MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush) {
|
|
17638
|
+
MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
|
|
17631
17639
|
if (this.activeRecording) {
|
|
17632
|
-
|
|
17640
|
+
var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
|
|
17641
|
+
if (disableActiveRecording) {
|
|
17642
|
+
this.activeRecording = null;
|
|
17643
|
+
}
|
|
17644
|
+
return stopRecordingPromise;
|
|
17633
17645
|
}
|
|
17634
17646
|
return PromisePolyfill.resolve();
|
|
17635
17647
|
};
|
|
@@ -17642,7 +17654,7 @@
|
|
|
17642
17654
|
|
|
17643
17655
|
return this.recordingRegistry.getActiveRecording()
|
|
17644
17656
|
.then(function (activeSerializedRecording) {
|
|
17645
|
-
if (activeSerializedRecording) {
|
|
17657
|
+
if (activeSerializedRecording && !this.stopRecordingInProgress) {
|
|
17646
17658
|
return this.startRecording({activeSerializedRecording: activeSerializedRecording});
|
|
17647
17659
|
} else if (startNewIfInactive) {
|
|
17648
17660
|
return this.startRecording({shouldStopBatcher: false});
|
|
@@ -17846,7 +17858,9 @@
|
|
|
17846
17858
|
'$elements': elementsJson,
|
|
17847
17859
|
'$el_attr__href': href,
|
|
17848
17860
|
'$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
|
|
17849
|
-
'$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0)
|
|
17861
|
+
'$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
|
|
17862
|
+
'$pageHeight': document$1['body']['offsetHeight'] || 0,
|
|
17863
|
+
'$pageWidth': document$1['body']['offsetWidth'] || 0,
|
|
17850
17864
|
};
|
|
17851
17865
|
_.each(captureExtraAttrs, function(attr) {
|
|
17852
17866
|
if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
|
|
@@ -18577,19 +18591,19 @@
|
|
|
18577
18591
|
return this.getFullConfig()[key];
|
|
18578
18592
|
};
|
|
18579
18593
|
|
|
18580
|
-
FeatureFlagManager.prototype.
|
|
18594
|
+
FeatureFlagManager.prototype.isSystemEnabled = function() {
|
|
18581
18595
|
return !!this.getMpConfig(FLAGS_CONFIG_KEY);
|
|
18582
18596
|
};
|
|
18583
18597
|
|
|
18584
|
-
FeatureFlagManager.prototype.
|
|
18585
|
-
if (!this.
|
|
18598
|
+
FeatureFlagManager.prototype.areFlagsReady = function() {
|
|
18599
|
+
if (!this.isSystemEnabled()) {
|
|
18586
18600
|
logger.error('Feature Flags not enabled');
|
|
18587
18601
|
}
|
|
18588
18602
|
return !!this.flags;
|
|
18589
18603
|
};
|
|
18590
18604
|
|
|
18591
18605
|
FeatureFlagManager.prototype.fetchFlags = function() {
|
|
18592
|
-
if (!this.
|
|
18606
|
+
if (!this.isSystemEnabled()) {
|
|
18593
18607
|
return;
|
|
18594
18608
|
}
|
|
18595
18609
|
|
|
@@ -18615,7 +18629,7 @@
|
|
|
18615
18629
|
_.each(responseFlags, function(data, key) {
|
|
18616
18630
|
flags.set(key, {
|
|
18617
18631
|
'key': data['variant_key'],
|
|
18618
|
-
'
|
|
18632
|
+
'value': data['variant_value']
|
|
18619
18633
|
});
|
|
18620
18634
|
});
|
|
18621
18635
|
this.flags = flags;
|
|
@@ -18625,7 +18639,7 @@
|
|
|
18625
18639
|
}.bind(this)).catch(function() {});
|
|
18626
18640
|
};
|
|
18627
18641
|
|
|
18628
|
-
FeatureFlagManager.prototype.
|
|
18642
|
+
FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
|
|
18629
18643
|
if (!this.fetchPromise) {
|
|
18630
18644
|
return new Promise(function(resolve) {
|
|
18631
18645
|
logger.critical('Feature Flags not initialized');
|
|
@@ -18634,15 +18648,15 @@
|
|
|
18634
18648
|
}
|
|
18635
18649
|
|
|
18636
18650
|
return this.fetchPromise.then(function() {
|
|
18637
|
-
return this.
|
|
18651
|
+
return this.getVariantSync(featureName, fallback);
|
|
18638
18652
|
}.bind(this)).catch(function(error) {
|
|
18639
18653
|
logger.error(error);
|
|
18640
18654
|
return fallback;
|
|
18641
18655
|
});
|
|
18642
18656
|
};
|
|
18643
18657
|
|
|
18644
|
-
FeatureFlagManager.prototype.
|
|
18645
|
-
if (!this.
|
|
18658
|
+
FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
|
|
18659
|
+
if (!this.areFlagsReady()) {
|
|
18646
18660
|
logger.log('Flags not loaded yet');
|
|
18647
18661
|
return fallback;
|
|
18648
18662
|
}
|
|
@@ -18655,31 +18669,37 @@
|
|
|
18655
18669
|
return feature;
|
|
18656
18670
|
};
|
|
18657
18671
|
|
|
18658
|
-
FeatureFlagManager.prototype.
|
|
18659
|
-
return this.
|
|
18660
|
-
return feature['
|
|
18672
|
+
FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
|
|
18673
|
+
return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
|
|
18674
|
+
return feature['value'];
|
|
18661
18675
|
}).catch(function(error) {
|
|
18662
18676
|
logger.error(error);
|
|
18663
18677
|
return fallbackValue;
|
|
18664
18678
|
});
|
|
18665
18679
|
};
|
|
18666
18680
|
|
|
18667
|
-
|
|
18668
|
-
|
|
18681
|
+
// TODO remove deprecated method
|
|
18682
|
+
FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
|
|
18683
|
+
logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
|
|
18684
|
+
return this.getVariantValue(featureName, fallbackValue);
|
|
18685
|
+
};
|
|
18686
|
+
|
|
18687
|
+
FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
|
|
18688
|
+
return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
|
|
18669
18689
|
};
|
|
18670
18690
|
|
|
18671
|
-
FeatureFlagManager.prototype.
|
|
18672
|
-
return this.
|
|
18673
|
-
return this.
|
|
18691
|
+
FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
|
|
18692
|
+
return this.getVariantValue(featureName).then(function() {
|
|
18693
|
+
return this.isEnabledSync(featureName, fallbackValue);
|
|
18674
18694
|
}.bind(this)).catch(function(error) {
|
|
18675
18695
|
logger.error(error);
|
|
18676
18696
|
return fallbackValue;
|
|
18677
18697
|
});
|
|
18678
18698
|
};
|
|
18679
18699
|
|
|
18680
|
-
FeatureFlagManager.prototype.
|
|
18700
|
+
FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
|
|
18681
18701
|
fallbackValue = fallbackValue || false;
|
|
18682
|
-
var val = this.
|
|
18702
|
+
var val = this.getVariantValueSync(featureName, fallbackValue);
|
|
18683
18703
|
if (val !== true && val !== false) {
|
|
18684
18704
|
logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
|
|
18685
18705
|
val = fallbackValue;
|
|
@@ -18708,13 +18728,16 @@
|
|
|
18708
18728
|
|
|
18709
18729
|
safewrapClass(FeatureFlagManager);
|
|
18710
18730
|
|
|
18711
|
-
FeatureFlagManager.prototype['
|
|
18712
|
-
FeatureFlagManager.prototype['
|
|
18731
|
+
FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
|
|
18732
|
+
FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
|
|
18733
|
+
FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
|
|
18734
|
+
FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
|
|
18735
|
+
FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
|
|
18736
|
+
FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
|
|
18737
|
+
FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
|
|
18738
|
+
|
|
18739
|
+
// Deprecated method
|
|
18713
18740
|
FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
|
|
18714
|
-
FeatureFlagManager.prototype['get_feature_data_sync'] = FeatureFlagManager.prototype.getFeatureDataSync;
|
|
18715
|
-
FeatureFlagManager.prototype['get_feature_sync'] = FeatureFlagManager.prototype.getFeatureSync;
|
|
18716
|
-
FeatureFlagManager.prototype['is_feature_enabled'] = FeatureFlagManager.prototype.isFeatureEnabled;
|
|
18717
|
-
FeatureFlagManager.prototype['is_feature_enabled_sync'] = FeatureFlagManager.prototype.isFeatureEnabledSync;
|
|
18718
18741
|
|
|
18719
18742
|
/* eslint camelcase: "off" */
|
|
18720
18743
|
|
|
@@ -19133,7 +19156,7 @@
|
|
|
19133
19156
|
return this._mixpanel._track_or_batch({
|
|
19134
19157
|
type: 'groups',
|
|
19135
19158
|
data: date_encoded_data,
|
|
19136
|
-
endpoint: this.
|
|
19159
|
+
endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
|
|
19137
19160
|
batcher: this._mixpanel.request_batchers.groups
|
|
19138
19161
|
}, callback);
|
|
19139
19162
|
};
|
|
@@ -19410,18 +19433,8 @@
|
|
|
19410
19433
|
* @param {Function} [callback] If provided, the callback will be called when the server responds
|
|
19411
19434
|
* @deprecated
|
|
19412
19435
|
*/
|
|
19413
|
-
MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function(
|
|
19414
|
-
|
|
19415
|
-
amount = parseFloat(amount);
|
|
19416
|
-
if (isNaN(amount)) {
|
|
19417
|
-
console$1.error('Invalid value passed to mixpanel.people.track_charge - must be a number');
|
|
19418
|
-
return;
|
|
19419
|
-
}
|
|
19420
|
-
}
|
|
19421
|
-
|
|
19422
|
-
return this.append('$transactions', _.extend({
|
|
19423
|
-
'$amount': amount
|
|
19424
|
-
}, properties), callback);
|
|
19436
|
+
MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
|
|
19437
|
+
console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
|
|
19425
19438
|
});
|
|
19426
19439
|
|
|
19427
19440
|
/*
|
|
@@ -19495,7 +19508,7 @@
|
|
|
19495
19508
|
return this._mixpanel._track_or_batch({
|
|
19496
19509
|
type: 'people',
|
|
19497
19510
|
data: date_encoded_data,
|
|
19498
|
-
endpoint: this.
|
|
19511
|
+
endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
|
|
19499
19512
|
batcher: this._mixpanel.request_batchers.people
|
|
19500
19513
|
}, callback);
|
|
19501
19514
|
};
|
|
@@ -20132,7 +20145,9 @@
|
|
|
20132
20145
|
*/
|
|
20133
20146
|
var DEFAULT_CONFIG = {
|
|
20134
20147
|
'api_host': 'https://api-js.mixpanel.com',
|
|
20148
|
+
'api_hosts': {},
|
|
20135
20149
|
'api_routes': DEFAULT_API_ROUTES,
|
|
20150
|
+
'api_extra_query_params': {},
|
|
20136
20151
|
'api_method': 'POST',
|
|
20137
20152
|
'api_transport': 'XHR',
|
|
20138
20153
|
'api_payload_format': PAYLOAD_TYPE_BASE64,
|
|
@@ -20516,20 +20531,23 @@
|
|
|
20516
20531
|
|
|
20517
20532
|
MixpanelLib.prototype.stop_session_recording = function () {
|
|
20518
20533
|
if (this._recorder) {
|
|
20519
|
-
this._recorder['stopRecording']();
|
|
20534
|
+
return this._recorder['stopRecording']();
|
|
20520
20535
|
}
|
|
20536
|
+
return Promise.resolve();
|
|
20521
20537
|
};
|
|
20522
20538
|
|
|
20523
20539
|
MixpanelLib.prototype.pause_session_recording = function () {
|
|
20524
20540
|
if (this._recorder) {
|
|
20525
|
-
this._recorder['pauseRecording']();
|
|
20541
|
+
return this._recorder['pauseRecording']();
|
|
20526
20542
|
}
|
|
20543
|
+
return Promise.resolve();
|
|
20527
20544
|
};
|
|
20528
20545
|
|
|
20529
20546
|
MixpanelLib.prototype.resume_session_recording = function () {
|
|
20530
20547
|
if (this._recorder) {
|
|
20531
|
-
this._recorder['resumeRecording']();
|
|
20548
|
+
return this._recorder['resumeRecording']();
|
|
20532
20549
|
}
|
|
20550
|
+
return Promise.resolve();
|
|
20533
20551
|
};
|
|
20534
20552
|
|
|
20535
20553
|
MixpanelLib.prototype.is_recording_heatmap_data = function () {
|
|
@@ -20720,6 +20738,8 @@
|
|
|
20720
20738
|
delete data['data'];
|
|
20721
20739
|
}
|
|
20722
20740
|
|
|
20741
|
+
_.extend(data, this.get_config('api_extra_query_params'));
|
|
20742
|
+
|
|
20723
20743
|
url += '?' + _.HTTPBuildQuery(data);
|
|
20724
20744
|
|
|
20725
20745
|
var lib = this;
|
|
@@ -21127,7 +21147,7 @@
|
|
|
21127
21147
|
var ret = this._track_or_batch({
|
|
21128
21148
|
type: 'events',
|
|
21129
21149
|
data: data,
|
|
21130
|
-
endpoint: this.
|
|
21150
|
+
endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
|
|
21131
21151
|
batcher: this.request_batchers.events,
|
|
21132
21152
|
should_send_immediately: should_send_immediately,
|
|
21133
21153
|
send_request_options: options
|
|
@@ -21629,13 +21649,31 @@
|
|
|
21629
21649
|
* Useful for clearing data when a user logs out.
|
|
21630
21650
|
*/
|
|
21631
21651
|
MixpanelLib.prototype.reset = function() {
|
|
21632
|
-
this
|
|
21633
|
-
|
|
21634
|
-
var
|
|
21635
|
-
|
|
21636
|
-
|
|
21637
|
-
|
|
21638
|
-
|
|
21652
|
+
var self = this;
|
|
21653
|
+
|
|
21654
|
+
var reset = function () {
|
|
21655
|
+
self['persistence'].clear();
|
|
21656
|
+
self._flags.identify_called = false;
|
|
21657
|
+
var uuid = _.UUID();
|
|
21658
|
+
self.register_once({
|
|
21659
|
+
'distinct_id': DEVICE_ID_PREFIX + uuid,
|
|
21660
|
+
'$device_id': uuid
|
|
21661
|
+
}, '');
|
|
21662
|
+
};
|
|
21663
|
+
|
|
21664
|
+
if (self._recorder) {
|
|
21665
|
+
self.stop_session_recording()
|
|
21666
|
+
.then(function () {
|
|
21667
|
+
reset();
|
|
21668
|
+
self._check_and_start_session_recording();
|
|
21669
|
+
})
|
|
21670
|
+
.catch(_.bind(function (err) {
|
|
21671
|
+
reset();
|
|
21672
|
+
this.report_error('Error restarting recording session', err);
|
|
21673
|
+
}, this));
|
|
21674
|
+
} else {
|
|
21675
|
+
reset();
|
|
21676
|
+
}
|
|
21639
21677
|
};
|
|
21640
21678
|
|
|
21641
21679
|
/**
|
|
@@ -21946,6 +21984,16 @@
|
|
|
21946
21984
|
return this['persistence'].load_prop([property_name]);
|
|
21947
21985
|
};
|
|
21948
21986
|
|
|
21987
|
+
/**
|
|
21988
|
+
* Get the API host for a specific endpoint type, falling back to the default api_host if not specified
|
|
21989
|
+
*
|
|
21990
|
+
* @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
|
|
21991
|
+
* @returns {String} The API host to use for this endpoint
|
|
21992
|
+
*/
|
|
21993
|
+
MixpanelLib.prototype.get_api_host = function(endpoint_type) {
|
|
21994
|
+
return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
|
|
21995
|
+
};
|
|
21996
|
+
|
|
21949
21997
|
MixpanelLib.prototype.toString = function() {
|
|
21950
21998
|
var name = this.get_config('name');
|
|
21951
21999
|
if (name !== PRIMARY_INSTANCE_NAME) {
|
|
@@ -22241,6 +22289,7 @@
|
|
|
22241
22289
|
MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
|
|
22242
22290
|
MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
|
|
22243
22291
|
MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
|
|
22292
|
+
MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
|
|
22244
22293
|
MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
|
|
22245
22294
|
MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
|
|
22246
22295
|
MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mixpanel-browser",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.66.0",
|
|
4
4
|
"description": "The official Mixpanel JavaScript browser client library",
|
|
5
5
|
"main": "dist/mixpanel.cjs.js",
|
|
6
6
|
"module": "dist/mixpanel.module.js",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"unit-test": "BABEL_ENV=test mocha --require babel-core/register tests/unit/*.js",
|
|
23
23
|
"validate": "npm ls"
|
|
24
24
|
},
|
|
25
|
+
"types": "./src/index.d.ts",
|
|
25
26
|
"repository": {
|
|
26
27
|
"type": "git",
|
|
27
28
|
"url": "https://github.com/mixpanel/mixpanel-js.git"
|
package/src/autocapture/utils.js
CHANGED
|
@@ -169,7 +169,9 @@ function getPropsForDOMEvent(ev, config) {
|
|
|
169
169
|
'$elements': elementsJson,
|
|
170
170
|
'$el_attr__href': href,
|
|
171
171
|
'$viewportHeight': Math.max(docElement['clientHeight'], window['innerHeight'] || 0),
|
|
172
|
-
'$viewportWidth': Math.max(docElement['clientWidth'], window['innerWidth'] || 0)
|
|
172
|
+
'$viewportWidth': Math.max(docElement['clientWidth'], window['innerWidth'] || 0),
|
|
173
|
+
'$pageHeight': document['body']['offsetHeight'] || 0,
|
|
174
|
+
'$pageWidth': document['body']['offsetWidth'] || 0,
|
|
173
175
|
};
|
|
174
176
|
_.each(captureExtraAttrs, function(attr) {
|
|
175
177
|
if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
|
package/src/config.js
CHANGED
package/src/flags/index.js
CHANGED
|
@@ -49,19 +49,19 @@ FeatureFlagManager.prototype.getConfig = function(key) {
|
|
|
49
49
|
return this.getFullConfig()[key];
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
FeatureFlagManager.prototype.
|
|
52
|
+
FeatureFlagManager.prototype.isSystemEnabled = function() {
|
|
53
53
|
return !!this.getMpConfig(FLAGS_CONFIG_KEY);
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
FeatureFlagManager.prototype.
|
|
57
|
-
if (!this.
|
|
56
|
+
FeatureFlagManager.prototype.areFlagsReady = function() {
|
|
57
|
+
if (!this.isSystemEnabled()) {
|
|
58
58
|
logger.error('Feature Flags not enabled');
|
|
59
59
|
}
|
|
60
60
|
return !!this.flags;
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
FeatureFlagManager.prototype.fetchFlags = function() {
|
|
64
|
-
if (!this.
|
|
64
|
+
if (!this.isSystemEnabled()) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -87,7 +87,7 @@ FeatureFlagManager.prototype.fetchFlags = function() {
|
|
|
87
87
|
_.each(responseFlags, function(data, key) {
|
|
88
88
|
flags.set(key, {
|
|
89
89
|
'key': data['variant_key'],
|
|
90
|
-
'
|
|
90
|
+
'value': data['variant_value']
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
93
|
this.flags = flags;
|
|
@@ -97,7 +97,7 @@ FeatureFlagManager.prototype.fetchFlags = function() {
|
|
|
97
97
|
}.bind(this)).catch(function() {});
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
FeatureFlagManager.prototype.
|
|
100
|
+
FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
|
|
101
101
|
if (!this.fetchPromise) {
|
|
102
102
|
return new Promise(function(resolve) {
|
|
103
103
|
logger.critical('Feature Flags not initialized');
|
|
@@ -106,15 +106,15 @@ FeatureFlagManager.prototype.getFeature = function(featureName, fallback) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
return this.fetchPromise.then(function() {
|
|
109
|
-
return this.
|
|
109
|
+
return this.getVariantSync(featureName, fallback);
|
|
110
110
|
}.bind(this)).catch(function(error) {
|
|
111
111
|
logger.error(error);
|
|
112
112
|
return fallback;
|
|
113
113
|
});
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
-
FeatureFlagManager.prototype.
|
|
117
|
-
if (!this.
|
|
116
|
+
FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
|
|
117
|
+
if (!this.areFlagsReady()) {
|
|
118
118
|
logger.log('Flags not loaded yet');
|
|
119
119
|
return fallback;
|
|
120
120
|
}
|
|
@@ -127,31 +127,37 @@ FeatureFlagManager.prototype.getFeatureSync = function(featureName, fallback) {
|
|
|
127
127
|
return feature;
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
-
FeatureFlagManager.prototype.
|
|
131
|
-
return this.
|
|
132
|
-
return feature['
|
|
130
|
+
FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
|
|
131
|
+
return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
|
|
132
|
+
return feature['value'];
|
|
133
133
|
}).catch(function(error) {
|
|
134
134
|
logger.error(error);
|
|
135
135
|
return fallbackValue;
|
|
136
136
|
});
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
// TODO remove deprecated method
|
|
140
|
+
FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
|
|
141
|
+
logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
|
|
142
|
+
return this.getVariantValue(featureName, fallbackValue);
|
|
141
143
|
};
|
|
142
144
|
|
|
143
|
-
FeatureFlagManager.prototype.
|
|
144
|
-
return this.
|
|
145
|
-
|
|
145
|
+
FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
|
|
146
|
+
return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
|
|
150
|
+
return this.getVariantValue(featureName).then(function() {
|
|
151
|
+
return this.isEnabledSync(featureName, fallbackValue);
|
|
146
152
|
}.bind(this)).catch(function(error) {
|
|
147
153
|
logger.error(error);
|
|
148
154
|
return fallbackValue;
|
|
149
155
|
});
|
|
150
156
|
};
|
|
151
157
|
|
|
152
|
-
FeatureFlagManager.prototype.
|
|
158
|
+
FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
|
|
153
159
|
fallbackValue = fallbackValue || false;
|
|
154
|
-
var val = this.
|
|
160
|
+
var val = this.getVariantValueSync(featureName, fallbackValue);
|
|
155
161
|
if (val !== true && val !== false) {
|
|
156
162
|
logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
|
|
157
163
|
val = fallbackValue;
|
|
@@ -180,12 +186,15 @@ function minApisSupported() {
|
|
|
180
186
|
|
|
181
187
|
safewrapClass(FeatureFlagManager);
|
|
182
188
|
|
|
183
|
-
FeatureFlagManager.prototype['
|
|
184
|
-
FeatureFlagManager.prototype['
|
|
189
|
+
FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
|
|
190
|
+
FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
|
|
191
|
+
FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
|
|
192
|
+
FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
|
|
193
|
+
FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
|
|
194
|
+
FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
|
|
195
|
+
FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
|
|
196
|
+
|
|
197
|
+
// Deprecated method
|
|
185
198
|
FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
|
|
186
|
-
FeatureFlagManager.prototype['get_feature_data_sync'] = FeatureFlagManager.prototype.getFeatureDataSync;
|
|
187
|
-
FeatureFlagManager.prototype['get_feature_sync'] = FeatureFlagManager.prototype.getFeatureSync;
|
|
188
|
-
FeatureFlagManager.prototype['is_feature_enabled'] = FeatureFlagManager.prototype.isFeatureEnabled;
|
|
189
|
-
FeatureFlagManager.prototype['is_feature_enabled_sync'] = FeatureFlagManager.prototype.isFeatureEnabledSync;
|
|
190
199
|
|
|
191
200
|
export { FeatureFlagManager };
|