@traceora/node
v0.4.8
Published
Shared Node.js instrumentation (AsyncLocalStorage, Prisma, Mongoose) for Traceora
Maintainers
Readme
The shared backend core that powers both
@traceora/expressand@traceora/next. ContainsAsyncLocalStoragecontext management, database plugins, and theemitTraceEventfunction.
📥 Installation
npm install @traceora/node✨ Exports
| Export | Description |
|---|---|
| emitTraceEvent() | Pushes a custom event into the current request's trace context. Safe no-op outside a request. |
| traceoraPrismaExtension() | Prisma client extension — auto-traces every query with filters, args, and execution time. |
| traceoraMongoosePlugin | Mongoose plugin — auto-traces every operation. |
🔧 Usage
Note: You generally don't need this package directly unless you're building a custom backend integration (e.g., for Fastify, NestJS, tRPC) or emitting manual events.
Emit Custom Events
If your app is already wrapped in a Traceora context (via @traceora/express or @traceora/next), you can emit custom events that appear in the frontend DevTools:
import { emitTraceEvent } from '@traceora/node';
export async function processPayment() {
emitTraceEvent({
type: 'NETWORK_REQUEST',
source: 'Stripe API',
metadata: {
action: 'charge',
status: 'success',
},
});
}Auto-Track Prisma
import { PrismaClient } from '@prisma/client';
import { traceoraPrismaExtension } from '@traceora/node';
const prisma = new PrismaClient().$extends(traceoraPrismaExtension());Auto-Track Mongoose
import mongoose from 'mongoose';
import { traceoraMongoosePlugin } from '@traceora/node';
mongoose.plugin(traceoraMongoosePlugin);🔗 Related Packages
| Package | Role |
|---|---|
| @traceora/express | Express middleware that uses this package |
| @traceora/next | Next.js adapter that uses this package |
