Privacy-first analytics for Swift
Two calls add analytics to an iOS or macOS app: configure once, then track events. No IDFA, no IDFV, no device fingerprints. Works with SwiftUI and UIKit.
Free for one app and 20,000 events a month, no card needed.
import RespectlyticsSwift
// 1. Configure once at app launch
Respectlytics.configure(apiKey: "your-api-key")
// 2. Track events anywhere
Respectlytics.track("purchase_completed")
Install
Add the package with Swift Package Manager, in Xcode or in Package.swift.
In Xcode, choose File, then Add Package Dependencies, and enter this URL:
https://github.com/respectlytics/respectlytics-swift.git
Or add it to your Package.swift dependencies:
dependencies: [
.package(
url: "https://github.com/respectlytics/respectlytics-swift.git",
from: "3.1.2"
)
]
Configure once, track anywhere
Call configure() when the app starts, in SwiftUI or UIKit, then track() wherever something happens.
import SwiftUI
import RespectlyticsSwift
@main
struct MyApp: App {
init() {
Respectlytics.configure(apiKey: "your-api-key")
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
import UIKit
import RespectlyticsSwift
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
Respectlytics.configure(apiKey: "your-api-key")
return true
}
}
import SwiftUI
import RespectlyticsSwift
struct ContentView: View {
var body: some View {
VStack(spacing: 20) {
Button("Sign Up") {
Respectlytics.track("signup_started")
}
.buttonStyle(.borderedProminent)
Button("Make Purchase") {
Respectlytics.track("purchase_completed")
}
.buttonStyle(.borderedProminent)
}
.padding()
}
}
Hosting the server yourself? Pass its address to configure(). The open source edition runs the same server.
Respectlytics.configure(
apiKey: "your-api-key",
apiEndpoint: URL(string: "https://analytics.example.com/api/v1/events/")!
)
The whole API
Three methods. An event carries its name, and on a paid plan the properties you declared.
configure(apiKey:)- Starts the SDK. Call it once when the app launches.
track(_:properties:)- Records an event. On a paid plan it may carry properties you declared in the app's Settings, such as an A/B test variant:
Respectlytics.track("paywall_viewed", properties: ["paywall": "b"]). Anything undeclared is dropped. flush()- Sends queued events now. Rarely needed: the SDK sends every 30 seconds, when 10 events are queued, and when the app goes to the background.
What leaves the app
Five fields per event and only the properties you declare, the same in every SDK. The API refuses unknown fields.
Stored for each event
event_name- the name you pass to track()
timestamp- when it happened
session_id- random, kept in memory, replaced every two hours and on each launch
platform- the operating system
country- looked up on the server from the IP address, which is then discarded
Never collected
- the IDFA, the Advertising ID or any other device identifier
- a fingerprint of the device
- user IDs, names or emails
- free-text properties on events (why)
- anything written to the device
Filling in the App Store privacy label? The privacy disclosure guide walks through each question for the data Respectlytics handles.
Coming from Firebase Analytics
The calls map one to one. The parameters and the user IDs go away.
Replace each Analytics.logEvent() with Respectlytics.track() and drop its parameters. Remove setUserId() and setUserProperty() calls: Respectlytics has no user IDs and no user properties.
Questions developers ask
What the SDK does, and what it leaves out on purpose.
Does the SDK read the IDFA?
No. It never reads the IDFA or the IDFV and does not fingerprint the device, so it gives your app no reason to show the App Tracking Transparency prompt. The only ID is a random session ID kept in memory, replaced every two hours and on each launch.
Does it work with SwiftUI and UIKit?
Yes. In a SwiftUI app, call configure() in your App's init(). In a UIKit app, call it in application(_:didFinishLaunchingWithOptions:). Then call track() from anywhere.
How do I fill in the App Store privacy label?
The privacy disclosure guide walks through each question for the data Respectlytics handles: product interaction, used for analytics, not linked to the user and not used for tracking. What your app declares as a whole depends on everything else it collects.
Which Apple platforms are supported?
iOS 15 and macOS 12 or later, built with Swift 5.9 and Xcode 15 or later.
Why can't I attach any property I like to an event?
Because properties are where personal data slips into analytics: an email in a parameter, a name in a label. The API refuses unknown fields, and keeps a property only when it was declared for your app, with a value declared for it, on a paid plan, so free text cannot get in by accident. On the free plan, put the detail you need in the event name instead, such as premium_plan_selected.
Other SDKs
The same five fields, the same declared properties and the same three calls in each.
- Kotlin One Gradle line from Maven Central Android 7.0 (API level 24) and later.
- Flutter One package for five platforms iOS, Android, macOS, Linux and Windows.
- React Native Works with Expo and bare projects React Native 0.70 and later, with TypeScript types.
Using an AI coding assistant? Connect Respectlytics to it, and it can add the SDK and check that your events arrive.
Sending from a platform without an SDK? The HTTP API reference documents the endpoint the SDKs send events to.
What sets the SDK apart
The choices behind it, and what each one means for your app.
What to track
Event plans for common funnels, with the calls in each SDK.
Try it on your own app
Free for one app and 20,000 events a month, no card needed. Unlimited apps on every paid plan.