1. Initialization
Start a session, establish user identity, and begin tracking kinematics.
To begin tracking, you must initialize the SDK. This step creates a session, generates a secure token, and caches the routing endpoints for all subsequent telemetry. You should do this as early as possible in your app's lifecycle, typically inside AppDelegate or your main App struct in SwiftUI.
import SwiftUI
import NX10CoreSDK
@main
struct YourApp: App {
init() {
Task {
do {
try await NX10Core.shared.configure(
apiKey: "YOUR_API_KEY",
appGroupdID: "group.your.app.identifier",
)
} catch {
print("NX10CoreSDK Configuration failed: (error)")
}
}
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}There are additional optional configuration parameters:
- errorTrackingEnabled: This enables crash error reporting for the SDK to improve the service, no PII is ever sent.
Default value: true - autoStartTelemetry: Immediately starts a session and begins data collection when the library is initialised. You can start/stop later in the lifecycle manually as needed.
Default value: true - identifiers: Send additional identifiers as needed, additional documentation below about how these are used.
Note that the deviceId is automatically populated if not provided, you can overwrite this with your own device ID if you wish, there are implications to doing this described later but in short, using the default will enable faster model inference. - appMetaData: Used to send additional meta data for the whole session.
try await NX10Core.shared.configure(
apiKey: "YOUR_API_KEY",
appGroupdID: "group.your.app.identifier",
errorTrackingEnabled: true,
autoStartTelemetry: true,
appMetaData: (
... any flat structure ..
),
identifiers: (
deviceId: "",
email: "",
phoneNumber: ""
)
)Identity Management (Crucial)
Why Identifiers Make or Break the LFM
The Nx10 Large Feelings Model (LFM) relies entirely on longitudinal data. It learns a user's unique emotional patterns over weeks and months to build a highly accurate "Per-User Embedding".
If your identifiers change accidentally between sessions, the LFM treats that player as a brand-new user (Cold Start) every time. This destroys the predictive data moat and severely limits the accuracy of your forecasts.
1. Device ID (Required)
The deviceId is the primary anchor for a user. In iOS, you should strictly rely on UIDevice.current.identifierForVendor?.uuidString. This identifier remains stable for your app across launches and updates, only resetting if the user uninstalls all apps from your vendor.
✅ Valid Implementation
deviceId: UIDevice.current.identifierForVendor?.uuidStringRelies on stable, OS-level hardware identifiers.
❌ Invalid Implementation
deviceId: UUID().uuidStringGenerates a new ID on every boot. The LFM will never learn this player's historical patterns.
2. Email & Phone Number (Optional)
While deviceId is required, hardware changes. If a user upgrades their iPhone, their identifierForVendor will change.
Providing an email or phoneNumber (if your app utilizes account logins) allows the Nx10 backend to fuzzy match the new device to their historical profile. This instantly restores their LFM embedding on the new device, preserving their personalized affective predictions.
Stable Metadata vs. Runtime State
The metaData dictionary inside the initialization signature is reserved for slow-moving or entirely static data. Examples include:
- The user's subscription tier (e.g., Free vs Pro).
- The install channel or ad-campaign ID they acquired the app through.
- A/B testing cohort assignments (e.g.,
"uiVariant": "B").
Important rules for metaData:
- It must be a flat dictionary of primitives (Strings, Ints, Doubles, Booleans, or nil).
- No nested arrays or complex JSON objects are allowed.
- For rapidly changing state (like "User just opened the checkout screen" or "User started a workout"), do not re-initialize the session. Instead, use the Attributes API detailed in the next step.
