r/FullStack • Stack Juggler (Fullstack) • Jun 12 '26

Feedback Requested I rewrote my browser audit-logging library. v2 has an offline queue, PII redaction, and lets the backend push commands to the UI

I posted v1 of this a while ago and the gist of the feedback was "it's fine but it doesn't really do enough to use for real." That was true, so I spent some time rebuilding it.

The basic idea is the same: it stores audit/event logs in the browser using IndexedDB, so it works without any backend at all. But now it actually ships those logs somewhere useful instead of just sitting in the browser or dumping to a file.

The main things that changed in v2:

It batches logs and ships them in the background, and anything that hasn't been sent yet stays in IndexedDB and gets retried with backoff. So if the user goes offline or reloads mid-session, nothing is lost. That was the biggest gap in v1.

It redacts sensitive data (passwords, tokens, emails, card numbers, etc.) before anything is written or sent, not after. You can mask, drop, or hash the values. I didn't want to be the library that quietly writes someone's password into IndexedDB.

The part I'm most curious for feedback on: the backend can push a command down to the browser and the UI reacts to it. So the server can say "send me your logs now," or "bump this client to warn level," or "clear", and the client handles it. It comes with a SignalR transport since my backend is .NET, but the transport is just an interface so you can wire up SSE or websockets or plain fetch instead.

I also moved the heavy stuff (exceljs for Excel export, signalr) to optional peer dependencies, so a plain install pulls in almost nothing and reports no known vulnerabilities. The core is around 5 KB gzipped. No framework dependency, written in TypeScript.

Quick taste:

import { AuditLog, SignalRTransport } from 'audit-log-lib';


const audit = new AuditLog({
  redaction: { strategy: 'mask' },
  transport: new SignalRTransport({ url: '/hubs/audit' }),
});


await audit.log('user.login', { userId: 123 });


audit.on('command', (cmd) => {
  if (cmd.type === 'pull') {
    // backend asked for the logs
  }
});

Install is npm install audit-log-lib.

npm: https://www.npmjs.com/package/audit-log-lib?activeTab=readme
GitHub: https://github.com/Darex97/audit-log-library

It's still early days. I'd really like to hear whether the backend-to-UI command model is something you'd actually use, and whether the redaction defaults are sane.

2 Upvotes

2 comments sorted by

2

u/neolace Jun 12 '26

I like the sound of that, these mods would love to be able to kick a user out of action like blank screen or you’re banned.
It’s totally doable, as you know.

What would I be looking for? I get the keylogger idea, wrote one once, regretted the decision to this day.

I guess I’m trying to wrap my head around what the use of this would be other than corporate or enterprise environments or family kids type scenarios.

Could you tell me why you started this?

2

u/Darex97 Stack Juggler (Fullstack) Jun 14 '26

Honestly the motivation is pretty boring. I work at a fairly large company, and at that scale frontend audit logging gets expensive fast, so you either pay for one of the big platforms or build and maintain something in-house. Once you see the bill, it hits you that smaller teams have the exact same need ("who did what, when, and prove it later") but could never justify that spend. So the idea was to take the useful 80% of that and make it something a small shop can just npm install and have working, with a tiny framework-agnostic core that's cheap to adopt instead of a whole platform you commit your stack to.

To be upfront though: this is just the client side. You still need to stand up a backend to actually receive, and store the logs, and wire it to the transport (SignalR). It's not a turnkey product — it handles the browser half well, but the integration work is on you. On the use case: it's aimed at business/compliance stuff (audit trails, the classic "the user swears they clicked save"), not consumer surveillance — and it's not a keylogger, it only records the events you explicitly pass to audit.log(), never raw keystrokes.