Skip to content

Manual Integration

How to Integrate the SDK Without Using ft-plugin

TrueWatch uses Android Gradle Plugin Transformation to implement code injection, thereby achieving automatic data collection. However, due to some compatibility issues, there may be situations where ft-plugin or ft-plugin-legacy cannot be used. The affected scope includes:

  • Action and Resource in RUM
  • Automatic capture of android.util.Log
  • Automatic capture of Java and Kotlin println console logs
  • Automatic upload of symbol files

Currently, for this situation, a manual integration solution can be adopted.

Application Startup Event

Refer to the source code example DemoForManualSet.kt.

// Application
@Override
public void onCreate() {
    super.onCreate();
    // Must be called before SDK initialization
    FTAutoTrack.startApp(null);
    // Set SDK configuration
    setSDK(this);
}
// Application
override fun onCreate() {
    super.onCreate()
    // Must be called before SDK initialization
    FTAutoTrack.startApp(null)
    // Set SDK configuration
    setSDK(this)
}

Manually Adding User Actions

Events such as button clicks need to be added manually at the trigger point. Here is an example using a Button onClick event. Refer to the source code example ManualActivity.kt:

view.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        FTRUMGlobalManager.get().startAction("[action button]", "click");
    }
});
view.setOnClickListener {
    FTRUMGlobalManager.get().startAction("[action button]", "click")
}

Manual Integration for OkHttp Resource / Trace

OkHttp can integrate Resource and Trace through addInterceptor and eventListener. The example is as follows. Refer to the source code example ManualActivity.kt:

OkHttpClient.Builder builder = new OkHttpClient.Builder()
    .addInterceptor(new FTTraceInterceptor())
    .addInterceptor(new FTResourceInterceptor())
    .eventListenerFactory(new FTResourceEventListener.FTFactory());
//.eventListenerFactory(new FTResourceEventListener.FTFactory(true));
OkHttpClient client = builder.build();
val builder = OkHttpClient.Builder()
    .addInterceptor(FTTraceInterceptor())
    .addInterceptor(FTResourceInterceptor())
    .eventListenerFactory(FTResourceEventListener.FTFactory())
    //.eventListenerFactory(new FTResourceEventListener.FTFactory(true))
val client = builder.build()

Other network frameworks require implementing FTRUMGlobalManager.startResource, stopResource, addResource, and FTTraceManager.getTraceHeader manually. For specific implementation methods, refer to the source code example ManualActivity.kt.

Manual Configuration for WebView

FTAutoTrack.setUpWebView(webview);
// Configure before performing the loadUrl operation
FTAutoTrack.setUpWebView(webview)
// Configure before performing the loadUrl operation