Skip to content

Commit 11ffe52

Browse files
authored
Telemetry for Getting Started (#193)
Signed-off-by: Rome Li <[email protected]>
1 parent 6d84403 commit 11ffe52

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/getting-started/assets/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,13 @@ if (navigator.platform.toLowerCase().indexOf("mac") === 0) {
1616

1717
const osToHide = os === "win" ? "mac" : "win";
1818
$(`[data-os=${osToHide}]`).hide();
19+
20+
declare function acquireVsCodeApi(): any;
21+
const vscode = acquireVsCodeApi();
22+
23+
$("a[data-toggle='tab']").on("shown.bs.tab", e => {
24+
vscode.postMessage({
25+
command: "tabActivated",
26+
tabId: e.target.id
27+
});
28+
});

src/getting-started/index.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import * as vscode from "vscode";
55
import * as path from "path";
66
import { loadTextFromFile, getExtensionContext } from "../utils";
7+
import { sendInfo, instrumentOperation } from "vscode-extension-telemetry-wrapper";
78

89
let javaGettingStartedView: vscode.WebviewPanel | undefined;
910

@@ -21,19 +22,28 @@ export async function javaGettingStartedCmdHandler(context: vscode.ExtensionCont
2122
retainContextWhenHidden: true
2223
});
2324

24-
await initializeJavaGettingStartedView(context, javaGettingStartedView, onDidDisposeWebviewPanel);
25+
await initializeJavaGettingStartedView(context, javaGettingStartedView, onDidDisposeWebviewPanel, operationId);
2526
}
2627

2728
function onDidDisposeWebviewPanel() {
2829
javaGettingStartedView = undefined;
2930
}
3031

31-
async function initializeJavaGettingStartedView(context: vscode.ExtensionContext, webviewPanel: vscode.WebviewPanel, onDisposeCallback: () => void) {
32+
async function initializeJavaGettingStartedView(context: vscode.ExtensionContext, webviewPanel: vscode.WebviewPanel, onDisposeCallback: () => void, operationId: string) {
3233
webviewPanel.iconPath = vscode.Uri.file(path.join(context.extensionPath, "logo.lowres.png"));
3334
const resourceUri = context.asAbsolutePath("./out/assets/getting-started/index.html");
3435
webviewPanel.webview.html = await loadTextFromFile(resourceUri);
3536

3637
context.subscriptions.push(webviewPanel.onDidDispose(onDisposeCallback));
38+
context.subscriptions.push(webviewPanel.webview.onDidReceiveMessage(async (e) => {
39+
if (e.command === "tabActivated") {
40+
let tabId = e.tabId;
41+
sendInfo(operationId, {
42+
infoType: "tabActivated",
43+
tabId: tabId
44+
});
45+
}
46+
}));
3747
}
3848

3949
export class JavaGettingStartedViewSerializer implements vscode.WebviewPanelSerializer {
@@ -45,6 +55,8 @@ export class JavaGettingStartedViewSerializer implements vscode.WebviewPanelSeri
4555
}
4656

4757
javaGettingStartedView = webviewPanel;
48-
initializeJavaGettingStartedView(getExtensionContext(), webviewPanel, onDidDisposeWebviewPanel);
58+
instrumentOperation("restoreGettingStartedView", operationId => {
59+
initializeJavaGettingStartedView(getExtensionContext(), webviewPanel, onDidDisposeWebviewPanel, operationId);
60+
})();
4961
}
5062
}

0 commit comments

Comments
 (0)