3. Events API
Capture and dispatch discrete, point-in-time user actions and app milestones to the telemetry backend.
Points in Time vs. Persistent State
While Attributes track the continuous, ongoing state of a session, Events represent specific, instantaneous occurrences.
An event fires at the exact moment something noteworthy happens - like a purchase, a completed step, or a match result. Events are sent through NX10Core.shared.events, backed by the SDK's EventsProvider.
Fire and Forget
Unlike the Attributes API, sendEvent is synchronous from your call site. The SDK builds the event payload immediately, then encodes and uploads it on a background task so dispatching an event never blocks your UI.
The API Surface
The SDK provides a straightforward method to dispatch events, allowing an optional flat data dictionary to be attached to the payload.
1. Sending Simple Events
For basic occurrences that do not require extra metadata, call sendEvent(_:) with just an event name.
import NX10CoreSDK
NX10Core.shared.events.sendEvent("settings_opened")2. Sending Events with Metadata
To provide deeper insight into an event, pass a flat dictionary as the second argument to sendEvent(_:with:). This is useful for tracking transaction amounts, item identifiers, or outcome details.
import NX10CoreSDK
func resolvePurchase(amount: Double) {
let eventData: [String: Any] = [
"amount": amount
]
NX10Core.shared.events.sendEvent("purchase_completed", with: eventData)
}Data Constraints
Supported Metadata Types
- Strings (e.g., "economy", "critical_hit")
- Integers (e.g., -50, 2500)
- Floats & Doubles (e.g., 4.25)
- Booleans (true, false)
Unsupported Types
Just like the Attributes API, the event data dictionary enforces a flat structure.
- No nested dictionaries or objects
- No arrays within the data dictionary
- No custom class or struct instances
