npm.io
3.12.5 • Published 8h ago

@elliemae/pui-diagnostics

Licence
MIT
Version
3.12.5
Deps
2
Size
5.2 MB
Vulns
0
Weekly
0

Diagnostics Library

pui-diagnostics is a framework-agnostic JavaScript library for logging messages from web applications, following ICEMT logging guidelines.

Build SonarQube Report

Documentation

Quick Start

import {
  logger,
  http,
  logUnhandledErrors,
  webvitals,
} from '@elliemae/pui-diagnostics';

const appLogger = logger({
  transport: http('https://int.api.ellielabs.com/diagnostics/v2/logging'),
  index: 'myapp',
  team: 'my team',
  appName: 'Hello World App',
});

logUnhandledErrors(appLogger);
webvitals(appLogger);

appLogger.info('Application launched');

Reducing API Load

The HTTP transport supports options to control log volume:

const transport = http('https://api.ellielabs.com/diagnostics/v2/logging', {
  flushInterval: 15000, // flush batched logs every 15s (default: 10s)
  maxBatchSize: 50, // flush early at 50 buffered logs (default: 50)
  maxLogsPerInterval: 200, // cap non-critical logs per window (default: unlimited)
  samplingRate: 0.5, // send ~50% of non-critical logs (default: 1 = all)
});

WARN, ERROR, and FATAL logs are always sent immediately and bypass batching, sampling, and rate limiting.

Documentation

Migration Guide