mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-09-28 05:54:50 +08:00
* fix: unify Canvas PostHog identity * fix: preserve funnel events across backend transitions * fix: preserve telemetry consent through cloud login * fix: isolate Canvas telemetry from host PostHog * fix: preserve telemetry during client startup * fix: centralize Canvas telemetry ownership * fix: make telemetry lifecycle atomic --------- Co-authored-by: neubig <neubig@users.noreply.github.com>
58 lines
1.2 KiB
TypeScript
58 lines
1.2 KiB
TypeScript
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
import { trackError } from "#/utils/error-handler";
|
|
import { trackException } from "#/services/telemetry";
|
|
|
|
vi.mock("#/services/telemetry", () => ({
|
|
trackException: vi.fn(),
|
|
}));
|
|
|
|
describe("Error Handler", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
describe("trackError", () => {
|
|
it("should send error to PostHog with basic info", () => {
|
|
const error = {
|
|
message: "Test error",
|
|
source: "test",
|
|
};
|
|
|
|
trackError(error);
|
|
|
|
expect(trackException).toHaveBeenCalledWith(
|
|
new Error("Test error"),
|
|
{
|
|
error_source: "test",
|
|
},
|
|
);
|
|
});
|
|
|
|
it("should include additional metadata in PostHog event", () => {
|
|
const error = {
|
|
message: "Test error",
|
|
source: "test",
|
|
metadata: {
|
|
extra: "info",
|
|
details: { foo: "bar" },
|
|
},
|
|
};
|
|
|
|
trackError(error);
|
|
|
|
expect(trackException).toHaveBeenCalledWith(
|
|
new Error("Test error"),
|
|
{
|
|
error_source: "test",
|
|
extra: "info",
|
|
details: { foo: "bar" },
|
|
},
|
|
);
|
|
});
|
|
});
|
|
});
|