feat(diagnostics): correlate staff operations errors and audit records
This commit is contained in:
1 parent
440ce4e556
commit
a2954e4408
14 files changed
+473
-110
No files matched your search
@@ -8,6 +8,7 @@ import {
|
||||
WebsiteArticles,
|
||||
} from "@/db/schema";
|
||||
import type { db } from "@/lib/db";
|
||||
import { getOperationContext } from "@/lib/foundation/request-context";
|
||||
import { type HistorySnapshot, sameSnapshot } from "./model";
|
||||
export type HistoryKind = "category" | "category_bc" | "prices" | "news";
|
||||
export type HistoryTransaction = Parameters<
|
||||
@@ -117,8 +118,10 @@ export async function recordHistory(
|
||||
action,
|
||||
target: kind,
|
||||
targetId: Number(id) <= 2147483647 ? Number(id) : null,
|
||||
details:
|
||||
Number(id) > 2147483647 ? JSON.stringify({ targetId: String(id) }) : null,
|
||||
details: JSON.stringify({
|
||||
...getOperationContext(),
|
||||
...(Number(id) > 2147483647 ? { targetId: String(id) } : {}),
|
||||
}),
|
||||
before: serializedBefore,
|
||||
after: serializedAfter,
|
||||
createdAt: new Date().toISOString(),
|
||||
|
||||
Reference in new issue
Block a user