onload performance beacon for LMS pages
This commit is contained in:
@@ -557,6 +557,7 @@ XBLOCK_SETTINGS = ENV_TOKENS.get('XBLOCK_SETTINGS', {})
|
||||
|
||||
##### CDN EXPERIMENT/MONITORING FLAGS #####
|
||||
CDN_VIDEO_URLS = ENV_TOKENS.get('CDN_VIDEO_URLS', CDN_VIDEO_URLS)
|
||||
ONLOAD_BEACON_SAMPLE_RATE = ENV_TOKENS.get('ONLOAD_BEACON_SAMPLE_RATE', ONLOAD_BEACON_SAMPLE_RATE)
|
||||
|
||||
##### ECOMMERCE API CONFIGURATION SETTINGS #####
|
||||
ECOMMERCE_API_URL = ENV_TOKENS.get('ECOMMERCE_API_URL', ECOMMERCE_API_URL)
|
||||
|
||||
@@ -352,6 +352,9 @@ FEATURES = {
|
||||
# enable beacons for video timing statistics
|
||||
'ENABLE_VIDEO_BEACON': False,
|
||||
|
||||
# enable beacons for lms onload event statistics
|
||||
'ENABLE_ONLOAD_BEACON': False,
|
||||
|
||||
# Certificates Web/HTML Views
|
||||
'CERTIFICATES_HTML_VIEW': False,
|
||||
}
|
||||
@@ -2074,9 +2077,13 @@ SEARCH_ENGINE = None
|
||||
# Use the LMS specific result processor
|
||||
SEARCH_RESULT_PROCESSOR = "lms.lib.courseware_search.lms_result_processor.LmsSearchResultProcessor"
|
||||
|
||||
##### CDN EXPERIMENT/MONITORING FLAGS #####
|
||||
### PERFORMANCE EXPERIMENT SETTINGS ###
|
||||
# CDN experiment/monitoring flags
|
||||
CDN_VIDEO_URLS = {}
|
||||
|
||||
# Page onload event sampling rate (min 0.0, max 1.0)
|
||||
ONLOAD_BEACON_SAMPLE_RATE = 0.0
|
||||
|
||||
# The configuration visibility of account fields.
|
||||
ACCOUNT_VISIBILITY_CONFIGURATION = {
|
||||
# Default visibility level for accounts without a specified value
|
||||
|
||||
@@ -182,3 +182,33 @@
|
||||
)
|
||||
) if course_id and enrollment_action else ""
|
||||
}</%def>
|
||||
|
||||
# Performance beacon for onload times
|
||||
% if settings.FEATURES.get('ENABLE_ONLOAD_BEACON', False):
|
||||
<script>
|
||||
(function () {
|
||||
var sample_rate = ${settings.ONLOAD_BEACON_SAMPLE_RATE};
|
||||
var roll = Math.floor(Math.random() * 100)/100;
|
||||
var onloadBeaconSent = false;
|
||||
|
||||
if(roll < sample_rate){
|
||||
$(window).load(function() {
|
||||
setTimeout(function(){
|
||||
var t = window.performance.timing;
|
||||
|
||||
var data = {
|
||||
event: "onload",
|
||||
value: t.loadEventEnd - t.navigationStart,
|
||||
page: window.location.href,
|
||||
};
|
||||
|
||||
if (!onloadBeaconSent) {
|
||||
$.ajax({method: "POST", url: "/performance", data: data});
|
||||
}
|
||||
onloadBeaconSent = true;
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
}());
|
||||
</script>
|
||||
% endif
|
||||
|
||||
Reference in New Issue
Block a user