diff options
author | Sean McGivern <sean@gitlab.com> | 2018-08-29 12:01:17 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-08-29 12:01:17 +0100 |
commit | 96904b0236329916666c829e9f569ac8b94d8879 (patch) | |
tree | 6d095ee8ce568b0f9b4cc59ae7116588d16510f0 /app | |
parent | e30e54b990f861f3e22543b66bc8b469273086d4 (diff) | |
download | gitlab-ce-96904b0236329916666c829e9f569ac8b94d8879.tar.gz |
Ignore API requests in performance bar
These don't have performance data saved as they use Grape.
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/performance_bar/services/performance_bar_service.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/app/assets/javascripts/performance_bar/services/performance_bar_service.js b/app/assets/javascripts/performance_bar/services/performance_bar_service.js index bc71911ae35..60d9ba62570 100644 --- a/app/assets/javascripts/performance_bar/services/performance_bar_service.js +++ b/app/assets/javascripts/performance_bar/services/performance_bar_service.js @@ -11,13 +11,10 @@ export default class PerformanceBarService { static registerInterceptor(peekUrl, callback) { const interceptor = response => { - const requestId = response.headers['x-request-id']; - // Get the request URL from response.config for Axios, and response for - // Vue Resource. - const requestUrl = (response.config || response).url; - const cachedResponse = response.headers['x-gitlab-from-cache'] === 'true'; + const [fireCallback, requestId, requestUrl] = + PerformanceBarService.callbackParams(response, peekUrl); - if (requestUrl !== peekUrl && requestId && !cachedResponse) { + if (fireCallback) { callback(requestId, requestUrl); } @@ -38,4 +35,16 @@ export default class PerformanceBarService { vueResourceInterceptor, ); } + + static callbackParams(response, peekUrl) { + const requestId = response.headers && response.headers['x-request-id']; + // Get the request URL from response.config for Axios, and response for + // Vue Resource. + const requestUrl = (response.config || response).url; + const apiRequest = requestUrl && requestUrl.match(/^\/api\//); + const cachedResponse = response.headers && response.headers['x-gitlab-from-cache'] === 'true'; + const fireCallback = requestUrl !== peekUrl && requestId && !apiRequest && !cachedResponse; + + return [fireCallback, requestId, requestUrl]; + } } |