SDK Integration
Send events directly from your codebase using the Klime SDK.
JavaScript (Browser)
Frontend · React, Vue, Next.js
JavaScript (Node.js)
Express, Fastify, NestJS
Python
Django, Flask, FastAPI
Go
Standard library, Gin, Echo
Ruby
Rails, Sinatra
PHP
Laravel, Symfony
Java
Spring Boot, Jakarta EE
Elixir
Phoenix, Plug, LiveView
The Klime SDK lets you send events directly from your application. It has three core methods: track(), identify(), and group().
Methods
track()
Record user actions and product events. Every event needs a name and can include arbitrary properties:
klime.track("Feature Used", {
feature: "dashboard",
plan: "pro",
})If you use Klime in group mode (B2B), pass the groupId on every track() call so events are attributed to the right company:
klime.track(
"Feature Used",
{ feature: "dashboard" },
{
groupId: "company_123",
},
)identify()
Tell Klime who a user is. Call this when a user signs up or logs in. Include traits like name and email:
klime.identify("user_456", {
name: "Jane Smith",
email: "jane@acme.com",
plan: "enterprise",
})group()
Send company traits to Klime. Call this when a user logs in or switches accounts to keep company data up to date:
klime.group("company_123", {
name: "Your Company",
plan: "enterprise",
industry: "SaaS",
})The Klime SDK is stateless. Calling group() sends company traits to Klime but does not set any persistent context. You still need to pass groupId on every track() call.
Group identification
If you use Klime in group mode, every track() call needs a groupId in its options so Klime can attribute the event to a company. You also need group() calls to send company traits (name, plan, industry, etc.).
Without groupId on your track() calls, Klime receives your events but can't attribute them to specific companies. Your dashboard will show events are arriving but company-level metrics will be empty.
// 1. Send company traits (once per session or when traits change)
klime.group("company_123", {
name: "Your Company",
plan: "enterprise",
})
// 2. Pass groupId on every track call
klime.track(
"Feature Used",
{ feature: "dashboard" },
{
groupId: "company_123",
},
)Common features
All SDKs share the same core API design while following platform-specific conventions:
- Automatic batching — Events are queued and sent in batches for efficiency
- Automatic retries — Failed requests retry with exponential backoff
- Graceful shutdown — Events are flushed before process exit
- Zero dependencies — Built on standard library only
- Type safety — Full TypeScript/type hints support
Configuration
All SDKs accept similar configuration options:
| Option | Default | Description |
|---|---|---|
writeKey | (required) | Your Klime write key |
endpoint | https://i.klime.com | API endpoint |
flushInterval | 2 seconds | Time between automatic flushes |
maxBatchSize | 20 events | Max events per batch (max: 100) |
maxQueueSize | 1000 events | Max queued events |
retryMaxAttempts | 5 | Max retry attempts |
Write key
Find your write key in Settings > Integrations. Use it when initializing the SDK:
const klime = new KlimeClient({
writeKey: process.env.KLIME_WRITE_KEY,
})See the individual SDK pages for language-specific initialization examples.
Tip: Use environment variables
Never commit your write key to source control. Store it in an environment variable like KLIME_WRITE_KEY and load it at runtime.