@segment/analytics-node
While the API is very similar, the documentation for the legacy SDK (`analytics-node`) is here: https://segment.com/docs/connections/sources/catalog/libraries/server/node/
Last updated 3 years ago by sethsegment .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @segment/analytics-node 
SYNC missed versions from official npm registry.

@segment/analytics-node

https://www.npmjs.com/package/@segment/analytics-node

OFFICIAL DOCUMENTATION (FULL)

LEGACY NODE SDK MIGRATION GUIDE:

Runtime Support

  • Node.js >= 18
  • AWS Lambda
  • Cloudflare Workers
  • Vercel Edge Functions
  • Web Workers / Browser (no device mode destination support)

Quick Start

Install library

# npm
npm install @segment/analytics-node
# yarn
yarn add @segment/analytics-node
# pnpm
pnpm install @segment/analytics-node

Usage

Assuming some express-like web framework.

import { Analytics } from '@segment/analytics-node'
// or, if you use require:
const { Analytics } = require('@segment/analytics-node')

// instantiation
const analytics = new Analytics({ writeKey: '<MY_WRITE_KEY>' })

app.post('/login', (req, res) => {
   analytics.identify({
      userId: req.body.userId,
      previousId: req.body.previousId
  })
  res.sendStatus(200)
})

app.post('/cart', (req, res) => {
  analytics.track({
    userId: req.body.userId,
    event: 'Add to cart',
    properties: { productId: '123456' }
  })
   res.sendStatus(201)
});

See our official documentation for more examples and information.

Settings & Configuration

See the documentation: https://segment.com/docs/connections/sources/catalog/libraries/server/node/#configuration

You can also see the complete list of settings in the AnalyticsSettings interface.

Current Tags

  • 2.3.0                                ...           latest (9 months ago)
  • 0.0.1-rc.3                                ...           old (3 years ago)

45 Versions

  • 2.3.0                                ...           9 months ago
  • 2.2.1                                ...           a year ago
  • 2.2.0                                ...           2 years ago
  • 2.1.3                                ...           2 years ago
  • 2.1.2                                ...           2 years ago
  • 2.1.1                                ...           2 years ago
  • 2.1.0                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.4                                ...           2 years ago
  • 1.1.3                                ...           2 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 1.0.0-beta.26                                ...           3 years ago
  • 1.0.0-beta.25                                ...           3 years ago
  • 1.0.0-beta.24                                ...           3 years ago
  • 1.0.0-beta.23                                ...           3 years ago
  • 1.0.0-beta.22                                ...           3 years ago
  • 1.0.0-beta.21                                ...           3 years ago
  • 1.0.0-beta.20                                ...           3 years ago
  • 1.0.0-beta.19                                ...           3 years ago
  • 0.0.1-rc.3                                ...           3 years ago
  • 0.0.1-beta.18                                ...           3 years ago
  • 0.0.1-beta.17                                ...           3 years ago
  • 0.0.1-beta.16                                ...           3 years ago
  • 0.0.1-beta.15                                ...           3 years ago
  • 0.0.1-beta.14                                ...           3 years ago
  • 0.0.1-beta.13                                ...           3 years ago
  • 0.0.1-beta.12                                ...           3 years ago
  • 0.0.1-beta.11                                ...           3 years ago
  • 0.0.1-beta.10                                ...           3 years ago
  • 0.0.1-beta.9                                ...           3 years ago
  • 0.0.1-beta.8                                ...           3 years ago
  • 0.0.1-beta.7                                ...           3 years ago
  • 0.0.1-beta.6                                ...           3 years ago
  • 0.0.1-beta.5                                ...           3 years ago
  • 0.0.1-beta.4                                ...           3 years ago
  • 0.0.1-beta.3                                ...           3 years ago
  • 0.0.1-beta.2                                ...           3 years ago
  • 0.0.1-beta.1                                ...           3 years ago
  • 0.0.1-rc.2                                ...           3 years ago
  • 0.0.1-rc.1                                ...           3 years ago
Maintainers (318)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |