mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-30 21:41:46 +01:00
EH search - add fileSearch telemetry
This commit is contained in:
@@ -12,6 +12,7 @@ import { PPromise, TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IFileMatch, ISearchComplete, ISearchProgressItem, ISearchQuery, ISearchResultProvider, ISearchService, QueryType, IRawFileMatch2 } from 'vs/platform/search/common/search';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { ExtHostContext, ExtHostSearchShape, IExtHostContext, MainContext, MainThreadSearchShape } from '../node/extHost.protocol';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadSearch)
|
||||
export class MainThreadSearch implements MainThreadSearchShape {
|
||||
@@ -21,7 +22,8 @@ export class MainThreadSearch implements MainThreadSearchShape {
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@ISearchService private readonly _searchService: ISearchService
|
||||
@ISearchService private readonly _searchService: ISearchService,
|
||||
@ITelemetryService private readonly _telemetryService: ITelemetryService
|
||||
) {
|
||||
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostSearch);
|
||||
}
|
||||
@@ -43,6 +45,10 @@ export class MainThreadSearch implements MainThreadSearchShape {
|
||||
$handleFindMatch(handle: number, session, data: UriComponents | IRawFileMatch2[]): void {
|
||||
this._searchProvider.get(handle).handleFindMatch(session, data);
|
||||
}
|
||||
|
||||
$handleTelemetry(eventName: string, data: any): void {
|
||||
this._telemetryService.publicLog(eventName, data);
|
||||
}
|
||||
}
|
||||
|
||||
class SearchOperation {
|
||||
|
||||
@@ -405,6 +405,7 @@ export interface MainThreadSearchShape extends IDisposable {
|
||||
$registerSearchProvider(handle: number, scheme: string): void;
|
||||
$unregisterProvider(handle: number): void;
|
||||
$handleFindMatch(handle: number, session: number, data: UriComponents | IRawFileMatch2[]): void;
|
||||
$handleTelemetry(eventName: string, data: any): void;
|
||||
}
|
||||
|
||||
export interface MainThreadTaskShape extends IDisposable {
|
||||
|
||||
@@ -36,7 +36,9 @@ export class ExtHostSearch implements ExtHostSearchShape {
|
||||
|
||||
constructor(mainContext: IMainContext, private _schemeTransformer: ISchemeTransformer, private _extfs = extfs, private _pfs = pfs) {
|
||||
this._proxy = mainContext.getProxy(MainContext.MainThreadSearch);
|
||||
this._fileSearchManager = new FileSearchManager(this._pfs);
|
||||
this._fileSearchManager = new FileSearchManager(
|
||||
(eventName: string, data: any) => this._proxy.$handleTelemetry(eventName, data),
|
||||
this._pfs);
|
||||
}
|
||||
|
||||
private _transformScheme(scheme: string): string {
|
||||
@@ -763,7 +765,7 @@ class FileSearchManager {
|
||||
|
||||
private caches: { [cacheKey: string]: Cache; } = Object.create(null);
|
||||
|
||||
constructor(private _pfs: typeof pfs) { }
|
||||
constructor(private telemetryCallback: (eventName: string, data: any) => void, private _pfs: typeof pfs) { }
|
||||
|
||||
public fileSearch(config: ISearchQuery, provider: vscode.SearchProvider): PPromise<ISearchComplete, OneOrMore<IFileMatch>> {
|
||||
if (config.sortByScore) {
|
||||
@@ -822,14 +824,7 @@ class FileSearchManager {
|
||||
searchPromise = this.doSearch(engine, provider, -1)
|
||||
.then(result => {
|
||||
c([result, results]);
|
||||
// TODO@roblou telemetry
|
||||
// if (this.telemetryPipe) {
|
||||
// // __GDPR__TODO__ classify event
|
||||
// this.telemetryPipe({
|
||||
// eventName: 'fileSearch',
|
||||
// data: result.stats
|
||||
// });
|
||||
// }
|
||||
this.telemetryCallback('fileSearch', null);
|
||||
}, e, progress => {
|
||||
if (Array.isArray(progress)) {
|
||||
results = progress;
|
||||
|
||||
Reference in New Issue
Block a user