# trace-event-lib

> A library to create a trace of your JS app per Google's Trace Event format.

Latest version **1.4.1** (published 2023-05-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install trace-event-lib
pnpm add trace-event-lib
yarn add trace-event-lib
bun add trace-event-lib
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2023-05-06 |
| First published | 2022-06-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 1 |
| Unpacked size | 64.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | yaroslavs |
| Keywords | trace-event, trace, event, trace-viewer, google |

## Links

- npm: https://www.npmjs.com/package/trace-event-lib
- Repository: https://github.com/wix-incubator/trace-event-lib
- Homepage: https://github.com/wix-incubator/trace-event-lib#readme
- Issues: https://github.com/wix-incubator/trace-event-lib/issues
- npm.io page: https://npm.io/package/trace-event-lib

## Dependencies (1)

- [browser-process-hrtime](https://npm.io/package/browser-process-hrtime.md) ^1.0.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.4.1 (latest) — 2023-05-06
- 1.4.0 — 2023-05-06
- 1.3.1 — 2022-08-25
- 1.3.0 — 2022-08-25
- 1.2.0 — 2022-08-23
- 1.1.0 — 2022-07-03
- 1.0.0 — 2022-06-30

## README

# trace-event-lib

[![npm version](https://badge.fury.io/js/trace-event-lib.svg)](https://badge.fury.io/js/trace-event-lib)
[![CI](https://github.com/wix-incubator/trace-event-lib/actions/workflows/ci.yml/badge.svg)](https://github.com/wix-incubator/trace-event-lib/actions/workflows/ci.yml)
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

A library to create a trace of your JS app per [Google's Trace Event format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU).

![chrome://tracing example](https://raw.githubusercontent.com/wix-incubator/trace-event-lib/master/media/duration-events-test-ts-multiple-threads-2-snap.png)

These logs can then be visualized with:

* <chrome://tracing> (see the [archive](https://github.com/catapult-project/catapult/tree/master/tracing))
* [Perfetto](https://ui.perfetto.dev) – doesn't support async events, as of 29.06.2022.

# Install

```shell
npm install trace-event-lib --save
````

# Usage

```javascript
import { AbstractEventBuilder } from 'chrome-trace-event';

class ConcreteEventBuilder extends AbstractEventBuilder {
    send(event) {
        // Implement the abstract method: push events into a stream, array, etc.
    }
}

const trace = new ConcreteEventBuilder();

trace.begin({ cat: 'category1,category2', name: 'duration event' });
// ...
trace.instant({ name: 'resolve config', args: { /* ... */ } });
// ...
trace.complete({ name: 'nested event', dur: 3e6 /* 3s */ });
// ...
trace.end();

/**
 * Also, see the other methods on the website.
 *
 * @see {@link AbstractEventBuilder#beginAsync}
 * @see {@link AbstractEventBuilder#instantAsync}
 * @see {@link AbstractEventBuilder#endAsync}
 * @see {@link AbstractEventBuilder#counter}
 * @see {@link AbstractEventBuilder#metadata}
 * @see {@link AbstractEventBuilder#process_name}
 * @see {@link AbstractEventBuilder#process_labels}
 * @see {@link AbstractEventBuilder#process_sort_index}
 * @see {@link AbstractEventBuilder#thread_name}
 * @see {@link AbstractEventBuilder#thread_sort_index}
 */
```

## Links

* GH pages: <https://wix-incubator.github.io/trace-event-lib>
* Chrome Trace Event format specification: <https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU>
* Catapult project Wiki (archived): <https://github.com/google/trace-viewer/wiki>

## License

[MIT License](LICENSE)

---
_Source: https://npm.io/package/trace-event-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
