@chamaeleonidae/chmln

中文文档
1.0.1发布于 2022/06/11Apache-2.0CommonJS零依赖近 30 天下载 94.3万

The official chameleon.io JavaScript client library

原始使用文档

Chameleon JavaScript Library

Easily add Chameleon to your product!

The Chameleon JavaScript Library is a set of methods attached to a global chmln object intended to be used by applications to display Chameleon Experiences to users.

Installation via NPM

This library is available as a package on NPM. To install into a project using NPM with a front-end packager such as Webpack or Browserify:

  npm install --save @chamaeleonidae/chmln

You can grab your token then require the lib like a standard Node.js module:

const chmln = require('@chamaeleonidae/chmln');

chmln.init('YOUR_TOKEN', { fastUrl: 'https://fast.chameleon.io/' });

Note for accounts created before 2022-05-21 you must omit the fastUrl If you're unsure, verify your account-specific instructions on the installation page.

chmln.init('YOUR_TOKEN');

To use Chameleon as first-party (i.e. via chameleon.your-product.com), first contact us to set this up, then use this updated script with your custom domain.

chmln.init('YOUR_TOKEN', { fastUrl: 'https://chameleon.your-product.com/' }); // << CHANGE ME

Usage

First, follow the installation process above. The script loads asynchronously and won’t affect your page loading times.

Next, identify your users by sending a unique ID (this normally matches the UIDs from your database). Without this, Chameleon can’t display Experiences to users. You should also send additional user data (such as “email address”, “role”) or company data (such as “plan type”, “subdomain”) so you can target Experiences to the right users, at the right time.

chmln.identify(USER.ID_IN_DB, {     // REQUIRED Unique ID of each user in your database (e.g. 23443 or "590b80e5f433ea81b96c9bf6")
  email: USER.EMAIL,                // RECOMMENDED Used to connect data coming from various integrations

  // SUGGESTED - User properties:
  created: USER.SIGN_UP_DATE,       // Send dates in ISO or unix timestamp format (e.g. "2017-07-01T03:21:10Z" or 1431432000)
  name: USER.NAME,                  // We will parse this to extra first and surnames (e.g. "James Doe")
  role: USER.ROLE,                  // Send properties useful for targeting types of users (e.g. "Admin")
  logins: USER.LOGIN_COUNT,         // Send any data about user engagement (e.g. 39)
  project: USER.PROJECT_ID,         // Send any unique data for a user that might appear in any page URLs (e.g. 09876 or "12a34b56")

  // OPTIONAL - Company properties:
  company: {                        // For B2B products, send company / account information here
    uid: COMPANY.ID_IN_DB,          // Unique ID of the company / account in your database (e.g. 9832 or "590b80e5f433ea81b96c9bf7")
    created: COMPANY.SIGN_UP_DATE,  // To enable targeting all users based on this company property
    name: COMPANY.NAME,             // Send any data that appears within URLs, such as subdomains (e.g. "airbnb")
    trial_ends: COMPANY.TRIAL_ENDS, // Send data about key milestones (e.g. "2017-08-01T03:21:10Z")
    version: COMPANY.VERSION,       // If your software varies by version then this will help show the correct guidance (e.g. "1.56")
    plan: COMPANY.PLAN,             // Send null when no value exists (e.g. "Gold", "Advanced")
    spend: COMPANY.CLV              // Send other properties that will help in targeting users (e.g. sales rep, source, stage)
  }
});

Optionally you have the ability to track user events:

chmln.track(PLAN_CHANGED);          // Example event "PLAN_CHANGED" can be used for targeting or measuring success
chmln.track(ACTIVATED);             // Having a defined activation point can be helpful for targeting onboarding experiences.

版本与发布记录

@chamaeleonidae/chmln 共发布 3 个版本,首次发布于 2021/08/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.1latest2022/06/114 年前
1.0.0-alpha.22021/08/195 年前
1.0.0-alpha.12021/08/195 年前

关于 @chamaeleonidae/chmln 的常见问题

@chamaeleonidae/chmln 是什么?

The official chameleon.io JavaScript client library

如何安装 @chamaeleonidae/chmln?

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

@chamaeleonidae/chmln 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/chamaeleonidae__chmln 是否存在。

@chamaeleonidae/chmln 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@chamaeleonidae/chmln 可以商用吗?

@chamaeleonidae/chmln 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@chamaeleonidae/chmln 的下载量有多少?

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

@chamaeleonidae/chmln 还在维护吗?

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