Add the Instalog dependency to your project.
dependencies {
implementation("dev.instalog:mobile:1.0.3")
}
<dependency>
<groupId>dev.instalog</groupId>
<artifactId>mobile</artifactId>
<version>1.0.3</version>
</dependency>
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
)
}
}
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.
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")
))
Identify users to track their activity across sessions:
instalog.identifyUser("user123")
Show a feedback modal to collect user feedback:
instalog.showFeedbackModal(context)
Crash reporting is automatically enabled after initialization. No additional setup is required.
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()
)
Simulate crashes for testing purposes:
Instalog.crash.simulateCrash()
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")
}
- Initialize the SDK as early as possible in your application lifecycle
- Identify users as soon as they log in
- Use descriptive event names and consistent parameter names
- Test crash reporting in a controlled environment before production
- Handle user feedback promptly and professionally
-
SDK not initialized
- Ensure you call
initialize()
before using other methods - Verify your API key is correct
- Ensure you call
-
Events not being tracked
- Check your internet connection
- Verify event names and parameters are valid
-
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]
Method | Description |
---|---|
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(): Instalog |
Gets the singleton instance |
InstalogLogModel
: Represents a log eventInstalogCrashModel
: Represents crash dataInstalogFeedbackModel
: Represents user feedback
The Instalog SDK is licensed under the MIT License. See LICENSE file for details.