Installation
CocoaPods
InstalogIOS is available through CocoaPods. To install it, add the following line to your Podfile:
Swift Package Manager
InstalogIOS is also available through Swift Package Manager. To install it, add the following to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/instalog-dev/instalog-ios.git", .exact("1.0.1"))
]
Or in Xcode:
- File > Add Packages…
- Enter package URL:
https://github.com/instalog-dev/instalog-ios.git
- Select “Exact Version” and enter “1.0.1”
- Click “Add Package”
Getting Started
Initialize the SDK
import InstalogIOS
// In AppDelegate
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Basic initialization
Instalog.shared.initialize(key: "your-api-key")
// Or initialize with specific features enabled/disabled
let options = InstalogOptions(dictionary: [
"isCrashEnabled": true, // Enable/disable crash reporting
"isFeedbackEnabled": true, // Enable/disable feedback functionality
"isLogEnabled": true, // Enable/disable event logging
"isLoggerEnabled": false // Enable/disable debug logging
])
Instalog.shared.initialize(key: "your-api-key", options: options)
return true
}
Feature Configuration
InstalogIOS allows you to configure which features are enabled or disabled:
Option | Default | Description |
---|
isCrashEnabled | true | Controls crash reporting functionality |
isFeedbackEnabled | true | Controls in-app feedback functionality |
isLogEnabled | true | Controls event logging functionality |
isLoggerEnabled | false | Controls internal debug logging |
You can configure these options when initializing the SDK, or use the default configuration.
Basic Usage
// Set user ID
Instalog.shared.identifyUser("user123")
// Log an event
let log = InstalogLogModel(
event: "onboarding_completed",
params: ["screen": "welcome", "user_type": "new"]
)
Instalog.shared.logEvent(log: log)
// Show feedback modal
Instalog.shared.showFeedbackModal()
Features
Crash Reporting
- Automatic crash detection
- Manual crash reporting
- Crash simulation for testing
- Can be enabled/disabled through configuration
// Manually report a crash
let error = NSError(domain: "MyErrorDomain", code: 100, userInfo: [NSLocalizedDescriptionKey: "Test error"])
Instalog.shared.sendCrash(name: "CustomError", report: error)
// Simulate a crash for testing
Instalog.shared.simulateCrash()
Event Logging
- Multiple log levels (debug, info, warning, error)
- Custom metadata support
- Automatic device information collection
- Can be enabled/disabled through configuration
// Log with custom metadata
let log = InstalogLogModel(
event: "payment_failed",
params: [
"paymentId": "pay_123456",
"amount": "99.99",
"currency": "USD"
]
)
Instalog.shared.logEvent(log: log)
User Feedback
- In-app feedback modal
- Screenshot attachment (up to 4 images)
- Programmatic feedback submission
- Can be enabled/disabled through configuration
Configurable Components
- Selectively enable or disable features based on your needs
- Control internal logging verbosity
- All configurations can be set at initialization
Example
To run the example project:
- Clone the repo
- Run
pod install
from the Example directory
- Open the workspace in Xcode
The example project demonstrates:
- SDK initialization with feature configuration
- Event logging with different log levels
- Crash reporting and simulation
- User feedback collection
Initialization Example
// Initialize with all default settings
Instalog.shared.initialize(key: "your-api-key")
// Initialize with custom configuration
let options = InstalogOptions(dictionary: [
"isCrashEnabled": true,
"isFeedbackEnabled": true,
"isLogEnabled": true,
"isLoggerEnabled": true // Enable internal logging for debugging
])
Instalog.shared.initialize(key: "your-api-key", options: options)
// Set a user identifier
Instalog.shared.identifyUser("user_123")
Logging Example
// Simple event log
let simpleLog = InstalogLogModel(
event: "product_viewed",
params: ["product_id": "12345", "category": "electronics"]
)
Instalog.shared.logEvent(log: simpleLog)
// Detailed event log
let detailedLog = InstalogLogModel(
event: "payment_failed",
params: [
"transaction_id": "tx_789",
"error_code": "payment_declined",
"amount": "99.99",
"currency": "USD"
]
)
Instalog.shared.logEvent(log: detailedLog)
Troubleshooting
Common Issues
-
SDK initialization failures
- Verify API key is correct
- Check network connectivity
- Ensure proper permissions in Info.plist
-
Missing crash reports
- Verify symbolication is properly configured
- Check that crash reporting is enabled in configuration
-
Feedback modal not appearing
- Ensure the SDK is properly initialized
- Verify the view controller hierarchy
For additional support, contact us at [email protected]
Responses are generated using AI and may contain mistakes.