@flinkk/audit
v1.0.4
Published
Shared Datadog audit and logging utilities for Flinkk CRM
Readme
@flinkk/audit
Shared Datadog RUM/logging and Microsoft Clarity instrumentation for Flinkk applications. Each app wires these in once at the root layout; nothing here talks to a database or holds any tenant data itself.
Exports
| Subpath | What it is |
| --- | --- |
| @flinkk/audit/datadog | <DataDogScript /> — injects the Datadog RUM browser agent via next/script. No-ops if NEXT_PUBLIC_DATADOG_CLIENT_TOKEN isn't set. |
| @flinkk/audit/datadog/client | <DataDogRUM config={...} /> — same RUM injection, but with an explicit config object instead of reading applicationId/site/service from module-level constants. |
| @flinkk/audit/datadog/server | Server-side structured logger built on pino (createLogger(config)), with trace-injection and PII-redaction options. |
| @flinkk/audit/datadog/edge | Edge-runtime-safe variant (no Node-only APIs). |
| @flinkk/audit/datadog/user-context | <DataDogUserContext /> — a client component that reads the NextAuth session and attaches userId/tenantId to the active RUM session once authenticated. |
| @flinkk/audit/datadog/dd-trace-init | Node-only dd-trace initialization, imported for its side effect at process startup. |
| @flinkk/audit/microsoft-clarity | <MicrosoftClarity /> — injects the Microsoft Clarity tracking snippet. No-ops if NEXT_PUBLIC_MICROSOFT_CLARITY_ID isn't set. |
Usage
// app/layout.tsx
import { DataDogScript } from "@flinkk/audit/datadog";
import { MicrosoftClarity } from "@flinkk/audit/microsoft-clarity";
import DataDogUserContext from "@flinkk/audit/datadog/user-context";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>
<DataDogScript />
<MicrosoftClarity />
<DataDogUserContext />
{children}
</body>
</html>
);
}// any server module
import { createLogger } from "@flinkk/audit/datadog/server";
const log = createLogger({ serviceName: "sales-api" });
log.info({ tenantId }, "quote created");Environment variables
NEXT_PUBLIC_DATADOG_CLIENT_TOKEN— required for the RUM script to render.NEXT_PUBLIC_MICROSOFT_CLARITY_ID— required for the Clarity script to render.NEXT_PUBLIC_ENVIRONMENT,NEXT_PUBLIC_APP_VERSION— tagged onto RUM sessions.
License
ISC License - Internal Flinkk library
