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

ct-debug

v1.0.1

Published

Headless Google Tag Manager (GTM) dataLayer wrapper and debug overlay for web applications

Readme

ct-debug

npm version CI Status License: MIT

A headless, zero-dependency Google Tag Manager (GTM) dataLayer wrapper and real-time debug overlay for web applications, Next.js, React, and single-page applications.

Decouple analytics instrumentation from your application logic while retaining full visibility into your dataLayer events without needing to launch GTM preview mode.


📥 Installation

npm install ct-debug
# or
yarn add ct-debug
# or
pnpm add ct-debug

🚀 How to Implement in Your App

1. Zero-Configuration Initialization

Call initGtmDebugger() once in your application's root layout or entry component:

Next.js (App Router: app/layout.tsx):

'use client';

import { useEffect } from 'react';
import { initGtmDebugger } from 'ct-debug';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  useEffect(() => {
    // ⚡ Zero-config: Automatically enables UI & Console logs in Development environment
    initGtmDebugger();
  }, []);

  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  );
}

Next.js (Pages Router: pages/_app.tsx):

import { useEffect } from 'react';
import { initGtmDebugger } from 'ct-debug';
import type { AppProps } from 'next/app';

export default function MyApp({ Component, pageProps }: AppProps) {
  useEffect(() => {
    initGtmDebugger();
  }, []);

  return <Component {...pageProps} />;
}

Vanilla JS / Vite:

import { initGtmDebugger } from 'ct-debug';

initGtmDebugger();

2. Pushing DataLayer Events

Import pushToDataLayer anywhere in your application (UI components, button handlers, form submissions):

import { pushToDataLayer } from 'ct-debug';

// Example: Button Click
const handleButtonClick = () => {
  pushToDataLayer('button_click', {
    button_name: 'hero_cta',
    category: 'engagement',
  });
};

// Example: User Signup Event
const handleUserSignup = (user) => {
  pushToDataLayer('sign_up', {
    method: 'email',
    user_id: user.id,
  });
};

⚡ Smart Environment Detection & URL Toggling

  • Development (NODE_ENV === 'development'): Debugger UI overlay and browser console logs are enabled automatically.
  • Production (NODE_ENV === 'production'): Debugger UI overlay is disabled automatically so end-users never see it.
  • URL Override: Want to open the overlay on Staging or Production? Add ?gtm_debug=true to any URL in your browser (e.g. https://yoursite.com/page?gtm_debug=true).

⚙️ Optional Configuration Options

initGtmDebugger(options) accepts optional parameters if you need custom behavior:

initGtmDebugger({
  gtmId: 'GTM-XXXXXXX', // Optional: automatically injects GTM script into <head>
  enableUi: true,       // Optional: force enable UI overlay
  debug: true,          // Optional: force enable console logging
});

📦 How to Publish ct-debug to npmjs.com

Follow these step-by-step instructions to publish the ct-debug package to npm:

Step 1: Login to your npm Account

If you haven't logged in on your terminal yet:

npm login

(Enter your npm username, password, and 2FA code)

Step 2: Verify Package Build

Run the build script to ensure all ESM (dist/index.mjs), CJS (dist/index.js), and TypeScript definitions (dist/index.d.ts) are generated cleanly:

npm run build

Step 3: Test Package Contents

Verify what files will be included in the published npm package:

npm pack --dry-run

Step 4: Publish to npm

For public publishing, run:

npm publish --access public

Step 5: Updating / Publishing New Versions

When you make updates in the future, bump the version before re-publishing:

# For bug fixes (1.0.0 -> 1.0.1)
npm version patch

# For new features (1.0.0 -> 1.1.0)
npm version minor

# For breaking changes (1.0.0 -> 2.0.0)
npm version major

# Then publish the new version
npm publish --access public

� How to Version, Push & Publish Automatically

The repository is configured with GitHub Actions (.github/workflows/publish.yml). Whenever you push a version tag (e.g. v1.0.1), GitHub Actions automatically:

  1. Builds & type-checks your code.
  2. Publishes the package to npmjs.com.
  3. Creates a GitHub Release with auto-generated release notes and attached .tgz package.

Step-by-Step Release Guide

1. One-Time Setup: Add npm Token to GitHub Secrets

If you haven't added your npm token to GitHub yet:

  1. Log in to npmjs.com > Access Tokens > Generate New Token (Automation or Granular with Read/Write for ct-debug).
  2. Go to GitHub repo mojahid2021/ct-debug > Settings > Secrets and variables > Actions.
  3. Click New repository secret:
    • Name: NPM_TOKEN
    • Secret: (Paste your npm token)

2. Make Code Changes & Commit

Make your code changes, then stage and commit them:

git add .
git commit -m "feat: updated dataLayer debug feature"

3. Bump Version (Creates Git Tag)

Use npm version to bump your package version. This automatically updates package.json and creates a corresponding git tag (e.g. v1.0.1):

  • Bug Fixes / Patch Release (1.0.01.0.1):

    npm version patch
  • New Feature Release (1.0.01.1.0):

    npm version minor
  • Breaking Change Release (1.0.02.0.0):

    npm version major

4. Push Commits & Tags to GitHub

Push your commits and the new tag to GitHub:

git push origin main --tags

⚡ What Happens Next Automatically:

Once pushed, GitHub Actions triggers the Publish Pipeline:

  • 📦 npmjs.com: ct-debug is compiled and published directly to npm.
  • 🚀 GitHub Releases: A new Release entry is published on https://github.com/mojahid2021/ct-debug/releases containing release notes and the build artifact.

🤝 Contributing

Contributions are welcome! Please see our Contributing Guide and Code of Conduct for details on how to set up the repository and submit pull requests.


📄 License

Distributed under the MIT License. Copyright © 2026 Mojahid.