mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
[html] telemetry for completion in embedded content
This commit is contained in:
parent
2fe6947154
commit
a29692641d
|
@ -10,6 +10,7 @@ import { languages, workspace, ExtensionContext, IndentAction } from 'vscode';
|
|||
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Range, RequestType } from 'vscode-languageclient';
|
||||
import { EMPTY_ELEMENTS } from './htmlEmptyTagsShared';
|
||||
import { activateColorDecorations } from './colorDecorators';
|
||||
import TelemetryReporter from 'vscode-extension-telemetry';
|
||||
|
||||
import * as nls from 'vscode-nls';
|
||||
let localize = nls.loadMessageBundle();
|
||||
|
@ -18,8 +19,17 @@ namespace ColorSymbolRequest {
|
|||
export const type: RequestType<string, Range[], any, any> = { get method() { return 'css/colorSymbols'; }, _: null };
|
||||
}
|
||||
|
||||
interface IPackageInfo {
|
||||
name: string;
|
||||
version: string;
|
||||
aiKey: string;
|
||||
}
|
||||
|
||||
export function activate(context: ExtensionContext) {
|
||||
|
||||
let packageInfo = getPackageInfo(context);
|
||||
let telemetryReporter: TelemetryReporter = packageInfo && new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
|
||||
|
||||
// The server is implemented in node
|
||||
let serverModule = context.asAbsolutePath(path.join('server', 'out', 'htmlServerMain.js'));
|
||||
// The debug options for the server
|
||||
|
@ -57,6 +67,11 @@ export function activate(context: ExtensionContext) {
|
|||
};
|
||||
let disposable = activateColorDecorations(colorRequestor, { html: true, handlebars: true, razor: true });
|
||||
context.subscriptions.push(disposable);
|
||||
client.onTelemetry(e => {
|
||||
if (telemetryReporter) {
|
||||
telemetryReporter.sendTelemetryEvent(e.key, e.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
languages.setLanguageConfiguration('html', {
|
||||
|
@ -103,4 +118,16 @@ export function activate(context: ExtensionContext) {
|
|||
}
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
function getPackageInfo(context: ExtensionContext): IPackageInfo {
|
||||
let extensionPackage = require(context.asAbsolutePath('./package.json'));
|
||||
if (extensionPackage) {
|
||||
return {
|
||||
name: extensionPackage.name,
|
||||
version: extensionPackage.version,
|
||||
aiKey: extensionPackage.aiKey
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
6
extensions/html/client/src/typings/vscode-extension-telemetry.d.ts
vendored
Normal file
6
extensions/html/client/src/typings/vscode-extension-telemetry.d.ts
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
declare module 'vscode-extension-telemetry' {
|
||||
export default class TelemetryReporter {
|
||||
constructor(extensionId: string, extensionVersion: string, key: string);
|
||||
sendTelemetryEvent(eventName: string, properties?: { [key: string]: string }, measures?: { [key: string]: number }): void;
|
||||
}
|
||||
}
|
15
extensions/html/npm-shrinkwrap.json
generated
15
extensions/html/npm-shrinkwrap.json
generated
|
@ -2,6 +2,16 @@
|
|||
"name": "html",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"applicationinsights": {
|
||||
"version": "0.15.6",
|
||||
"from": "applicationinsights@0.15.6",
|
||||
"resolved": "https://registry.npmjs.org/applicationinsights/-/applicationinsights-0.15.6.tgz"
|
||||
},
|
||||
"vscode-extension-telemetry": {
|
||||
"version": "0.0.5",
|
||||
"from": "vscode-extension-telemetry@>=0.0.5 <0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/vscode-extension-telemetry/-/vscode-extension-telemetry-0.0.5.tgz"
|
||||
},
|
||||
"vscode-jsonrpc": {
|
||||
"version": "3.0.1-alpha.2",
|
||||
"from": "vscode-jsonrpc@>=3.0.1-alpha.2 <4.0.0",
|
||||
|
@ -21,6 +31,11 @@
|
|||
"version": "1.0.7",
|
||||
"from": "vscode-nls@>=1.0.7 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-1.0.7.tgz"
|
||||
},
|
||||
"winreg": {
|
||||
"version": "0.0.13",
|
||||
"from": "winreg@0.0.13",
|
||||
"resolved": "https://registry.npmjs.org/winreg/-/winreg-0.0.13.tgz"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"name": "html",
|
||||
"version": "0.1.0",
|
||||
"publisher": "vscode",
|
||||
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
|
||||
"engines": {
|
||||
"vscode": "0.10.x"
|
||||
},
|
||||
|
@ -143,6 +144,7 @@
|
|||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"vscode-extension-telemetry": "0.0.5",
|
||||
"vscode-languageclient": "3.0.1-alpha.2",
|
||||
"vscode-languageserver-types": "3.0.1-alpha.2",
|
||||
"vscode-nls": "^1.0.7"
|
||||
|
|
|
@ -132,6 +132,9 @@ connection.onCompletion(textDocumentPosition => {
|
|||
let document = documents.get(textDocumentPosition.textDocument.uri);
|
||||
let mode = languageModes.getModeAtPosition(document, textDocumentPosition.position);
|
||||
if (mode && mode.doComplete) {
|
||||
if (mode.getId() !== 'html') {
|
||||
connection.telemetry.logEvent({ key: 'html.embbedded.complete', value: { languageId: mode.getId() } });
|
||||
}
|
||||
return mode.doComplete(document, textDocumentPosition.position);
|
||||
}
|
||||
return { isIncomplete: true, items: [] };
|
||||
|
|
Loading…
Reference in a new issue