4. Outcome Events API
Label and dispatch critical outcomes to explicit target states, optimization goals, and conversion metrics.
What are Outcome Events?
While standard Events capture raw, generic point-in-time telemetry, Outcome Events are specialized data points explicitly labelled with a result.
By attaching an outcome label to an event, you train the telemetry model to recognize patterns leading up to actions you want to encourage (e.g., completing a purchase) or discourage (e.g., abandoning a flow).
The Outcome Parameter
sendOutcomeEvent(_:with:and:) takes the outcome as a plain String label rather than a fixed enum, so your app defines the exact values. Use a small, consistent pair of opposite labels per funnel, for example "converted" and "unconverted", so the same funnel name can be compared across both outcomes.
The API Surface
The SDK provides a dedicated method for outcome events. It requires an event name, an outcome label, and a data dictionary describing the context of that outcome.
1. Sending Outcome Events
Call sendOutcomeEvent(_:with:and:) to label a conversion result immediately as it resolves. Like standard events, this call is synchronous from your call site; the SDK encodes and uploads the payload on a background task.
import NX10CoreSDK
func handlePurchaseResult(wasSuccessful: Bool, packId: String, price: Double) {
let eventData: [String: Any] = [
"pack_id": packId,
"price_usd": price
]
if wasSuccessful {
NX10Core.shared.events.sendOutcomeEvent(
"iap_funnel",
with: "converted",
and: eventData
)
} else {
NX10Core.shared.events.sendOutcomeEvent(
"iap_funnel",
with: "unconverted",
and: eventData
)
}
}Data Constraints
Supported Metadata Types
- Strings (e.g., "premium_battlepass")
- Integers (e.g., 100, -5)
- Floats & Doubles (e.g., 9.99)
- Booleans (true, false)
Unsupported Types
Outcome event data dictionaries must adhere to a strict flat structure.
- No nested dictionaries or objects
- No arrays within the data dictionary
- No custom class or struct instances
