@esri/telemetry-reporting-client

中文文档
4.0.0发布于 2025/04/23Apache-2.0TypeScriptESM + CJS近 30 天下载 6395

[![npm version][npm-img]][npm-url] [![build status][build-img]][build-url] [![apache licensed][license-img]][license-url]

原始使用文档
文档目录8 节
  1. Installation
  2. Example Usage
  3. getTelemetryReport
  4. buildSimpleDimensionFilters
  5. isAuthorized
  6. Commands
  7. Contributing
  8. License

npm version build status apache licensed

Telemetry Reporting Client

Library for interfacing with the Telemetry Reporting Service.

Installation

yarn add @esri/telemetry-reporting-client

Example Usage

getTelemetryReport

import { getTelemetryReport } from '@esri/telemetry-reporting-client';

const requestParams = {
  scope: {
    hostname: 'hostname',
  },
  dateRange: {
    startDate: '2019-01-01',
    endDate: '2019-01-31',
  },
  metrics: ['page-views:count'],
};

const requestOptions = {
  httpMethod: 'POST',
  params: {},
  authentication: {
    token: 'token',
  },
  hubApiUrl: 'https://hubqa.arcgis.com',
  customDimensionsConfig: {
    details: 1,
    userType: 2,
    id: 16,
  },
};

const report = getTelemetryReport(requestParams, requestOptions)
  .then((response) => {
    data = response.data;
  })
  .catch((error) => {
    // Handle error
  });

buildSimpleDimensionFilters

import { buildSimpleDimensionFilters } from '@esri/telemetry-reporting-client';

const event = {
  category: 'Interaction',
  action: 'Download',
  label: 'Cache',
};

const dimensionFilters = buildSimpleDimensionFilters(event);

isAuthorized

import { isAuthorized } from '@esri/telemetry-reporting-client';

const result = isAuthorized({
      itemId: '3ef',
      hostname: 'hubqa.arcgis.com',
      agoPortalUrl: 'https://qaext.arcgis.com/sharing/rest',
      hubApiUrl: 'https://hubqa.arcgis.com',
      token: 'token'
    })
    .then((response) => {
      return response;
    })
    .catch((error) => {
      // Handle error
    });

If you have already fetch the AGO user, you can make this call more perfomant by passing in the user (thus avoiding have to fetch it again) :

import { ArcGISIdentityManager } from '@esri/arcgis-rest-request';
import { isAuthorized } from '@esri/telemetry-reporting-client';

// see https://developers.arcgis.com/arcgis-rest-js/api-reference/arcgis-rest-request/ArcGISIdentityManager/
const manager = await ArcGISIdentityManager.signIn(username, password)
const user = await manager.getUser();

const result = isAuthorized({
      itemId: '3ef',
      hostname: 'hubqa.arcgis.com',
      agoPortalUrl: 'https://qaext.arcgis.com/sharing/rest',
      hubApiUrl: 'https://hubqa.arcgis.com',
      user,
      token: 'token'
    })
    .then((response) => {
      return response;
    })
    .catch((error) => {
      // Handle error
    });

Note that the token is still required in order to fetch the target item (if it is private).

Commands

  • yarn start: This builds to /dist and runs the project in watch mode so any edits you save inside src rebuilds to /dist.

  • yarn build: One-off build to the /dist

  • yarn test: Runs the full test suite.

  • yarn test:watch: Runs the full test suite in watch mode so any edits you make will re-run the tests.

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-reporting-client 共发布 17 个版本,首次发布于 2022/04/28;过去 12 个月发布了 0 个版本。

版本发布日期距今
4.0.0latest2025/04/231.6 年前
3.2.52025/03/241.6 年前
3.2.42023/09/163 年前
3.2.32023/06/073 年前
3.2.22023/05/203 年前
3.2.12022/09/144 年前

关于 @esri/telemetry-reporting-client 的常见问题

@esri/telemetry-reporting-client 是什么?

[![npm version][npm-img]][npm-url] [![build status][build-img]][build-url] [![apache licensed][license-img]][license-url]

如何安装 @esri/telemetry-reporting-client?

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

@esri/telemetry-reporting-client 支持 TypeScript 吗?

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

@esri/telemetry-reporting-client 支持 ESM 还是 CommonJS?

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

@esri/telemetry-reporting-client 需要什么版本的 Node.js?

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

@esri/telemetry-reporting-client 可以商用吗?

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

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

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

@esri/telemetry-reporting-client 还在维护吗?

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