npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@traceo-sdk/node

v0.34.1

Published

Library for integration with the [Traceo Platform](https://github.com/traceo-dev/traceo).

Readme

Traceo SDK for Node.js

Library for integration with the Traceo Platform.

Installation

To install this SDK add this package to your package.json like below:

yarn add @traceo-sdk/node

or

npm install @traceo-sdk/node

Usage

First what you need is to initialize TraceoClient in your application.

import { TraceoClient } from "@traceo-sdk/node";

new TraceoClient(<project_api_key>, {
    host: <traceo_host>
});

TraceoClient constructor required two attribtues. First one in api key which you can generate in project settings. Second is an object contains required attribute host which specifies the address where your Traceo Platform instance is located. Address should be passed in the format <protocol>://<domain>:<port>, eq. http://localhost:3000.

Incidents handling

Incidents are all the exceptions and other problems that occur in your application. After each exception occurs, the Traceo SDK catches the exception and sends it to the Traceo Platform. This package provide the two main ways to catch exceptions in your application - Handlers and Middlewares.

Handlers

The easiest way is to use ExceptionsHandlers.catchException() in try-catch clause like below:

import { ExceptionHandlers } from "@traceo-sdk/node";

try {
    //your code
} catch (error) {
    ExceptionHandlers.catchException(error);
}

If you use NestJS framework then you can also create Interceptor to catch exceptions like below:

traceo.interceptor.ts

import { ExceptionHandlers } from "@traceo-sdk/node";
//other imports

@Injectable()
export class TraceoInterceptor implements NestInterceptor {
  intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
    return next.handle().pipe(
      tap(null, (exception) => {
        ExceptionHandlers.catchException(exception);
      }),
    );
  }
}

main.ts

  app.useGlobalInterceptors(new TraceoInterceptor());
Middleware

Another approach is to use ExceptionMiddlewares.errorMiddleware(). If you use the Express.js framework, you can use our middleware like below:

Javascript:

import { ExceptionMiddlewares } from "@traceo-sdk/node";

app.use(ExceptionMiddlewares.errorMiddleware());

Typescript:

const { ExceptionMiddlewares } from "@traceo-sdk/node";

app.use(ExceptionMiddlewares.errorMiddleware() as express.ErrorRequestHandler);

Remember that ExceptionMiddlwares.errorMiddleware() should be before any other error middlewares and after all routes/controllers.

Middleware options

| Parameter | Description | Default | | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | | allowLocalhost | If false then middleware doesn't catch exceptions from requests coming from localhost | true | | allowHttp | If false then middleware doesn't catch exceptions received from requests where req.protocol = http and catch only exception received with https | true |

Logger

The Traceo SDK can be used also as a logger. Each log is saved on the Traceo Platform, thanks to which it is possible to later easily access the recorded information. Logs are sent to Traceo in every 60 seconds. To change this behavior, set a custom value (measured in seconds) in the scrapLogsInterval field inside traceo client properties like below:

import { TraceoClient } from "@traceo-sdk/node";

new TraceoClient(<project_api_key>, {
    host: <traceo_host>,
    scrapLogsInterval: 120 //in seconds
});

Example of using logger:

import { Logger } from "@traceo-sdk/node";

const traceo = new TraceoClient({...});

traceo.logger.log("Traceo");

The logger can use 5 different types of log: log, info, debug, warn, error. Each function responsible for logging the appropriate log type accepts a list of arguments in the parameter.

traceo.logger.log("Traceo", "Example", "Log");
// [TraceoLogger][LOG] - 31.10.2022, 13:55:45 - Traceo Example Log

traceo.logger.debug("Traceo", {
    hello: "World"
});
// [TraceoLogger][DEBUG] - 31.10.2022, 13:58:00 - Traceo { hello: 'World' }

Metrics

To activate the collection of metrics from your application, set the parameter collectMetrics in your TraceoClient to true:

new TraceoClient({ collectMetrics: true });

Metrics are collected from the application every 30 seconds. If you want to collect metrics at a different time interval then you can use the scrapMetricsInterval parameter.

new TraceoClient({ scrapMetricsInterval: <interval_in_seconds> });

Remember that provided scrapMetricsInterval can't be less than 15 seconds.

Support

Feel free to create Issues, Pull Request and Discussion. If you want to contact with the developer working on this package click here.