@amplitude/identify

中文文档
1.10.2发布于 2022/09/08MITTypeScriptESM + CJS近 30 天下载 130.3万

Utility functions to build and interact with the Identify API

原始使用文档
文档目录3 节
  1. Compatibility with Amplitude-Javascript
  2. Group Identify
  3. Clear All


npm version

General

Utility functions to build and interact with the Identify API with the Node SDK. This is a builder library to help interface with creating Identify events. These events help add user properties to users and devices in your analytics, and do not count towards the event volume.

To use this, create an Identify instance and use the provided functions to set properties, chaining along function calls:

import { Identify } from '@amplitude/identify'

const identify = new Identify();
identify
  .set('start_date', 'March 3rd')
  .add('num_clicks', 4)
  .unset('needs_to_activate')

Then, this can be used with the Node SDK to send an identify call. Because identify calls are special events, there are two different ways to accomplish this:

import Amplitude from '@amplitude/node';

const client = Amplitude.init('YOUR_API_KEY');

// One way to call the identify
client.identify('USER_ID', 'DEVICE_ID', identify);
// Equivalent way to call identify
// Can also modify the identifyEvent directly here
const identifyEvent = identify.identifyUser('USER_ID', 'DEVICE_ID');
client.logEvent(identifyEvent);

Compatibility with Amplitude-Javascript

This is not compatible with the Amplitude Javascript SDK (amplitude-js). This package should not be used with that SDK, and the identify API provided there should not be used with the Node SDK. There are plans to consolidate these incompatibilities .

Group Identify

This identify supports the setGroup function. Any identify operation calls made on this object will also be treated as a group identify call. Certain operations will not be transferred to the group properties (see the docs on the Group Identify API to see which properties are supported here).

To not associate a user with the group identify, you can also use the identifyGroup function to send $groupIdentify events for a group.

Clear All

Clear all will clear all user properties from the user and device on all events going forward. Use this carefully and make sure this is something you want to do instead of creating a new user/device id. When clear all is used on the identify builder, all other operations are canceled and no new operations can be added. This is because clear all must be sent as its own identify object.

版本与发布记录

@amplitude/identify 共发布 23 个版本,首次发布于 2021/01/30;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.10.2latest2022/09/084 年前
1.10.12022/08/304 年前
1.10.02022/04/014 年前
1.9.22022/02/014 年前
1.9.12021/11/114 年前
1.9.02021/10/155 年前

关于 @amplitude/identify 的常见问题

@amplitude/identify 是什么?

Utility functions to build and interact with the Identify API

如何安装 @amplitude/identify?

在项目目录运行 npm install @amplitude/identify,或使用 pnpm add / yarn add / bun add。

@amplitude/identify 支持 TypeScript 吗?

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

@amplitude/identify 支持 ESM 还是 CommonJS?

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

@amplitude/identify 需要什么版本的 Node.js?

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

@amplitude/identify 可以商用吗?

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

@amplitude/identify 的下载量有多少?

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

@amplitude/identify 还在维护吗?

最新版本 1.10.2 发布于 2022/09/08(4 年前);至今共发布 23 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/01/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。