Quick Start¶
This document provides the shortest path to integrate the Unity RUM SDK, helping you complete a verifiable data report with minimal steps.
Prerequisites¶
Before starting, please complete the following preparations:
- Create Unity Android and Unity iOS applications in RUM respectively, and obtain the corresponding
App ID - Confirm the reporting address and authentication method:
- Local environment deployment: Prepare
datakitUrl - Public DataWay: Prepare
datawayUrlandclientToken - Confirm that
ft-sdk-unity.unitypackagehas been imported into the project - Confirm that
"com.unity.nuget.newtonsoft-json"is installed in the project
Integration Steps¶
- Drag and drop
FTSDK.prefabinto the first scene - Call
FTUnityBridge.Install(...)when the application starts - Initialize
RUMConfigand pass in theApp IDcorresponding to Android and iOS - Initialize
LogConfigandTraceConfigas needed - Run the application and trigger a page view, log print, or network request
- Confirm in the Unity console and the Guance platform that the data has been successfully reported
Minimal Initialization Example¶
FTUnityBridge.Install(new SDKConfig
{
// Use datakitUrl for local environment deployment
datakitUrl = "http://10.0.0.1:9529",
// Use datawayUrl + clientToken for public DataWay
// datawayUrl = "https://open.dataway.url",
// clientToken = "client-token",
env = "prod",
debug = true,
});
FTUnityBridge.InitRUMConfig(new RUMConfig
{
androidAppId = "androidAppId",
iOSAppId = "iOSAppId",
sampleRate = 1.0f,
});
Use either
datakitUrlordatawayUrl. If using public DataWay, also pass inclientToken.
Optional: Initialize Log and Trace¶
FTUnityBridge.InitLogConfig(new LogConfig
{
enableCustomLog = true,
enableLinkRumData = true,
sampleRate = 1.0f,
});
FTUnityBridge.InitTraceConfig(new TraceConfig
{
enableNativeAutoTrace = true,
enableLinkRumData = true,
sampleRate = 1.0f,
});
Optional: Supplement Unity Exception Listening¶
If you want to convert Unity exceptions into RUM Errors, you can listen to Application.logMessageReceived:
void OnEnable()
{
Application.logMessageReceived += LogCallBack;
}
void OnDisable()
{
Application.logMessageReceived -= LogCallBack;
}
void LogCallBack(string condition, string stackTrace, LogType type)
{
if (type == LogType.Exception)
{
FTUnityBridge.AddError(stackTrace, condition);
}
}
Verify Integration Success¶
- Keep
debug = trueenabled and run the application - Open a page, or initiate a network request
- Confirm in the Unity console that logs related to SDK initialization and data synchronization appear
- Return to the Guance console and confirm that corresponding RUM data has appeared in the application
If further troubleshooting is needed, please refer to Troubleshooting.
Next Steps¶
- For complete installation and initialization instructions, continue reading Application Integration
- For explanations of all initialization parameters, read SDK Initialization
- For detailed configurations of RUM, Log, and Trace, read RUM Configuration, Log Configuration, Trace Configuration
- If your project involves native and Unity hybrid development, read Native and Unity Hybrid Development
- If you need to manually collect Views, Actions, Resources, Errors, or LongTasks, read Custom Data Collection Rules