Skip to content

Commit 6539929

Browse files
add log module
1 parent 9632ebc commit 6539929

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

pnpm-lock.yaml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v-next/hardhat/src/internal/cli/telemetry/sentry/reporter.ts

+9
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import {
22
HardhatError,
33
HardhatPluginError,
44
} from "@ignored/hardhat-vnext-errors";
5+
import debug from "debug";
56

67
import { getHardhatVersion } from "../../../utils/package.js";
78
import { isTelemetryAllowed } from "../telemetry-permissions.js";
89

910
import { getSubprocessTransport } from "./transport.js";
1011

12+
const log = debug("hardhat:cli:telemetry:sentry:reporter");
13+
1114
// TODO: replace with PROD version
1215
// export const SENTRY_DSN =
1316
// "https://[email protected]/522486955555555555";
@@ -50,9 +53,12 @@ class Reporter {
5053

5154
if (!telemetryAllowed) {
5255
// No need to initialize Sentry because telemetry is disabled
56+
log("Reporter not initialized because telemetry is not allowed");
5357
return this.#instance;
5458
}
5559

60+
log("Initializing Reporter instance");
61+
5662
const { Integrations, init, setExtra } = await import("@sentry/node");
5763

5864
const linkedErrorsIntegration = new Integrations.LinkedErrors({
@@ -83,13 +89,16 @@ class Reporter {
8389
configPath: string = "",
8490
): Promise<boolean> {
8591
if (!(await this.shouldBeReported(error))) {
92+
log("Error not send: this type of error should not be reported");
8693
return false;
8794
}
8895

8996
const { captureException, setExtra } = await import("@sentry/node");
9097

9198
setExtra("configPath", configPath);
9299

100+
log("Capturing exception");
101+
93102
captureException(error);
94103

95104
// TODO: where to run it?

v-next/hardhat/src/internal/cli/telemetry/sentry/transport.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import type { Event, Response } from "@sentry/node";
22

33
import { spawnDetachedSubProcess } from "@ignored/hardhat-vnext-utils/subprocess";
4+
import debug from "debug";
5+
6+
const log = debug("hardhat:cli:telemetry:sentry:transport");
47

58
// This class is wrapped in a function to avoid having to
69
// import @sentry/node just for the BaseTransport base class
@@ -12,6 +15,8 @@ export async function getSubprocessTransport(): Promise<any> {
1215
const extra: { configPath?: string } = event.extra ?? {};
1316
const { configPath } = extra;
1417

18+
log("Processing event");
19+
1520
// Don't send user's full config path for privacy reasons
1621
delete event.extra?.configPath;
1722
// We don't care about the verbose setting
@@ -43,6 +48,8 @@ export async function getSubprocessTransport(): Promise<any> {
4348

4449
await spawnDetachedSubProcess(subprocessFile, args, env);
4550

51+
log("Exception sent to detached subprocess");
52+
4653
return {
4754
status: Status.Success,
4855
};

0 commit comments

Comments
 (0)