Installation

Add the Instalog dependency to your project.

Gradle (build.gradle)

dependencies {
    implementation("dev.instalog:mobile:1.0.4")
}

Maven (pom.xml)

<dependency>
    <groupId>dev.instalog</groupId>
    <artifactId>mobile</artifactId>
    <version>1.0.4</version>
</dependency>

Initialization

Initialize the SDK in your Application class or MainActivity:

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        Instalog.getInstance().initialize(
            key = "YOUR_API_KEY",
            context = this
        )
    }
}

With Additional Configuration

For more control, you can configure the SDK with additional options:

Instalog.getInstance().initialize(
    key = "YOUR_API_KEY",
    context = this,
    handler = customAlertHandler, // Optional: Your custom alert handler
    options = InstalogOptions(
        isLogEnabled = true,    // Some options are disabled by default
        isLoggerEnabled = true, // Enable logging for debugging
        isCrashEnabled = true   // Enable crash reporting
    )
)

Note: Some InstalogOptions features are disabled by default for performance reasons. You’ll need to explicitly enable them based on your application’s requirements.

Basic Usage

1. Log Events

Track user actions and events in your app:

val instalog = Instalog.getInstance()
instalog.logEvent(context, InstalogLogModel(
    event = "button_clicked",
    params = mapOf("button_name" to "submit")
))

2. User Identification

Identify users to track their activity across sessions:

instalog.identifyUser("user123")

3. Feedback Collection

Show a feedback modal to collect user feedback:

instalog.showFeedbackModal(context)

4. Crash Reporting

Crash reporting is automatically enabled after initialization. No additional setup is required.

Advanced Features

Custom Alert Handler

Implement a custom alert handler to control how alerts are displayed:

class CustomAlertHandler : InstalogAlertDialogHandler {
    override fun show(data: InstalogAlertData) {
        // Implement your custom alert display logic
    }
}

// Set the custom handler during initialization
Instalog.getInstance().initialize(
    key = "YOUR_API_KEY",
    context = this,
    handler = CustomAlertHandler()
)

Manual Crash Simulation

Simulate crashes for testing purposes:

Instalog.crash.simulateCrash()

Manual Crash Reporting

Send crash reports manually when you catch exceptions:

try {
    // Your code that might throw an exception
} catch (e: Exception) {
    Instalog.getInstance().sendCrash(e, "Additional context about the crash")
}

Best Practices

  1. Initialize the SDK as early as possible in your application lifecycle
  2. Identify users as soon as they log in
  3. Use descriptive event names and consistent parameter names
  4. Test crash reporting in a controlled environment before production
  5. Handle user feedback promptly and professionally

Troubleshooting

Common Issues

  1. SDK not initialized

    • Ensure you call initialize() before using other methods
    • Verify your API key is correct
  2. Events not being tracked

    • Check your internet connection
    • Verify event names and parameters are valid
  3. Crash reports not appearing

    • Ensure the SDK is initialized before any crashes occur
    • Check for proper permissions

For additional support, contact our developer support team at [email protected]

API Reference

Instalog Class

MethodDescription
initialize(key: String, context: Context, handler: InstalogAlertDialogHandler? = null, options: InstalogOptions? = null)Initializes the SDK with optional custom alert handler and configuration options
logEvent(context: Context, log: InstalogLogModel)Logs an event
identifyUser(id: String)Identifies the current user
showFeedbackModal(context: Context)Shows feedback collection UI
sendCrash(string: error, stack: String)Manually sends a crash report for a caught exception
getInstance(): InstalogGets the singleton instance

Options

OptionTypeDefaultDescription
isCrashEnabledbooleanfalseEnable crash reporting
isFeedbackEnabledbooleanfalseEnable user feedback collection
isLogEnabledbooleanfalseEnable event logging
isLoggerEnabledbooleanfalseEnable console logging

Models

  • InstalogLogModel: Represents a log event
  • InstalogCrashModel: Represents crash data
  • InstalogFeedbackModel: Represents user feedback