@sistemtakip/sdk
v0.1.0
Published
SistemTakip SDK - Projelerinizden log ve bildirim gönderin
Maintainers
Readme
@sistemtakip/sdk
Official Node.js / TypeScript SDK for SistemTakip. Send log notifications directly from your projects using a single package.
Installation
npm install @sistemtakip/sdkQuick Start
import { SistemTakip } from '@sistemtakip/sdk'
const st = new SistemTakip({
apiKey: 'st_your_api_key_here',
})The apiKey is the SDK API key you create from the SistemTakip dashboard under SDK Keys.
API URLs are fixed and cannot be changed:
- Production:
live.sistemtakip.com/api- Test:
localhost/api
Methods
All methods accept a { title, message } payload and return a TriggerResponse.
st.info(payload)
Send an informational notification.
await st.info({
title: 'Deploy Tamamlandı',
message: 'v1.4.2 production ortamına başarıyla deploy edildi.',
})st.warn(payload)
Send a warning notification.
await st.warn({
title: 'Yüksek Bellek Kullanımı',
message: 'Bellek kullanımı %83 seviyesine ulaştı.',
})st.error(payload)
Send an error notification. Marked as important.
await st.error({
title: 'Veritabanı Hatası',
message: 'MySQL bağlantısı kurulamadı: Connection refused',
})st.critical(payload)
Send a critical alert. Marked as important — use for urgent failures.
await st.critical({
title: 'SERVİS ÇÖKTÜ',
message: 'Ödeme servisi 3 dakikadır yanıt vermiyor.',
})st.confirm(payload)
Send a confirmation/success notification.
await st.confirm({
title: 'Sipariş Onaylandı',
message: '#1234 numaralı sipariş ödendi ve işleme alındı.',
})st.debug(payload)
Send a debug notification (development use).
await st.debug({
title: 'Request Log',
message: 'POST /api/orders - 342ms - 200 OK',
})st.send(payload)
Send a notification with a custom level.
await st.send({
title: 'Özel Bildirim',
message: 'İstediğiniz bir mesaj.',
level: 'info', // 'info' | 'warn' | 'error' | 'critical' | 'confirm' | 'debug'
})Configuration
const st = new SistemTakip({
apiKey: 'st_xxxxx', // Required — incoming webhook API key
mode: 'production', // Optional — 'production' (default) or 'test'
timeout: 10000, // Optional — request timeout in ms (default: 10000)
})Error Handling
import { SistemTakipError } from '@sistemtakip/sdk'
try {
await st.error({
title: 'Kritik Hata',
message: 'Bir şeyler ters gitti.',
})
} catch (err) {
if (err instanceof SistemTakipError) {
console.error(`[${err.statusCode}] ${err.message}`)
}
}Real-World Examples
Express.js — Global Error Handler
import express from 'express'
import { SistemTakip } from '@sistemtakip/sdk'
const st = new SistemTakip({ apiKey: process.env.SISTEMTAKIP_API_KEY! })
app.use(async (err: Error, req: express.Request, res: express.Response, next: express.NextFunction) => {
await st.error({
title: 'Uygulama Hatası',
message: `${req.method} ${req.path} — ${err.message}`,
})
res.status(500).json({ error: 'Internal Server Error' })
})Cron Job — Sonuç Bildirimi
import { SistemTakip } from '@sistemtakip/sdk'
const st = new SistemTakip({ apiKey: process.env.SISTEMTAKIP_API_KEY! })
async function dailyBackup() {
try {
await runBackup()
await st.confirm({
title: 'Günlük Yedek Alındı',
message: `${new Date().toLocaleDateString('tr-TR')} tarihli yedek başarıyla tamamlandı.`,
})
} catch (err) {
await st.critical({
title: 'Yedekleme Başarısız',
message: String(err),
})
}
}Next.js — API Route Error Tracking
// app/api/payments/route.ts
import { SistemTakip } from '@sistemtakip/sdk'
const st = new SistemTakip({ apiKey: process.env.SISTEMTAKIP_API_KEY! })
export async function POST(req: Request) {
try {
const result = await processPayment(await req.json())
await st.confirm({
title: 'Ödeme Başarılı',
message: `Sipariş #${result.orderId} ödendi.`,
})
return Response.json(result)
} catch (err) {
await st.error({
title: 'Ödeme Hatası',
message: String(err),
})
return Response.json({ error: 'Payment failed' }, { status: 500 })
}
}Log Levels
| Method | Level | Önem | Kullanım |
|--------|-------|------|---------|
| info | info | Normal | Başarılı işlemler, deploy, genel bilgi |
| warn | warn | Normal | Eşik aşımları, potansiyel sorunlar |
| error | error | Önemli | Hata durumları, exception'lar |
| critical | critical | Önemli | Servis çöküşleri, acil müdahale gerektiren durumlar |
| confirm | confirm | Normal | Onaylar, başarılı ödeme, tamamlanan görevler |
| debug | debug | Normal | Geliştirme ve test amaçlı |
errorvecriticalseviyeleri önemli olarak işaretlenir ve push bildirim önceliği yükseltilir.
Build & Publish
npm run build # tsup ile ESM + CJS + DTS
npm version patch # versiyon artır
npm publish # npm'e yayınla