Skip to content
AppSpector is a debugging service for mobile apps
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
images Update readme (#5) Feb 7, 2019
README.md Update README.md Mar 20, 2019
proguard-rules.pro

README.md

AppSpector

With AppSpector you can remotely debug your app running in the same room or on another continent. You can measure app performance, view database content, logs, network requests and many more in realtime. This is the instrument that you've been looking for. Don't limit yourself only to simple logs. Debugging doesn't have to be painful!

Installation

Each app you want to use with AppSpector SDK you have to register on the web (https://app.appspector.com). After adding the application navigate to app settings and copy API key.

Add AppSpector SDK to your project

GitHub release

Add AppSpector dependency to buildscript in your project-level build.gradle

buildscript {
  repositories {
      jcenter()
      google()
      maven {
          url "https://maven.appspector.com/artifactory/android-sdk"
      }
  }
  
  dependencies {
      classpath "com.appspector:android-sdk-plugin:1.+"
  }
}

Modify your app-level build.gradle

apply plugin: 'com.android.application'
// Put AppSpector plugin after Android plugin
apply plugin: 'com.appspector.sdk'

// Add AppSpector maven repository
repositories {
    maven {
        url "https://maven.appspector.com/artifactory/android-sdk"
    }
}

dependencies {
    implementation "com.appspector:android-sdk:1.+"
}

In case when you don't want to have AppSpector SDK in your release APK use AppSpector NO-OP artifact

dependencies {
    debugImplementation "com.appspector:android-sdk:1.+"
    releaseImplementation "com.appspector:android-sdk-noop:1.+"
}

Initialize AppSpector SDK

import android.app.Application;

import com.appspector.sdk.AppSpector;

public class AmazingApp extends Application {

   @Override
   public void onCreate() {
      super.onCreate();
      
      // We recommend to start AppSpector from Application#onCreate method
      
      // You can start all monitors
      AppSpector
            .build(this)
            .withDefaultMonitors()            
            .run("API_KEY");
            
      // Or you can select monitors that you want to use
      AppSpector
            .build(this)
            .addPerformanceMonitor()
            .addHttpMonitor()
            // If specific monitor is not added then this kind of data won't be tracked and available on the web
            .addLogMonitor()
            .addScreenshotMonitor()
            .addSQLMonitor()
            .run("API_KEY");
   }

}

Build and Run

Build your project and see everything work! When your app is up and running you can go to https://app.appspector.com and connect to your application session.

Configure

SDK start/stop

AppSpector start is two step process. When you link with AppSpector framework it starts to collect data immediately after load. When you call run method - AppSpector opens a connection to the backend and from that point you can see your session on the frontend.

You can manually control AppSpector state by calling start and stop methods. stop tells AppSpector to disable all data collection and close current session. start starts it again using config you provided at load. This will be a new session, all activity between stop and start calls will not be tracked.

AppSpector.shared().stop();
AppSpector.shared().start();

Custom device name

You can assign a custom name to your device to easily find needed sessions in the sessions list. To do this you have to add the desired name as a value for AppSpector.METADATA_KEY_DEVICE_NAME key to the metadata dictionary:

AppSpector
            .build(this)
            .withDefaultMonitors()
            .addMetadata(AppSpector.METADATA_KEY_DEVICE_NAME, "YOUR_DEVICE_NAME")
            .run("YOUR_API_KEY");

Filtering your data

Sometimes you may want to adjust or completely skip some pieces of data AppSpector gather. We have a special feature called Sanitizing for this, for now it’s available only for HTTP and logs monitors, more coming. For these two monitors you can provide a filter which allows to modify or block events before AppSpector sends them to the backend. You can specify filters via addHttpMonitor(HTTPFilter) and addLogMonitor(LogMonitor.Filter) methods.

Some examples. Let's say we want to skip our auth token from requests headers:

public class TokenFilter implements HTTPFilter {
    @Nullable
    @Override
    public HttpRequest filter(HttpRequest request) {
        if (request.getHeaders().containsKey("YOUR-AUTH-HEADER")) {
             request.getHeaders().remove("YOUR-AUTH-HEADER");
        }
        return request;
    }

    @Nullable
    @Override
    public HttpResponse filter(HttpResponse response) {
        return response;
    }
}

And here, for example, we want to change a log level to WARN for all messages with word token:

public class LogFilter implements Filter {
  
    @Nullable
    @Override
    public LogEvent filter(LogEvent event) {
        if (event.message.contains("token")) {
             event.level = LogLevel.WARN;
        }
        return request;
    }
}

Let's provide them to monitors:

AppSpector
            .build(this)
            .withDefaultMonitors()
            .addLogMonitor(new LogFilter())
            .addHttpMonitor(new TokenFilter())
            .run("YOUR_API_KEY");

Getting session URL

Sometimes you may need to get URL pointing to current session from code. Say you want link crash in your crash reporter with it, write it to logs or display in your debug UI. To get this URL you have to add a session start callback:

AppSpector.shared().setSessionUrlListener(new SessionUrlListener() {
    @Override
    public void onReceived(@NonNull String sessionUrl) {
        // Save url for future use...
    }
});

Disable background data collection

By default, AppSpector SDK is active until the application is killed by Android OS, even if no activities left. It may lead to unnecessary data collection and long sessions for inactive apps. We provide API to disable data collection for a case when the app has no started activities.

AppSpector
        .build(this)
        .collectDataInBackground(false) // Set this flag to disable data collection if no activities left
        .withDefaultMonitors()
        .run("YOUR_API_KEY");

Using OkHttp interceptor instead of AppSpector Gradle Plugin

If you don't want to use AppSpector Gradle Plugin you could use an alternative way to intercept HTTP requests and responses. You can manually add AppSpectorOkHttp3Interceptor to your OkHttpClient (Or AppSpectorOkHttp2Interceptor for old version of OkHttpClient). Also, don't forget to remove AppSpector plugin from your app/build.gradle file.

new OkHttpClient.Builder()
  .addInterceptor(new AuthenticationInterceptor()) // for example, it adds auth token to you request
  .addInterceptor(new AppSpectorOkHttp3Interceptor()) // it will track your requests and responses
  .build()

Features

AppSpector provides many monitors that tracks different activities inside your app:

SQLite monitor

Provides browser for sqlite databases found in your app. Allows to track all queries, shows DB scheme and data in DB. You can issue custom SQL query on any DB and see results in browser immediately.

SQLite monitor

HTTP monitor

Shows all HTTP traffic in your app. You can examine any request, see request/response headers and body. We provide XML and JSON highliting for request/responses with formatting and folding options so even huge responses are easy to look through.

SQLite monitor

Logs monitor

Displays all logs generated by your app.

Logs

Location monitor

Most of the apps are location-aware. Testing it requires changing locations yourself. In this case, location mocking is a real time saver. Just point to the location on the map and your app will change its geodata right away.

Location

Performance monitor

Displays real-time graphs of the CPU / Memory / Network / Disk / Battery usage.

Performance

Screenshot monitor

Simply captures screenshot from the device.

Screenshots

Feedback

Let us know what do you think or what would you like to be improved: info@appspector.com.

Join our slack to discuss setup process and features

You can’t perform that action at this time.