# Eight SDKs, one profile per person

Eight open-source analytics SDKs for the browser, Android, iOS, React Native, Flutter, Node.js, Go, and Ruby, plus an HTTP API for any other language.

Source: https://pug.sh/sdks

Web, Android, iOS, React Native, Flutter, Node, Go, and Ruby have shipped since July 2026. Each sends to the same pipeline, so one person’s web, app, and server events land on the same profile.

## Install and initialize

### Web

```typescript
import { init, identify, track } from '@pug-sh/browser'

init('your-project-id', { apiKey: 'pub_your_key' })
// Page views, clicks, scrolls, form interactions, rage clicks
// and dead clicks are captured automatically from here on.

identify('user_123', { email: 'ada@example.com', plan: 'pro' })
track('signup', { plan: 'pro' })
track('order_completed', { amount: 49.0, currency: 'USD' })
```

### Android

```kotlin
import sh.pug.android.Options
import sh.pug.android.Pug

Pug.init(this, "your-project-id", Options("pub_your_key"))
// Call once in Application.onCreate(). Lifecycle, screen
// views and installs are tracked automatically from here.

Pug.identify("user_123", mapOf("plan" to "pro"))
Pug.track.purchase(amount = 49.0, currency = "USD")
```

### iOS

```swift
import Pug
do {
  try Pug.initialize(
    projectId: "your-project-id",
    options: Pug.Options(apiKey: "pub_your_key"))
} catch { assertionFailure("Pug was not started: \(error)") }
// App opens, screen views and installs are tracked from here.
Pug.identify("user_123", traits: ["plan": "pro"])
Pug.track.purchase(amount: 49.0, currency: "USD")
```

### React Native

```typescript
import { identify, init, track } from '@pug-sh/react-native'

init('your-project-id', { apiKey: 'pub_your_key' })
// Once, in the app's entry file. App opens, closes, installs
// and updates are tracked from here; trackNavigation(ref)
// adds a screen view for each route your navigator shows.

identify('user_123', { plan: 'pro' })
track('purchase', { amount: 49.0, currency: 'USD' })
```

### Flutter

```dart
import 'package:pug_flutter/pug_flutter.dart';

await Pug.init('your-project-id',
    const PugOptions(apiKey: 'pub_your_key'));
// Auto-tracking starts immediately. Identify users on sign-in:
await Pug.identify('user_123', traits: {'plan': 'pro'});

// Typed methods for well-known events, custom props in extras:
Pug.track.signup(extras: {'plan': 'pro'});
```

### Node

```typescript
import { Pug } from '@pug-sh/node'

const pug = new Pug({ apiKey: process.env.PUG_PRIVATE_KEY })

// Server events name the user explicitly: no ambient session.
pug.track('user_123', 'order_completed', { amount: 49.0 })
await pug.identify('user_123', { email: 'ada@example.com' })
// Private keys can also read: profiles and insight queries.
const profile = await pug.profiles.getByExternalId('user_123')
```

### Go

```go
import pug "github.com/pug-sh/sdk-go"
key := os.Getenv("PUG_PRIVATE_KEY") // private key, prv_...
client, err := pug.New(pug.Options{APIKey: key})
if err != nil {
	log.Fatal(err) // no key, or not a prv_ key
}
defer client.Close(context.Background()) // drains the queues
client.Track("user_123", "signup", pug.String("plan", "pro"))
client.Identify("user_123", pug.Email("ada@example.com"))
```

### Ruby

```ruby
require "pug"

pug = Pug::Client.new(api_key: ENV.fetch("PUG_PRIVATE_KEY"))

# Server events name the user explicitly: no ambient session.
pug.track("user_123", "order_completed", amount: 49.0)
pug.identify("user_123", email: "ada@example.com", plan: "pro")
# Private keys can also read: profiles and insight queries.
profile = pug.profiles.get_by_external_id("user_123")
```

## Client and server SDKs

The client SDKs (Web, Android, iOS, React Native, and Flutter) use your public key, which is safe to ship in an app bundle. The server SDKs (Node, Go, and Ruby) use a private key, which can also read profiles and insights.

### Web (Since July 2026)

Autocapture, sessions, consent states, and batched delivery for any website or web app.

`npm install @pug-sh/browser`

- [Framework setup guides](https://pug.sh/integrations)
- [Web SDK reference](https://docs.pug.sh/sdks/web/)

### Android (Since October 2026)

Native Kotlin SDK, also callable from Java, on two runtime dependencies. Tracks app lifecycle, installs, and each activity as a screen; a composable or fragment is named with Pug.screen.

`implementation("sh.pug:android:0.3.0")`

- [Android setup guide](https://pug.sh/integrations/android)
- [Android SDK reference](https://docs.pug.sh/sdks/android/)

### iOS (Since November 2026)

Native Swift SDK for iOS, iPadOS, and Mac Catalyst, with no runtime dependencies. Tracks app lifecycle, installs, and each view controller as a screen; a SwiftUI screen is named with .pugScreen.

`.package(url: "https://github.com/pug-sh/sdk-ios.git", from: "0.2.0")`

- [iOS setup guide](https://pug.sh/integrations/ios)
- [iOS SDK reference](https://docs.pug.sh/sdks/ios/)

### React Native (Since December 2026)

For React Native 0.83 or newer on the New Architecture, in bare apps and Expo development builds, on the Android and iOS SDKs. Tracks app lifecycle and installs; trackNavigation names each React Navigation or Expo Router screen.

`npm install @pug-sh/react-native`

- [React Native setup guide](https://pug.sh/integrations/react-native)
- [React Native SDK reference](https://github.com/pug-sh/sdk-react-native#readme)

### Flutter (Since July 2026)

Tracks app opens and installs on its own, with identity and sessions. On Android and iOS, each route change is a screen view once PugRouteObserver is on the navigator.

`flutter pub add pug_flutter`

- [Flutter setup guide](https://pug.sh/integrations/flutter)
- [Flutter SDK reference](https://docs.pug.sh/sdks/flutter/)

### Node (Since July 2026)

Server-side events that name the user on every call, plus profile and insight reads.

`npm install @pug-sh/node`

- [Node.js setup guide](https://pug.sh/integrations/nodejs)
- [Node SDK reference](https://docs.pug.sh/sdks/node/#server-side-reads)

### Go (Since October 2026)

Server-side events plus profile and insight reads for Go 1.26+, with typed properties and well-known events checked at compile time. Tracking never fails or waits on the network.

`go get github.com/pug-sh/sdk-go`

- [Go setup guide](https://pug.sh/integrations/go)
- [Go SDK reference](https://docs.pug.sh/sdks/go/)

### Ruby (Since October 2026)

Server-side events plus profile and insight reads from Rails or plain Ruby, thread- and fork-safe under Puma and Sidekiq.

`bundle add pug-sh`

- [Rails setup guide](https://pug.sh/integrations/rails)
- [Ruby SDK reference](https://docs.pug.sh/sdks/ruby/)

### HTTP API (Available)

From any other language, a POST of JSON sends events and identifies users through the same Connect API the SDKs call.

`POST https://api.pugs.dev`

[HTTP API reference](https://docs.pug.sh/sdks/http/)

### AI crawlers (Since November 2026)

Reports each request from a known crawler, such as GPTBot or ClaudeBot, from your site’s own request handling, after the response. It has no dependencies and runs on Cloudflare Workers, Vercel and Next.js, Hono, Bun, Deno, Express, and plain Node.

`npm install @pug-sh/crawlers`

[AI crawler setup in the docs](https://docs.pug.sh/crawlers/)

## Rust, Java, and Python server SDKs are in development.

They use the same events and identity model as the SDKs above.

[Pug’s public roadmap](https://docs.pug.sh/roadmap/)
