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

error-reporting-client

v0.0.3

Published

JavaScript client for [Google Cloud Error Reporting](https://cloud.google.com/error-reporting/docs/grouping-errors).

Readme

Error Reporting Client for Client-side JavaScript

JavaScript client for Google Cloud Error Reporting.

It can be used in web browsers.

Inspired by stackdriver-errors-js, added the ability to insert the source location to the request body automatically, and changed the behavior if the source maps are available.

Prerequisites

See the Prerequisites in the stackdriver-errors-js package.

Installation

npm i error-reporting-client
# if you use pnpm
pnpm i error-reporting-client

Usage

import ErrorReporting from "error-reporting-client";

// Initialize the error reporting client with your API key and project ID
const reportClient = new ErrorReporting({
    apiKey: "YOUR_API_KEY",
    projectId: "YOUR_PROJECT_ID",
    // below are optional
    // 
    // service: "my-service",
    // version: "1.0.0",
    // reportUncaughtExceptions: true,
    // reportUnhandledPromiseRejections: true,
    // sourceReferences: [
    //     {
    //         repository: "",
    //         revisionId: "",
    //     },
    // ],
});

// Register the global error and unhandled promise rejection handlers
reportClient.registerHandler();

// Set the user identifier
reportClient.setUser("john-smith");

// Send an error report manually
try {
    // code that might throw an error
} catch(e) {
    reportClient.sendError(e);
}

// You can also provide a source location
reportClient.sendError(new Error("An error occurred"), {
    filePath: "src/App.tsx",
    lineNumber: 53,
    functionName: "App",
});

as a utility

// errorHandler.ts
import ErrorReporting from "error-reporting-client";

let errorHandler: ErrorReporting | undefined
if (typeof window !== "undefined" && typeof errorHandler === "undefined") {
    errorHandler = new ErrorReporting({
        apiKey: "YOUR_API_KEY",
        projectId: "YOUR_PROJECT_ID",
    })
    errorHandler.registerHandler()
}
export default errorHandler
import errorHandler from "./errorHandler"

errorHandler?.sendError(err);

API

ErrorReporting

constructor(options: { projectId: string; apiKey: string; service?: string; version?: string; reportUncaughtExceptions?: boolean; reportUnhandledPromiseRejections?: boolean; sourceReferences?: SourceReference[]; })

Creates a new instance of the ErrorReporting client.

  • projectId: Your Google Cloud project ID.
  • apiKey: Your Google Cloud API key.
  • service: (Optional) The service name. Defaults to "web".
  • version: (Optional) The version of the service.
  • reportUncaughtExceptions: (Optional) Whether to report uncaught exceptions. Defaults to true.
  • reportUnhandledPromiseRejections: (Optional) Whether to report unhandled promise rejections. Defaults to true.
  • sourceReferences: (Optional) A list of source references.

setUser(user: string | undefined): void

Sets the user identifier for error reports.

  • user: The user identifier.

disable(): void

Disables error reporting.

enable(): void

Enables error reporting.

registerHandler(): void

Registers global error and unhandled promise rejection handlers.

sendError(err: Error | string, reportLocation?: SourceLocation): Promise<void>

Sends an error report.

  • err: The error to report.
  • reportLocation: (Optional) The location in the source code where the error was reported. If not provided, the location is determined automatically.

SourceLocation

Indicates a location in the source code of the service for which errors are reported.

  • filePath: The source code filename, which can include a truncated relative path, or a full path from a production machine.
  • lineNumber: (Optional) 1-based. 0 indicates that the line number is unknown.
  • functionName: Human-readable name of a function or method. The value can include optional context like the class or package name.

SourceReference

A reference to a particular snapshot of the source tree used to build and deploy an application.

  • repository: (Optional) A URI string identifying the repository.
  • revisionId: The canonical and persistent identifier of the deployed revision.