# @balena/event-log

> Balena events logging util

Latest version **6.8.0** (published 2023-05-18) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @balena/event-log
pnpm add @balena/event-log
yarn add @balena/event-log
bun add @balena/event-log
```

## Health

**Score 35/100 (D)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 6.8.0 |
| Published | 2023-05-18 |
| First published | 2020-05-07 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10.0 |
| Dependencies | 2 |
| Unpacked size | 27.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Iskren Slavov |
| Maintainers | dfunckt, page, balena.io |

## Links

- npm: https://www.npmjs.com/package/@balena/event-log
- Repository: https://github.com/balena-io-modules/balena-event-log
- Issues: https://github.com/balena-io-modules/balena-event-log/issues
- npm.io page: https://npm.io/package/@balena/event-log

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.19
- [analytics-client](https://npm.io/package/analytics-client.md) ^2.0.0

## Recent versions

- 6.8.0 (latest) — 2023-05-18
- 6.8.1-build-replace-lodash-with-es-toolkit-8173c80e0e730df0019bf24fd6203dd897339853-1 (build-replace-lodash-with-es-toolkit) — 2025-12-24
- 6.8.1-build-replace-lodash-with-es-toolkit-d9e55240d9ce8d5da6dbdfb2a80cf7173798dff1-2 — 2025-12-23
- 6.8.1-build-replace-lodash-with-es-toolkit-d9e55240d9ce8d5da6dbdfb2a80cf7173798dff1-1 — 2025-12-19
- 6.8.0-build-add-autogenerated-app-name-tracking-a6bda59a51055477d28d90b7248241094b7209a6-1 — 2023-05-18
- 6.7.0 — 2023-05-03
- 6.7.0-build-add-flash-event-log-d36d067f7e070e00fa86625f7d43cd9f1acd12be-1 — 2023-05-03
- 6.7.0-build-add-flash-event-log-fd160bfd8e988021a79c0283d59ed0af2965dbed-1 — 2023-05-03
- 6.6.0 — 2023-04-05
- 6.6.0-build-add-credits-runway-calculator-tracking-575924c018f15686aa5ef861dcb0c79799ba4926-2 — 2023-04-05
- 6.5.1 — 2023-03-06
- 6.5.1-build-adds-missing-types-b8ec4ed48b96e8e4bca9c3bdb18c0e9c2e103bac-1 — 2023-03-06
- 6.5.0 — 2023-03-06
- 6.5.0-build-add-new-device-and-release-actions-f195e566d39be865fac972f0258267bcb32b2582-1 — 2023-03-06
- 6.4.0 — 2023-02-02
- … 66 more at https://npm.io/package/@balena/event-log/versions

## README

# Balena Event Log

Balena event logging facility.

## Installing

```sh
$ npm install @balena/event-log
```

## Using

```javascript
var EventLog = require('@balena/event-log')

var eventLogger = EventLog({
	debug: true,
	prefix: 'UI, CLI, etc.',
	// Hooks:
	beforeCreate: function (type, jsonData, applicationId, deviceId, callback) {
		this.start('User ID', callback)
	}
	afterCreate: function (error, type, jsonData, applicationId, deviceId) {
		if (type === 'User Logout') {
			this.end()
		}
		if (error) {
			console.error(error)
		}
	}
})

// Example logged event:
eventLoger.user.login(
	{ json: 'data' }, // Or null
	'Application ID', // Optional
	'Device ID' // Optional
)

// Example logged event without params:
eventLoger.user.login()
```

## Options

* `prefix` - subsystem name like UI or CLI, acts as events names prefix
* `[debug = false]` — will print some warnings

### Hooks:

```javascript
beforeCreate = function (type, jsonData, applicationId, deviceId, callback) { return callback() } 
afterCreate = function (error, type, jsonData, applicationId, deviceId) {}
```

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