Skip to content

SDK Initialization

This article covers the initialization and runtime capabilities of the Unity SDK.

Basic Configuration

FTUnityBridge.Install(new SDKConfig
{
    datakitUrl = "http://10.0.0.1:9529",
    env = "prod",
    debug = true,
});
Field Type Required Description
datakitUrl string Yes The reporting URL address for the local environment deployment (Datakit). Example: http://10.0.0.1:9529. The default port is 9529. The device installing the SDK must be able to access this address. Note: Choose one between datakitUrl and datawayUrl.
datawayUrl string Yes The public DataWay reporting URL address, obtained from the [RUM] application. Example: https://open.dataway.url. The device installing the SDK must be able to access this address. Note: Choose one between datakitUrl and datawayUrl.
clientToken string Yes Authentication token, must be used together with datawayUrl.
debug boolean No Sets whether to allow printing Debug logs. Default is false.
env string No Environment. Default is prod. Any string is allowed, but a single word is recommended, e.g., test.
serviceName string No Sets the name of the associated business or service. Default: df_rum_ios, df_rum_android.
globalContext object No Adds custom tags. For detailed rules, please refer to Custom Tag Usage.
autoSync boolean No Whether to automatically sync collected data to the server. Default is YES. When set to NO, use flushSyncData() to manage data synchronization manually.
syncPageSize number No Sets the number of entries per sync request. Range: [5,). A larger number means the data sync consumes more computing resources. Default is 10.
syncSleepTime number No Sets the interval time between syncs. Range: [0,5000]. Not set by default.
enableDataIntegerCompatible boolean No Recommended to enable when coexistence with Web data is needed. Enabled by default in SDK version 1.1.0 and later.
compressIntakeRequests boolean No Compresses upload/sync data using deflate. Disabled by default. Supported in SDK version 1.1.0 and above.
enableLimitWithDbSize boolean No Enables limiting data size using DB. Default limit is 100MB, unit Byte. When enabled, logCacheLimitCount and rumCacheLimitCount become ineffective.
dbCacheLimit number No DB cache size limit. Range: [30MB,). Default is 100MB, unit byte.
dbDiscardStrategy string No Sets the data discard rule in the database: discard discards new data (default), discardOldest discards old data.
dataModifier object No Modifies a single field. Supported in SDK version 1.1.0 and above. See example in Data Collection Masking.
lineDataModifier object No Modifies a single piece of data. Supported in SDK version 1.1.0 and above. See example in Data Collection Masking.

User Information Binding and Unbinding

Usage

/// <summary>
/// Binds RUM user information.
/// </summary>
/// <param name="userId">Unique user id</param>
public static async Task BindUserData(string userId)

/// <summary>
/// Binds RUM user information.
/// </summary>
/// <param name="userData"></param>
public static async Task BindUserData(UserData userData)

public static async Task UnBindUserdata()
Method Name Type Required Description
userId string Yes User id.
userName string No Username.
userEmail string No User email.
extra dictionary No Assign values in KV format. For addition rules, please refer to Application Access.

Code Example

FTUnityBridge.BindUserData(new UserData
{
    userId = "userid",
    userName = "userName",
    userEmail = "[email protected]",
    extra = new Dictionary<string, string>
    {
        {"custom_data", "custom data"}
    }
});

FTUnityBridge.UnBindUserdata();

Runtime Capabilities

Clearing SDK Cache Data

Use FTUnityBridge to clear cached data that has not been reported.

FTUnityBridge.clearAllData();

Manual Data Synchronization

When SDKConfig.autoSync is configured as true, no additional action is needed; the SDK will sync automatically. When SDKConfig.autoSync is configured as false, you need to manually trigger the data synchronization method.

FTUnityBridge.flushSyncData();

Shutting Down the SDK

FTUnityBridge.DeInit();