SDKs#
LogTap ships official SDKs for three platforms that report "structured logs" and "events" to the gateway, wrapping batch buffering, gzip compression, retry-on-failure, and context merging. Other languages can call the HTTP API directly — see the Ingest API.
Common configuration#
baseUrl: gateway addressprojectId: project IDprojectKey: required whenAUTH_SECRETis enabled (X-Project-Key: pk_...)gzip: optional; automatically downgrades on platforms that don't support it
Shared capabilities: an internal queue flushes on flushIntervalMs or as soon as minBatchSize items accumulate; failures retry with exponential backoff (capped at 30 s); globalTags / globalContexts merge into every payload; identify() sets user context; a beforeSend hook supports redaction or dropping.
JavaScript / TypeScript (Browser / Node)#
Package: logtap-sdk (repo directory sdks/js/logtap/)
npm i logtap-sdkimport { LogtapClient } from "logtap-sdk";
const client = new LogtapClient({
baseUrl: "https://your-logtap-host",
projectId: 1,
projectKey: "pk_xxx",
gzip: true,
flushIntervalMs: 5000, // max delay (also sends when the timer fires)
minBatchSize: 20, // send immediately once this many items queue up
immediateEvents: ["purchase", "payment_succeeded"],
globalTags: { env: "prod" },
globalContexts: { app: { version: "1.2.3" } },
});
client.captureBrowserErrors(); // optional in browsers
client.captureNodeErrors(); // optional in Node
client.identify("u1", { plan: "pro" });
client.info("hello", { k: "v" }, { tags: { req: "1" } });
client.track("signup", { from: "landing" });
await client.close();Go#
go get github.com/aak1247/logtap/sdks/go/logtapclient, err := logtap.NewClient(logtap.ClientOptions{
BaseURL: "https://your-logtap-host",
ProjectID: 1,
ProjectKey: "pk_xxx",
Gzip: true,
GlobalTags: map[string]string{"env": "prod"},
GlobalContexts: map[string]any{
"app": map[string]any{"version": "1.2.3"},
},
})
if err != nil {
panic(err)
}
defer client.Close(context.Background())
defer client.Recover(true) // optional: report panics
client.Identify("u1", map[string]any{"plan": "pro"})
client.Info("hello", map[string]any{"k": "v"}, nil)
client.Track("signup", map[string]any{"from": "landing"}, nil)Flutter#
Package: logtap_flutter (repo directory sdks/flutter/logtap_flutter/)
final client = await LogtapClient.create(
const LogtapClientOptions(
baseUrl: "https://your-logtap-host",
projectId: 1,
projectKey: "pk_xxx",
gzip: true, // Web automatically downgrades to non-gzip
globalTags: {"env": "prod"},
globalContexts: {"app": {"version": "1.2.3"}},
),
);
client.captureFlutterErrors(); // optional: capture unhandled errors
client.identify("u1", {"plan": "pro"});
client.info("hello", {"k": "v"});
client.track("signup", {"from": "landing"});
await client.close();Other languages#
You don't need an SDK — report over plain HTTP (see the Ingest API). A Python example:
import requests
requests.post(
"https://your-logtap-host/api/1/logs/",
headers={"X-Project-Key": "pk_xxx"},
json=[{"level": "info", "message": "hello", "user": {"id": "u1"}}],
)More language integration examples (Python, Java, PHP, Ruby, .NET) live in the repository under docs/integrations/.
What about error monitoring?#
For error monitoring prefer the Sentry SDK (zero changes except the DSN — see Sentry compatibility); the per-platform capture*Errors() helpers fit lightweight scenarios where no Sentry SDK is present.