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

Add chainId to telemetry stats for ignition #5212

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 5 additions & 0 deletions .changeset/afraid-buses-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Add chainId to telemetry stats for ignition
15 changes: 14 additions & 1 deletion packages/hardhat-core/src/internal/cli/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
writeTelemetryConsent,
} from "../util/global-dir";
import { getPackageJson } from "../util/packageInfo";
import { HardhatRuntimeEnvironment } from "../../types";
import { confirmTelemetryConsent } from "./prompt";

const log = debug("hardhat:core:analytics");
Expand Down Expand Up @@ -58,6 +59,7 @@ interface TaskHitPayload extends AnalyticsPayload {
session_id?: string;
scope?: string;
task?: string;
chainId?: string;
};
}>;
}
Expand Down Expand Up @@ -119,7 +121,8 @@ export class Analytics {
*/
public async sendTaskHit(
scopeName: string | undefined,
taskName: string
taskName: string,
hre: HardhatRuntimeEnvironment
): Promise<[AbortAnalytics, Promise<void>]> {
if (!this._enabled) {
return [() => {}, Promise.resolve()];
Expand All @@ -130,9 +133,19 @@ export class Analytics {
(scopeName === "ignition" && taskName === "deploy") ||
(scopeName === undefined && taskName === "deploy")
) {
let chainId: number | undefined;
try {
chainId = Number(
await hre.network.provider.request({
method: "eth_chainId",
})
);
} catch {}

eventParams = {
scope: scopeName,
task: taskName,
chainId: chainId?.toString(),
kanej marked this conversation as resolved.
Show resolved Hide resolved
};
}

Expand Down
3 changes: 2 additions & 1 deletion packages/hardhat-core/src/internal/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ async function main() {

const [abortAnalytics, hitPromise] = await analytics.sendTaskHit(
scopeName,
taskName
taskName,
env
);

let taskArguments: TaskArguments;
Expand Down
Loading