feat: add diagnostics and telemetry runtime
This commit is contained in:
@@ -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/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user