CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/db-schema/central-log.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Table } from "./types";
7
8
Table({
9
name: "central_log",
10
fields: {
11
id: {
12
type: "uuid",
13
desc: "Random id for this event",
14
},
15
event: {
16
type: "string",
17
desc: "Event name which must start with 'webapp-' to not conflict with other names that might be used already (e.g., by the backend).",
18
},
19
value: {
20
type: "map",
21
desc: "Any JSON-type data for this event",
22
},
23
time: {
24
type: "timestamp",
25
desc: "When the event took place",
26
},
27
expire: {
28
type: "timestamp",
29
desc: "future date, when the entry will be deleted",
30
},
31
},
32
rules: {
33
desc: "Table for logging system stuff that happens. Meant for analytics, to help in running and understanding CoCalc better. Not read by the frontend clients at all, except admins.",
34
primary_key: "id",
35
durability: "soft", // loss of some log data not serious, since used only for analytics
36
pg_indexes: ["time", "event"],
37
user_query: {
38
get: {
39
admin: true,
40
fields: {
41
id: null,
42
event: null,
43
value: null,
44
time: null,
45
},
46
},
47
set: {
48
fields: {
49
id: true,
50
event: true,
51
value: true,
52
time: true,
53
},
54
check_hook: (_db, query, _account_id, _project_id, cb): void => {
55
if (!query.event.startsWith("webapp-")) {
56
cb("event must start with 'webapp-'");
57
} else {
58
cb();
59
}
60
},
61
},
62
},
63
},
64
});
65
66