remotex_sdk 0.1.1
remotex_sdk: ^0.1.1 copied to clipboard
A package to work with Remotex
Remotex SDK #
A Flutter package for integrating with the Remotex platform. This SDK provides functionality for event tracking, user identification, and fetching remote configurations.
Installation #
Add the package to your pubspec.yaml:
dependencies:
remotex_sdk:
git:
url: https://github.com/kamaravichow/remotex_sdk.git
ref: master
Usage #
Initialization #
Initialize the SDK early in your application lifecycle, typically in your main() function or top-level widget.
import 'package:remotex_sdk/remotex_sdk.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize Remotex with your App ID
await Remotex().init('YOUR_APP_ID');
runApp(const MyApp());
}
Tracking Events #
Track custom events with optional properties to analyze user behavior.
// Track a simple event
await Remotex().track('button_clicked');
// Track an event with properties
await Remotex().track(
'purchase_completed',
{
'item_id': 'prod_123',
'price': 29.99,
'currency': 'USD',
},
);
User Identification #
Identify users to associate events with specific profiles.
final userData = UserData(
name: 'John Doe',
email: 'john.doe@example.com',
phone: '+1234567890',
avatarUrl: 'https://example.com/avatar.jpg',
customProps: {
'plan': 'premium',
'signup_source': 'mobile_app',
},
);
await Remotex().identify(userData);
Remote Configuration #
Fetch dynamic configuration values from the Remotex server. The SDK automatically includes device context (platform, OS version, app version, etc.). You can also pass additional context.
try {
// Fetch config with default context
final config = await Remotex().fetchConfig();
// Or fetch with additional context
final configWithContext = await Remotex().fetchConfig({
'user_tier': 'gold',
'beta_tester': true,
});
print('Feature enabled: ${config['enable_new_feature']}');
} catch (e) {
print('Failed to fetch config: $e');
}
Lifecycle Management #
The SDK automatically handles app lifecycle changes (pausing/resuming) to manage session pings and data ingestion efficiently. No manual lifecycle management is required after initialization.