open-index/open-npm huggingface dataset:
npm package: @safaricom-mxl/node-cli
Description: MXL Node CLI for uploading sourcemaps from Node.js services
Author: MXL
Latest version: 0.0.2

# MXL Node SDK CLI

This CLI helps with build-time sourcemap processing for Node.js services instrumented with the MXL Node SDK.

## Quick Start

npm:

```sh
npm install --save-dev @safaricom-mxl/node-cli
```

yarn:

```sh
yarn add -D @safaricom-mxl/node-cli
```

## Upload sourcemaps

To upload sourcemaps to MXL as part of your build process you will require the following:
* Your MXL Service ID
* Your MXL `Symbol Upload` API token (found in your MXL dashboard in
[Settings->API](https://mxl.apps.ocpthikadev01.safaricom.net/settings/organization/api))
* The path to where the built JS files live

```sh
npx mxl-node-cli upload -s "YOUR_MXL_SERVICE_ID" -t "YOUR_MXL_UPLOAD_API_TOKEN" -p "ARTIFACT_PATH"
```

> [!WARNING]
> The CLI must be run BEFORE the files are packaged (e.g., before creating a Docker image or deployment archive).
> The CLI injects a comment and a short function to the end of bundle files to enable symbolication, so it needs to
> happen before packaging.

## Setting service version

The same `upload` sub-command as above can be used to inject your app's version into your bundle if the value is only
known at build time. If the version is known prior to build time you can provide it when initializing the SDK.
Execute the same command as above while also providing your service version:

```sh
npx mxl-node-cli upload -s "YOUR_MXL_SERVICE_ID" -t "YOUR_MXL_UPLOAD_API_TOKEN" -p "ARTIFACT_PATH" --service-version "SERVICE_VERSION"
```
npm package: @safaricom-mxl/node-sdk
Description: MXL Node.js OpenTelemetry SDK
Author: MXL
Latest version: 0.0.2

# @safaricom-mxl/node-sdk

Server-side OpenTelemetry SDK for Node.js services.

## Install

```bash
npm install @safaricom-mxl/node-sdk
```

## Quick start

```ts
import { initSDK } from '@safaricom-mxl/node-sdk';

initSDK({
  serviceName: 'orders-api',
});
```

## CLI preload

```bash
opentelemetry-instrument ./dist/server.js
```

## Framework helpers

- Express: `setupExpressErrorHandler`
- Koa: `setupKoaErrorHandler`
- Fastify: `setupFastifyErrorHandler`
- Nest: `createNestLogger`

## Logger adapters

- Pino: `getPinoTransport`, `getPinoMixinFunction`
- Winston: `getWinstonTransport`

## Environment variables

- `OTEL_SERVICE_NAME`
- `OTEL_EXPORTER_OTLP_ENDPOINT`
- `OTEL_EXPORTER_OTLP_PROTOCOL` (`http/protobuf`, `http/json`, `grpc`)
- `OTEL_EXPORTER_OTLP_HEADERS`
- `OTEL_TRACES_SAMPLER`
- `OTEL_TRACES_SAMPLER_ARG`
- `MXL_NODE_ADVANCED_NETWORK_CAPTURE`
- `MXL_NODE_SENTRY_INTEGRATION_ENABLED`

## Troubleshooting

- Ensure collector protocol matches `OTEL_EXPORTER_OTLP_PROTOCOL`.
- If logs are missing, confirm `OTEL_LOGS_EXPORTER` is not set to `none`.
- For preload mode in bundled apps, verify the preload command runs before app bootstrap.