Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18, 20, 22]

steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm build

- name: Test
run: pnpm test
63 changes: 36 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# logdash - JS SDK
# @logdash/node

Logdash is a zero-config observability platform. This package serves an javascript interface to use it.
Logdash is a zero-config observability platform. This package serves a Node.js/Bun/Deno/Browser interface to use it.

## Pre-requisites

Expand All @@ -9,39 +9,48 @@ Setup your free project in less than 2 minutes at [logdash.io](https://logdash.i
## Installation

```
npm install @logdash/js-sdk
npm install @logdash/node
```

## Logging

```typescript
import { createLogDash } from '@logdash/js-sdk';
import { Logdash } from '@logdash/node';

const { logger } = createLogDash({
// optional, but recommended to see your logs in the dashboard
apiKey: '<your-api-key>',
});
const logdash = new Logdash('<your-api-key>');

logger.info('Application started successfully');
logger.error('An unexpected error occurred');
logger.warn('Low disk space warning');
logdash.info('Application started successfully');
logdash.error('An unexpected error occurred');
logdash.warn('Low disk space warning');
```

## Namespaced Logging

```typescript
const authLogdash = logdash.withNamespace('auth');
authLogdash.info('User logged in');
authLogdash.error('Authentication failed');
```

## Metrics

```typescript
import { createLogDash } from '@logdash/js-sdk';
import { Logdash } from '@logdash/node';

const { metrics } = createLogDash({
// optional, but recommended as metrics are only hosted remotely
apiKey: '<your-api-key>',
});
const logdash = new Logdash('<your-api-key>');

// to set absolute value
metrics.set('users', 0);
logdash.setMetric('users', 0);

// to modify existing metric
metrics.mutate('users', 1);
logdash.mutateMetric('users', 1);
```

## Graceful Shutdown

```typescript
// Ensure all logs and metrics are sent before exiting
await logdash.flush();
```

## View
Expand All @@ -53,20 +62,20 @@ To see the logs or metrics, go to your project dashboard

## Configuration

| Parameter | Required | Default | Description |
| --------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| `apiKey` | no | - | Api key used to authorize against logdash servers. If you don't provide one, logs will be logged into local console only |
| `host` | no | - | Custom API host, useful with self-hosted instances |
| `verbose` | no | - | Useful for debugging purposes |
```typescript
new Logdash(apiKey?, options?)
```

| Parameter | Required | Default | Description |
| ----------------- | -------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
| `apiKey` | no | - | Api key used to authorize against logdash servers. If you don't provide one, logs will be logged into local console only |
| `options.host` | no | `https://api.logdash.io` | Custom API host, useful with self-hosted instances |
| `options.verbose` | no | `false` | Useful for debugging purposes |

## License

This project is licensed under the MIT License.

## Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

## Support

If you encounter any issues, please open an issue on GitHub or let us know at [[email protected]](mailto:[email protected]).
93 changes: 48 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
{
"name": "@logdash/js-sdk",
"version": "1.0.9",
"private": false,
"description": "Modern observability platform.",
"scripts": {
"build": "tsc -p tsconfig.lib.json",
"release": "pnpm build && changeset publish",
"changeset": "changeset",
"version-packages": "changeset version"
},
"author": "Simon Gracki <[email protected]>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/logdash-io/js-sdk.git"
},
"homepage": "https://github.com/logdash-io/js-sdk",
"devDependencies": {
"@changesets/cli": "^2.28.1",
"@swc/core": "^1.10.18",
"@types/node": "^22.13.5",
"prettier": "^3.5.2",
"typescript": "5.7.3",
"vitest": "^3.0.6"
},
"bugs": {
"url": "https://github.com/logdash-io/js-sdk/issues"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=18"
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"keywords": [
"observability",
"monitoring",
"logging",
"tracing",
"metrics"
],
"dependencies": {
"chalk": "^4.1.2"
}
"name": "@logdash/node",
"version": "1.0.0",
"private": false,
"description": "How solo founders keep their SaaS apps healthy.",
"scripts": {
"build": "tsc -p tsconfig.lib.json",
"test": "vitest run",
"test:watch": "vitest",
"release": "pnpm build && changeset publish",
"changeset": "changeset",
"version-packages": "changeset version"
},
"author": "Logdash Team <[email protected]>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/logdash-io/node-sdk.git"
},
"homepage": "https://github.com/logdash-io/node-sdk",
"devDependencies": {
"@changesets/cli": "^2.29.8",
"@swc/core": "^1.15.6",
"@types/node": "^25.0.3",
"prettier": "^3.7.4",
"typescript": "5.9.3",
"vitest": "^4.0.16"
},
"bugs": {
"url": "https://github.com/logdash-io/node-sdk/issues"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=18"
},
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"keywords": [
"observability",
"monitoring",
"logging",
"tracing",
"metrics"
],
"dependencies": {
"chalk": "^5.6.2"
}
}
Loading