Segment Analytics-Next

Segment's flagship JavaScript SDK for capturing and routing customer data

SDK
npm
v1.84.3
478 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
84 /100 Excellent
Development Activity 80
Maintenance 88
Community 80
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 85
Code Quality 80
Innovation 75
Learning Curve 78

Analytics-Next (Analytics 2.0) is Segment’s official browser SDK for instrumenting product and marketing analytics from a single API call. Instead of writing a bespoke integration for every downstream tool, teams call track, identify, and page once and let Segment’s plugin architecture fan the event out to hundreds of destinations — from Amplitude to Google Ads.

The SDK is built around a middleware/plugin pipeline that runs before, during, and after delivery, letting teams enrich, filter, or redirect events without touching application code. It ships as a monorepo alongside @segment/analytics-node and shared core packages, and is actively maintained by Segment as one of its most heavily used open-source libraries.

What You Get

  • A typed AnalyticsBrowser client with load, track, identify, page, group, and alias methods
  • A plugin/middleware system (before, enrichment, destination, after) for intercepting and transforming events
  • Built-in buffering so events fire before the destination loads and before user consent is confirmed
  • First-party integration with Segment’s cloud-mode and device-mode destinations without hand-writing vendor SDK calls
  • A companion @segment/analytics-node package for server-side tracking with the same event API

Common Use Cases

  • Sending product usage events (signups, feature clicks, purchases) to multiple analytics tools from one call site
  • Gating tracking behind a consent-management plugin (e.g. OneTrust) before any destination loads
  • Enriching events with session, page, or campaign context via custom middleware before they reach Segment
  • Migrating off direct vendor SDKs (GA, Amplitude, Mixpanel) to a single maintained tracking layer

Under The Hood

Architecture: The SDK centers on an Analytics/AnalyticsBrowser class (packages/browser/src/core/analytics) that dispatches typed calls (track, identify, page) through a Context-wrapped event queue (src/core/queue) into a plugin pipeline. Plugins are typed by phase — before, enrichment, destination, after — registered via src/plugins/* (e.g. ajs-destination, segmentio, routing-middleware), so vendor integrations and consent/enrichment logic are just plugins running at defined points rather than hardcoded branches, and the same event model is reused by the sibling @segment/analytics-node package via @segment/analytics-core.

Tech Stack: Pure TypeScript targeting ES5 for browser compatibility, built with a Yarn/Turborepo monorepo (turbo.json) spanning packages/browser, packages/node, packages/core, packages/consent, and shared config packages. Runtime dependencies are deliberately small — @lukeed/uuid, dset, js-cookie, unfetch/node-fetch — keeping the shipped bundle lean since this code loads on every page view for every Segment customer.

Code Quality: 70+ Jest test files back the browser package alone (src/core/analytics/__tests__/analytics.test.ts covers the public API surface), TypeScript strict mode is enabled project-wide, and ESLint/Prettier run via shared packages/config presets. Public interfaces are explicitly typed (interfaces.ts files alongside implementation), reducing the risk of silent breaking changes across the many destination plugins.

API Design: The public surface is deliberately minimal — AnalyticsBrowser.load({writeKey}) plus track/identify/page/group/alias — so most consumers never touch the plugin system directly, while power users can register custom middleware for consent gating or event enrichment. Buffered/lazy loading (new AnalyticsBrowser() then .load() later) is a well-documented escape hatch for consent-gated tracking, a common real-world requirement this SDK handles natively instead of leaving to userland code.

Used by 11 apps in this directory

TypeScript
100%
Other

Activepieces

AI Assistants · Automation · Mcp

24,756

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
64
Dependency
Built with
TypeScript 100%
Updated 4 days ago
TypeScript
96%
Other

Amplication

AI Code Assistants · Automation · Developer Tools

16,015

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
58
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
TypeScript
68%
Apache 2.0

Appsmith

Automation · Developer Tools · No Code Platforms

40,959

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript 68%
Java 21%
Updated 6 days ago
TypeScript
82%
MIT

evidence

Analytics · Data Engineering

6,962

Turn SQL queries and markdown files into polished, interactive data apps and business intelligence reports — no drag-and-drop, no GUI, just code.

View details
90
Repo Health
79
Technical
64
Dependency
Built with
TypeScript 82%
Svelte 17%
Updated 1 weeks ago
Go
64%
MIT

hoop

Monitoring · Security

823

A wire-protocol gateway that enforces data masking, command blocking, approval workflows, and full session recording for engineers and AI agents accessing production infrastructure.

View details
85
Repo Health
80
Technical
64
Dependency
Built with
Go 64%
Clojure 17%
JavaScript 11%
Updated 1 weeks ago
TypeScript
62%
MIT

Jitsu

Data Engineering

5,094

Open-source, fully-scriptable data ingestion engine that streams events from web, apps, and APIs to any data warehouse in real time.

View details
88
Repo Health
79
Technical
66
Dependency
Built with
TypeScript 62%
Go 36%
Updated 1 weeks ago
TypeScript
88%
MIT

medusa

Ecommerce

36,494

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
93
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 88%
JavaScript 12%
Updated 1 weeks ago
TypeScript
98%
Other

Novu

Developer Tools

40,084

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 98%
Updated 5 days ago
TypeScript
98%
Other

Novu

Developer Tools

40,084

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 98%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers