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 🙏

© 2025 – Pkg Stats / Ryan Hefner

erralytics

v1.0.0

Published

Lib para rastrear erros HTTP e disparar eventos para ferramentas analíticas (dataLayer ou gtag)

Readme

errAlytics

npm version License: MIT

errAlytics é uma biblioteca leve e flexível para rastrear erros HTTP no navegador. Ela realiza uma requisição HEAD para a URL especificada (ou para a URL atual) e dispara eventos analíticos para ferramentas como o Google Tag Manager (via dataLayer – padrão) ou via gtag, conforme sua configuração.

Recursos

  • Monitoramento de Erros HTTP: Suporte para códigos de status comuns, como 400, 401, 403, 404, 408, 429, 500, 502, 503 e 504.
  • Disparo de Eventos Analíticos: Integração simples para disparar eventos no dataLayer (padrão) ou via gtag.
  • Configuração Personalizável: Permite sobrescrever o método de rastreamento e customizar os eventos disparados para cada código HTTP.
  • Compatibilidade UMD: Bundle gerado em formato UMD para uso em ambientes com módulos (ES/CommonJS) e via CDN.

Instalação

Via npm

npm install err-alytics
pnpm add err-alytics

Uso

Em um Projeto com Módulos (ES6/Node) Importe a classe e instancie-a, passando (opcionalmente) sua configuração personalizada. Por padrão, o método de rastreamento é o dataLayer.

import ErrAlytics from 'err-alytics';

const tracker = new ErrAlytics({
  // A configuração padrão já abrange:
  // 400: bad_request, 401: unauthorized, 403: forbidden, 404: page_not_found, 408: request_timeout,
  // 429: too_many_requests, 500: server_error, 502: bad_gateway, 503: service_unavailable, 504: gateway_timeout
  // Você pode sobrescrever ou adicionar novas configurações se necessário.
});

// Rastreia a URL atual (ou passe outra URL como parâmetro)
tracker.track().then((response) => {
  console.log('Status verificado:', response.status);
});

Usando via CDN

<!DOCTYPE html>
<html lang="pt-BR">
<head>
  <meta charset="UTF-8">
  <title>Exemplo errAlytics via CDN</title>
  <!-- Inclua o bundle UMD da lib -->
  <script src="https://cdn.jsdelivr.net/npm/err-alytics/dist/err-alytics.umd.js"></script>
</head>
<body>
  <script>
    // A lib estará disponível globalmente como HttpErrorTracker
    const tracker = new HttpErrorTracker({
      // Para usar gtag em vez de dataLayer, basta alterar:
      // trackingMethod: 'gtag'
    });
    tracker.track();
  </script>
</body>
</html>

TODO

[] Monitoramento de Erros JavaScript: Implementar uma camada adicional que capture erros JavaScript globais (por exemplo, via window.onerror ou window.addEventListener('error')) e dispare eventos analíticos, integrando essa funcionalidade à lib.