1. Initialisation & Consent
Manage user consent, start and stop sessions, establish player identity, and begin tracking.
User Consent Requirement (Mandatory)
You must not call NX10Manager.Instance.StartSession() until you have obtained valid consent from the user (for example, via your Consent Management Platform or in-game privacy prompt). If a user declines or has not yet responded, do not start a session.
In addition, if a user withdraws their consent at any point (such as through your game's privacy settings), you must immediately call NX10Manager.Instance.StopSession() to terminate the session and halt all data collection.
Starting & Stopping a Session
Once user consent has been granted (either immediately after the user accepts your consent prompt, or early in your loading sequence on subsequent launches after verifying stored consent), initialize the SDK by calling StartSession. This step creates a session, generates a secure token, and caches the routing endpoints for all subsequent data.
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()
{
// Only start a session if the user has already granted consent
if (HasUserGrantedNX10Consent())
{
OnUserConsentGranted();
}
}
// Call this once the user grants consent (or on startup if consent is already stored)
public void OnUserConsentGranted()
{
// 1. Define your flat, app-provided metadata
var appMetaData = new Dictionary<string, object>
{
{ "gameName", "SuperFarm" },
{ "totalLevels", 120 },
{ "installChannel", "google-play" },
{ "isPaidUser", false }
};
// 2. Initialise the SDK only after consent is confirmed
NX10Manager.Instance.StartSession(appMetaData, (success) =>
{
if (success)
{
// The SDK is initialised; now we can start collecting telemetry
NX10Manager.Instance.StartTelemetry();
}
});
}
// Call this immediately if the user withdraws consent in your privacy settings
public void OnUserConsentWithdrawn()
{
// Stops the active session and halts ALL data collection
// (telemetry, events, outcome events, and attributes)
NX10Manager.Instance.StopSession();
}
private bool HasUserGrantedNX10Consent()
{
// Replace with your CMP or consent storage check
return false;
}
}Session Lifecycle vs. Telemetry Control
The SDK separates session lifecycle (StartSession / StopSession) from kinematic telemetry capture (StartTelemetry / StopTelemetry). Understanding the difference is essential for handling user consent accurately:
StartSession&StopSession(Full Consent Gate): Controls the entire NX10 session. BeforeStartSessionis called—or onceStopSession()is called—nothing is collected (no telemetry, no events, and no attributes). Always use these methods to enforce user consent and consent withdrawal.StartTelemetry&StopTelemetry(Kinematic Sensor Toggle): Controls only high-frequency kinematic telemetry collection (touch, accelerometer, and gyroscope) within an active, consented session. CallingStopTelemetry()stops collecting telemetry data while allowing the SDK to keep collecting Events and Attributes (such asSendEvent,SendOutcomeEvent, andSetAttribute). CallingStartTelemetry()resumes kinematic telemetry collection.
| Method | Telemetry Data | Events & Attributes | When to Call |
|---|---|---|---|
| StartSession(...) | Ready (starts on StartTelemetry) | Active | Only after the user has granted consent. |
| StartTelemetry() | Active | Active | Inside the StartSession success callback, or to resume sensor capture after pausing. |
| StopTelemetry() | Stopped | Active | To pause kinematic telemetry (e.g., password screens) while continuing to collect events and attributes. |
| StopSession() | Stopped | Stopped | Immediately when a user withdraws consent. |
It is critical to wait for the StartSession callback to complete successfully before calling NX10Manager.Instance.StartTelemetry(). Explicitly triggering StartTelemetry() at this stage opens the high-frequency telemetry pipeline so zero baseline metrics are missed once a consented session begins.
Identity Management (Crucial)
Why Identifiers Matter
NX10 relies entirely on longitudinal data. We learn user's unique emotional patterns over weeks and months to build a highly accurate "Per-User Embedding".
If your identifiers change accidentally between sessions, NX10 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.
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.
