retainpixel 0.1.0
retainpixel: ^0.1.0 copied to clipboard
RetainPixel SDK for Flutter/Dart. Lightweight event tracking for mobile apps.
RetainPixel Flutter SDK #
Lightweight event tracking for Flutter/Dart apps. Sends behavioral events to the RetainPixel ingest API for activation mapping, retention measurement, and experiment attribution.
Install #
dependencies:
retainpixel: ^0.1.0
Quick Start #
import 'package:retainpixel/retainpixel.dart';
final rp = RetainPixelClient(RetainPixelConfig(
orgId: 'YOUR_ORG_UUID',
appId: 'YOUR_APP_UUID',
apiKey: 'rpx_live_...',
));
await rp.init();
// Track events
rp.track('video_uploaded', properties: {'duration': 30});
// Screen views
rp.screen('home_feed');
// Identify user (SHA-256 hashed automatically)
rp.identify('user-firebase-uid');
// Revenue
rp.revenue(9.99, properties: {'plan': 'pro'});
// Paywall exposure
rp.paywallExposure(properties: {'variant': 'A'});
// Experiment exposure
rp.experimentExposure('paywall_timing_v1', 'variant_a');
// Flush on app background
await rp.flush();
// Clean up on dispose
await rp.dispose();
Configuration #
| Parameter | Required | Default | Description |
|---|---|---|---|
orgId |
Yes | — | Organization UUID from dashboard |
appId |
Yes | — | App UUID from dashboard |
apiKey |
Yes | — | API key (rpx_live_... or rpx_test_...) |
environment |
No | live |
live or test |
endpoint |
No | https://ingest.retainpixel.com |
Ingest API URL |
maxBufferSize |
No | 20 |
Auto-flush threshold |
flushInterval |
No | 30s |
Periodic flush interval |
Activation States #
Pass optional activation states to track() for funnel mapping:
rp.track('onboarding_complete', activationState: ActivationState.setup);
rp.track('first_analysis', activationState: ActivationState.firstValue);
Persistence #
Events are buffered in SharedPreferences before sending (persist-first pattern). If the app crashes or loses connectivity, buffered events are retried on next init().
License #
MIT