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

slack-tracker

v4.0.5

Published

A simple Slack logger that sends logs to a Slack channel via a webhook URL

Readme

slack-tracker

Simple Slack logging for Node.js and browser applications using Slack Incoming Webhooks.

slack-tracker sends formatted logs, block messages, and raw Slack payloads to a Slack channel. Server-side code sends directly to Slack. Browser code sends to your own backend proxy route so your Slack webhook URL stays private.

Features

  • Node.js and browser support
  • TypeScript declarations included
  • Slack Incoming Webhook support
  • Direct server-side Slack delivery
  • Browser-safe proxy delivery
  • Simple log levels with Slack colors
  • Raw Slack Block Kit payload support
  • Build-before-publish workflow with only dist exposed in the npm package

Installation

npm install slack-tracker
yarn add slack-tracker
pnpm add slack-tracker

Demo

Live demo:

https://stackblitz.com/edit/stackblitz-starters-5gwmyjxy?file=index.js

Download code from stackblitz

cd demo
npm start

Open:

http://localhost:3030

Configuration

Call slackLogConfig() once when your app starts, such as in onload, oninit, bootloader, module loader, app constructor, or server startup code.

import { slackLogConfig } from "slack-tracker";

slackLogConfig({
  webhookUrl: "https://hooks.slack.com/services/XXX/YYY/ZZZ",
  enable: true,
});

Config options:

  • webhookUrl: Slack Incoming Webhook URL. Required on the server.
  • enable: Set false to disable Slack logs.
  • proxy_url: Optional browser proxy route.

If slackLogConfig() is not called before logging, the package prints a console error and skips the log.

Type:

slackLogConfig({
  webhookUrl: string,
  enable: boolean,
  proxy_url?: string,
});

Basic Usage

const { LogLevel, slack, slackLogConfig } = require("slack-tracker");

slackLogConfig({
  webhookUrl: "https://hooks.slack.com/services/XXX/YYY/ZZZ",
  enable: true,
});

await slack.log("Server started", { port: 3000 }, LogLevel.SUCCESS);
await slack.log("User created", { id: 101, email: "[email protected]" });
await slack.log("Validation warning", { field: "email" }, LogLevel.WARN);
await slack.log(
  "Unhandled error",
  { message: "Something failed" },
  LogLevel.ERROR,
);
import { LogLevel, slack, slackLogConfig } from "slack-tracker";

slackLogConfig({
  webhookUrl: "https://hooks.slack.com/services/XXX/YYY/ZZZ",
  enable: true,
});

await slack.log(
  "Payment received",
  { amount: 49, currency: "USD" },
  LogLevel.INFO,
);

Log Levels

LogLevel.DEFAULT;
LogLevel.SUCCESS;
LogLevel.INFO;
LogLevel.WARN;
LogLevel.ERROR;

Each level adds a label, icon, and color to the Slack message.

Block Message Usage

Use logBlockMessage when you want to send multiple titled values.

import { LogLevel, slack } from "slack-tracker";

await slack.logBlockMessage(
  "Order created",
  [
    { title: "Order ID", value: "ORD-1001" },
    { title: "Amount", value: 129.99 },
    { title: "Customer", value: { id: 12, name: "Jane Doe" } },
  ],
  LogLevel.SUCCESS,
);

Raw Slack Payload

Use raw when you need full control over the Slack payload.

import { slack } from "slack-tracker";

await slack.raw({
  text: "Deployment completed",
  blocks: [
    {
      type: "section",
      text: {
        type: "mrkdwn",
        text: "*Deployment completed successfully*",
      },
    },
    {
      type: "context",
      elements: [
        {
          type: "mrkdwn",
          text: "Environment: production",
        },
      ],
    },
  ],
});

Browser Usage

Browser usage is supported. The browser build does not send requests directly to Slack. It posts log requests to your backend proxy route.

import { LogLevel, slack, slackLogConfig } from "slack-tracker";

slackLogConfig({
  enable: true,
});

await slack.log("Button clicked", { page: "/pricing" }, LogLevel.INFO);

The browser request is sent to:

/api/slack-tracker

Do not put your Slack webhook URL in browser config. Use only enable and proxy_url in the browser. Configure webhookUrl only in the server/proxy runtime.

Set proxy_url only when your proxy route is different.

slackLogConfig({
  enable: true,
  proxy_url: "/api/logs/slack",
});

Next.js Proxy Route

Create app/api/slack-tracker/route.ts:

import { handleSlackLogsRequest, slackLogConfig } from "slack-tracker";

slackLogConfig({
  webhookUrl: process.env.SLACK_WEBHOOK_URL,
  enable: true,
});

export async function POST(request: Request) {
  const body = await request.json();
  const result = await handleSlackLogsRequest(body);

  return Response.json(
    {
      success: result.success,
      message: result.message,
    },
    {
      status: result.status,
    },
  );
}

Express Proxy Route

const express = require("express");
const { handleSlackLogsRequest, slackLogConfig } = require("slack-tracker");

const app = express();

slackLogConfig({
  webhookUrl: process.env.SLACK_WEBHOOK_URL,
  enable: true,
});

app.use(express.json());

app.post("/api/slack-tracker", async (req, res) => {
  const result = await handleSlackLogsRequest(req.body);

  res.status(result.status).json({
    success: result.success,
    message: result.message,
  });
});

API

slack.log(label, data, errorType?)

Sends a formatted Slack log message.

slack.log("Label", { any: "value" }, LogLevel.INFO);

slack.logBlockMessage(label, objectData, errorType?)

Sends a Slack message with titled fields.

slack.logBlockMessage("Label", [{ title: "Status", value: "OK" }]);

slack.raw(payload)

Sends a custom Slack webhook payload.

slack.raw({ text: "Hello Slack" });

handleSlackLogsRequest(body)

Handles browser proxy requests and sends them to Slack from your server.

const result = await handleSlackLogsRequest(body);

slackLogConfig(config)

Stores Slack config once for later log calls.

slackLogConfig({
  webhookUrl: "https://hooks.slack.com/services/XXX/YYY/ZZZ",
  enable: true,
});

Call this before slack.log, slack.logBlockMessage, slack.raw, or handleSlackLogsRequest.