Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Fix client timings regression and bring back 'show trivial' #441

Merged
merged 1 commit into from May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 40 additions & 26 deletions lib/html/includes.js
Expand Up @@ -108,18 +108,8 @@ var MiniProfiler = (function() {
// ie is buggy strip out functions
var copy = {
navigation: {},
timing: {}
timing: clientPerformance.timing.toJSON()
};
var timing = extend({}, clientPerformance.timing);

for (p in timing) {
if (
timing.hasOwnProperty(p) &&
!(typeof timing[p] === "function")
) {
copy.timing[p] = timing[p];
}
}

if (clientPerformance.navigation) {
copy.navigation.redirectCount =
Expand Down Expand Up @@ -147,10 +137,13 @@ var MiniProfiler = (function() {
(function() {
var request = new XMLHttpRequest();
var url = options.path + "results";
var params = "id="
.concat(id, "&clientPerformance=")
.concat(clientPerformance, "&clientProbes=")
.concat(clientProbes, "&popup=1");
var params = {
id: id,
clientPerformance: clientPerformance,
clientProbes: clientProbes,
popup: 1
};
var queryParam = toQueryString(params);
request.open("POST", url, true);

request.onload = function() {
Expand All @@ -172,24 +165,45 @@ var MiniProfiler = (function() {
"Content-Type",
"application/x-www-form-urlencoded"
);
request.send(params);
request.send(queryParam);
})();
}
}
};

var extend = function extend(out) {
out = out || {};

for (var i = 1; i < _arguments.length; i++) {
if (!_arguments[i]) continue;

for (var key in _arguments[i]) {
if (_arguments[i].hasOwnProperty(key)) out[key] = _arguments[i][key];
var toQueryString = function toQueryString(data, parentKey) {
var result = [];
for (var key in data) {
var val = data[key];
var newKey = !parentKey ? key : parentKey + "[" + key + "]";
if (
typeof val === "object" &&
!Array.isArray(val) &&
val !== null &&
val !== undefined
) {
result[result.length] = toQueryString(val, newKey);
} else {
if (Array.isArray(val)) {
val.forEach(function(v) {
result[result.length] =
encodeURIComponent(newKey + "[]") + "=" + encodeURIComponent(v);
});
} else if (val === null || val === undefined) {
result[result.length] = encodeURIComponent(newKey) + "=";
} else {
result[result.length] =
encodeURIComponent(newKey) +
"=" +
encodeURIComponent(val.toString());
}
}
}

return out;
return result
.filter(function(element) {
return element && element.length > 0;
})
.join("&");
};

var renderTemplate = function renderTemplate(json) {
Expand Down
4 changes: 2 additions & 2 deletions lib/html/includes.tmpl
Expand Up @@ -128,8 +128,8 @@
{{? it.custom_link}}
<a href="{{= it.custom_link }}" class="profiler-custom-link" target="_blank">{{= it.custom_link_name }}</a>
{{?}}
{{? it.has_trivial_timings}}
<a class="profiler-toggle-trivial" data-show-on-load="{{= it.has_all_trivial_timings }}" title="toggles any rows with &lt; {{= it.trivial_duration_threshold_milliseconds }} ms">
{{? it.page.has_trivial_timings}}
<a class="profiler-toggle-trivial" data-show-on-load="{{= it.page.has_all_trivial_timings }}" title="toggles any rows with &lt; {{= it.page.trivial_duration_threshold_milliseconds }} ms">
show trivial
</a>
{{?}}
Expand Down
2 changes: 1 addition & 1 deletion lib/html/vendor.js
Expand Up @@ -11,7 +11,7 @@ var out=' <div class="profiler-result"> <div class="profiler-button ';if(it.has_
}
MiniProfiler.templates["linksTemplate"] = function anonymous(it
) {
var out=' <a href="'+( MiniProfiler.shareUrl(it.page.id) )+'" class="profiler-share-profiler-results" target="_blank">share</a> <a href="'+( MiniProfiler.moreUrl(it.timing.name) )+'" class="profiler-more-actions">more</a> ';if(it.custom_link){out+=' <a href="'+( it.custom_link )+'" class="profiler-custom-link" target="_blank">'+( it.custom_link_name )+'</a> ';}out+=' ';if(it.has_trivial_timings){out+=' <a class="profiler-toggle-trivial" data-show-on-load="'+( it.has_all_trivial_timings )+'" title="toggles any rows with &lt; '+( it.trivial_duration_threshold_milliseconds )+' ms"> show trivial </a> ';}return out;
var out=' <a href="'+( MiniProfiler.shareUrl(it.page.id) )+'" class="profiler-share-profiler-results" target="_blank">share</a> <a href="'+( MiniProfiler.moreUrl(it.timing.name) )+'" class="profiler-more-actions">more</a> ';if(it.custom_link){out+=' <a href="'+( it.custom_link )+'" class="profiler-custom-link" target="_blank">'+( it.custom_link_name )+'</a> ';}out+=' ';if(it.page.has_trivial_timings){out+=' <a class="profiler-toggle-trivial" data-show-on-load="'+( it.page.has_all_trivial_timings )+'" title="toggles any rows with &lt; '+( it.page.trivial_duration_threshold_milliseconds )+' ms"> show trivial </a> ';}return out;
}
MiniProfiler.templates["timingTemplate"] = function anonymous(it
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/mini_profiler/asset_version.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
module Rack
class MiniProfiler
ASSET_VERSION = '67dd1c2571ced7fc74ae7f1813e47bdf'
ASSET_VERSION = '22e813e9a683ebee90a5afa948cffb0b'
end
end