Segment Analytics-Next

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

SDK
npm
v1.84.1
476stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
84/100Excellent
Development Activity80
Maintenance88
Community80
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture85
Code Quality80
Innovation75
Learning Curve78

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
99%
Other

Activepieces

Automation · AI Assistants

24,298

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
TypeScript99%
Updated today
TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,011

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
60
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 2 months ago
TypeScript
68%
Apache 2.0

Appsmith

Developer Tools · Automation · No Code Platforms

40,825

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
TypeScript68%
Java21%
Updated 3 days ago
TypeScript
82%
MIT

evidence

Analytics · Data Engineering

6,911

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
87
Repo Health
79
Technical
64
Dependency
Built with
TypeScript82%
Svelte18%
Updated 3 days ago
Go
60%
MIT

hoop

Security · Monitoring

807

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
Go60%
Clojure19%
JavaScript14%
Updated 3 days ago
TypeScript
57%
MIT

Jitsu

Data Engineering

5,063

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
TypeScript57%
Go41%
Updated 3 days ago
TypeScript
86%
MIT

medusa

Ecommerce

36,163

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
TypeScript86%
JavaScript14%
Updated 2 days ago
TypeScript
98%
Other

Novu

Developer Tools

39,870

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
TypeScript98%
Updated yesterday
TypeScript
98%
Other

Novu

Developer Tools

39,870

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
TypeScript98%
Updated yesterday

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

Search