Skip to content

Dynamic Configuration and Dynamic Update Endpoints

Proactively Synchronize Dynamic Configuration

Use FTSdk to proactively synchronize dynamic configuration. When automatic updates do not meet requirements, adjust the update timing by actively calling the method.

Supported in ft-sdk >= 1.6.16. You can parse environment variables yourself via FetchResult.onConfigSuccessFetched(RemoteConfigBean configBean, String jsonConfig).

/**
 * Proactively update remote configuration. The call frequency is affected by FTSDKConfig.setRemoteConfigMiniUpdateInterval.
 */
FTSdk.updateRemoteConfig();

/**
 * Proactively update remote configuration. This method ignores the FTSDKConfig.setRemoteConfigMiniUpdateInterval configuration.
 *
 * @param remoteConfigMiniUpdateInterval Remote configuration update interval, in seconds [0,)
 * @param result                         Returns the update result.
 */
FTSdk.updateRemoteConfig(int remoteConfigMiniUpdateInterval, FTRemoteConfigManager.FetchResult result);
/**
 * Proactively update remote configuration. The call frequency is affected by FTSDKConfig.setRemoteConfigMiniUpdateInterval.
 */
FTSdk.updateRemoteConfig()

/**
 * Proactively update remote configuration. This method ignores the FTSDKConfig.setRemoteConfigMiniUpdateInterval configuration.
 *
 * @param remoteConfigMiniUpdateInterval Remote configuration update interval, in seconds [0,)
 * @param result                         Returns the update result.
 */
FTSdk.updateRemoteConfig(remoteConfigMiniUpdateInterval, result)

Code Sample

FTSdk.updateRemoteConfig(0, new FTRemoteConfigManager.FetchResult() {
    @Override
    public void onResult(boolean success) {
        //
    }

    @Override
    public RemoteConfigBean onConfigSuccessFetched(RemoteConfigBean configBean, String jsonConfig) {
        // Optional extension: custom parsing and modification of local configuration.
        boolean isVip = false;
        try {
            JSONObject jsonObject = new JSONObject(jsonConfig);
            String userid = jsonObject.optString("custom_userid");
            isVip = (userid.equals("custom_user_test6"));
        } catch (JSONException e) {
        }

        if (isVip) {
            configBean.setRumSampleRate(1f);
            configBean.setLogSampleRate(1f);
            configBean.setTraceSampleRate(1f);
        }
        return configBean;
    }
});
FTSdk.updateRemoteConfig(0, object : FTRemoteConfigManager.FetchResult {
    override fun onResult(success: Boolean) {
        // 
    }

    override fun onConfigSuccessFetched(
        configBean: RemoteConfigBean,
        jsonConfig: String
    ): RemoteConfigBean {
        // Optional extension: custom parsing and modification of local configuration.
        var isVip = false
        try {
            val jsonObject = JSONObject(jsonConfig)
            val userId = jsonObject.optString("custom_userid")
            isVip = userId == "custom_user_test6"
        } catch (e: JSONException) {
            // ignore
        }

        if (isVip) {
            configBean.setRumSampleRate(1f)
        }
        return configBean
    }
})

Dynamically Enable and Disable AndroidID Retrieval

Use FTSdk to set whether to retrieve Android ID within the SDK.

FTSdk.setEnableAccessAndroidID(true);
FTSdk.setEnableAccessAndroidID(false);
FTSdk.setEnableAccessAndroidID(true)
FTSdk.setEnableAccessAndroidID(false)

Dynamically Update Reporting Endpoint

Use FTSdk to dynamically switch the data reporting endpoint during SDK runtime. After successful setting, subsequent data will continue to be uploaded to the new address.

Supported in ft-sdk >= 1.6.17. Use either setDatakitUrl or setDatawayUrl. When using setDatawayUrl, the new clientToken must also be provided.

Use Cases

FTSDKConfig.builder() supports initialization without providing datakitUrl or datawayUrl. In this scenario, the SDK will perform data collection but will not upload it.

When FTSdk.setDatakitUrl(...) or FTSdk.setDatawayUrl(..., ...) is subsequently called to dynamically set the reporting endpoint, the SDK will start consuming the local cache and perform data reporting.

Note that data collected before the upload endpoint is set is still subject to local cache limits. The cache limit is primarily influenced by the following configurations:

  • FTLoggerConfig.setLogCacheLimitCount
  • FTRUMConfig.setRumCacheLimitCount
  • The database cache limit corresponding to FTSDKConfig.enableLimitWithDbSize

If the cache reaches its limit, data exceeding the limit may be discarded. Therefore, it is recommended to provide the upload endpoint as soon as possible in this mode, or to set cache limits appropriately based on business scenarios.

FTSdk.setDatakitUrl("http://10.0.0.1:9529");
FTSdk.setDatawayUrl("https://openway.guance.com", "your-client-token");
FTSdk.setDatakitUrl("http://10.0.0.1:9529")
FTSdk.setDatawayUrl("https://openway.guance.com", "your-client-token")
Method Name Type Required Meaning
setDatakitUrl String Yes Dynamically sets the Datakit reporting endpoint. After successful setting, the SDK will continue uploading data to the new Datakit address.
setDatawayUrl String, String Yes Dynamically sets the Dataway reporting endpoint and clientToken. After successful setting, the SDK will continue uploading data to the new Dataway address.