Sinsera Track SDK
Official Sinsera Track SDK for Flutter applications. Provides advanced attribution tracking with device fingerprinting and fraud analysis capabilities.
Features
- π Secure Attribution Tracking - Military-grade HMAC-SHA256 authentication
- π± Device Fingerprinting - Advanced device identification and fraud prevention
- π Native Performance - C++ native library for crypto operations
- π― Real-time Events - Track user actions and engagement metrics
- π Cross-platform - iOS, Android, macOS, Windows, and Linux support
- π§ Easy Integration - Simple API with comprehensive documentation
Installation
Add this to your package's pubspec.yaml
file:
dependencies:
sinsera_track_sdk: ^1.0.0
Then run:
flutter pub get
Quick Start
1. Initialize the SDK
import 'package:sinsera_track_sdk/sinsera_track_sdk.dart';
final sdk = SinseraTrackSdk(
appToken: 'your-app-token-here',
secretKey: 'your-secret-key-here',
packageName: 'com.yourcompany.yourapp',
enableDebugLogs: true, // Set to false in production
);
// Initialize the SDK
try {
final success = await sdk.initialize();
if (success) {
print('SDK initialized successfully');
} else {
print('SDK initialization failed');
}
} catch (e) {
print('SDK initialization error: $e');
}
2. Create a Session
// Create a tracking session
try {
final success = await sdk.createSession();
if (success) {
print('Session created successfully');
}
} catch (e) {
print('Session creation error: $e');
}
3. Track Events
// Track simple events
await sdk.trackEvent('user_login');
// Track events with custom data
await sdk.trackEvent('purchase', {
'item_id': 'premium_upgrade',
'price': 9.99,
'currency': 'USD',
'category': 'subscription',
});
// Track game events
await sdk.trackEvent('level_completed', {
'level': 5,
'score': 12500,
'time_spent': 180, // seconds
'difficulty': 'hard',
});
Advanced Usage
Custom Base URL
final sdk = SinseraTrackSdk(
appToken: 'your-app-token',
secretKey: 'your-secret-key',
packageName: 'com.yourcompany.yourapp',
baseUrl: 'https://your-custom-endpoint.com',
);
Error Handling
try {
await sdk.initialize();
await sdk.createSession();
await sdk.trackEvent('user_action');
} on SinseraException catch (e) {
// Handle Sinsera-specific errors
print('Sinsera error: ${e.message}');
if (e.code != null) {
print('Error code: ${e.code}');
}
} catch (e) {
// Handle general errors
print('General error: $e');
}
Check SDK Status
// Check if SDK is initialized
if (sdk.isInitialized) {
print('SDK is ready to use');
}
// Check if session is active
if (sdk.hasActiveSession) {
print('Session is active, install ID: ${sdk.installId}');
}
Configuration
Required Parameters
Parameter | Type | Description |
---|---|---|
appToken |
String | Your application token from Sinsera dashboard |
secretKey |
String | Secret key for HMAC authentication |
packageName |
String | Your app's package name (e.g., com.example.app) |
Optional Parameters
Parameter | Type | Default | Description |
---|---|---|---|
baseUrl |
String | https://track.sinseragames.com |
Custom API endpoint |
enableDebugLogs |
bool | false |
Enable debug logging |
API Reference
SinseraTrackSdk Class
Methods
initialize()
βFuture<bool>
- Initialize the SDKcreateSession()
βFuture<bool>
- Create a new tracking sessiontrackEvent(String eventName, [Map<String, dynamic>? eventValue])
βFuture<bool>
- Track an event
Properties
isInitialized
βbool
- Check if SDK is initializedhasActiveSession
βbool
- Check if session is activeinstallId
βString?
- Get current install ID
Error Types
SinseraException
- Base exception classSinseraInitializationException
- SDK initialization errorsSinseraNetworkException
- Network-related errorsSinseraAuthenticationException
- Authentication failuresSinseraSessionException
- Session management errorsSinseraDeviceException
- Device information collection errorsSinseraCryptoException
- Cryptographic operation errors
Platform Support
Platform | Minimum Version | Architecture |
---|---|---|
iOS | 12.0+ | arm64, x86_64 |
Android | API 21+ | arm64-v8a, armeabi-v7a, x86_64 |
macOS | 10.14+ | arm64, x86_64 |
Windows | Windows 10+ | x64 |
Linux | Ubuntu 18.04+ | x64 |
Security
The Sinsera Track SDK implements multiple security measures:
- HMAC-SHA256 authentication for all API requests
- Native cryptographic operations to protect sensitive algorithms
- Device fingerprinting for fraud detection
- Secure token management with automatic expiration
- No sensitive data storage in plain text
Privacy
The SDK collects device and usage information for attribution tracking. This includes:
- Device hardware information (model, sensors, etc.)
- App usage events and metrics
- Network and system information
- Unique device identifiers
All data collection complies with privacy regulations and is used solely for attribution and fraud prevention purposes.
Troubleshooting
Common Issues
SDK initialization fails
- Verify your app token and secret key are correct
- Check network connectivity
- Enable debug logs to see detailed error messages
Session creation fails
- Ensure SDK is initialized first
- Check if JWT token is valid and not expired
- Verify API endpoints are accessible
Native library not found
- Run
flutter clean && flutter pub get
- Rebuild your app to ensure native libraries are included
- Check platform-specific build configurations
Debug Logs
Enable debug logging during development:
final sdk = SinseraTrackSdk(
// ... other parameters
enableDebugLogs: true,
);
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- π§ Email: dev@sinseragames.com
- π Documentation: https://docs.sinseragames.com/track-sdk
- π Issues: https://github.com/sinseragames/sinsera_track_sdk/issues