API Reference

Core SDK methods across all supported platforms.

Kotlin / Android SDK

AndroidiOSDesktop

Initialization

MethodDescription
Snapbug.initialize(context)Initialize the SDK with an Android Context
Snapbug.initialize()Initialize the SDK for Desktop or iOS

Analytics

val analytics = snapbugAnalytics("user_events")
analytics.log("button_clicked", mapOf("screen" to "home"))
MethodDescription
snapbugAnalytics(id)Get an analytics logger by table ID

Dashboards

snapbugDashboard("app_metrics") {
    // define dashboard widgets
}
MethodDescription
snapbugDashboard(id) { }Define a custom dashboard with widgets

Deep Links

snapbugDeeplink {
    // configure deep link handlers
}
MethodDescription
snapbugDeeplink { }Configure deep link handling for the Desktop inspector

Tables

val table = snapbugTable("request_log")
table.addRow(mapOf("endpoint" to "/api/users", "status" to "200"))
MethodDescription
snapbugTable(name)Get a table logger for custom tabular data

Database

MethodDescription
snapbugRegisterDatabase(...)Register a local database for inspection
snapbugLogDatabaseQuery(...)Log a database query for the Desktop query viewer

Preferences

MethodDescription
snapbugRegisterPreference(...)Register a SharedPreferences or DataStore instance

WebSocket

MethodDescription
snapbugLogWebSocketEvent(...)Log a WebSocket event (send, receive, connect, disconnect)

Flutter SDK

Flutter

Initialization

Snapbug.start(plugins: [
  SnapbugCrashReporter(catchFatalErrors: true),
  SnapbugNetwork(),
]);
MethodDescription
Snapbug.start(plugins: [...])Initialize the SDK with a list of plugins
Snapbug.updateServerHost(host)Change the Desktop app host address

Analytics

final analytics = Snapbug.analytics("user_events");
analytics.log("button_clicked", {"screen": "home"});
MethodDescription
Snapbug.analytics(tableId)Get an analytics logger by table ID

Plugins

MethodDescription
Snapbug.getPlugin<T>()Get a registered plugin instance by type

Network Interceptor

final dio = Dio();
dio.interceptors.add(SnapbugDioInterceptor());
MethodDescription
SnapbugDioInterceptor()Dio HTTP interceptor for capturing network traffic

React Native SDK

React Native

Initialization

import { Snapbug, SnapbugNetwork, SnapbugCrashReporter } from 'snapbug-react-native';
 
Snapbug.start({
  plugins: [
    new SnapbugNetwork(),
    new SnapbugCrashReporter({ catchFatalErrors: true }),
  ],
});
MethodDescription
Snapbug.start(config)Initialize the SDK with plugins and configuration
Snapbug.stop()Stop the SDK and disconnect from Desktop

Analytics

const analytics = Snapbug.analytics("user_events");
analytics.log("button_clicked", { screen: "home" });
MethodDescription
Snapbug.analytics(tableId)Get an analytics logger by table ID

Plugins

MethodDescription
Snapbug.getPlugin(Class)Get a registered plugin instance by class

Fetch Interception

Automatically intercept all fetch calls to capture network traffic:

import { patchFetch, unpatchFetch } from 'snapbug-react-native';
 
// Start intercepting
patchFetch();
 
// Stop intercepting
unpatchFetch();
MethodDescription
patchFetch()Monkey-patch global fetch to auto-capture network calls
unpatchFetch()Restore the original fetch function