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

brtspd-audit

v2.3.2

Published

`brtspd-audit` is a simple and effective JavaScript package for auditing user interactions on your website. The package logs clicks on elements with a specific `data-audit` attribute, enabling easy tracking of user activity. It also supports handling elem

Readme

brtspd-audit

brtspd-audit is a simple and effective JavaScript package for auditing user interactions on your website. The package logs clicks on elements with a specific data-audit attribute, enabling easy tracking of user activity. It also supports handling elements that are dynamically loaded in modals or popovers.

Table of Contents

Installation

To install brtspd-audit, you can use npm or yarn:

npm install brtspd-audit

or

yarn add brtspd-audit

Usage

The package exposes three primary functions: init, logAudit, and loadEntries. Each function provides different ways to handle audit logs based on your needs.

init

The init function automatically sets up event listeners for all elements with a data-audit attribute. It logs an audit entry when any of these elements are clicked.

init(options: InitOptions): void

InitOptions:

  • url: The URL to which the audit data will be sent.

  • user: The username of the person performing the action.

Example Usage

import { init } from 'brtspd-audit';

const options = {
  url: 'https://example.com/audit-log',
  user: 'john_doe'
};

init(options);

This function will attach click event listeners to all elements with the data-audit attribute. When clicked, it sends an audit log with the data available on the element (such as data-audit, data-audit-message, data-page), as well as the username provided in the InitOptions.

logAudit

The logAudit function allows you to manually log an audit entry. This is useful for cases where the element is inside a modal or popover, where the data-audit element may not be available in the DOM initially.

logAudit(options: LogAuditOptions): void

LogAuditOptions:

  • url: The URL to which the audit data will be sent.

  • meta: An object containing metadata for the audit log:

    • actionType: The type of action performed (e.g., "click").

    • message: A custom message describing the action.

    • user: The username of the person performing the action.

    • page: The name or URL of the page where the action occurred.

Example Usage

import { logAudit } from 'brtspd-audit';

const options = {
  url: 'https://example.com',
  meta: {
    actionType: 'click',
    message: 'Clicked button in modal',
    user: 'john_doe',
    page: 'modal-page'
  }
};

logAudit(options);

This function manually logs an audit entry with the provided metadata, regardless of whether the element was dynamically added to the page (e.g., inside a modal or popover).

loadEntries

The loadEntries function retrieves all the audit entries created so far from a specified URL.

loadEntries(options: EntriesOptions): AuditLogEntry[]

EntriesOptions

  • url: The URL from which to fetch the audit log entries.

Example Usage

import { loadEntries } from 'brtspd-audit';

const options = {
  url: 'https://example.com'
};

const logs = loadEntries(options);

console.log(logs); // An array of audit log entries

This function fetches the audit entries from the provided URL and returns them as JSON data.

Options

InitOptions

This object is used with the init function.

type InitOptions = {
  url: string;  // The URL where the audit logs will be sent
  user: string; // The user performing the actions
};

LogAuditOptions

This object is used with the logAudit function.

type LogAuditOptions = {
  url: string;  // The URL where the audit logs will be sent
  meta: {
    actionType: string; // Type of action (e.g., 'click', 'view')
    message: string;    // Custom message describing the action
    user: string;       // Username of the person performing the action
    page: string;       // Name or URL of the page where the action took place
  };
};

EntriesOptions

This object is used with the loadEntries function.

type EntriesOptions = {
  url: string; // The URL for which to load audit log entries
};

License

brtspd-audit is licensed under the MIT License.