Skip to content

Commit

Permalink
Merge pull request #120 from algolia/feat/processingTime
Browse files Browse the repository at this point in the history
Add engine processing time
  • Loading branch information
asurak committed Jun 19, 2018
2 parents 8f1202b + 4a745cc commit 5d31149
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/assets/javascripts/app.js
Expand Up @@ -187,7 +187,7 @@ $(document).ready(function() {
});
});

window.trackResource = function(queryId){
window.trackResource = function(query){
try {
if (performance === undefined) {
return false
Expand Down Expand Up @@ -224,6 +224,8 @@ window.trackResource = function(queryId){
var encodedBodySize = lastAlgoliaRequest.encodedBodySize
// transferSize
var transferSize = lastAlgoliaRequest.transferSize
// Engine processing time
var engineProcessingTime = query.processingTimeMS

var supportsNavigator = navigator && typeof navigator.sendBeacon === 'function';

Expand All @@ -239,6 +241,7 @@ window.trackResource = function(queryId){
decodedBodySize,
encodedBodySize,
transferSize,
engineProcessingTime,
nextHopProtocol: lastAlgoliaRequest.nextHopProtocol,
domain: lastAlgoliaRequest.name.match(/(.*)\:\/\/(.*?)\//)[2]
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/controllers.js
Expand Up @@ -132,7 +132,7 @@ angular.module('HNSearch.controllers', ['ngSanitize', 'ngDropdowns', 'pasvaz.bin
var _search = function(ids) {
var parsedQuery = parseQuery($scope.query || '', search.getParams(ids));
getIndex(parsedQuery.query).search(parsedQuery.query, parsedQuery.params).then(function(results) {
typeof window.trackResource === 'function' && window.trackResource(results.queryID);
typeof window.trackResource === 'function' && window.trackResource(results);

aa && aa('initSearch', { getQueryID: function() { return results.queryID; }});
parsedQuery = parseQuery($scope.query || '', search.getParams(ids)); // reparse the query once the promise is resolved
Expand Down

0 comments on commit 5d31149

Please sign in to comment.