@payfit/audit-log
v3.17.7
Published
Library to handle audit logs at Payfit
Keywords
Readme
Audit logs SDK
The SDK is an npm package that sends audit-log records to the durable SQS ingest queue.
Using the SDK in your project
First, install it :
npm i @payfit/audit-logThen, you must instanciate a client :
import { AuditLogger } from '@payfit/audit-log'
const logger = new AuditLogger({
environment: 'dev', // must be one of: dev, staging, prod
service: 'the-name-of-the-service',
})You can finally write an audit log:
logger.log({
namespace: 'payroll',
target: 'employee.bonus',
event: 'create',
payload: {
amount: 200,
},
account: {
internalId: 'an internal id',
individualId: 'an invidiaul id',
employeeId: 'an employee id',
},
scope: {
employeeId: 'another employee id',
companyId: 'a company id',
},
})Contributing
Building the SDK
The SDK's transport is maintained TypeScript code. It publishes records to SQS and retains the public AuditLogger contract while the consumer persists records directly to Aurora.
To build it, simply run
corepack yarn nx run sdk:buildfrom the repository root (where the workspace package.json is located).
Testing
For now, no unit tests have been written, but it should arrive soon !
Playing around with he SDK
Could it be for testing some changes you made, or just to discover how to use the SDK, there is a playground at your disposal.
It uses the current code in the repository, not the published one, so you don't have to npm publish or npm link to make it work 🙂
To run it, run from the repository root:
corepack yarn workspace @payfit/audit-log start:playground