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

@thred-apps/thred-track

v1.1.5

Published

Browser SDK for lead tracking and enrichment from ChatGPT referrals

Readme

Thred SDK

A modern TypeScript SDK for browser tracking and lead enrichment from ChatGPT referrals.

Features

  • 🎯 ChatGPT Detection - Automatic detection of visitors from ChatGPT
  • 🔒 Browser Fingerprinting - Privacy-friendly visitor identification
  • 📊 Page View Tracking - Anonymous page view analytics
  • 📝 Form Tracking - Automatic form submission tracking
  • 💼 Lead Enrichment - Capture and enrich lead data
  • 🚀 Zero Dependencies - Lightweight with no external dependencies
  • 📦 Multiple Formats - UMD, CommonJS, and ES modules
  • 🔧 TypeScript Support - Full TypeScript definitions included

Installation

NPM

npm install thred-track

Yarn

yarn add thred-track

CDN (Script Tag)

<script src="https://unpkg.com/thred-track/dist/thred-track.umd.js?browserKey=YOUR_KEY"></script>

Quick Start

Auto-Initialize (Script Tag)

Add the script with your browser key, and it will auto-initialize:

<script src="./dist/thred-track.umd.js?browserKey=751fe47a-d4f5-496a-ba9c-fb298c281e8a"></script>

The SDK will automatically:

  • Detect ChatGPT referrals
  • Generate browser fingerprint
  • Track page views
  • Monitor form submissions

Manual Initialization (Module)

import { ThredSDK } from 'thred-track';

const thred = new ThredSDK({
  browserKey: 'your-browser-key',
  debug: true,
  autoInit: false, // Control initialization
});

// Initialize manually
await thred.init();

API Reference

Constructor Options

interface ThredOptions {
  browserKey: string;      // Required: Your Thred browser key
  baseUrl?: string;        // Optional: API base URL (default: https://api.thred.dev/v1)
  debug?: boolean;         // Optional: Enable debug logging (default: false)
  autoInit?: boolean;      // Optional: Auto-initialize on construction (default: true)
}

Methods

init(): Promise<void>

Initialize the SDK manually (only needed if autoInit: false).

await thred.init();

trackPageView(): Promise<void>

Manually track a page view event.

await thred.trackPageView();

identify(leadData: LeadData): Promise<void>

Identify a user and enrich lead data.

await thred.identify({
  name: 'John Doe',
  email: '[email protected]',
  company: 'Acme Inc',
});

trackFormSubmit(formData: FormData): Promise<void>

Manually track a form submission.

const form = document.getElementById('myForm');
const formData = new FormData(form);
await thred.trackFormSubmit(formData);

getFingerprint(): string | null

Get the current browser fingerprint (synchronous).

const fingerprint = thred.getFingerprint();

isFromChatGPT(): boolean

Check if the visitor came from ChatGPT.

if (thred.isFromChatGPT()) {
  console.log('Visitor from ChatGPT!');
}

destroy(): void

Clean up the SDK instance and remove event listeners.

thred.destroy();

Usage Examples

Basic Form Tracking

<form id="form">
  <input type="text" name="name" required>
  <input type="email" name="email" required>
  <input type="text" name="company">
  <button type="submit">Submit</button>
</form>

<script src="./dist/thred-track.umd.js?browserKey=YOUR_KEY"></script>

Programmatic Tracking

import { ThredSDK } from 'thred-track';

const thred = new ThredSDK({
  browserKey: 'your-key',
  debug: true,
});

// Track custom events
await thred.trackPageView();

// Identify users manually
document.querySelector('#signup-btn').addEventListener('click', async () => {
  await thred.identify({
    name: userName,
    email: userEmail,
    company: userCompany,
  });
});

React Integration

import { useEffect, useState } from 'react';
import { ThredSDK } from 'thred-track';

function App() {
  const [thred] = useState(() => new ThredSDK({
    browserKey: process.env.REACT_APP_THRED_KEY,
    debug: process.env.NODE_ENV === 'development',
  }));

  useEffect(() => {
    return () => thred.destroy();
  }, [thred]);

  const handleSubmit = async (formData) => {
    await thred.identify({
      name: formData.name,
      email: formData.email,
      company: formData.company,
    });
  };

  return <YourApp onSubmit={handleSubmit} />;
}

Development

Setup

# Install dependencies
npm install

# Build the SDK
npm run build

# Run in watch mode
npm run dev

# Run tests
npm test

# Lint code
npm run lint

# Format code
npm run format

Project Structure

thred-track/
├── src/
│   ├── core/           # Core SDK functionality
│   │   ├── api.ts      # API client
│   │   ├── fingerprint.ts  # Fingerprint management
│   │   └── tracker.ts  # Event tracking
│   ├── utils/          # Utility functions
│   │   ├── detector.ts # ChatGPT detection
│   │   └── logger.ts   # Logging utility
│   ├── types/          # TypeScript definitions
│   │   └── index.ts
│   ├── __tests__/      # Test files
│   └── index.ts        # Main entry point
├── examples/           # Usage examples
├── dist/               # Build output
├── thred-track.js           # Original implementation (reference)
└── package.json

Building

The SDK builds to multiple formats:

  • UMD (dist/thred-track.umd.js) - For script tags
  • CommonJS (dist/index.js) - For Node.js
  • ES Module (dist/index.esm.js) - For bundlers
  • TypeScript (dist/index.d.ts) - Type definitions

Testing

Run the test suite:

npm test

# Watch mode
npm run test:watch

Local Testing

Serve examples locally:

npm run serve

Then open http://localhost:8080/basic.html?utm_source=chatgpt

Configuration

The SDK fetches configuration from your Thred API:

{
  "enabled": true,
  "formId": "form",
  "emailId": "email",
  "nameId": "name",
  "companyId": "company",
  "hasChatSession": true
}

Privacy & Security

  • Only tracks visitors from ChatGPT (opt-in by source)
  • Uses browser fingerprinting (no cookies required)
  • All tracking controlled by API configuration
  • No PII collected without explicit user submission
  • Compliant with privacy regulations (GDPR, CCPA)

Browser Support

  • Chrome/Edge (latest)
  • Firefox (latest)
  • Safari (latest)
  • Opera (latest)

Requires ES2015+ support.

API Endpoints

  • Config: GET /v1/config?browserKey={key}
  • Page View: POST /v1/events/page-view?browserKey={key}
  • Enrich: POST /v1/customers/enrich?browserKey={key}

TypeScript

Full TypeScript support with exported types:

import type {
  ThredOptions,
  ThredConfig,
  LeadData,
  PageViewPayload,
  EnrichPayload,
} from 'thred-track';

License

MIT

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Support

For questions or issues, please open a GitHub issue or contact [email protected].