
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Official JavaScript/TypeScript client for LogzAI — send logs to the LogzAI platform using the OpenTelemetry Protocol (OTLP).
npm install logzai-js
import logzai from 'logzai-js';
// Initialize LogzAI
logzai.init({
ingestToken: 'your-ingest-token',
ingestEndpoint: 'https://ingest.logzai.com',
serviceName: 'my-node-app',
environment: 'production'
});
// Send logs
logzai.info('Application started', { version: '1.0.0' });
logzai.error('Something went wrong', { error: 'details' });
// Cleanup
await logzai.shutdown();
<script type="module">
import logzai from 'logzai-js/browser';
// Initialize LogzAI
logzai.init({
ingestToken: 'your-ingest-token',
ingestEndpoint: 'https://ingest.logzai.com',
serviceName: 'my-web-app',
environment: 'production'
});
// Send logs
logzai.info('User action', { userId: '123', action: 'click' });
</script>
// Log levels
logzai.debug('Debug message', { key: 'value' });
logzai.info('Info message', { key: 'value' });
logzai.warn('Warning message', { key: 'value' });
logzai.error('Error message', { key: 'value' });
// Exception logging with stack traces
logzai.exception('Error occurred', new Error('Something failed'), {
userId: '123',
context: 'checkout',
});
// Wrap functions with spans for distributed tracing
await logzai.span('my-operation', async (span) => {
// Your operation here
span.setAttribute('custom.attribute', 'value');
return result;
}, { operation: 'database-query' });
logzai.init({
ingestToken: string; // Required: Your LogzAI ingest token
ingestEndpoint: string; // Required: LogzAI ingest endpoint
serviceName?: string; // Optional: Service name (default: 'app')
serviceNamespace?: string; // Optional: Service namespace (default: 'default')
environment?: string; // Optional: Environment (default: 'production')
mirrorToConsole?: boolean; // Optional: Also log to console (default: false)
timeoutMillis?: number; // Optional: Request timeout (default: 10000)
});
LogzAI supports a plugin system for easy integration with different frameworks and environments.
The browser plugin automatically captures JavaScript errors and unhandled promise rejections.
import logzai, { browserPlugin } from 'logzai-js/browser';
// Initialize LogzAI
logzai.init({
ingestToken: 'your-ingest-token',
ingestEndpoint: 'https://ingest.logzai.com',
serviceName: 'my-app',
});
// Enable automatic error capture
logzai.plugin('browser', browserPlugin);
import logzai, { browserPlugin } from 'logzai-js/browser';
import store from './store'; // Your Redux/Vuex store
logzai.init({ /* ... */ });
logzai.plugin('browser', browserPlugin, {
// Capture both errors and unhandled rejections (default: true)
captureErrors: true,
captureUnhandledRejections: true,
// Filter errors before logging
errorFilter: (error) => {
// Skip non-critical errors
return !error.message?.includes('ResizeObserver');
},
// Inject context from your application state
contextInjector: () => {
const state = store.getState();
return {
userId: state.user?.id,
userEmail: state.user?.email,
currentRoute: window.location.pathname,
};
},
// Custom error message formatting
messageFormatter: (error) => {
return `Error: ${error.message}`;
},
});
captureErrors (boolean, default: true): Enable window.onerror handlercaptureUnhandledRejections (boolean, default: true): Enable window.onunhandledrejection handlererrorFilter (function): Filter errors before logging. Return false to skip an error.contextInjector (function): Inject additional context (user info, route, etc.) into error logsmessageFormatter (function): Custom error message formattingThe Express plugin automatically logs HTTP requests, responses, and errors.
import express from 'express';
import logzai, { expressPlugin } from 'logzai-js';
const app = express();
logzai.init({ /* ... */ });
// Enable automatic request/response/error logging
logzai.plugin('express', expressPlugin, { app });
This will automatically:
POST /ingest/otel/logs -> 200 2.35simport express from 'express';
import logzai, { expressPlugin } from 'logzai-js';
const app = express();
logzai.plugin('express', expressPlugin, {
app,
// Skip health check endpoints
skipPaths: ['/health', '/metrics', '/favicon.ico'],
// Log slow requests (> 1 second)
slowRequestThreshold: 1000,
// Inject user context into all logs
contextInjector: (req) => ({
userId: req.user?.id,
userEmail: req.user?.email,
sessionId: req.sessionID,
}),
// Filter requests before logging
requestFilter: (req) => {
// Don't log static assets
return !req.path.match(/\.(css|js|png|jpg)$/);
},
// Log request bodies (careful with sensitive data!)
logRequestBody: true,
logResponseBody: false,
});
The Express plugin automatically creates OpenTelemetry spans for each HTTP request. All logs emitted during the request (including logs from your route handlers) are automatically associated with the request span, making it easy to trace the full lifecycle of a request.
app.post('/api/users', async (req, res) => {
// These logs will be automatically associated with the "POST /api/users" span
logzai.info('Validating user data', { email: req.body.email });
const user = await createUser(req.body);
logzai.info('User created successfully', { userId: user.id });
res.json({ success: true, userId: user.id });
// Span ends automatically when response is sent
// Log message: "POST /api/users -> 200 0.52s"
});
The span includes:
contextInjectorapp (required): Express application instancelogRequests (boolean, default: true): Log incoming requestslogResponses (boolean, default: true): Log responses with status codescaptureErrors (boolean, default: true): Capture and log errorsskipPaths (string[], default: []): Paths to skip (supports wildcards: '/api/*')slowRequestThreshold (number): Log requests slower than this (ms)requestFilter (function): Filter requests before loggingcontextInjector (function): Inject additional context (user info, session, etc.)logRequestBody (boolean, default: false): Include request body in logslogResponseBody (boolean, default: false): Include response body in logsYou can create your own plugins for custom integrations:
import type { LogzAIPlugin } from 'logzai-js';
const myPlugin: LogzAIPlugin<{ threshold: number }> = (instance, config) => {
// Setup your plugin
console.log('Plugin initialized with threshold:', config?.threshold);
// Use logzai instance methods
instance.info('Plugin loaded');
// Return cleanup function (optional)
return () => {
console.log('Plugin cleanup');
};
};
// Use your plugin
logzai.plugin('my-plugin', myPlugin, { threshold: 100 });
// Later, unregister the plugin
logzai.unregisterPlugin('my-plugin');
# Install dependencies
npm install
# Build the library
npm run build
# Run in development mode
npm run dev
The library is built using Vite and outputs multiple formats:
dist/logzai-js.es.js)dist/logzai-js.cjs.js)dist/logzai-js.umd.js)dist/index.d.ts)npm publish
MIT
FAQs
LogzAI JS - A TypeScript library for OpenTelemetry logging
The npm package logzai-js receives a total of 32 weekly downloads. As such, logzai-js popularity was classified as not popular.
We found that logzai-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.