Skip to content

Commit db06025

Browse files
zoeyTMalcuadrado
authored andcommitted
add chainId to telemetry stats for ignition
1 parent 221f640 commit db06025

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/hardhat-core/src/internal/cli/analytics.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
writeTelemetryConsent,
1616
} from "../util/global-dir";
1717
import { getPackageJson } from "../util/packageInfo";
18+
import { HardhatRuntimeEnvironment } from "../../types";
1819
import { confirmTelemetryConsent } from "./prompt";
1920

2021
const log = debug("hardhat:core:analytics");
@@ -58,6 +59,7 @@ interface TaskHitPayload extends AnalyticsPayload {
5859
session_id?: string;
5960
scope?: string;
6061
task?: string;
62+
chainId?: string;
6163
};
6264
}>;
6365
}
@@ -119,7 +121,8 @@ export class Analytics {
119121
*/
120122
public async sendTaskHit(
121123
scopeName: string | undefined,
122-
taskName: string
124+
taskName: string,
125+
hre: HardhatRuntimeEnvironment
123126
): Promise<[AbortAnalytics, Promise<void>]> {
124127
if (!this._enabled) {
125128
return [() => {}, Promise.resolve()];
@@ -130,9 +133,19 @@ export class Analytics {
130133
(scopeName === "ignition" && taskName === "deploy") ||
131134
(scopeName === undefined && taskName === "deploy")
132135
) {
136+
let chainId: number | undefined;
137+
try {
138+
chainId = Number(
139+
await hre.network.provider.request({
140+
method: "eth_chainId",
141+
})
142+
);
143+
} catch {}
144+
133145
eventParams = {
134146
scope: scopeName,
135147
task: taskName,
148+
chainId: chainId?.toString(),
136149
};
137150
}
138151

packages/hardhat-core/src/internal/cli/cli.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ async function main() {
271271

272272
const [abortAnalytics, hitPromise] = await analytics.sendTaskHit(
273273
scopeName,
274-
taskName
274+
taskName,
275+
env
275276
);
276277

277278
let taskArguments: TaskArguments;

0 commit comments

Comments
 (0)