mixpanel-browser 2.64.0 → 2.65.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/README.md +1 -1
- package/dist/mixpanel-core.cjs.js +50 -40
- package/dist/mixpanel-recorder.js +6 -2
- 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 +50 -40
- package/dist/mixpanel-with-recorder.js +50 -40
- package/dist/mixpanel-with-recorder.min.js +1 -1
- package/dist/mixpanel.amd.js +50 -40
- package/dist/mixpanel.cjs.js +50 -40
- package/dist/mixpanel.globals.js +50 -40
- package/dist/mixpanel.min.js +145 -144
- package/dist/mixpanel.module.js +50 -40
- package/dist/mixpanel.umd.js +50 -40
- package/package.json +1 -1
- package/src/autocapture/utils.js +3 -1
- package/src/config.js +1 -1
- package/src/flags/index.js +34 -25
- package/src/mixpanel-core.js +5 -0
- package/src/mixpanel-people.js +2 -12
- package/src/utils.js +5 -1
package/dist/mixpanel.module.js
CHANGED
|
@@ -13942,7 +13942,7 @@ if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]'
|
|
|
13942
13942
|
|
|
13943
13943
|
var Config = {
|
|
13944
13944
|
DEBUG: false,
|
|
13945
|
-
LIB_VERSION: '2.
|
|
13945
|
+
LIB_VERSION: '2.65.0'
|
|
13946
13946
|
};
|
|
13947
13947
|
|
|
13948
13948
|
/* eslint camelcase: "off", eqeqeq: "off" */
|
|
@@ -15427,6 +15427,9 @@ _.info = {
|
|
|
15427
15427
|
return 'Microsoft Edge';
|
|
15428
15428
|
} else if (_.includes(user_agent, 'FBIOS')) {
|
|
15429
15429
|
return 'Facebook Mobile';
|
|
15430
|
+
} else if (_.includes(user_agent, 'Whale/')) {
|
|
15431
|
+
// https://user-agents.net/browsers/whale-browser
|
|
15432
|
+
return 'Whale Browser';
|
|
15430
15433
|
} else if (_.includes(user_agent, 'Chrome')) {
|
|
15431
15434
|
return 'Chrome';
|
|
15432
15435
|
} else if (_.includes(user_agent, 'CriOS')) {
|
|
@@ -15478,7 +15481,8 @@ _.info = {
|
|
|
15478
15481
|
'Android Mobile': /android\s(\d+(\.\d+)?)/,
|
|
15479
15482
|
'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
|
|
15480
15483
|
'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
|
|
15481
|
-
'Mozilla': /rv:(\d+(\.\d+)?)
|
|
15484
|
+
'Mozilla': /rv:(\d+(\.\d+)?)/,
|
|
15485
|
+
'Whale Browser': /Whale\/(\d+(\.\d+)?)/
|
|
15482
15486
|
};
|
|
15483
15487
|
var regex = versionRegexs[browser];
|
|
15484
15488
|
if (regex === undefined) {
|
|
@@ -17840,7 +17844,9 @@ function getPropsForDOMEvent(ev, config) {
|
|
|
17840
17844
|
'$elements': elementsJson,
|
|
17841
17845
|
'$el_attr__href': href,
|
|
17842
17846
|
'$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
|
|
17843
|
-
'$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0)
|
|
17847
|
+
'$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
|
|
17848
|
+
'$pageHeight': document$1['body']['offsetHeight'] || 0,
|
|
17849
|
+
'$pageWidth': document$1['body']['offsetWidth'] || 0,
|
|
17844
17850
|
};
|
|
17845
17851
|
_.each(captureExtraAttrs, function(attr) {
|
|
17846
17852
|
if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
|
|
@@ -18571,19 +18577,19 @@ FeatureFlagManager.prototype.getConfig = function(key) {
|
|
|
18571
18577
|
return this.getFullConfig()[key];
|
|
18572
18578
|
};
|
|
18573
18579
|
|
|
18574
|
-
FeatureFlagManager.prototype.
|
|
18580
|
+
FeatureFlagManager.prototype.isSystemEnabled = function() {
|
|
18575
18581
|
return !!this.getMpConfig(FLAGS_CONFIG_KEY);
|
|
18576
18582
|
};
|
|
18577
18583
|
|
|
18578
|
-
FeatureFlagManager.prototype.
|
|
18579
|
-
if (!this.
|
|
18584
|
+
FeatureFlagManager.prototype.areFlagsReady = function() {
|
|
18585
|
+
if (!this.isSystemEnabled()) {
|
|
18580
18586
|
logger.error('Feature Flags not enabled');
|
|
18581
18587
|
}
|
|
18582
18588
|
return !!this.flags;
|
|
18583
18589
|
};
|
|
18584
18590
|
|
|
18585
18591
|
FeatureFlagManager.prototype.fetchFlags = function() {
|
|
18586
|
-
if (!this.
|
|
18592
|
+
if (!this.isSystemEnabled()) {
|
|
18587
18593
|
return;
|
|
18588
18594
|
}
|
|
18589
18595
|
|
|
@@ -18609,7 +18615,7 @@ FeatureFlagManager.prototype.fetchFlags = function() {
|
|
|
18609
18615
|
_.each(responseFlags, function(data, key) {
|
|
18610
18616
|
flags.set(key, {
|
|
18611
18617
|
'key': data['variant_key'],
|
|
18612
|
-
'
|
|
18618
|
+
'value': data['variant_value']
|
|
18613
18619
|
});
|
|
18614
18620
|
});
|
|
18615
18621
|
this.flags = flags;
|
|
@@ -18619,7 +18625,7 @@ FeatureFlagManager.prototype.fetchFlags = function() {
|
|
|
18619
18625
|
}.bind(this)).catch(function() {});
|
|
18620
18626
|
};
|
|
18621
18627
|
|
|
18622
|
-
FeatureFlagManager.prototype.
|
|
18628
|
+
FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
|
|
18623
18629
|
if (!this.fetchPromise) {
|
|
18624
18630
|
return new Promise(function(resolve) {
|
|
18625
18631
|
logger.critical('Feature Flags not initialized');
|
|
@@ -18628,15 +18634,15 @@ FeatureFlagManager.prototype.getFeature = function(featureName, fallback) {
|
|
|
18628
18634
|
}
|
|
18629
18635
|
|
|
18630
18636
|
return this.fetchPromise.then(function() {
|
|
18631
|
-
return this.
|
|
18637
|
+
return this.getVariantSync(featureName, fallback);
|
|
18632
18638
|
}.bind(this)).catch(function(error) {
|
|
18633
18639
|
logger.error(error);
|
|
18634
18640
|
return fallback;
|
|
18635
18641
|
});
|
|
18636
18642
|
};
|
|
18637
18643
|
|
|
18638
|
-
FeatureFlagManager.prototype.
|
|
18639
|
-
if (!this.
|
|
18644
|
+
FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
|
|
18645
|
+
if (!this.areFlagsReady()) {
|
|
18640
18646
|
logger.log('Flags not loaded yet');
|
|
18641
18647
|
return fallback;
|
|
18642
18648
|
}
|
|
@@ -18649,31 +18655,37 @@ FeatureFlagManager.prototype.getFeatureSync = function(featureName, fallback) {
|
|
|
18649
18655
|
return feature;
|
|
18650
18656
|
};
|
|
18651
18657
|
|
|
18652
|
-
FeatureFlagManager.prototype.
|
|
18653
|
-
return this.
|
|
18654
|
-
return feature['
|
|
18658
|
+
FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
|
|
18659
|
+
return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
|
|
18660
|
+
return feature['value'];
|
|
18655
18661
|
}).catch(function(error) {
|
|
18656
18662
|
logger.error(error);
|
|
18657
18663
|
return fallbackValue;
|
|
18658
18664
|
});
|
|
18659
18665
|
};
|
|
18660
18666
|
|
|
18661
|
-
|
|
18662
|
-
|
|
18667
|
+
// TODO remove deprecated method
|
|
18668
|
+
FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
|
|
18669
|
+
logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
|
|
18670
|
+
return this.getVariantValue(featureName, fallbackValue);
|
|
18671
|
+
};
|
|
18672
|
+
|
|
18673
|
+
FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
|
|
18674
|
+
return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
|
|
18663
18675
|
};
|
|
18664
18676
|
|
|
18665
|
-
FeatureFlagManager.prototype.
|
|
18666
|
-
return this.
|
|
18667
|
-
return this.
|
|
18677
|
+
FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
|
|
18678
|
+
return this.getVariantValue(featureName).then(function() {
|
|
18679
|
+
return this.isEnabledSync(featureName, fallbackValue);
|
|
18668
18680
|
}.bind(this)).catch(function(error) {
|
|
18669
18681
|
logger.error(error);
|
|
18670
18682
|
return fallbackValue;
|
|
18671
18683
|
});
|
|
18672
18684
|
};
|
|
18673
18685
|
|
|
18674
|
-
FeatureFlagManager.prototype.
|
|
18686
|
+
FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
|
|
18675
18687
|
fallbackValue = fallbackValue || false;
|
|
18676
|
-
var val = this.
|
|
18688
|
+
var val = this.getVariantValueSync(featureName, fallbackValue);
|
|
18677
18689
|
if (val !== true && val !== false) {
|
|
18678
18690
|
logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
|
|
18679
18691
|
val = fallbackValue;
|
|
@@ -18702,13 +18714,16 @@ function minApisSupported() {
|
|
|
18702
18714
|
|
|
18703
18715
|
safewrapClass(FeatureFlagManager);
|
|
18704
18716
|
|
|
18705
|
-
FeatureFlagManager.prototype['
|
|
18706
|
-
FeatureFlagManager.prototype['
|
|
18717
|
+
FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
|
|
18718
|
+
FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
|
|
18719
|
+
FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
|
|
18720
|
+
FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
|
|
18721
|
+
FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
|
|
18722
|
+
FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
|
|
18723
|
+
FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
|
|
18724
|
+
|
|
18725
|
+
// Deprecated method
|
|
18707
18726
|
FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
|
|
18708
|
-
FeatureFlagManager.prototype['get_feature_data_sync'] = FeatureFlagManager.prototype.getFeatureDataSync;
|
|
18709
|
-
FeatureFlagManager.prototype['get_feature_sync'] = FeatureFlagManager.prototype.getFeatureSync;
|
|
18710
|
-
FeatureFlagManager.prototype['is_feature_enabled'] = FeatureFlagManager.prototype.isFeatureEnabled;
|
|
18711
|
-
FeatureFlagManager.prototype['is_feature_enabled_sync'] = FeatureFlagManager.prototype.isFeatureEnabledSync;
|
|
18712
18727
|
|
|
18713
18728
|
/* eslint camelcase: "off" */
|
|
18714
18729
|
|
|
@@ -19404,18 +19419,8 @@ MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name
|
|
|
19404
19419
|
* @param {Function} [callback] If provided, the callback will be called when the server responds
|
|
19405
19420
|
* @deprecated
|
|
19406
19421
|
*/
|
|
19407
|
-
MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function(
|
|
19408
|
-
|
|
19409
|
-
amount = parseFloat(amount);
|
|
19410
|
-
if (isNaN(amount)) {
|
|
19411
|
-
console$1.error('Invalid value passed to mixpanel.people.track_charge - must be a number');
|
|
19412
|
-
return;
|
|
19413
|
-
}
|
|
19414
|
-
}
|
|
19415
|
-
|
|
19416
|
-
return this.append('$transactions', _.extend({
|
|
19417
|
-
'$amount': amount
|
|
19418
|
-
}, properties), callback);
|
|
19422
|
+
MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
|
|
19423
|
+
console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
|
|
19419
19424
|
});
|
|
19420
19425
|
|
|
19421
19426
|
/*
|
|
@@ -20127,6 +20132,7 @@ var DEFAULT_API_ROUTES = {
|
|
|
20127
20132
|
var DEFAULT_CONFIG = {
|
|
20128
20133
|
'api_host': 'https://api-js.mixpanel.com',
|
|
20129
20134
|
'api_routes': DEFAULT_API_ROUTES,
|
|
20135
|
+
'api_extra_query_params': {},
|
|
20130
20136
|
'api_method': 'POST',
|
|
20131
20137
|
'api_transport': 'XHR',
|
|
20132
20138
|
'api_payload_format': PAYLOAD_TYPE_BASE64,
|
|
@@ -20714,6 +20720,8 @@ MixpanelLib.prototype._send_request = function(url, data, options, callback) {
|
|
|
20714
20720
|
delete data['data'];
|
|
20715
20721
|
}
|
|
20716
20722
|
|
|
20723
|
+
_.extend(data, this.get_config('api_extra_query_params'));
|
|
20724
|
+
|
|
20717
20725
|
url += '?' + _.HTTPBuildQuery(data);
|
|
20718
20726
|
|
|
20719
20727
|
var lib = this;
|
|
@@ -21630,6 +21638,8 @@ MixpanelLib.prototype.reset = function() {
|
|
|
21630
21638
|
'distinct_id': DEVICE_ID_PREFIX + uuid,
|
|
21631
21639
|
'$device_id': uuid
|
|
21632
21640
|
}, '');
|
|
21641
|
+
this.stop_session_recording();
|
|
21642
|
+
this._check_and_start_session_recording();
|
|
21633
21643
|
};
|
|
21634
21644
|
|
|
21635
21645
|
/**
|
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.65.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) {
|
|
@@ -17846,7 +17850,9 @@
|
|
|
17846
17850
|
'$elements': elementsJson,
|
|
17847
17851
|
'$el_attr__href': href,
|
|
17848
17852
|
'$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
|
|
17849
|
-
'$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0)
|
|
17853
|
+
'$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
|
|
17854
|
+
'$pageHeight': document$1['body']['offsetHeight'] || 0,
|
|
17855
|
+
'$pageWidth': document$1['body']['offsetWidth'] || 0,
|
|
17850
17856
|
};
|
|
17851
17857
|
_.each(captureExtraAttrs, function(attr) {
|
|
17852
17858
|
if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
|
|
@@ -18577,19 +18583,19 @@
|
|
|
18577
18583
|
return this.getFullConfig()[key];
|
|
18578
18584
|
};
|
|
18579
18585
|
|
|
18580
|
-
FeatureFlagManager.prototype.
|
|
18586
|
+
FeatureFlagManager.prototype.isSystemEnabled = function() {
|
|
18581
18587
|
return !!this.getMpConfig(FLAGS_CONFIG_KEY);
|
|
18582
18588
|
};
|
|
18583
18589
|
|
|
18584
|
-
FeatureFlagManager.prototype.
|
|
18585
|
-
if (!this.
|
|
18590
|
+
FeatureFlagManager.prototype.areFlagsReady = function() {
|
|
18591
|
+
if (!this.isSystemEnabled()) {
|
|
18586
18592
|
logger.error('Feature Flags not enabled');
|
|
18587
18593
|
}
|
|
18588
18594
|
return !!this.flags;
|
|
18589
18595
|
};
|
|
18590
18596
|
|
|
18591
18597
|
FeatureFlagManager.prototype.fetchFlags = function() {
|
|
18592
|
-
if (!this.
|
|
18598
|
+
if (!this.isSystemEnabled()) {
|
|
18593
18599
|
return;
|
|
18594
18600
|
}
|
|
18595
18601
|
|
|
@@ -18615,7 +18621,7 @@
|
|
|
18615
18621
|
_.each(responseFlags, function(data, key) {
|
|
18616
18622
|
flags.set(key, {
|
|
18617
18623
|
'key': data['variant_key'],
|
|
18618
|
-
'
|
|
18624
|
+
'value': data['variant_value']
|
|
18619
18625
|
});
|
|
18620
18626
|
});
|
|
18621
18627
|
this.flags = flags;
|
|
@@ -18625,7 +18631,7 @@
|
|
|
18625
18631
|
}.bind(this)).catch(function() {});
|
|
18626
18632
|
};
|
|
18627
18633
|
|
|
18628
|
-
FeatureFlagManager.prototype.
|
|
18634
|
+
FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
|
|
18629
18635
|
if (!this.fetchPromise) {
|
|
18630
18636
|
return new Promise(function(resolve) {
|
|
18631
18637
|
logger.critical('Feature Flags not initialized');
|
|
@@ -18634,15 +18640,15 @@
|
|
|
18634
18640
|
}
|
|
18635
18641
|
|
|
18636
18642
|
return this.fetchPromise.then(function() {
|
|
18637
|
-
return this.
|
|
18643
|
+
return this.getVariantSync(featureName, fallback);
|
|
18638
18644
|
}.bind(this)).catch(function(error) {
|
|
18639
18645
|
logger.error(error);
|
|
18640
18646
|
return fallback;
|
|
18641
18647
|
});
|
|
18642
18648
|
};
|
|
18643
18649
|
|
|
18644
|
-
FeatureFlagManager.prototype.
|
|
18645
|
-
if (!this.
|
|
18650
|
+
FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
|
|
18651
|
+
if (!this.areFlagsReady()) {
|
|
18646
18652
|
logger.log('Flags not loaded yet');
|
|
18647
18653
|
return fallback;
|
|
18648
18654
|
}
|
|
@@ -18655,31 +18661,37 @@
|
|
|
18655
18661
|
return feature;
|
|
18656
18662
|
};
|
|
18657
18663
|
|
|
18658
|
-
FeatureFlagManager.prototype.
|
|
18659
|
-
return this.
|
|
18660
|
-
return feature['
|
|
18664
|
+
FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
|
|
18665
|
+
return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
|
|
18666
|
+
return feature['value'];
|
|
18661
18667
|
}).catch(function(error) {
|
|
18662
18668
|
logger.error(error);
|
|
18663
18669
|
return fallbackValue;
|
|
18664
18670
|
});
|
|
18665
18671
|
};
|
|
18666
18672
|
|
|
18667
|
-
|
|
18668
|
-
|
|
18673
|
+
// TODO remove deprecated method
|
|
18674
|
+
FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
|
|
18675
|
+
logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
|
|
18676
|
+
return this.getVariantValue(featureName, fallbackValue);
|
|
18677
|
+
};
|
|
18678
|
+
|
|
18679
|
+
FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
|
|
18680
|
+
return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
|
|
18669
18681
|
};
|
|
18670
18682
|
|
|
18671
|
-
FeatureFlagManager.prototype.
|
|
18672
|
-
return this.
|
|
18673
|
-
return this.
|
|
18683
|
+
FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
|
|
18684
|
+
return this.getVariantValue(featureName).then(function() {
|
|
18685
|
+
return this.isEnabledSync(featureName, fallbackValue);
|
|
18674
18686
|
}.bind(this)).catch(function(error) {
|
|
18675
18687
|
logger.error(error);
|
|
18676
18688
|
return fallbackValue;
|
|
18677
18689
|
});
|
|
18678
18690
|
};
|
|
18679
18691
|
|
|
18680
|
-
FeatureFlagManager.prototype.
|
|
18692
|
+
FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
|
|
18681
18693
|
fallbackValue = fallbackValue || false;
|
|
18682
|
-
var val = this.
|
|
18694
|
+
var val = this.getVariantValueSync(featureName, fallbackValue);
|
|
18683
18695
|
if (val !== true && val !== false) {
|
|
18684
18696
|
logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
|
|
18685
18697
|
val = fallbackValue;
|
|
@@ -18708,13 +18720,16 @@
|
|
|
18708
18720
|
|
|
18709
18721
|
safewrapClass(FeatureFlagManager);
|
|
18710
18722
|
|
|
18711
|
-
FeatureFlagManager.prototype['
|
|
18712
|
-
FeatureFlagManager.prototype['
|
|
18723
|
+
FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
|
|
18724
|
+
FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
|
|
18725
|
+
FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
|
|
18726
|
+
FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
|
|
18727
|
+
FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
|
|
18728
|
+
FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
|
|
18729
|
+
FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
|
|
18730
|
+
|
|
18731
|
+
// Deprecated method
|
|
18713
18732
|
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
18733
|
|
|
18719
18734
|
/* eslint camelcase: "off" */
|
|
18720
18735
|
|
|
@@ -19410,18 +19425,8 @@
|
|
|
19410
19425
|
* @param {Function} [callback] If provided, the callback will be called when the server responds
|
|
19411
19426
|
* @deprecated
|
|
19412
19427
|
*/
|
|
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);
|
|
19428
|
+
MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
|
|
19429
|
+
console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
|
|
19425
19430
|
});
|
|
19426
19431
|
|
|
19427
19432
|
/*
|
|
@@ -20133,6 +20138,7 @@
|
|
|
20133
20138
|
var DEFAULT_CONFIG = {
|
|
20134
20139
|
'api_host': 'https://api-js.mixpanel.com',
|
|
20135
20140
|
'api_routes': DEFAULT_API_ROUTES,
|
|
20141
|
+
'api_extra_query_params': {},
|
|
20136
20142
|
'api_method': 'POST',
|
|
20137
20143
|
'api_transport': 'XHR',
|
|
20138
20144
|
'api_payload_format': PAYLOAD_TYPE_BASE64,
|
|
@@ -20720,6 +20726,8 @@
|
|
|
20720
20726
|
delete data['data'];
|
|
20721
20727
|
}
|
|
20722
20728
|
|
|
20729
|
+
_.extend(data, this.get_config('api_extra_query_params'));
|
|
20730
|
+
|
|
20723
20731
|
url += '?' + _.HTTPBuildQuery(data);
|
|
20724
20732
|
|
|
20725
20733
|
var lib = this;
|
|
@@ -21636,6 +21644,8 @@
|
|
|
21636
21644
|
'distinct_id': DEVICE_ID_PREFIX + uuid,
|
|
21637
21645
|
'$device_id': uuid
|
|
21638
21646
|
}, '');
|
|
21647
|
+
this.stop_session_recording();
|
|
21648
|
+
this._check_and_start_session_recording();
|
|
21639
21649
|
};
|
|
21640
21650
|
|
|
21641
21651
|
/**
|
package/package.json
CHANGED
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 };
|
package/src/mixpanel-core.js
CHANGED
|
@@ -100,6 +100,7 @@ var DEFAULT_API_ROUTES = {
|
|
|
100
100
|
var DEFAULT_CONFIG = {
|
|
101
101
|
'api_host': 'https://api-js.mixpanel.com',
|
|
102
102
|
'api_routes': DEFAULT_API_ROUTES,
|
|
103
|
+
'api_extra_query_params': {},
|
|
103
104
|
'api_method': 'POST',
|
|
104
105
|
'api_transport': 'XHR',
|
|
105
106
|
'api_payload_format': PAYLOAD_TYPE_BASE64,
|
|
@@ -687,6 +688,8 @@ MixpanelLib.prototype._send_request = function(url, data, options, callback) {
|
|
|
687
688
|
delete data['data'];
|
|
688
689
|
}
|
|
689
690
|
|
|
691
|
+
_.extend(data, this.get_config('api_extra_query_params'));
|
|
692
|
+
|
|
690
693
|
url += '?' + _.HTTPBuildQuery(data);
|
|
691
694
|
|
|
692
695
|
var lib = this;
|
|
@@ -1603,6 +1606,8 @@ MixpanelLib.prototype.reset = function() {
|
|
|
1603
1606
|
'distinct_id': DEVICE_ID_PREFIX + uuid,
|
|
1604
1607
|
'$device_id': uuid
|
|
1605
1608
|
}, '');
|
|
1609
|
+
this.stop_session_recording();
|
|
1610
|
+
this._check_and_start_session_recording();
|
|
1606
1611
|
};
|
|
1607
1612
|
|
|
1608
1613
|
/**
|
package/src/mixpanel-people.js
CHANGED
|
@@ -262,18 +262,8 @@ MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name
|
|
|
262
262
|
* @param {Function} [callback] If provided, the callback will be called when the server responds
|
|
263
263
|
* @deprecated
|
|
264
264
|
*/
|
|
265
|
-
MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function(
|
|
266
|
-
|
|
267
|
-
amount = parseFloat(amount);
|
|
268
|
-
if (isNaN(amount)) {
|
|
269
|
-
console.error('Invalid value passed to mixpanel.people.track_charge - must be a number');
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return this.append('$transactions', _.extend({
|
|
275
|
-
'$amount': amount
|
|
276
|
-
}, properties), callback);
|
|
265
|
+
MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
|
|
266
|
+
console.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
|
|
277
267
|
});
|
|
278
268
|
|
|
279
269
|
/*
|
package/src/utils.js
CHANGED
|
@@ -1483,6 +1483,9 @@ _.info = {
|
|
|
1483
1483
|
return 'Microsoft Edge';
|
|
1484
1484
|
} else if (_.includes(user_agent, 'FBIOS')) {
|
|
1485
1485
|
return 'Facebook Mobile';
|
|
1486
|
+
} else if (_.includes(user_agent, 'Whale/')) {
|
|
1487
|
+
// https://user-agents.net/browsers/whale-browser
|
|
1488
|
+
return 'Whale Browser';
|
|
1486
1489
|
} else if (_.includes(user_agent, 'Chrome')) {
|
|
1487
1490
|
return 'Chrome';
|
|
1488
1491
|
} else if (_.includes(user_agent, 'CriOS')) {
|
|
@@ -1534,7 +1537,8 @@ _.info = {
|
|
|
1534
1537
|
'Android Mobile': /android\s(\d+(\.\d+)?)/,
|
|
1535
1538
|
'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
|
|
1536
1539
|
'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
|
|
1537
|
-
'Mozilla': /rv:(\d+(\.\d+)?)
|
|
1540
|
+
'Mozilla': /rv:(\d+(\.\d+)?)/,
|
|
1541
|
+
'Whale Browser': /Whale\/(\d+(\.\d+)?)/
|
|
1538
1542
|
};
|
|
1539
1543
|
var regex = versionRegexs[browser];
|
|
1540
1544
|
if (regex === undefined) {
|