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

trapshot-widget

v1.0.4

Published

A TypeScript widget for bug reporting with screenshot capture, console logging, and server integration

Readme

TrapShot Widget

A TypeScript widget for bug reporting with screenshot capture, console logging, and server integration. This widget can be easily dropped into any web project to provide users with a seamless bug reporting experience.

Features

  • 🐛 Easy Bug Reporting - Floating widget with intuitive form
  • 📸 Screenshot Capture - Automatic screenshot capture using html2canvas
  • 📝 Console Log Collection - Captures and includes console logs
  • 🎨 Customizable Themes - Light and dark themes
  • 📱 Mobile Responsive - Works on all device sizes
  • 🔧 TypeScript Support - Full TypeScript definitions included
  • 🌐 Server Integration - Ready for backend integration
  • 📦 Multiple Build Formats - UMD for CDN, ES modules for bundlers
  • ⚡ Zero Dependencies - Only requires html2canvas for screenshots

Quick Start

CDN Usage (Standalone)

<!-- Include the widget -->
<script src="https://your-cdn.com/trapshot.js"></script>

<!-- Initialize -->
<script>
const trapShot = new TrapShot({
    position: 'bottom-right',
    theme: 'light',
    autoCapture: true,
    showConsoleToggle: true
});
</script>

NPM Installation

npm install trapshot-widget

ES Module Usage

import { TrapShot, type TrapShotOptions } from 'trapshot-widget';

const options: TrapShotOptions = {
    position: 'bottom-right',
    theme: 'light',
    autoCapture: true,
    showConsoleToggle: true,
    customLabels: ['frontend', 'production'],
    serverUrl: 'https://your-api.com/bugs'
};

const trapShot = new TrapShot(options);

Configuration Options

interface TrapShotOptions {
    position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
    theme?: 'light' | 'dark';
    autoCapture?: boolean;           // Auto-capture screenshot when opened
    showConsoleToggle?: boolean;     // Show console logs section
    customLabels?: string[];         // Custom labels to add to reports
    serverUrl?: string | null;       // URL for server submission
}

Default Values

{
    position: 'bottom-right',
    theme: 'light',
    autoCapture: true,
    showConsoleToggle: true,
    customLabels: [],
    serverUrl: null
}

API Reference

Constructor

const trapShot = new TrapShot(options?: TrapShotOptions);

Methods

// Initialize the widget (called automatically)
trapShot.init(): void

// Destroy the widget and cleanup
trapShot.destroy(): void

// Event handlers (override these)
trapShot.onBugReported(bugReport: BugReport): void
trapShot.onReportSubmitted(result: ServerResponse): void

Bug Report Object

When a bug is reported, the following object is created:

interface BugReport {
    title: string;                    // "[SEVERITY] Bug title"
    description: string;              // Description with category/severity
    consoleLogs: string[];            // Array of console log entries
    userAgent: string;                // Browser user agent
    url: string;                      // Current page URL
    timestamp: Date;                  // When the report was created
    screenshot?: string;              // Base64 encoded screenshot (if enabled)
    additionalInfo: {
        customLabels: string[];       // Your custom labels
    };
}

Server Integration

The widget can POST bug reports to your server endpoint:

const trapShot = new TrapShot({
    serverUrl: 'https://your-api.com/bugs'
});

// Handle successful submission
trapShot.onReportSubmitted = function(result) {
    console.log('Bug submitted:', result);
    // Show success message to user
};

Expected Server Response

interface ServerResponse {
    success: boolean;
    issueUrl?: string;      // Link to created issue (e.g., GitHub)
    message?: string;       // Success/error message
}

Example Server Handler (Node.js/Express)

app.post('/api/bugs', async (req, res) => {
    try {
        const bugReport = req.body;
        
        // Process the bug report
        // - Save to database
        // - Create GitHub issue
        // - Send notifications
        
        const issueUrl = await createGitHubIssue(bugReport);
        
        res.json({
            success: true,
            issueUrl: issueUrl,
            message: 'Bug report submitted successfully'
        });
    } catch (error) {
        res.status(500).json({
            success: false,
            message: error.message
        });
    }
});

Development

Prerequisites

  • Node.js 16+
  • npm or yarn

Setup

# Clone the repository
git clone <repository-url>
cd trapshot-widget

# Install dependencies
npm install

# Build the project
npm run build

# Start development server
npm run dev

Build Scripts

npm run build          # Build both library and widget
npm run build:lib      # Build TypeScript library
npm run build:widget   # Build standalone widget
npm run dev            # Start development server
npm run clean          # Clean dist folder

Project Structure

src/
├── types/
│   └── index.ts       # TypeScript type definitions
├── TrapShot.ts        # Main widget class
├── index.ts           # Library entry point
├── widget.ts          # Standalone widget entry point
└── styles.css         # Widget styles

dist/
├── trapshot.js        # Standalone widget (UMD)
├── trapshot.css       # Extracted CSS
├── index.js           # ES module version
├── index.d.ts         # TypeScript definitions
└── demo.html          # Demo page

examples/
└── demo.html          # Example usage

Browser Support

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+

Dependencies

  • html2canvas - For screenshot capture
  • Development only: TypeScript, Webpack, and build tools

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Changelog

v1.0.0

  • Initial TypeScript release
  • Improved folder structure
  • Added build system with Webpack
  • Full TypeScript support
  • UMD and ES module builds
  • Enhanced documentation

Support

For issues and questions:

  • Create an issue on GitHub
  • Check the examples folder for usage patterns
  • Review the TypeScript definitions for API details