Custom Tag Usage¶
Compilation Configuration Method¶
- Create multiple
productFlavorsinbuild.gradleto differentiate tags
android{
//…
productFlavors {
prodTest {
buildConfigField "String", "CUSTOM_VALUE", "\"Custom Test Value\""
//…
}
prodPublish {
buildConfigField "String", "CUSTOM_VALUE", "\"Custom Publish Value\""
//…
}
}
}
- Add the corresponding
BuildConfigconstant in theRUMconfiguration
Runtime File Read/Write Method¶
- Store data in a file type, such as
SharedPreferences, configure theSDK, and add code to retrieve the tag data at the configuration point.
SharedPreferences sp = context.getSharedPreferences(SP_STORE_DATA, MODE_PRIVATE);
String customDynamicValue = sp.getString(CUSTOM_DYNAMIC_TAG, "not set");
// Configure RUM
FTSdk.initRUMWithConfig(
new FTRUMConfig().addGlobalContext(CUSTOM_DYNAMIC_TAG, customDynamicValue)
//… Add other configurations
);
- Add a method to change the file data anywhere.
3.Finally, restart the application. For detailed details, please see SDK Demo
Adding at SDK Runtime¶
After the SDK initialization is complete, use FTSdk.appendGlobalContext(globalContext), FTSdk.appendRUMGlobalContext(globalContext), FTSdk.appendLogGlobalContext(globalContext) to dynamically add tags. Once set, it takes effect immediately. Subsequently, data reported by RUM or Log will automatically include the tag data. This usage is suitable for scenarios where data acquisition is delayed, such as when tag data needs to be obtained via a network request.