SDK Initialization¶
This article covers the content related to Flutter SDK initialization and runtime capabilities.
Basic Configuration¶
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Local environment deployment, Datakit deployment
await FTMobileFlutter.sdkConfig(
datakitUrl: datakitUrl,
);
// Using public network DataWay
await FTMobileFlutter.sdkConfig(
datawayUrl: datawayUrl,
cliToken: cliToken,
);
}
| Field | Type | Required | Description |
|---|---|---|---|
| datakitUrl | String | Yes | Local environment deployment (Datakit) reporting URL address, example: http://10.0.0.1:9529, 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 | Public network 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 |
| cliToken | String | Yes | Authentication token, must be configured together with datawayUrl |
| debug | bool | No | Sets whether to allow log printing, default is false |
| env | String | No | Environment configuration, default is prod, any characters, it is recommended to use a single word, e.g., test |
| envType | enum EnvType | No | Environment configuration, default is EnvType.prod. Note: Only one of env and envType needs to be configured |
| autoSync | bool | No | Whether to automatically sync collected data to the server, default is true. When false, use FTMobileFlutter.flushSyncData() to manage data synchronization manually |
| syncPageSize | enum | No | Sets the number of entries for sync requests, SyncPageSize.mini 5 entries, SyncPageSize.medium 10 entries, SyncPageSize.large 50 entries, default is SyncPageSize.medium |
| customSyncPageSize | number | No | Sets the number of entries for sync requests, range [5, ). A larger number of request entries means data synchronization consumes more computing resources |
| syncSleepTime | number | No | Sets the sync interval time, range [0,5000], default is not set |
| globalContext | object | No | Adds custom tags. For addition rules, please refer to Conflict Field Description |
| serviceName | String | No | Service name |
| enableLimitWithDbSize | boolean | No | Enables limiting data size using DB, default 100MB, unit Byte, not enabled by default. After enabling, logCacheLimitCount and rumCacheLimitCount will become invalid. Supported in SDK 0.5.3-pre.2 and above |
| dbCacheLimit | number | No | DB cache limit size, range [30MB, ), default 100MB, unit byte, supported in SDK 0.5.3-pre.2 and above |
| dbCacheDiscard | string | No | Sets the data discard rule in the database. FTDBCacheDiscard.discard discards new data (default), FTDBCacheDiscard.discardOldest discards old data. Supported in SDK 0.5.3-pre.2 and above |
| compressIntakeRequests | boolean | No | Deflate compression for uploaded sync data, supported in SDK 0.5.3-pre.2 and above, disabled by default |
| enableDataIntegerCompatible | boolean | No | Recommended to enable when coexistence with Web data is needed, used to handle Web data type storage compatibility issues. Enabled by default in 0.5.4-pre.1 and above |
| dataModifier | Map |
No | Modifies a single field, for usage examples see Data Collection Desensitization |
| lineDataModifier | Map |
No | Modifies a single piece of data, for usage examples see Data Collection Desensitization |
User Information Binding and Unbinding¶
Usage Method¶
/// Bind user
///
/// [userid] user id
/// [userName] username
/// [userEmail] user email
/// [userExt] extended data
static Future<void> bindRUMUserData(String userId,
{String? userName, String? userEmail, Map<String, String>? ext})
/// Unbind user
static Future<void> unbindRUMUserData()
Code Example¶
For ext addition rules, please refer to Conflict Field Description.
Runtime Capabilities¶
Active Data Synchronization¶
Manual data synchronization is only required when
autoSync: false.