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

@arraypress/waveform-tracker

v1.0.0

Published

Simple analytics tracking for WaveformPlayer

Readme

WaveformTracker

Lightweight analytics tracking for WaveformPlayer. Track meaningful audio engagement with minimal overhead.

Features

  • 🎯 Smart Tracking - Only tracks meaningful events (real listens, not bounces)
  • 🪶 Lightweight - ~2KB minified, <1KB gzipped
  • 🔌 Zero Config - Works out of the box with sensible defaults
  • 📊 Flexible - Send to any endpoint or handle events yourself
  • 🔒 Privacy-First - No user tracking, just content metrics

Installation

NPM

npm install @arraypress/waveform-tracker

CDN

<script src="https://unpkg.com/@arraypress/waveform-tracker@latest/dist/waveform-tracker.min.js"></script>

Quick Start

// Just track 30-second listens
WaveformTracker.init({
  endpoint: 'https://api.example.com/track',
  events: { listen: 30 }
});

That's it! The tracker automatically finds all WaveformPlayer instances and tracks them.

Configuration

Basic Options

WaveformTracker.init({
  // Where to send events (required unless using handler)
  endpoint: '/api/track',
  
  // What events to track
  events: {
    play: 3,        // Track play after 3 seconds
    listen: 30,     // Track listen after 30 seconds  
    complete: 90    // Track complete at 90%
  },
  
  // Optional: Add headers for authentication
  headers: {
    'Authorization': 'Bearer token123'
  },
  
  // Optional: Add metadata to all events
  metadata: {
    user_id: 123,
    post_id: 456
  }
});

WordPress Integration

// In your theme/plugin PHP:
wp_localize_script('my-script', 'tracker_config', [
    'endpoint' => admin_url('admin-ajax.php'),
    'nonce' => wp_create_nonce('track_audio')
]);

// In your JavaScript:
WaveformTracker.init({
  handler: (payload) => {
    jQuery.post(tracker_config.endpoint, {
      action: 'track_audio',
      nonce: tracker_config.nonce,
      ...payload
    });
  },
  events: { listen: 30 }
});

Custom Handler

WaveformTracker.init({
  handler: (payload) => {
    // Send to Google Analytics
    gtag('event', 'audio_' + payload.event, {
      event_label: payload.url,
      value: payload.time
    });
  },
  events: { listen: 30, complete: 90 }
});

Event Payload

Each event sends this data:

{
  "event": "listen",
  "url": "audio/episode-42.mp3",
  "time": 30,
  "duration": 180,
  "page": "/podcast/episode-42",
  "session": "abc123def456"
}

Events Explained

  • play: User started playback (filters out accidental clicks)
  • listen: User engaged meaningfully (e.g., 30+ seconds)
  • complete: User finished (or reached threshold like 90%)

Debug Mode

See what's being tracked without sending events:

WaveformTracker.init({
  endpoint: '/track',
  events: { listen: 30 },
  debug: true  // Logs to console instead of sending
});

License

MIT © ArrayPress

Related