Dynamic Configuration and Dynamic Endpoint Updates¶
Remote Configuration¶
Supported since SDK 0.5.7.
Use remote configuration to retrieve environment variables delivered by the platform and adjust settings such as sampling, log filtering, and data upload.
Prerequisites¶
In FTMobileFlutter.sdkConfig(), set enableRemoteConfiguration: true and configure a valid reporting endpoint. Then use FTRUMManager().setConfig() to set the RUM App ID for the current platform. For complete setup instructions, see SDK Initialization and RUM Configuration. Logs, traces, and Session Replay still need to be initialized separately.
Scope¶
Field names follow the native SDK. For supported fields, units, and how they take effect, see Flutter Remote Configuration Fields. Common settings such as sampling, log filtering, and upload affect Flutter data. Switches such as native View, Action, Resource, and jank only control native collection; they do not change Flutter automatic routing, Dart network collection, or Dart LongTask configuration.
Update Methods¶
| Update Method | Minimum Update Interval | Result Retrieval |
|---|---|---|
| SDK automatic update | remoteConfigMiniUpdateInterval, in seconds, default 12 hours |
FTMobileFlutter.addRemoteConfigListener() |
FTMobileFlutter.updateRemoteConfig() |
Uses the interval set during initialization | The returned Future<FTRemoteConfigResult> |
FTMobileFlutter.updateRemoteConfigWithMiniUpdateInterval(interval) |
Uses the interval passed in this call, in seconds; must be a non-negative integer; 0 skips the interval check |
The returned Future<FTRemoteConfigResult> |
The minimum update interval limits request frequency; it does not mean that the SDK refreshes at 12-hour intervals. Manual updates are asynchronous operations; passing 0 still requires meeting the initialization conditions above.
// Use the minimum update interval set during initialization
final result = await FTMobileFlutter.updateRemoteConfig();
debugPrint('远程配置更新结果:${result.success}');
// Skip the minimum interval check when the business needs an immediate update
final immediateResult =
await FTMobileFlutter.updateRemoteConfigWithMiniUpdateInterval(0);
debugPrint('主动更新结果:${immediateResult.success}');
Listen for Update Results¶
Use FTMobileFlutter.addRemoteConfigListener() to listen for automatic update results. Results of manual calls are obtained through the returned Future and are not notified through this listener.
// Custom business callback; the function name can be customized
void onRemoteConfigUpdated(FTRemoteConfigResult result) {
debugPrint('自动更新结果:${result.success}');
}
FTMobileFlutter.addRemoteConfigListener(onRemoteConfigUpdated);
To stop listening, call FTMobileFlutter.removeRemoteConfigListener(onRemoteConfigUpdated).
Dynamically Update the Reporting Endpoint¶
Use FTMobileFlutter to switch the data reporting endpoint at SDK runtime. After the setting succeeds, subsequent data is uploaded to the new endpoint.
Choose either setDatakitURL or setDatawayURL; when using setDatawayURL, you must also pass cliToken.
await FTMobileFlutter.setDatakitURL(datakitUrl);
// Choose either the public DataWay or the method above
// await FTMobileFlutter.setDatawayURL(datawayUrl, cliToken);
Set the Reporting Endpoint Later¶
Supported since SDK 0.5.8.
During initialization, FTMobileFlutter.sdkConfig() can omit datakitUrl, datawayUrl, and cliToken. The SDK collects and caches data first without uploading it. After obtaining the endpoint, call the methods above to set the endpoint, and data will be uploaded according to the sync settings.
Data is still subject to the local cache configuration and may be discarded when the limit is reached. If autoSync: false is set, you need to call FTMobileFlutter.flushSyncData() to upload data manually.