Openstatus
www.openstatus.dev
1import { Tinybird } from "@chronark/zod-bird";
2
3import { AuditLog } from "./client";
4
5const tb = new Tinybird({ token: process.env.TINY_BIRD_API_KEY || "" });
6
7const auditLog = new AuditLog({ tb });
8
9// biome-ignore lint/correctness/noUnusedVariables: <explanation>
10async function seed() {
11 await auditLog.publishAuditLog({
12 id: "monitor:2",
13 action: "monitor.failed",
14 targets: [{ id: "2", type: "monitor" }],
15 metadata: { region: "gru", statusCode: 500, message: "timeout" },
16 });
17 await auditLog.publishAuditLog({
18 id: "monitor:1",
19 action: "monitor.recovered",
20 targets: [{ id: "1", type: "monitor" }],
21 metadata: { region: "gru", statusCode: 200 },
22 });
23 await auditLog.publishAuditLog({
24 id: "user:1",
25 actor: {
26 type: "user",
27 id: "1",
28 },
29 targets: [{ id: "1", type: "user" }],
30 action: "notification.sent",
31 metadata: { provider: "email" },
32 });
33}
34
35// biome-ignore lint/correctness/noUnusedVariables: <explanation>
36async function history() {
37 return await auditLog.getAuditLog({ event_id: "user:1" });
38}
39
40// seed();
41// const all = await history();
42// console.log(all);
43// const first = all.data[0];
44
45// if (first.action === "monitor.failed") {
46// first.metadata.message;
47// }