Skip to content

Commit

Permalink
migrate existing Sentry.captureException calls to the wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
shouples committed Nov 16, 2024
1 parent 3a7ebc2 commit c988235
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/commands/docker.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as Sentry from "@sentry/node";
import { CancellationToken, Disposable, ProgressLocation, window } from "vscode";
import { registerCommandWithLogging } from ".";
import { ResponseError } from "../clients/docker";
import { isDockerAvailable } from "../docker/configs";
import { LocalResourceKind } from "../docker/constants";
import { getKafkaWorkflow, getSchemaRegistryWorkflow } from "../docker/workflows";
import { LocalResourceWorkflow } from "../docker/workflows/base";
import { captureException } from "../errors";
import { Logger } from "../logging";
import { localResourcesQuickPick } from "../quickpicks/localResources";

Expand Down Expand Up @@ -115,7 +115,7 @@ export async function runWorkflowWithProgress(
workflow.sendTelemetryEvent("Workflow Errored", {
start,
});
Sentry.captureException(error, {
captureException(error, {
tags: {
dockerImage: workflow.imageRepoTag,
extensionUserFlow: "Local Resource Management",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Sentry from "@sentry/node";
import * as vscode from "vscode";
import { captureException } from "../errors";
import { Logger } from "../logging";
import { getTelemetryLogger } from "../telemetry/telemetryLogger";

Expand All @@ -18,7 +18,7 @@ export function registerCommandWithLogging(
logger.error(msg, e);
if (e instanceof Error) {
// capture error with Sentry (only enabled in production builds)
Sentry.captureException(e, { tags: { command: commandName } });
captureException(e, { tags: { command: commandName } });
// also show error notification to the user
vscode.window.showErrorMessage(`${msg} ${e.message}`, "Open Logs").then(async (action) => {
if (action !== undefined) {
Expand Down
4 changes: 2 additions & 2 deletions src/consume.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as Sentry from "@sentry/node";
import { utcTicks } from "d3-time";
import { Data } from "dataclass";
import { ObservableScope } from "inertial";
Expand All @@ -25,6 +24,7 @@ import {
} from "./clients/sidecar";
import { registerCommandWithLogging } from "./commands";
import { getExtensionContext } from "./context/extension";
import { captureException } from "./errors";
import { Logger } from "./logging";
import { type KafkaTopic } from "./models/topic";
import { kafkaClusterQuickPick } from "./quickpicks/kafkaClusters";
Expand Down Expand Up @@ -517,7 +517,7 @@ function messageViewerStartPollingCommand(
}
default: {
reportable = { message: "Something went wrong." };
Sentry.captureException(error, { extra: { status, payload } });
captureException(error, { extra: { status, payload } });
window
.showErrorMessage("Error response while consuming messages.", "Open Logs")
.then((action) => {
Expand Down
3 changes: 2 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import { observabilityContext } from "./context/observability";
import { ContextValues, setContextValue } from "./context/values";
import { EventListener } from "./docker/eventListener";
import { SchemaDocumentProvider } from "./documentProviders/schema";
import { captureException } from "./errors";
import { Logger, outputChannel } from "./logging";
import { SSL_PEM_PATHS, SSL_VERIFY_SERVER_CERT_DISABLED } from "./preferences/constants";
import { createConfigChangeListener } from "./preferences/listener";
Expand Down Expand Up @@ -92,7 +93,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<vscode
} catch (e) {
logger.error("Error activating extension:", e);
// if the extension is failing to activate for whatever reason, we need to know about it to fix it
Sentry.captureException(e);
captureException(e);
throw e;
}
// XXX: used for testing; do not remove
Expand Down
4 changes: 2 additions & 2 deletions src/scaffold.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as Sentry from "@sentry/node";
import * as vscode from "vscode";

import { posix } from "path";
Expand All @@ -9,6 +8,7 @@ import { getSidecar } from "./sidecar";

import { ExtensionContext, ViewColumn } from "vscode";
import { registerCommandWithLogging } from "./commands";
import { captureException } from "./errors";
import { getTelemetryLogger } from "./telemetry/telemetryLogger";
import { WebviewPanelCache } from "./webview-cache";
import { handleWebviewMessage } from "./webview/comms/comms";
Expand Down Expand Up @@ -167,7 +167,7 @@ async function applyTemplate(
}
} catch (e) {
logger.error("Failed to apply template", e);
Sentry.captureException(e);
captureException(e, { extra: { templateName: pickedTemplate.spec.display_name } });
const action = await vscode.window.showErrorMessage(
"There was an error while generating the project. Try again or file an issue.",
{ title: "Try again" },
Expand Down
5 changes: 2 additions & 3 deletions src/viewProviders/resources.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as Sentry from "@sentry/node";
import { randomUUID } from "crypto";
import * as vscode from "vscode";
import { CCLOUD_CONNECTION_ID, IconNames } from "../constants";
Expand All @@ -10,7 +9,7 @@ import {
localKafkaConnected,
localSchemaRegistryConnected,
} from "../emitters";
import { ExtensionContextNotSetError } from "../errors";
import { captureException, ExtensionContextNotSetError } from "../errors";
import { getLocalResources, LocalResourceGroup } from "../graphql/local";
import { getCurrentOrganization } from "../graphql/organizations";
import { Logger } from "../logging";
Expand Down Expand Up @@ -209,7 +208,7 @@ export async function loadCCloudResources(
// what went wrong since the user is effectively locked out of the CCloud resources for this org
const msg = `Failed to load Confluent Cloud environments for the "${currentOrg?.name}" organization.`;
logger.error(msg, e);
Sentry.captureException(e);
captureException(e);
vscode.window.showErrorMessage(msg, "Open Logs", "File Issue").then(async (action) => {
if (action === "Open Logs") {
vscode.commands.executeCommand("confluent.showOutputChannel");
Expand Down

0 comments on commit c988235

Please sign in to comment.