diff --git a/src/vs/workbench/api/electron-browser/mainThreadSearch.ts b/src/vs/workbench/api/electron-browser/mainThreadSearch.ts index 2348c66ce48..e8853d0dfdc 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadSearch.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadSearch.ts @@ -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 { diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 1e6a260aa8f..e24f4b33b37 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -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 { diff --git a/src/vs/workbench/api/node/extHostSearch.ts b/src/vs/workbench/api/node/extHostSearch.ts index 616387de355..58ea46e898e 100644 --- a/src/vs/workbench/api/node/extHostSearch.ts +++ b/src/vs/workbench/api/node/extHostSearch.ts @@ -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> { 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;