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

@d8a-tech/gd

v0.34.0

Published

GA4 network request duplicator (browser inline script) - TypeScript source + minified dist build.

Readme

GA4 Duplicator

Intercepts Google Analytics 4 (GA4) collect requests and duplicates them to a D8A server endpoint.

What it does

This library provides browser-based network interception to duplicate GA4 analytics calls. It intercepts requests made to Google Analytics and forwards them to a configured D8A server endpoint, enabling parallel data collection.

Supported interception methods:

  • Fetch API requests
  • XMLHttpRequest calls
  • navigator.sendBeacon calls
  • Script tag loads

Usage

Include the built script in your HTML and initialize the duplicator:

<script src="dist/gd.min.js"></script>
<script>
  window.createGA4Duplicator({
    server_container_url: "https://your-d8a-endpoint.com",
    debug: false
  });
</script>

Configuration Options

  • server_container_url: Default D8A server endpoint URL. Can be overridden for each destination.
  • destinations: Array of destination objects with measurement_id, server_container_url, and optional convert_to_get (default: []).
  • debug: Enable debug logging (default: false).
  • convert_to_get: Convert POST requests into multiple GET requests (default: false). This is useful for environments that don't support POST or when you want to split batched requests into individual hits.

Multiple Destinations

window.createGA4Duplicator({
  server_container_url: "https://default-endpoint.com",
  destinations: [
    {
      measurement_id: "G-ABC123",
      server_container_url: "https://endpoint1.com",
    },
    {
      measurement_id: "G-XYZ789",
      server_container_url: "https://endpoint2.com",
      convert_to_get: true
    }
  ]
});

Build

Production build (minified):

npm run build:prod

Output: dist/gd.min.js

Development build:

npm run build:dev

Output: dist/gd.js

Source Code Hashing

The build process generates a SHA256 hash of all TypeScript source files in the src/ directory and saves it to src.hash. This ensures build integrity and enables CI verification.

Verify source code integrity:

npm run hash

This command compares the stored hash with the current source code hash:

  • Exit code 0: Source code matches the hash (build is up-to-date)
  • Exit code 1: Source code has changed since last build

Use this in CI pipelines to ensure dist/ files are regenerated when source code changes.

Test

Unit tests:

npm test

End-to-end tests:

  1. Install Playwright browsers (first time only):
npx playwright install chromium
  1. Run e2e tests:
npm run test:e2e

The e2e tests start a local HTTP server and use Playwright to verify that GA4 requests are properly duplicated to the D8A endpoint.

Manual testing:

Open test.html in a browser to manually test different network interception methods. The page includes buttons to trigger various types of GA4 requests and displays logs of duplication activity.