retenshun 1.1.0 copy "retenshun: ^1.1.0" to clipboard
retenshun: ^1.1.0 copied to clipboard

Official Retenshun Flutter SDK for event tracking, user identification, and e-commerce analytics.

Retenshun Flutter SDK #

Official Flutter SDK for Retenshun — AI-powered retention analytics. Track events, identify users, and monitor e-commerce activity in your Flutter apps.

Features #

  • Event Tracking — Track custom events with properties
  • User Identification — Identify users and attach properties
  • Screen Tracking — Automatic or manual screen view tracking
  • E-commerce Analytics — Standardized product, cart, and order tracking
  • App Lifecycle Tracking — Automatic app_opened / app_backgrounded events
  • Batched Delivery — Events are batched and flushed efficiently
  • Offline Resilience — Failed events are re-queued for retry

Getting Started #

1. Install #

dependencies:
  retenshun: ^1.0.0
flutter pub get

2. Initialize #

Call Retenshun.init() once at app startup, before runApp():

import 'package:retenshun/retenshun.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Retenshun.init(
    projectId: 'proj_abc123',
    apiKey: 'pk_live_your_key',
  );

  runApp(const MyApp());
}

3. Identify Users #

Call on login or registration:

Retenshun.identify('user_123', properties: {
  'email': 'john@example.com',
  'name': 'John Doe',
  'plan': 'pro',
});

4. Track Events #

Retenshun.track('button_clicked', properties: {
  'button': 'cta',
  'screen': 'home',
});

5. Track Screen Views #

Add RetenshunObserver for automatic screen tracking:

MaterialApp(
  navigatorObservers: [RetenshunObserver()],
  // ...
)

Or track manually:

Retenshun.screen('Home', properties: {'tab': 'feed'});

6. E-commerce Tracking #

// Product viewed
Retenshun.ecommerce.productViewed(
  productId: 'prod_1',
  name: 'Wireless Headphones',
  price: 79.99,
  category: 'Electronics',
);

// Added to cart
Retenshun.ecommerce.addedToCart(
  productId: 'prod_1',
  price: 79.99,
  quantity: 1,
);

// Order completed
Retenshun.ecommerce.orderCompleted(
  orderId: 'ord_123',
  total: 79.99,
  currency: 'USD',
);

Configuration #

Parameter Default Description
projectId required Your Retenshun project ID
apiKey required Your public API key
apiUrl https://api.retenshun.com/v1 Custom API base URL
debug false Enable debug logging
autoTrackScreens true Auto-track screen views
autoTrackLifecycle true Auto-track app lifecycle
flushAt 20 Flush when queue reaches this size
flushIntervalSeconds 30 Periodic flush interval

Widget Integration #

Wrap your app with RetenshunProvider for widget-tree access:

RetenshunProvider(
  child: MaterialApp(...),
)

// Then anywhere in the tree:
final retenshun = RetenshunProvider.of(context);

Logout #

Retenshun.reset();

Additional Information #

1
likes
155
points
10
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Official Retenshun Flutter SDK for event tracking, user identification, and e-commerce analytics.

Homepage
Repository (GitHub)
View/report issues

Topics

#analytics #tracking #retention #ecommerce #events

License

MIT (license)

Dependencies

flutter, http, shared_preferences, uuid

More

Packages that depend on retenshun