Skip to content

Commit 8ab6293

Browse files
authored
Add OPEN_RESOURCE_EXTERNALLY telemetry event (#1589)
## Changes "openExternal" command is used for Bundle Resources and Docs panels. Resources already have "type" fields, I've added the same field for Docs panel items, and the new telemetry event is sent with the "type" information (and not a full url). It should help us understand what resources people open externally, or what documentation guides people open more frequently than others. ## Tests Manually
1 parent b65c540 commit 8ab6293

File tree

5 files changed

+39
-8
lines changed

5 files changed

+39
-8
lines changed

packages/databricks-vscode/src/configuration/LoginWizard.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ async function collectTokenForPatAuth(
554554
if (token === "Create a new Personal Access Token") {
555555
commands.executeCommand("databricks.utils.openExternal", {
556556
url: `${host.toString()}settings/user/developer/access-tokens`,
557+
type: "pat_settings_page",
557558
});
558559
return collectTokenForPatAuth(host, input, step, totalSteps);
559560
}

packages/databricks-vscode/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ export async function activate(
852852
});
853853

854854
// Utils
855-
const utilCommands = new UtilsCommands.UtilsCommands();
855+
const utilCommands = new UtilsCommands.UtilsCommands(telemetry);
856856
context.subscriptions.push(
857857
telemetry.registerCommand(
858858
"databricks.utils.openExternal",

packages/databricks-vscode/src/telemetry/constants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export enum Events {
2323
COMPUTE_SELECTED = "computeSelected",
2424
WORKFLOW_RUN = "workflowRun",
2525
DBCONNECT_RUN = "dbconnectRun",
26+
OPEN_RESOURCE_EXTERNALLY = "openResourceExternally",
2627
}
2728
/* eslint-enable @typescript-eslint/naming-convention */
2829

@@ -200,6 +201,14 @@ export class EventTypes {
200201
comment: "The type of the compute",
201202
},
202203
};
204+
[Events.OPEN_RESOURCE_EXTERNALLY]: EventType<{
205+
type: string;
206+
}> = {
207+
comment: "An external resource URL was opened",
208+
type: {
209+
comment: "The resource type",
210+
},
211+
};
203212
}
204213

205214
/**

packages/databricks-vscode/src/ui/docs-view/DocsViewTreeDataProvider.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
TreeDataProvider,
55
TreeItem,
66
TreeItemCollapsibleState,
7-
Uri,
87
} from "vscode";
98
import {logging} from "@databricks/databricks-sdk";
109
import {Loggers} from "../../logger";
@@ -57,52 +56,66 @@ export class DocsViewTreeDataProvider
5756

5857
const items: DocsTreeItem[] = [quickStartItem];
5958

60-
const baseUrl = "https://docs.databricks.com/";
61-
const docLinks = [
59+
const baseUrl = "https://docs.databricks.com";
60+
const guides = [
6261
{
6362
label: "Setup authentication",
6463
path: "dev-tools/vscode-ext/authentication",
64+
type: "auth_guide",
6565
},
6666
{
6767
label: "Configure your project",
6868
path: "dev-tools/vscode-ext/configure",
69+
type: "configuration_guide",
6970
},
7071
{
7172
label: "Work with Databricks Asset Bundles",
7273
path: "dev-tools/vscode-ext/bundles",
74+
type: "bundles_guide",
7375
},
7476
{
7577
label: "Run files on a cluster",
7678
path: "dev-tools/vscode-ext/run",
79+
type: "run_files_guide",
7780
},
7881
{
7982
label: "Run files with Databricks Connect",
8083
path: "dev-tools/vscode-ext/databricks-connect",
84+
type: "dbconnect_guide",
8185
},
8286
{
8387
label: "Run notebooks cell by cell",
8488
path: "dev-tools/vscode-ext/notebooks",
89+
type: "notebooks_guide",
8590
},
8691
{
8792
label: "Run tests on a cluster",
8893
path: "dev-tools/vscode-ext/pytest",
94+
type: "pytest_guide",
8995
},
9096
{
9197
label: "Explore extension settings",
9298
path: "dev-tools/vscode-ext/settings",
99+
type: "settings_guide",
93100
},
94101
{
95102
label: "Troubleshoot problems",
96103
path: "dev-tools/vscode-ext/troubleshooting",
104+
type: "troubleshooting_guide",
97105
},
98106
];
99-
for (const doc of docLinks) {
100-
const item = new TreeItem(doc.label, TreeItemCollapsibleState.None);
107+
for (const guide of guides) {
108+
const item = new TreeItem(
109+
guide.label,
110+
TreeItemCollapsibleState.None
111+
);
101112
item.iconPath = new ThemeIcon("link");
102113
item.command = {
103-
command: "vscode.open",
114+
command: "databricks.utils.openExternal",
104115
title: "Open URL",
105-
arguments: [Uri.parse(`${baseUrl}${doc.path}`)],
116+
arguments: [
117+
{url: `${baseUrl}/${guide.path}`, type: guide.type},
118+
],
106119
};
107120
items.push(item);
108121
}

packages/databricks-vscode/src/utils/UtilsCommands.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import {Disposable, window, env} from "vscode";
22
import {openExternal} from "./urlUtils";
3+
import {Events, Telemetry} from "../telemetry";
34

45
export class UtilsCommands implements Disposable {
56
private disposables: Disposable[] = [];
67

8+
constructor(private telemetry: Telemetry) {}
9+
710
openExternalCommand() {
811
return async (value: any | undefined) => {
912
let url: string | undefined;
@@ -20,6 +23,11 @@ export class UtilsCommands implements Disposable {
2023
);
2124
return;
2225
}
26+
if (value.type !== undefined) {
27+
this.telemetry.recordEvent(Events.OPEN_RESOURCE_EXTERNALLY, {
28+
type: value.type,
29+
});
30+
}
2331
await openExternal(url);
2432
};
2533
}

0 commit comments

Comments
 (0)