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

fix(telemetry): correctly parse alerted date #8042

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 2 additions & 7 deletions packages/turbo-telemetry/src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ describe("TelemetryConfig", () => {
telemetry_enabled: true,
telemetry_id: "123456",
telemetry_salt: "private-salt",
telemetry_alerted: new Date(),
telemetry_alerted: new Date().toISOString(),
},
});

Expand Down Expand Up @@ -389,7 +389,7 @@ describe("TelemetryConfig", () => {
telemetry_enabled: true,
telemetry_id: "123456",
telemetry_salt: "private-salt",
telemetry_alerted: new Date(),
telemetry_alerted: new Date().toISOString(),
},
});

Expand All @@ -401,11 +401,6 @@ describe("TelemetryConfig", () => {
test("should set telemetry_alerted to current date and write the config if telemetry_alerted is undefined", (t) => {
const mockWriteFileSync = mock.fn();
t.mock.method(fs, "writeFileSync", mockWriteFileSync);
mock.timers.enable({
apis: ["Date"],
now: new Date("2021-01-01T00:00:00.000Z"),
});

const result = telemetryConfig.alertShown();

assert.equal(result, true);
Expand Down
4 changes: 2 additions & 2 deletions packages/turbo-telemetry/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ConfigSchema = z.object({
telemetry_enabled: z.boolean(),
telemetry_id: z.string(),
telemetry_salt: z.string(),
telemetry_alerted: z.date().optional(),
telemetry_alerted: z.string().optional(),
});

type Config = z.infer<typeof ConfigSchema>;
Expand Down Expand Up @@ -188,7 +188,7 @@ export class TelemetryConfig {
return true;
}

this.config.telemetry_alerted = new Date();
this.config.telemetry_alerted = new Date().toISOString();
this.tryWrite();
return true;
}
Expand Down