@esri/telemetry

中文文档
9.1.2发布于 2026/10/23Apache-2.0TypeScriptESM + CJS零依赖近 30 天下载 1.3万

A JavaScript Implementation of the ArcGIS Telemetry Specification

原始使用文档
文档目录10 节
  1. Table of Contents
  2. Installation
  3. Usage
  4. Terminology
  5. Privacy Tracking Consent
  6. In Browser
  7. In Server
  8. Issues
  9. Contributing
  10. License

@esri/telemetry

This is the "core" package for ArcGIS-Telemetry.js. It is necessary for sending data to analytics platforms such as Google, Adobe, and AWS.

Table of Contents

Installation

npm install @esri/telemetry

Usage

Terminology

  • Telemetry: the vendor-agnostic collection and routing interface for usage signals.
  • Plugin: the external-facing integration term used in documentation and in the plugins configuration array.
  • Tracker: the internal code-level actor/interface used by the core runtime.
  • Analytics: downstream destination/reporting systems (for example AWS, Google, Adobe, Siteimprove).

Starting with version 7.x, telemetry.js has support for privacy tracking consent. The host application can decide to enable this behavior passing .requireConsent in the options passed into the constructor, along with an optional IPrivacySettings object. The example below shows this structure.

Users can consent to the following types of "tracking":

  • Performance: Allows only application performance information to be sent and stored
  • Functional: Allows for functional information to be stored, like perferences, past searches etc
  • Targeting: Allows for user targeting information to be sent

When requireConsent is passed, and no userPrivacySettings is sent, telemetry.js operates as though the user has opted out of all tracking. This is expected behavior as per GDPR.

When userPrivacySettings.performance: true, and an Amazon plugin is configured, it will be initialized.

For Hub Sites (and some other platform applications) customers can configure additional 3rd party tracking systems (Google Analytics, Adobe, SiteImprove). In order for those trackers to be enabled, the end-user must opt into performance, functional and targeting, because we do not know or control what the 3rd party trackers are doing, so we must assume they are tracking all three.

In Browser

import { Telemetry } from '@esri/telemetry';

// create options object
const opts = {
  requireConsent: true, // if your app requires privacy consent, set this to true
  plugins: [list of vendor plugins goes in here]
};
// Host app should load user privacy settings from localStorage or cookies
const storedSettings = window.localStorage.getItem('esri_privacy_settings');
if (storedSettings) {
  opts.userPrivacySettings = JSON.parse(storedSettings);
} else {
  // this is optional, as telemetry.js will construct the same thing
  // if requiteConsent: true and not settings are passed in
  opts.userPrivacySettings = {
    id: '3ef...', // create some unique id
    timestamp: Date.now(),
    accepted: false, // user has not actually set these, so this is false
    performance: false, // all set to false by default
    functional: false,
    targeting: false,
  }
}
// create the telemetry instance
const telemetry = new Telemetry(opts);

await telemetry.init();
// now it is ready to go

In Server

Since this is done on the server, it is not able to take user privacy settings into account. Thus, it is discouraged to inject script tags on the server, as tracking is likely to start before the host application actually boots and can apply the user privacy settings.

import { Telemetry } from '@esri/telemetry';

// create options object
const opts = {
  plugins: [list of vendor plugins goes in here]
};
// create the telemetry instance
const telemetry = new Telemetry(opts);
// in server
const scriptTags = telemetry.getScriptTags();
// now inject script tags into html page before sending it down

Issues

If something isn't working, please take a look at previously logged issues first. Have you found a new bug? Create an issue here.

Contributing

Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.

License

Copyright © 2022 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's LICENSE file.

版本与发布记录

@esri/telemetry 共发布 91 个版本,首次发布于 2017/04/28;过去 12 个月发布了 1 个版本。

版本发布日期距今
9.1.2latest2026/10/2322 天前
9.1.12025/07/121.3 年前
9.1.02025/07/111.3 年前
9.0.02025/07/101.3 年前
8.0.12025/04/161.6 年前
8.0.02024/03/202 年前

其他发布通道:beta → 4.0.0-beta.2,next → 7.1.4。

关于 @esri/telemetry 的常见问题

@esri/telemetry 是什么?

A JavaScript Implementation of the ArcGIS Telemetry Specification

如何安装 @esri/telemetry?

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

@esri/telemetry 支持 TypeScript 吗?

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

@esri/telemetry 支持 ESM 还是 CommonJS?

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

@esri/telemetry 可以商用吗?

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

@esri/telemetry 的下载量有多少?

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

@esri/telemetry 还在维护吗?

最新版本 9.1.2 发布于 2026/10/23(22 天前);至今共发布 91 个版本,其中过去 12 个月发布了 1 个;首次发布于 2017/04/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。