提交 7a90daa4 编写于 作者: C Christof Marti

Include duration and options in searchResultsShown (#15321)

上级 2b5b63b0
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import * as timer from 'vs/base/common/timer'; import * as timer from 'vs/base/common/timer';
import paths = require('vs/base/common/paths'); import paths = require('vs/base/common/paths');
import objects = require('vs/base/common/objects');
import strings = require('vs/base/common/strings'); import strings = require('vs/base/common/strings');
import errors = require('vs/base/common/errors'); import errors = require('vs/base/common/errors');
import { RunOnceScheduler } from 'vs/base/common/async'; import { RunOnceScheduler } from 'vs/base/common/async';
...@@ -555,8 +556,8 @@ export class SearchModel extends Disposable { ...@@ -555,8 +556,8 @@ export class SearchModel extends Disposable {
onFirstRenderStopwatch(duration => this.telemetryService.publicLog('searchResultsFirstRender', { duration })); onFirstRenderStopwatch(duration => this.telemetryService.publicLog('searchResultsFirstRender', { duration }));
this.currentRequest.then( this.currentRequest.then(
value => this.onSearchCompleted(value), value => this.onSearchCompleted(value, timerEvent.timeTaken()),
e => this.onSearchError(e), e => this.onSearchError(e, timerEvent.timeTaken()),
p => { p => {
progressEmitter.fire(); progressEmitter.fire();
this.onSearchProgress(p); this.onSearchProgress(p);
...@@ -566,17 +567,24 @@ export class SearchModel extends Disposable { ...@@ -566,17 +567,24 @@ export class SearchModel extends Disposable {
return this.currentRequest; return this.currentRequest;
} }
private onSearchCompleted(completed: ISearchComplete): ISearchComplete { private onSearchCompleted(completed: ISearchComplete, duration: number): ISearchComplete {
if (completed) { if (completed) {
this._searchResult.add(completed.results, false); this._searchResult.add(completed.results, false);
} }
this.telemetryService.publicLog('searchResultsShown', { count: this._searchResult.count(), fileCount: this._searchResult.fileCount() }); const options: IPatternInfo = objects.assign({}, this._searchQuery.contentPattern);
delete options.pattern;
this.telemetryService.publicLog('searchResultsShown', {
count: this._searchResult.count(),
fileCount: this._searchResult.fileCount(),
options,
duration
});
return completed; return completed;
} }
private onSearchError(e: any): void { private onSearchError(e: any, duration: number): void {
if (errors.isPromiseCanceledError(e)) { if (errors.isPromiseCanceledError(e)) {
this.onSearchCompleted(null); this.onSearchCompleted(null, duration);
} }
} }
......
...@@ -115,7 +115,7 @@ suite('SearchModel', () => { ...@@ -115,7 +115,7 @@ suite('SearchModel', () => {
testObject.search({ contentPattern: { pattern: 'somestring' }, type: 1 }); testObject.search({ contentPattern: { pattern: 'somestring' }, type: 1 });
assert.ok(target.calledOnce); assert.ok(target.calledOnce);
assert.deepEqual(['searchResultsShown', { count: 3, fileCount: 2 }], target.args[0]); assert.deepEqual(['searchResultsShown', { count: 3, fileCount: 2, options: {}, duration: -1 }], target.args[0]);
}); });
test('Search Model: Search reports timed telemetry on search when progress is not called', function (done) { test('Search Model: Search reports timed telemetry on search when progress is not called', function (done) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册