Sinsera Track SDK

pub.flutter-io.cn License

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 SDK
  • createSession() β†’ Future<bool> - Create a new tracking session
  • trackEvent(String eventName, [Map<String, dynamic>? eventValue]) β†’ Future<bool> - Track an event

Properties

  • isInitialized β†’ bool - Check if SDK is initialized
  • hasActiveSession β†’ bool - Check if session is active
  • installId β†’ String? - Get current install ID

Error Types

  • SinseraException - Base exception class
  • SinseraInitializationException - SDK initialization errors
  • SinseraNetworkException - Network-related errors
  • SinseraAuthenticationException - Authentication failures
  • SinseraSessionException - Session management errors
  • SinseraDeviceException - Device information collection errors
  • SinseraCryptoException - 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

Libraries

sinsera_track_sdk