feat: add diagnostics and telemetry runtime

This commit is contained in:
donghyeon-ka
2026-07-26 16:42:27 +09:00
parent 2fa0baa577
commit 5173b6c8d6
43 changed files with 1760 additions and 116 deletions
+15 -1
View File
@@ -52,7 +52,10 @@ describe("TanStack QueryCachePort adapter", () => {
it("normalizes adapter exceptions without raw key data", async () => {
const client = new QueryClient();
vi.spyOn(client, "invalidateQueries").mockRejectedValue(new Error("secret-key"));
const adapter = createQueryCacheAdapter(client);
const record = vi.fn();
const adapter = createQueryCacheAdapter(client, {
diagnostics: { record },
});
const result = await adapter.invalidate(["resource", "sensitive-filter"]);
expect(result).toMatchObject({
@@ -60,5 +63,16 @@ describe("TanStack QueryCachePort adapter", () => {
error: { kind: "QUERY_CACHE_FAILURE" },
});
expect(JSON.stringify(result)).not.toContain("sensitive-filter");
expect(record).toHaveBeenCalledWith({
level: "warn",
eventId: "cache.operation.failed",
context: {
operation: "invalidate",
error_kind: "QUERY_CACHE_FAILURE",
},
});
expect(JSON.stringify(record.mock.calls)).not.toMatch(
/sensitive-filter|secret-key/,
);
});
});