@distributed/analytics-node

中文文档
4.2.24发布于 2024/03/19MITTypeScriptESM + CJS近 30 天下载 2947

The hassle-free way to integrate analytics into any Node.js application

原始使用文档
文档目录7 节
  1. How to get started
  2. Why?
  3. 🚀 Startup Program
  4. Installation
  5. Usage
  6. Documentation
  7. License

@distributed/analytics-node

A Node.js client for [Segment](https://segment.com) — The hassle-free way to integrate analytics into any application.

Code Style npm version License MIT
dependencies Circle CI npm downloads Package Phobia Bundle Phobia

You can't fix what you can't measure

Analytics helps you measure your users, product, and business. It unlocks insights into your app's funnel, core business metrics, and whether you have product-market fit.

How to get started

  1. Collect analytics data from your app(s).
    • The top 200 Segment companies collect data from 5+ source types (web, mobile, server, CRM, etc.).
  2. Send the data to analytics tools (for example, Google Analytics, Amplitude, Mixpanel).
    • Over 250+ Segment companies send data to eight categories of destinations such as analytics tools, warehouses, email marketing and remarketing systems, session recording, and more.
  3. Explore your data by creating metrics (for example, new signups, retention cohorts, and revenue generation).
    • The best Segment companies use retention cohorts to measure product market fit. Netflix has 70% paid retention after 12 months, 30% after 7 years.

Segment collects analytics data and allows you to send it to more than 250 apps (such as Google Analytics, Mixpanel, Optimizely, Facebook Ads, Slack, Sentry) just by flipping a switch. You only need one Segment code snippet, and you can turn integrations on and off at will, with no additional code. Sign up with Segment today.

Why?

  1. Power all your analytics apps with the same data. Instead of writing code to integrate all of your tools individually, send data to Segment, once.

  2. Install tracking for the last time. We're the last integration you'll ever need to write. You only need to instrument Segment once. Reduce all of your tracking code and advertising tags into a single set of API calls.

  3. Send data from anywhere. Send Segment data from any device, and we'll transform and send it on to any tool.

  4. Query your data in SQL. Slice, dice, and analyze your data in detail with Segment SQL. We'll transform and load your customer behavioral data directly from your apps into Amazon Redshift, Google BigQuery, or Postgres. Save weeks of engineering time by not having to invent your own data warehouse and ETL pipeline.

    For example, you can capture data on any app:

    analytics.track('Order Completed', { price: 99.84 });
    

    Then, query the resulting data in SQL:

    select * from app.order_completed
    order by price desc
    

🚀 Startup Program

If you are part of a new startup (<$5M raised, <2 years since founding), we just launched a new startup program for you. You can get a Segment Team plan (up to $25,000 value in Segment credits) for free up to 2 years — apply here!

Installation

$ npm install @distributed/analytics-node

Usage

import { Analytics } from 'distributed/analytics-node';

const client = new Analytics('write key');

async function createUser() {
  const user = await db.create({ username: 'foo', password: 'bar' });

  await client.identify({
    userId: user.id,

    traits: {
      username: user.username,
    },
  });
}

Documentation

Documentation is available at https://segment.com/libraries/node.

License

Copyright © 2017 Segment Inc. <[email protected]>

版本与发布记录

@distributed/analytics-node 共发布 72 个版本,首次发布于 2020/07/14;过去 12 个月发布了 0 个版本。

版本发布日期距今
4.2.24latest2024/03/192 年前
4.2.232024/03/032 年前
4.2.222023/11/222 年前
4.2.212023/11/043 年前
4.2.202023/10/053 年前
4.2.192023/04/283 年前

关于 @distributed/analytics-node 的常见问题

@distributed/analytics-node 是什么?

The hassle-free way to integrate analytics into any Node.js application

如何安装 @distributed/analytics-node?

在项目目录运行 npm install @distributed/analytics-node,或使用 pnpm add / yarn add / bun add。

@distributed/analytics-node 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@distributed/analytics-node 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@distributed/analytics-node 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=14.7。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@distributed/analytics-node 可以商用吗?

@distributed/analytics-node 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@distributed/analytics-node 的下载量有多少?

根据 npm 官方下载统计,@distributed/analytics-node 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,947 次,日均约 98 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@distributed/analytics-node 还在维护吗?

最新版本 4.2.24 发布于 2024/03/19(2 年前);至今共发布 72 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/07/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。