Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@ibm/telemetry-js

ibm-telemetry576.4kApache-2.01.9.1

JavaScript telemetry tooling for open/inner source projects

ibm, telemetry, metrics, opentelemetry, javascript, typescript

readme

IBM Telemetry JS

JavaScript telemetry tooling for open/inner source projects

IBM Telemetry JS is released under the Apache-2.0 license PRs welcome

NPM version NPM downloads

Quality gate status Continuous integration checks status

Quality metrics

Security Rating Reliability Rating Maintainability Rating

Vulnerabilities Bugs Code Smells Coverage

Overview

IBM Telemetry collects anonymized usage data for open source and inner source packages when they have been instrumented with this JavaScript tooling. The data is reported back to a central server so package maintainers can analyze usage and make improvements.

IBM Telemetry uses OpenTelemetry as the foundation of its data transport format.

Find out more detailed documentation and guidelines by choosing from the following sections what best describes your use case:

IBM Telemetry collection basics

If you're reading this section, you're likely using a package and have noticed that it is collecting telemetry data using IBM Telemetry. We call that an "instrumented package". Here's what you need to know about how that works:

  • Telemetry data collection runs on CI servers, like GitHub Actions, Travis CI, or Jenkins. It never runs locally on a developer's machine. However, collection will occur when running inside a container, like Docker, or Podman, as we consider these environments part of CI workflows.
  • When npm install (or equivalent) is run on the CI server/container (resulting in the instrumented package getting installed), IBM Telemetry gets installed too and runs a script which analyzes your source code and captures data about your usage of the instrumented package.
  • This data is anonymized and reported back to a server at IBM. Details on what data is captured and how data is anonymized are described below.
  • Though IBM Telemetry is installed as a regular dependency in the instrumented package, it has no exports and therefore does not impact your project's source code or build output in any way. Said differently: this is not a runtime package. It has no "shippable code". It is static source code analysis performed during builds.

The point of capturing this data is to help the open source and inner source maintainers within IBM by giving them meaningful insights and metrics based on actual data. IBM Telemetry's purpose is to enable data-driven decision-making to enable maintainers to focus on features that are actually used by developers like you.

What data gets collected?

Depending on the nature of the instrumented package and its telemetry configuration, IBM Telemetry may capture the following data about your project:

General

  • Date and time of collection
  • A de-identified version of your project's git repository URL
  • A de-identified version of your project's most recent Git commit hash
  • De-identified versions of the branches and tags associated with that commit hash

NPM data

  • A de-identified version of your project's name (as defined in your package.json file)
  • Your project's version (as defined in package.json) with any identifiable parts removed
  • De-identified names and versions of your project's dependencies

JSX data

  • JSX elements (aka components) imported by your project from the instrumented package and details about the elements’ attributes (aka props) including names, values, and import paths.

Element attribute names that haven't been specifically configured by the instrumented package to be collected will be anonymized before collection.

Boolean and number values will be captured for allowed attribute names. String values that haven't been specifically configured by the instrumented package and other value types (such as complex objects or variable names) are also anonymized. This means your project-specific data supplied to JSX elements will never be captured.

JS data

  • JavaScript tokens and functions imported by your project from the instrumented package and details such as function arguments.

The argument boolean, number, and string values are handled the same as JSX data with instrumented package allowlist configurations.

Sensitive data that may contain confidential or personally identifiable information that gets collected by the IBM Telemetry JS tooling gets anonymized/de-identified using the SHA-256 cryptographic function prior to storage in our database, see anonymizing.

When does data get collected?

Telemetry collection runs exclusively in CI environments. Collection will never occur on local development environments or on projects that aren't configured to run automated scripts in a CI environment (e.g. GitHub Actions, Travis CI, etc.) However, if your project runs inside a container (e.g. Docker, Podman), telemetry may be collected, as containerized environments are considered production-like and thus fall under the scope of CI workflows.

During a build or any other CI operation that installs package dependencies (npm install, yarn install, ...), IBM telemetry will run as a background process and perform data collection.

Opting out of IBM Telemetry data collection

IBM Telemetry will collect metric data for instrumented packages by default. If your project is installing an IBM Telemetry-instrumented package and you want to opt-out of metric collection, set the following environment variable to prevent any and all data from being collected in your project.

Unix, Linux, MacOS, BSD, etc.

IBM_TELEMETRY_DISABLED='true'

Windows (powershell)

$Env:IBM_TELEMETRY_DISABLED='true'

Anonymizing / de-identifying

When data is to be de-identified, it is hashed using the SHA-256 cryptographic function, meaning an instrumented package owner can query for specific known names/values but can never recover original values from the stored data in the database.

When data is to be anonymized, it is redacted/substituted in a way where its original value can never be recovered, and there is no meaningful way to query the data to ascertain its value.

As a general philosophy, we favor anonymizing fields over de-identifying them.

Onboarding a package to IBM Telemetry

1. Obtain a project ID from the IBM Telemetry team by opening an issue here.

The IBM Telemetry team will assign you a project ID to include in your telemetry.yml config file.

2. Create a telemetry.yml config file.

[!IMPORTANT] This config file needs to be included in your published NPM package!

This file defines what types of metrics will be captured for your project as well as some general configuration settings.

See the telemetry config schema for a detailed explanation of all available configuration options.

Sample:

`yaml path="sample-telemetry.yml"

yaml-language-server: $schema=https://unpkg.com/@ibm/telemetry-config-schema@1/dist/config.schema.json

version: 1 projectId: '<your assigned project id>' endpoint: 'https://example.com/v1/metrics' collect: npm: dependencies: null jsx: elements: allowedAttributeNames:

    - 'size'
    - 'title'
    - 'etc.'
  allowedAttributeStringValues:
    - 'small'
    - 'medium'
    - 'large'
    - 'title1'
    - 'title2'
    - 'etc.'

> **Note**: Though this file can live anywhere within your project, it is customary to place it at
> the root level.

Optionally, use the
[IBM Telemetry Js Config Generator](https://www.npmjs.com/package/@ibm/telemetry-js-config-generator)
script to automatically generate the config file. Remember to verify that the generated output is
correct before using the config file.

### 3. Install `@ibm/telemetry-js` dependency.

> **Note**: This must be installed as a regular dependency, not a dev dependency in the instrumented
> project.

`npm install @ibm/telemetry-js`

or

`yarn add @ibm/telemetry-js`

### 4. Add a `postinstall` script to your `package.json` file.

The `postinstall` script runs telemetry collection anytime your package gets installed inside of
another project.

```jsonc path="package.json"
// ...
"scripts": {
  // ...
  "postinstall": "ibmtelemetry --config=path/to/your/telemetry.yml"
}
// ...

Make sure the --config option points to your telemetry.yml file within your package.

5. Add telemetry collection notice to your docs.

You'll want to be as transparent as possible about telemetry collection and the data that is being stored. You should strongly consider adding an informational paragraph to your docs (usually the README) as follows:

## <picture><source height="20" width="20" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-dark.svg"><source height="20" width="20" media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"><img height="20" width="20" alt="IBM Telemetry" src="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"></picture> IBM Telemetry

This package uses IBM Telemetry to collect de-identified and anonymized metrics data. By installing
this package as a dependency you are agreeing to telemetry collection. To opt out, see
[Opting out of IBM Telemetry data collection](https://github.com/ibm-telemetry/telemetry-js/tree/main#opting-out-of-ibm-telemetry-data-collection).
For more information on the data being collected, please see the
[IBM Telemetry documentation](https://github.com/ibm-telemetry/telemetry-js/tree/main#ibm-telemetry-collection-basics).
<summary>Preview notice</summary>

<picture><source height="20" width="20" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-dark.svg"><source height="20" width="20" media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg">IBM Telemetry</picture> IBM Telemetry

This package uses IBM Telemetry to collect de-identified and anonymized metrics data. By installing this package as a dependency you are agreeing to telemetry collection. To opt out, see Opting out of IBM Telemetry data collection. For more information on the data being collected, please see the IBM Telemetry documentation.

6. Publish a new version of your package.

Package consumers need to install a version of your package that includes both the config file and post-install script in order for telemetry collection to occur.

7. Done!

Whenever consumers pick up a version of your package that includes the config file and post-install script, telemetry collection will run and collect metrics.

I don't work for IBM. Can I still use this?

Yes! This package can send its output to any OpenTelemetry-compatible collector endpoint via the standard v1/metrics Rest API endpoint. All you need to do is specify your collector endpoint's URL in the endpoint configuration setting in your telemetry.yml file.

changelog

Changelog

1.9.1 (2025-01-28)

Bug Fixes

1.9.0 (2025-01-22)

Features

  • add logging on ChooChooTrain (#288) (c272c25)
  • collect emitter environment name and custom CI check (#290) (7068a5c)

1.8.0 (2024-10-31)

Features

1.7.1 (2024-10-22)

Bug Fixes

1.7.0 (2024-10-18)

Features

Bug Fixes

  • deps: upgrade contributor-assistant/github-action action to v2.5.1 (#263) (580100f)
  • deps: upgrade contributor-assistant/github-action action to v2.6.1 (#271) (2b70386)
  • deps: upgrade devDependencies (minor) (#264) (d892e3e)
  • deps: upgrade devDependencies (minor) (#266) (4740cae)

1.6.1 (2024-08-13)

Bug Fixes

  • deps: upgrade devDependencies (minor) (#256) (e51c855)
  • deps: upgrade devDependencies (minor) (#259) (38d13be)
  • deps: upgrade devDependencies (minor) (#260) (9cf3b9d)
  • deps: upgrade devDependencies (minor) (#261) (45fd249)

1.6.0 (2024-07-03)

Features

  • add command line telemetry disclosure (#242) (2c08976)

Bug Fixes

  • adjust environment instance naming for consistency (7d05a9a)
  • adjust spacing and formatting of notify message (687b761)
  • deps: upgrade devDependencies (minor) (#245) (5455d7d)
  • deps: upgrade devDependencies (minor) (#248) (42ba19c)
  • deps: upgrade devDependencies (minor) (#249) (f97c66d)
  • move notify imports below copyright statement (8dfb556)
  • prevent terminal popup on windows (#251) (1d37108), closes #250
  • refine getTrackedSourceFiles logic (#253) (57c4fc6)

1.5.2 (2024-05-21)

Features

Bug Fixes

  • deps: upgrade contributor-assistant/github-action action to v2.4.0 (#239) (dfefe9c)
  • deps: upgrade devDependencies (minor) (#236) (bea5a86)
  • deps: upgrade devDependencies (minor) (#241) (938a9e9)
  • refine js scope function parsing logic (#243) (5e1990f)

Continuous Integration

1.5.1 (2024-05-08)

Bug Fixes

  • deps: upgrade devDependencies (minor) (#234) (b6f5e74)
  • resolve absolute path for config files (5c96589)

1.5.0 (2024-04-19)

Features

Bug Fixes

  • add release-please version hint (b20586e)
  • deps: upgrade devDependencies (minor) (#229) (9870632)

1.4.0 (2024-04-11)

Features

Bug Fixes

  • deps: upgrade contributor-assistant/github-action action to v2.3.2 (#221) (9484631)
  • deps: upgrade devDependencies (minor) (#219) (2203fd8)
  • deps: upgrade devDependencies (minor) (#222) (2bcc4bd)
  • deps: upgrade devDependencies (minor) (#225) (6dd44b3)
  • deps: upgrade devDependencies (minor) (#226) (50650ab)
  • deps: upgrade vitest monorepo to v1 (#213) (a09332e)
  • do not emit metrics if empty (#228) (d578cb9)

1.3.0 (2024-03-14)

Features

Bug Fixes

  • add gzip compression to outgoing metrics requests (a9f6929)
  • deps: upgrade actions/checkout action to v4 (#201) (925e3ee)
  • deps: upgrade actions/setup-node action to v4 (#202) (2723b90)
  • deps: upgrade commitlint monorepo to v19 (#203) (06e32cc)
  • deps: upgrade dependency eslint-plugin-jsdoc to v48 (#206) (f0572b9)
  • deps: upgrade dependency eslint-plugin-simple-import-sort to v12 (#207) (d9edcfe)
  • deps: upgrade dependency husky to v9 (#208) (e0ac62b)
  • deps: upgrade dependency lint-staged to v15 (#209) (6b11ba6)
  • deps: upgrade devDependencies (minor) (4509f35)
  • deps: upgrade devDependencies (minor) (#180) (1e9aded)
  • deps: upgrade devDependencies (minor) (#191) (ebdd792)
  • deps: upgrade GitHub Artifact Actions to v4 (#199) (3e88814)
  • deps: upgrade typescript-eslint monorepo to v7 (#212) (e041294)
  • increase stability when running in legacy environments (#215) (14212fd)
  • remove invoker attributes from jsx scope (#194) (6c2d122)

1.2.1 (2024-02-08)

Bug Fixes

1.2.0 (2024-01-24)

Features

  • add combined repository key to metrics (#170) (ffc53af)
  • add new keys to element and dependency metrics (#169) (10ddf21)
  • JsxScope - Capture metrics only for files contained within local package (#146) (c4da537)

Bug Fixes

  • deps: upgrade dependency vite to v5.0.12 [SECURITY] (#172) (c2d7a62)
  • deps: upgrade devDependencies (minor) (#159) (1d4bc52)
  • deps: upgrade devDependencies (minor) (#168) (348fee2)
  • refactor some git-related commands (4ef95b3)
  • update copyrights to 2024 (#176) (7632e30)

1.1.0 (2023-12-18)

Features

  • npm: add support for querying instrumented pkg dependency metrics (037e846)
  • run telemetry collection as a background process (#147) (273a466)

Bug Fixes

  • jsx: remove trace from captureFileMetrics (fec2265)

1.0.0 (2023-12-14)

⚠ BREAKING CHANGES

  • promote to v1

Features

Bug Fixes

  • deps: upgrade devDependencies (minor) (#141) (bbf3c4a)
  • dev-deps: update vite to latest (222423b)

0.8.1 (2023-12-08)

Bug Fixes

  • remove WIP heading from readme (7503381)

0.8.0 (2023-12-08)

Features

  • add ci awareness (994431c)
  • adjust metric names for consistency (2c31748)
  • core: remove nullish values from captured metrics (738e035)
  • fully qualify scope metric attribute names (1891a35)

Bug Fixes

  • add tracing to JsxScope#processFile (2c8d326)
  • core: use Object.fromEntries instead of map/reduce (71e245a)
  • get-package-data regular expression workspace bug (c52ad7c), closes #107
  • improve promise tracking in debug logging (cc14bc2)
  • run jsxScope e2e run one file at a time in tests (#145) (c7ea7b6)

0.7.0 (2023-11-18)

Features

  • core: move to schema version 0.3.0 (4efd234)

0.6.2 (2023-11-17)

Bug Fixes

0.6.1 (2023-11-17)

Bug Fixes

  • core: improve substitute and safeStringify stability (a859944)
  • npm: improve performance of getPackageData (8c43570)

0.6.0 (2023-11-17)

Features

  • jsx: remove raw attr from jsx elements (0e5db9d)

Bug Fixes

  • npm: add caching to get-package-data (692ac0a)

0.5.3 (2023-11-17)

Bug Fixes

  • tracked-file-enumerator: improve robustness and error handling (e2a38ac)

0.5.2 (2023-11-17)

Bug Fixes

  • resolution of overlapping root and tracked file paths (8d7a282)

0.5.1 (2023-11-17)

Bug Fixes

  • deps: upgrade devDependencies (minor) (#128) (4c46ae0)
  • relativize tracked file path before resolving it (4be0b35)

0.5.0 (2023-11-17)

Features

  • switch everything to absolute pathing (a57263c)

0.4.0 (2023-11-15)

Features

0.3.8 (2023-11-15)

Bug Fixes

  • deps: upgrade devDependencies (minor) (#124) (e7cf605)
  • only consider root-most npm ls when finding installing packages (ecb0925)
  • otel currency updates, get ready for export (f070c57)
  • regular expression security hotspots (0a1711f)
  • remove test output (2a6d541)

0.3.7 (2023-10-26)

Bug Fixes

  • dependency-metric: output undefined for missing attributes (7f32468)

0.3.6 (2023-10-26)

Bug Fixes

0.3.5 (2023-10-26)

Bug Fixes

  • improve logging stability for complex objects (2646d66)
  • remove truncateString (df495d2)

0.3.4 (2023-10-26)

Bug Fixes

0.3.3 (2023-10-25)

Bug Fixes

  • index: pass correct schema to telemetry collector (8608b35)

0.3.2 (2023-10-25)

Bug Fixes

  • experiment with app token in workflow (7967583)
  • ibmtelemetry bin hashbang (18e3abb)

0.3.1 (2023-10-24)

Bug Fixes

  • adjust pathing of bin file in package.json (507d766)

0.3.0 (2023-10-24)

Features

  • add esbuild bundling (e757e36)
  • add more details for installer to DependencyMetric (#82) (3a06462)

Bug Fixes

  • correct package output files (47d1b14)
  • deps: update node module minor versions (1e785ca)
  • deps: upgrade actions/checkout action to v4 (#93) (800d804)
  • deps: upgrade contributor-assistant/github-action action to v2.3.1 (#114) (69023f4)
  • deps: upgrade dependencies (minor) (#108) (eb3e4eb)
  • deps: upgrade dependencies (minor) to ^1.17.0 (#94) (1ec3ba7)
  • deps: upgrade dependency eslint-plugin-vitest to ^0.3.1 (#79) (675dc5a)
  • deps: upgrade dependency object-scan to ^19.0.5 (#103) (6ba3627)
  • deps: upgrade devDependencies (minor) (#104) (7c43cbc)
  • deps: upgrade devDependencies (minor) (#109) (e69e4c7)
  • deps: upgrade devDependencies (minor) (#95) (37c1acf)
  • logger: consolidate trace functions and fix bugs (aa395fe)
  • move deps to dev deps, update ci scripts (a3bc47c)
  • update naming from telemetrics to telemetry (cc2dbaf)
  • validate presence of dependency key in npm scope (#83) (89c9a7c)

0.2.0 (2023-09-21)

Features

  • add command line data gathering and basic usages (51ee6ac)
  • add DependencyMetric and NpmScope (#53) (fb0dd74)
  • add transistor config schema file (#18) (75c20e4)
  • config file schema parsing & validation (#54) (a6d03bb)
  • core: add basic otel initialization logic (#17) (daa73fb)
  • core: add core framework for metric and scope definition (9df4c7d)
  • core: implement data metric capturing in Scope class (75d1460)
  • end-to-end run logic (feat/commander) (#81) (3042616)
  • logging feature (#44) (49e8745)
  • otel: switch to global registration of meter provider (c4284ea)
  • switch to generic project name of "telemetry" (63a0991)

Bug Fixes

  • deps: remove @types/tmp in favor of tmp-promise (8ee37c2)
  • deps: update linter package major versions (0d14985)
  • deps: upgrade dependency prettier to ^3.0.3 (#64) (b9344c0)
  • get package name and version (fcc2a2e)
  • move origin tokenization to its own file (#43) (83ddce3)
  • replace carbon-design-system org with ibm-telemetry (#86) (84feaeb)
  • resolve eslint warnings on jsdocs (acb2b7d)
  • switching to use spawn instead of exec (71654c7)
  • upgrade commitlint monorepo (9d2b88c)
  • upgrade dependency eslint to ^8.46.0 (#22) (bba0e94)
  • upgrade dependency eslint-plugin-import to ^2.28.0 (#14) (9d695c3)
  • upgrade dependency eslint-plugin-import to ^2.28.1 (#55) (bdc55c0)
  • upgrade dependency eslint-plugin-n to ^16.0.2 (#56) (cf6f87f)
  • upgrade dependency lint-staged to v14 (#62) (289e03f)
  • upgrade dependency prettier to ^3.0.1 (#21) (7e61348)
  • upgrade dependency prettier to ^3.0.2 (#48) (df2548d)
  • upgrade opentelemetry-js monorepo to ^1.15.2 (#24) (d2a16d6)
  • upgrade vitest monorepo to ^0.34.3 (#49) (b211f14)

0.1.1 (2023-07-28)

Bug Fixes

  • remove deps from allowable commit types (fe1aea8)