Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump @vscode/extension-telemetry from 0.4.10 to 0.9.8 #1911

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 125 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Syntax highlighting and autocompletion for Terraform",
"version": "2.34.2024121211",
"publisher": "hashicorp",
"appInsightsKey": "885372d2-6f3c-499f-9d25-b8b219983a52",
"appInsightsKey": "InstrumentationKey=885372d2-6f3c-499f-9d25-b8b219983a52;IngestionEndpoint=https://westus2-1.in.applicationinsights.azure.com/;LiveEndpoint=https://westus2.livediagnostics.monitor.azure.com/;ApplicationId=6734158a-8ab9-4aec-9b5a-af151d14a754",
"license": "MPL-2.0",
"preview": false,
"private": true,
Expand Down Expand Up @@ -955,7 +955,7 @@
"changelog:build": "changie batch auto && changie merge && npm i --package-lock-only"
},
"dependencies": {
"@vscode/extension-telemetry": "^0.4.9",
"@vscode/extension-telemetry": "^0.9.8",
"@zodios/core": "^10.9.2",
"@zodios/plugins": "^10.6.0",
"axios": "^1.7.4",
Expand Down
17 changes: 13 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
}

const manifest = context.extension.packageJSON;
reporter = new TelemetryReporter(context.extension.id, manifest.version, manifest.appInsightsKey);
reporter = new TelemetryReporter(manifest.appInsightsKey);
context.subscriptions.push(reporter);

// always register commands needed to control terraform-ls
Expand Down Expand Up @@ -102,7 +102,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
initializationFailedHandler: (error: ResponseError<InitializeError> | Error) => {
initializationError = error;

reporter.sendTelemetryException(error);
reporter.sendTelemetryErrorEvent('initializationError', {
message: error.message,
stack: error.stack,
code: error instanceof ResponseError ? error.code.toString() : undefined,
});

let msg = 'Failure to start terraform-ls. Please check your configuration settings and reload this window';

Expand Down Expand Up @@ -235,12 +239,17 @@ export async function deactivate(): Promise<void> {
} catch (error) {
if (error instanceof Error) {
outputChannel.appendLine(error.message);
reporter.sendTelemetryException(error);
reporter.sendTelemetryErrorEvent('deactivate', {
message: error.message,
stack: error.stack,
});
vscode.window.showErrorMessage(error.message);
lsStatus.setLanguageServerState(error.message, false, vscode.LanguageStatusSeverity.Error);
} else if (typeof error === 'string') {
outputChannel.appendLine(error);
reporter.sendTelemetryException(new Error(error));
reporter.sendTelemetryErrorEvent('deactivate', {
message: error,
});
vscode.window.showErrorMessage(error);
lsStatus.setLanguageServerState(error, false, vscode.LanguageStatusSeverity.Error);
}
Expand Down
6 changes: 5 additions & 1 deletion src/features/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export class TelemetryFeature implements StaticFeature {
return;
}

this.reporter.sendRawTelemetryEvent(event.name, event.properties);
const thing: Record<string, string> = {};
for (const [key, value] of Object.entries(event.properties)) {
thing[key] = String(value);
}
this.reporter.sendRawTelemetryEvent(event.name, thing);
}),
);
}
Expand Down
5 changes: 4 additions & 1 deletion src/providers/tfc/applyProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ export class ApplyTreeDataProvider implements vscode.TreeDataProvider<vscode.Tre
if (error instanceof Error) {
message += error.message;
vscode.window.showErrorMessage(message);
this.reporter.sendTelemetryException(error);
this.reporter.sendTelemetryErrorEvent('applyLogError', {
message: message,
stack: error.stack,
});
return;
}

Expand Down
19 changes: 15 additions & 4 deletions src/providers/tfc/authenticationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,16 @@ class TerraformCloudSessionHandler {
if ((error.response.status as number) === 401) {
throw new InvalidToken();
}
this.reporter.sendTelemetryException(error);
this.reporter.sendTelemetryErrorEvent('storeSession', {
message: error.message,
stack: error.stack,
});
throw new Error(`Failed to login: ${apiErrorsToString(error.response.data.errors)}`);
} else if (error instanceof Error) {
this.reporter.sendTelemetryException(error);
this.reporter.sendTelemetryErrorEvent('storeSession', {
message: error.message,
stack: error.stack,
});
}

throw error;
Expand Down Expand Up @@ -243,11 +249,16 @@ export class TerraformCloudAuthenticationProvider implements vscode.Authenticati
return this.createSession(_scopes);
} else if (error instanceof Error) {
vscode.window.showErrorMessage(error.message);
this.reporter.sendTelemetryException(error);
this.reporter.sendTelemetryErrorEvent('invalidHCPToken', {
message: error.message,
stack: error.stack,
});
this.logger.error(error.message);
} else if (typeof error === 'string') {
vscode.window.showErrorMessage(error);
this.reporter.sendTelemetryException(new Error(error));
this.reporter.sendTelemetryErrorEvent('invalidHCPToken', {
message: error,
});
this.logger.error(error);
}

Expand Down
10 changes: 8 additions & 2 deletions src/providers/tfc/organizationPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,16 @@ export class OrganizationAPIResource implements APIResource {
return picks;
} else if (isErrorFromAlias(apiClient.api, 'listOrganizations', error)) {
message += apiErrorsToString(error.response.data.errors);
this.reporter.sendTelemetryException(error);
this.reporter.sendTelemetryErrorEvent('orgranizationFetchError', {
message: message,
stack: error.stack,
});
} else if (error instanceof Error) {
message += error.message;
this.reporter.sendTelemetryException(error);
this.reporter.sendTelemetryErrorEvent('orgranizationFetchError', {
message: message,
stack: error.stack,
});
} else if (typeof error === 'string') {
message += error;
}
Expand Down
5 changes: 4 additions & 1 deletion src/providers/tfc/planProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ export class PlanTreeDataProvider implements vscode.TreeDataProvider<vscode.Tree
if (error instanceof Error) {
message += error.message;
vscode.window.showErrorMessage(message);
this.reporter.sendTelemetryException(error);
this.reporter.sendTelemetryErrorEvent('planLogError', {
message: message,
stack: error.stack,
});
return;
}

Expand Down
10 changes: 8 additions & 2 deletions src/providers/tfc/runProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,21 @@ export class RunTreeDataProvider implements vscode.TreeDataProvider<TFCRunTreeIt
if (isErrorFromAlias(apiClient.api, 'listRuns', error)) {
message += apiErrorsToString(error.response.data.errors);
vscode.window.showErrorMessage(message);
this.reporter.sendTelemetryException(error);
this.reporter.sendTelemetryErrorEvent('runProviderError', {
message: message,
stack: error.stack,
});
return [];
}
}

if (error instanceof Error) {
message += error.message;
vscode.window.showErrorMessage(message);
this.reporter.sendTelemetryException(error);
this.reporter.sendTelemetryErrorEvent('runProviderError', {
message: message,
stack: error.stack,
});
return [];
}

Expand Down
5 changes: 4 additions & 1 deletion src/providers/tfc/uiHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export async function handleZodiosError(
outputChannel: vscode.OutputChannel,
reporter: TelemetryReporter,
) {
reporter.sendTelemetryException(error);
reporter.sendTelemetryErrorEvent('zodiosError', {
message: error.message,
stack: error.stack,
});
outputChannel.append(JSON.stringify({ cause: error.cause }, undefined, 2));
const chosenItem = await vscode.window.showErrorMessage(
`${msgPrefix} Response validation failed. Please report this as a bug.`,
Expand Down
10 changes: 8 additions & 2 deletions src/providers/tfc/workspaceFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,16 @@ export class ProjectsAPIResource implements APIResource {
return picks;
} else if (isErrorFromAlias(apiClient.api, 'listProjects', error)) {
message += apiErrorsToString(error.response.data.errors);
this.reporter.sendTelemetryException(error);
this.reporter.sendTelemetryErrorEvent('projectWorkspaceFetchError', {
message: message,
stack: error.stack,
});
} else if (error instanceof Error) {
message += error.message;
this.reporter.sendTelemetryException(error);
this.reporter.sendTelemetryErrorEvent('projectWorkspaceFetchError', {
message: message,
stack: error.stack,
});
} else if (typeof error === 'string') {
message += error;
}
Expand Down
Loading
Loading