Respectlytics Respect lytics
Menu

Official SDKs

Privacy-first analytics SDKs for Swift, Flutter, React Native, and Kotlin. Simple integration, automatic session management, offline support, and zero device identifier collection.

v2.1.0 πŸ“¦ Swift Package Manager iOS 15+ / macOS 12+ View on GitHub 🍎 View Full Swift Guide β†’

Installation

Add the Respectlytics SDK to your project using Swift Package Manager:

Option 1: Xcode

In Xcode, go to File β†’ Add Package Dependencies and enter:

URL
https://github.com/respectlytics/respectlytics-swift.git

Option 2: Package.swift

Add to your Package.swift dependencies:

Swift
dependencies: [
    .package(url: "https://github.com/respectlytics/respectlytics-swift.git", from: "2.1.0")
]

Quick Start

Get started with just 2 lines of code:

Swift
import RespectlyticsSwift

// 1. Configure (call once at app launch)
Respectlytics.configure(apiKey: "your-api-key")

// 2. Track events
Respectlytics.track("purchase")

API Reference

Method Description
configure(apiKey:) Initialize the SDK. Call once in application(_:didFinishLaunchingWithOptions:)
track(_:) Track an event
flush() Force send queued events. SDK auto-flushes, rarely needed

Full Example

Swift
import SwiftUI
import RespectlyticsSwift

@main
struct MyApp: App {
    init() {
        // Configure SDK at launch
        Respectlytics.configure(apiKey: "your-api-key")
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

struct ContentView: View {
    var body: some View {
        VStack {
            Button("Sign Up") {
                Respectlytics.track("signup_started")
            }

            Button("Purchase") {
                Respectlytics.track("purchase_completed")
            }
        }
    }
}

πŸ”’ Privacy by Design

Respectlytics is designed to minimize data collection by default. We use anonymized identifiers that are stored only in device memory (RAM) and rotate automatically every two hours or upon app restart. IP addresses are processed transiently for country-level geolocation lookup and immediately discardedβ€”no personal data is ever persisted server-side. This privacy-by-design architecture avoids persistent device storage and cross-session tracking, significantly reducing compliance complexity compared to traditional analytics. While this approach may reduce or eliminate consent requirements in some jurisdictions, regulations and their interpretation vary. We recommend consulting with your legal team to determine your specific compliance requirements.

βœ… What We Store (5 Fields Only)

  • Event name (e.g., "purchase")
  • Session ID (RAM-only, 2-hour rotation)
  • Timestamp
  • Platform (ios, android, web)
  • Country (auto-detected from IP)

❌ What We NEVER Collect or Store

  • IDFA / GAID / Advertising IDs
  • Device fingerprints or hardware IDs
  • IP addresses (processed transiently, never stored)
  • Custom properties or user-defined data
  • User IDs or persistent identifiers
  • Email, name, phone, or any PII
πŸ€–

AI-Assisted Integration

For Vibe Coders

Building with AI coding assistants like Copilot, Cursor, or Claude? Copy this prompt and paste it into your AI assistant. It will analyze your codebase and add event tracking at appropriate locations throughout your project.

⚠️ Review the results: Always review what your AI assistant generates. The prompt provides guidance, but you know your app best. Remove any events you don't need and add any that are missing.

AI Integration Prompt
I want you to integrate Respectlytics analytics into my project. Respectlytics is a privacy-first analytics SDK that tracks events with minimal data collection.

## ⚠️ IMPORTANT: Less is More

**Target 10-20 total events per app.** More events β‰  better analytics. Too many events create noise and make conversion path analysis meaningless (every user journey becomes unique and ungroupable).

Focus on the **conversion funnel**: What path do users take before their first purchase?

## SDK Installation

πŸ“‹ **Package identifiers (copy exactly):**
| Platform | Identifier |
|----------|------------|
| Swift | `https://github.com/respectlytics/respectlytics-swift.git` |
| Flutter | `respectlytics_flutter` |
| React Native | `respectlytics-react-native` |
| Kotlin | `io.github.respectlytics:respectlytics-kotlin` |

Install the SDK for my platform:

**Swift (iOS/macOS):**
```swift
// In Xcode: File β†’ Add Package Dependencies
// URL: https://github.com/respectlytics/respectlytics-swift.git
import RespectlyticsSwift
```

**Flutter:**
```yaml
# pubspec.yaml
dependencies:
  respectlytics_flutter: ^2.1.0
```

**React Native:**
```bash
npm install respectlytics-react-native
# or
yarn add respectlytics-react-native
```

**Kotlin (Android):**
```kotlin
// build.gradle.kts
implementation("io.github.respectlytics:respectlytics-kotlin:2.1.0")
```

## ⚠️ CRITICAL: Initialization Order

**configure() MUST be called BEFORE any track() calls.** Events tracked before configuration are silently dropped.

❌ **WRONG** - track() before configure():
```swift
// DON'T DO THIS - events will be lost!
class HomeViewController: UIViewController {
    override func viewDidLoad() {
        Respectlytics.track("home_viewed")  // ❌ SDK not configured yet!
    }
}
// configure() called later in AppDelegate... too late!
```

βœ… **CORRECT** - configure() at earliest app lifecycle point:
```swift
// configure() runs FIRST, before any screen can call track()
@main struct MyApp: App {
    init() {
        Respectlytics.configure(apiKey: "YOUR_API_KEY")  // βœ… First!
    }
}
```

## Configuration (MUST be first)

Call configure() once at the **earliest possible point** in your app lifecycleβ€”before any UI renders or any track() calls can execute.

**Swift:** (synchronous)
```swift
// In @main App init() or AppDelegate didFinishLaunchingWithOptions
Respectlytics.configure(apiKey: "YOUR_API_KEY")
```

**Flutter:** (async - use await!)
```dart
// In main() BEFORE runApp() - must await!
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Respectlytics.configure(apiKey: 'YOUR_API_KEY');  // await is required!
  runApp(MyApp());  // Only run app AFTER configure completes
}
```

**React Native:** (synchronous - call at module level, NOT in useEffect)
```typescript
// In index.js or App.tsx - call BEFORE component definition
import { Respectlytics } from 'respectlytics-react-native';

// Configure at module level - runs before any component renders
Respectlytics.configure('YOUR_API_KEY');

export default function App() {
  // App is safe to call track() anywhere now
}
```

**Kotlin:** (synchronous)
```kotlin
// In Application.onCreate() - runs before any Activity
class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        Respectlytics.configure(apiKey = "YOUR_API_KEY")  // Before any Activity
    }
}
```

## Event Tracking

Use this pattern to track events:

**Swift:**
```swift
Respectlytics.track("event_name")
```

**Flutter:**
```dart
Respectlytics.track('event_name');
```

**React Native:**
```typescript
Respectlytics.track('event_name');
```

**Kotlin:**
```kotlin
Respectlytics.track("event_name")
```

## Event Naming Conventions

- Use snake_case: `purchase_completed`, `signup_started`
- **Only lowercase letters and underscores**: No numbers, no special characters
  - βœ… `purchase_success`, `premium_plan_selected`
  - ❌ `purchase$success`, `plan-selected`, `Purchase_Completed`
- **Include screen/context as prefix** when the same action can occur on multiple screens:
  - βœ… `home_upgrade_tapped`, `settings_upgrade_tapped` (if upgrade button exists in both places)
  - βœ… `purchase_started` (if it only happens in one place, no prefix needed)
- NO custom properties allowed - encode ALL meaning in the event name itself

## Your Task: Add 10-20 Strategic Events

Analyze my codebase and add Respectlytics event tracking. **Be selective** - only track events that help understand the path to conversion.

### TIER 1: ESSENTIAL (Always add these ~5-8 events)

These are the core conversion funnel events. Every app needs these:

**Purchase funnel (pick the ones that apply):**
- `paywall_viewed` - user sees pricing/upgrade screen
- `purchase_started` - user initiates purchase flow
- `purchase_success` - payment completed βœ…
- `purchase_failed` - payment failed
- `purchase_cancelled` - user backed out

**Onboarding (if your app has it):**
- `onboarding_completed` - user finished onboarding

**Key entry points:**
- `signup_completed` or `login_completed` - user authenticated

### TIER 2: IMPORTANT (Add 3-5 of these if relevant)

These help understand user behavior before conversion:

- `[feature]_used` - main feature engagement (e.g., `photo_edited`, `workout_completed`)
- `[screen]_viewed` - only for key screens in the conversion path (e.g., `premium_features_viewed`)
- `free_trial_started` - if you offer trials
- `share_completed` - if sharing is a growth driver
- `notification_opened` - if push notifications drive engagement

### TIER 3: OPTIONAL (Only if you have specific questions)

Add these sparingly, only if you need to answer a specific question:

- `[specific_feature]_used` - to compare converting vs non-converting users
- `error_displayed` - if you suspect errors hurt conversion
- `help_requested` - if you suspect UX confusion

## ❌ DO NOT ADD (Anti-patterns)

These create noise and hurt analytics quality:

- ❌ Generic screen views for every screen (`home_viewed`, `settings_viewed`, `profile_viewed`...)
- ❌ Every button tap (`button_clicked`, `back_button_tapped`...)
- ❌ Scroll events, keystroke events, focus events
- ❌ Redundant purchase events (`purchase_initiated` AND `purchase_started` AND `checkout_began`)
- ❌ Tab switches unless tabs represent major features
- ❌ Every form field interaction
- ❌ Events that fire multiple times per session for the same action

## Important Rules

1. **configure() BEFORE any track()**: This is critical! Place configure() at the earliest app lifecycle point.

2. **No custom properties**: The SDK only accepts `eventName`. Encode context in the event name itself.

3. **Event name format**: Only lowercase letters and underscores. No special characters like `$`, `-`, or numbers.

4. **One configure() call**: Only call configure() once. Do not call it in individual screens.

5. **Don't track sensitive screens**: Skip screens with personal data entry (password fields, payment details).

6. **flush() is usually automatic**: The SDK auto-flushes. Only call manually before logout if needed.

Now please scan my project and add **10-20 strategic events** focused on the conversion funnel. Show me the files you would modify and explain why each event matters for understanding conversion.
1️⃣

Copy the prompt

Click the button above to copy the full integration prompt

2️⃣

Paste in your AI assistant

Works with Copilot, Cursor, Claude, ChatGPT, and others

3️⃣

Review & customize

Check the generated events and adjust to your needs

Automatic Behaviors

The SDKs handle these automatically so you don't have to:

Feature Behavior
Session Management Auto-generates session ID (RAM-only), rotates after 2 hours or on app restart
Event Queue Batches events and sends every 30 seconds or when queue reaches 10 events
Offline Support Queues events when offline, sends when connectivity returns
Background Flush Automatically sends queued events when app enters background
Retry Logic 3 retries with exponential backoff on network failures
Metadata Collection Auto-collects 4 fields only: event_name, timestamp, session_id, platform

Need Help?

Questions about integration? We're here to help.