Skip to content

Commit

Permalink
Fire telemetry event when a github dependency is fetched (#1747)
Browse files Browse the repository at this point in the history
As the title says -- simple enough.
  • Loading branch information
sezna authored Jul 18, 2024
1 parent 3a78aa8 commit 7d4a7bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions vscode/src/projectSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import * as vscode from "vscode";
import { URI, Utils } from "vscode-uri";
import { invokeAndReportCommandDiagnostics } from "./diagnostics";
import { sendTelemetryEvent, EventType } from "./telemetry";

/** Returns the manifest document if one is found
* returns null otherwise
Expand Down Expand Up @@ -247,6 +248,14 @@ export async function fetchGithubRaw(
const uri = `${githubEndpoint}/${owner}/${repo}/${ref}/${pathNoLeadingSlash}`;
log.info(`making request to ${uri}`);
const response = await fetch(uri);
// note that if the above fetch fails, we will never send this telemetry event.
// however, this is okay, because if a network request to github is failing, it is likely
// that the user's network itself is suspect and the telemetry wouldn't send anyway.
sendTelemetryEvent(
EventType.FetchGitHub,
{ status: response.status.toString() },
{},
);
if (!response.ok) {
log.warn(
`fetchGithubRaw: ${owner}/${repo}/${ref}/${path} -> ${response.status} ${response.statusText}`,
Expand Down
5 changes: 5 additions & 0 deletions vscode/src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export enum EventType {
FormatStart = "Qsharp.FormatStart",
FormatEnd = "Qsharp.FormatEnd",
CreateProject = "Qsharp.CreateProject",
FetchGitHub = "Qsharp.FetchGitHub",
TriggerCircuit = "Qsharp.TriggerCircuit",
CircuitStart = "Qsharp.CircuitStart",
CircuitEnd = "Qsharp.CircuitEnd",
Expand Down Expand Up @@ -224,6 +225,10 @@ type EventTypes = {
properties: Empty;
measurements: Empty;
};
[EventType.FetchGitHub]: {
properties: { status: string };
measurements: Empty;
};
[EventType.TriggerCircuit]: {
properties: {
associationId: string;
Expand Down

0 comments on commit 7d4a7bd

Please sign in to comment.