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

@junctionjs/destination-posthog

v0.2.0

Published

PostHog destination for Junction — web (device-mode) and server (cloud-mode)

Readme

@junctionjs/destination-posthog

PostHog destination for Junction, offered as two tree-shakeable factories mirroring the web (device-mode) vs server (cloud-mode) split.

  • createPostHogWeb — loads posthog-js on the page. Full library: sessionization, person profiles, session replay, feature flags, browser-signal enrichment. Junction stays the event source of truth (autocapture/pageview off by default).
  • createPostHogServer — forwards events to PostHog's HTTP capture API. No replay, flags, or client sessionization. The "just get events into my dataset" path.

Import only the one you need — the other is eliminated by tree-shaking. posthog-js is loaded from PostHog's CDN at runtime, never bundled.

Install

npm install @junctionjs/destination-posthog

Web (device-mode)

import { createPostHogWeb } from "@junctionjs/destination-posthog";

const posthogWeb = createPostHogWeb({
  apiKey: "phc_...",
  host: "https://us.i.posthog.com", // or eu.i.posthog.com / self-hosted
  sessionReplay: false,             // opt in when you want replay
});

Server (cloud-mode)

import { createPostHogServer } from "@junctionjs/destination-posthog";

const posthogServer = createPostHogServer({
  apiKey: "phc_...",
  batchSize: 20,        // buffer then POST to /batch; 1 = per-event /capture
  flushIntervalMs: 5000,
  maxRetries: 3,
});

Configuration

| Option | Web | Server | Default | Notes | |---|---|---|---|---| | apiKey | ✓ | ✓ | — | PostHog project API key (required) | | host | ✓ | ✓ | https://us.i.posthog.com | EU cloud or self-hosted URL | | consent | ✓ | ✓ | ["analytics"] | Consent categories (AND logic) | | eventNameMap | ✓ | ✓ | — | Override entity:action → PostHog event name | | loadScript | ✓ | — | true | Inject the posthog-js snippet | | scriptUrl | ✓ | — | ${host}/static/array.js | Reverse-proxy / self-host override | | sessionReplay | ✓ | — | false | Enable session recording | | autocapture | ✓ | — | false | Let posthog-js autocapture on its own | | capturePageview | ✓ | — | false | Junction owns page:viewed by default | | batchSize | — | ✓ | 20 | Buffer size before flush to /batch | | flushIntervalMs | — | ✓ | 5000 | Max time between flushes | | maxRetries | — | ✓ | 3 | Retries with exponential backoff | | maxBufferSize | — | ✓ | 1000 | Cap on buffered events while flushes fail; oldest dropped past it |