Open blokhin opened 1 year ago
Schema of logs
table:
CREATE TABLE logs (
id SERIAL PRIMARY KEY,
type TEXT NOT NULL,
value JSONB,
user_id INTEGER REFERENCES user (id),
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);
To logging events we can use one of two approaches:
logs
table;use a server side script to insert events to the logs
table;
API to retrieve logs /v0/logs
can accept http get method
Query parameter:
limit - optional default 1000
offset - optional
type - optional default all
user_ids - optional (example user_id=1,2,3
)
after - optional default now - 1 hour
To authorize access to the logs
table we can use one of two approaches:
@blokhin @knopki
@pyoner many thanks! To log events, I'd vote for:
- use database triggers to insert events to the logs table;
To authorize access, I'd vote for retrieving the admin users and checking if the request issuer is among them, which is, apparently:
- use a server side script
Probably /v0/logs
should use SSE for responding, shouldn't it?
Probably
/v0/logs
should use SSE for responding, shouldn't it?
@blokhin admin can use SSE for listening real-time events
partially implemented in https://github.com/basf/metis-bff/blob/master/routes/%5Bversion%5D/logs.js
The admin users should be able to claim their interest in the general events which do not concern their accounts. https://github.com/basf/metis-bff/blob/1dd1a04fb6b86d51de7705f2c1c5464724bd00c0/db_seed.js#L322-L336 Such general events are, mainly:
@pyoner has suggested to log such events and flush them to the user in the API. @knopki we should provision this somewhere in the API client.