1. Initialisation
Start a session, establish player identity, and begin tracking.
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 game's loading sequence.
Because you configured your API keys in the Nx10 Configuration Window during setup, you do not need to pass an API key directly into the configuration. The SDK will automatically inject the correct key based on your build settings.
using NX10;
using System.Collections.Generic;
using UnityEngine;
public class GameBootstrapper : MonoBehaviour
{
void Start()
{
StartSessionExample();
}
private void StartSessionExample()
{
// 1. Define your flat, app-provided metadata
var appMetaData = new Dictionary<string, object>
{
{ "gameName", "SuperFarm" },
{ "totalLevels", 120 },
{ "installChannel", "google-play" },
{ "isPaidUser", false }
};
// 2. Identify User
string email = "example@1234.com //optional
string phoneNumber = 123456789 //Optional
//3. Initialise the SDK
NX10Manager.Instance.StartSession(email, phoneNumber, appMetaData, (success) =>
{
if (success)
{
//the SDK is initialised
}
});
}
}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. Email & Phone Number (Optional)
While the SDK handles getting the DeviceId, hardware changes. If a user upgrades their iPhone, their DeviceId will change.
Providing an Email or PhoneNumber (if your game 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 object inside the initialization signature is reserved for slow-moving or entirely static data. Examples include:
- The total number of levels available in the current build.
- The install channel or ad-campaign ID they acquired the game through.
- A/B testing cohort assignments (e.g.,
"uiVariant": "B").
Important rules for MetaData:
- It must be a flat dictionary of primitives (strings, numbers, booleans, or null).
- No nested arrays or complex JSON objects are allowed.
- For rapidly changing state (like "Player just leveled up" or "Opened the shop menu"), do not re-initialize the session. Instead, use the Attributes API detailed in the next step.
