{"_id":"@alertship/alertship","_rev":"3-795b49ee19b864b3a4386124e047770a","name":"@alertship/alertship","dist-tags":{"latest":"1.1.3"},"versions":{"1.0.1":{"name":"@alertship/alertship","version":"1.0.1","keywords":["telegram","logger","error-handler","monitoring","node.js","typescript","sentry-alternative","crash-report"],"author":{"name":"Nwankwo Samuel"},"license":"ISC","_id":"@alertship/alertship@1.0.1","maintainers":[{"name":"devtoolz","email":"nwankwosami@gmail.com"}],"homepage":"https://github.com/saminwankwo/telegram-logger#readme","bugs":{"url":"https://github.com/saminwankwo/telegram-logger/issues"},"dist":{"shasum":"84c31a0060a317b0083e99dcc43d6392e2742d6f","tarball":"https://registry.npmjs.org/@alertship/alertship/-/alertship-1.0.1.tgz","fileCount":11,"integrity":"sha512-LFBH16QayGA+kkQNF3ahfStCXDMyJgayR2AKRBTp3nH0hX/s73VZpNba+bVaE2szxN7MV0sDPs5Kw+Wrv7OFLw==","signatures":[{"sig":"MEUCIQDGIcqdA8R7q92/fAOAEwUBszkP2KQqM3cH50kr/c90/QIgBFwWWwb2xBdlihLgvLKAqh9NqhL7g9v6QhMnh1k/GvI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30756},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"e13692d22c0e306db04f9f7f967d8b9da41a290a","scripts":{"dev":"tsx watch tests/test.ts","test":"tsx tests/test.ts","build":"tsc -p tsconfig.build.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"devtoolz","email":"nwankwosami@gmail.com"},"repository":{"url":"git+https://github.com/saminwankwo/telegram-logger.git","type":"git"},"_npmVersion":"10.8.2","description":"A production-grade Telegram error logger for Node.js, capturing crashes, resource usage, and request context.","directories":{},"_nodeVersion":"20.20.2","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.3","dotenv":"^16.4.7","typescript":"^5.8.2","@types/node":"^22.13.10"},"peerDependencies":{"dotenv":">=16"},"_npmOperationalInternal":{"tmp":"tmp/alertship_1.0.1_1780386066420_0.5811250691193914","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@alertship/alertship","version":"1.1.0","keywords":["telegram","logger","error-handler","monitoring","node.js","typescript","sentry-alternative","crash-report"],"author":{"name":"Nwankwo Samuel"},"license":"ISC","_id":"@alertship/alertship@1.1.0","maintainers":[{"name":"devtoolz","email":"nwankwosami@gmail.com"}],"homepage":"https://github.com/saminwankwo/telegram-logger#readme","bugs":{"url":"https://github.com/saminwankwo/telegram-logger/issues"},"dist":{"shasum":"a05293cb5709ac775145399afbec419abae283ba","tarball":"https://registry.npmjs.org/@alertship/alertship/-/alertship-1.1.0.tgz","fileCount":13,"integrity":"sha512-uiy4wUGIuerQID+CFYfqt3lIRtHAUd91X9ttELxwcxuOnO5ftQ5sFrXSsPF2+SV1IH00NRI1OVgScPdb6he7xw==","signatures":[{"sig":"MEUCIQC1k8aqCh7Vx2tEYuVHy22x7wq+64a5raBhNYqj+5cjDwIgZ0AeHlksUSAiaNsoHqYqOt1OVk6sB2PDyljXggmvZzE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51220},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"7bab5093f8c995165dadd436e89b51b91bb66918","scripts":{"dev":"tsx watch tests/test.ts","test":"tsx tests/test.ts","build":"rm -rf dist && tsc -p tsconfig.build.json && mv dist/index.js dist/index.mjs && mv dist/logger.js dist/logger.mjs && tsc -p tsconfig.build.json --module commonjs --verbatimModuleSyntax false --moduleResolution node --target es2022 --declaration false --declarationMap false","prepublishOnly":"npm run build"},"_npmUser":{"name":"devtoolz","email":"nwankwosami@gmail.com"},"repository":{"url":"git+https://github.com/saminwankwo/telegram-logger.git","type":"git"},"_npmVersion":"10.8.2","description":"A production-grade Telegram error logger for Node.js, capturing crashes, resource usage, and request context.","directories":{},"_nodeVersion":"20.20.2","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.3","dotenv":"^16.4.7","typescript":"^5.8.2","@types/node":"^22.13.10"},"peerDependencies":{"dotenv":">=16"},"_npmOperationalInternal":{"tmp":"tmp/alertship_1.1.0_1780398082097_0.9953839468919539","host":"s3://npm-registry-packages-npm-production"}},"1.1.3":{"name":"@alertship/alertship","version":"1.1.3","description":"A production-grade Telegram error logger for Node.js, capturing crashes, resource usage, and request context.","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"rm -rf dist && tsc -p tsconfig.build.json && mv dist/index.js dist/index.mjs && mv dist/logger.js dist/logger.mjs && tsc -p tsconfig.build.json --module commonjs --verbatimModuleSyntax false --moduleResolution node --target es2022 --declaration false --declarationMap false","test":"tsx tests/test.ts","dev":"tsx watch tests/test.ts","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/saminwankwo/telegram-logger.git"},"bugs":{"url":"https://github.com/saminwankwo/telegram-logger/issues"},"homepage":"https://github.com/saminwankwo/telegram-logger#readme","keywords":["telegram","logger","error-handler","monitoring","node.js","typescript","sentry-alternative","crash-report"],"author":{"name":"Nwankwo Samuel"},"license":"ISC","dependencies":{},"peerDependencies":{"dotenv":">=16"},"devDependencies":{"@types/node":"^22.13.10","dotenv":"^16.4.7","tsx":"^4.19.3","typescript":"^5.8.2"},"_id":"@alertship/alertship@1.1.3","gitHead":"0a4e133a3d221bf43ecad8b88eb434066c4773f1","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Oax2XzHaqWrLt3T2n5syLyH6DiPtxQ5E8YrJoy7jjkJjrEItiNjsG3hsgRhP+yP7IAb8WXp6aKWhXevZncuyfg==","shasum":"86e20650286698e9b461829a604669fdbb91a062","tarball":"https://registry.npmjs.org/@alertship/alertship/-/alertship-1.1.3.tgz","fileCount":13,"unpackedSize":51219,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICOwjGqmqaVkWk6GJd80JNERwG+DtOnbvp8vlJEt3BUgAiEAndIs5zwrVQhRptAsFpmdR6Y5ZZNfJW7Ew56kRQ5Vdrs="}]},"_npmUser":{"name":"devtoolz","email":"nwankwosami@gmail.com"},"directories":{},"maintainers":[{"name":"devtoolz","email":"nwankwosami@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/alertship_1.1.3_1780417763987_0.2991081000743938"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-02T07:41:06.240Z","modified":"2026-06-02T16:29:24.257Z","1.0.1":"2026-06-02T07:41:06.563Z","1.1.0":"2026-06-02T11:01:22.243Z","1.1.3":"2026-06-02T16:29:24.145Z"},"bugs":{"url":"https://github.com/saminwankwo/telegram-logger/issues"},"author":{"name":"Nwankwo Samuel"},"license":"ISC","homepage":"https://github.com/saminwankwo/telegram-logger#readme","keywords":["telegram","logger","error-handler","monitoring","node.js","typescript","sentry-alternative","crash-report"],"repository":{"type":"git","url":"git+https://github.com/saminwankwo/telegram-logger.git"},"description":"A production-grade Telegram error logger for Node.js, capturing crashes, resource usage, and request context.","maintainers":[{"name":"devtoolz","email":"nwankwosami@gmail.com"}],"readme":"# Telegram Error Logger SDK\n\nA production-grade, **zero-dependency** NPM package that captures, enriches, and sends application errors and server events to Telegram.\n\n## Features\n\n- 🚀 **Zero Dependencies**: Uses native `fetch` (Node 18+). No bloat.\n- ✅ **Automatic Monitoring**: Catches `uncaughtException` and `unhandledRejection`.\n- 📊 **Resource Monitoring**: Tracks CPU usage, Heap memory, and Event-loop lag.\n- 🔗 **Request Context**: Ties errors to HTTP requests using `AsyncLocalStorage`.\n- 🔍 **Log Level Filtering**: Filter logs by severity to control noise.\n  - `DEBUG` (0): Every detail (e.g., raw API responses).\n  - `INFO` (1): Standard milestones (e.g., \"Server started\").\n  - `WARN` (2): **Default.** Non-critical issues (e.g., \"Disk 80% full\").\n  - `ERROR` (3): Operation failures (e.g., \"Database connection failed\").\n  - `CRITICAL` (4): System-wide danger (e.g., \"Out of Memory\", \"Uncaught Exception\").\n  - *Note: Setting a level (e.g., WARN) will include all levels above it (ERROR, CRITICAL) but ignore those below it (INFO, DEBUG).*\n- 🛡️ **Spam Protection**: Advanced 5-minute deduplication window for identical errors.\n- ✂️ **Message Splitting**: Automatically splits logs > 4096 chars to stay within Telegram limits.\n- 🔒 **Sanitization**: Automatically redacts sensitive keys (passwords, tokens, etc.) from metadata.\n\n## Installation\n\n```bash\nnpm install @alertship/alertship\n```\n\n## Usage\n\n### Basic Setup\n\n```typescript\nimport { TelegramLogger, LogLevel } from '@alertship/alertship';\n\nconst logger = new TelegramLogger({\n  botToken: 'YOUR_BOT_TOKEN',\n  chatId: 'YOUR_CHAT_ID',\n  appName: 'MyService',\n  minLevel: LogLevel.WARN // Default: WARN\n});\n\n// Deployment notification (useful at end of bootstrap/main.ts)\nawait logger.notifyStartup();\n\n// Manual logging with context\nlogger.info('System started');\nlogger.error(new Error('Database connection failed'), { \n  dbHost: 'localhost',\n  userId: 'user_123',\n  type: 'connection_error'\n});\n```\n\n### Express Middleware Usage\n\n```typescript\nimport express from 'express';\nconst app = express();\n\napp.use(logger.middleware());\n\napp.get('/', (req, res) => {\n  // Logs inside this route will automatically include requestId, method, and url\n  logger.info('Handling request');\n  res.send('Hello World');\n});\n```\n\n### Global Console Interception\n\nIf you want to send all your existing `console.log`, `console.warn`, and `console.error` calls to Telegram without changing your code:\n\n```typescript\nconst logger = new TelegramLogger({\n  botToken: '...',\n  chatId: '...',\n  appName: 'ChatApi',\n  interceptConsole: true\n});\n\n// Now this will also send to Telegram!\nconsole.log(\"This is a test log\");\nconsole.error(new Error(\"Database connection failed\"));\n```\n\n## Configuration Options\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `botToken` | `string` | - | Telegram Bot Token from @BotFather |\n| `chatId` | `string` | - | Target Chat or Channel ID |\n| `appName` | `string` | - | Name of your application |\n| `minLevel` | `LogLevel` | `LogLevel.WARN` | Minimum level to send to Telegram |\n| `enabled` | `boolean` | `true` (if prod) | Set to `false` to disable Telegram alerts |\n| `resourceMonitoringInterval` | `number` | `60000` | ms between resource checks (0 to disable) |\n| `eventLoopLagThreshold` | `number` | `100` | ms threshold for event-loop lag alerts |\n| `preferIPv4` | `boolean` | `true` | Forces IPv4 first to avoid `EHOSTUNREACH` issues |\n| `interceptConsole` | `boolean` | `false` | If `true`, automatically sends all `console.log/warn/error` to Telegram |\n\n## Environment Variables\n\nThe logger automatically respects the following environment variables if `dotenv` is configured:\n- `NODE_ENV`: Sets default `enabled` and `environment` name.\n- `TELEGRAM_BOT_TOKEN`: Alternative to passing in constructor.\n- `TELEGRAM_CHAT_ID`: Alternative to passing in constructor.\n- `APP_NAME`: Alternative to passing in constructor.\n\n---\nLicense: ISC | Author: Samuel Nwankwo\n","readmeFilename":"README.md"}