littlefish_analytics_sentry 1.2.0
littlefish_analytics_sentry: ^1.2.0 copied to clipboard
The implementation of littlefish_core for Sentry Analytics
littlefish_analytics_sentry #
The Sentry implementation of the littlefish analytics package for event tracking and user analytics.
Features #
- Event logging via Sentry breadcrumbs
- User identification and properties
- Screen tracking
- Navigation observer for automatic screen tracking
Getting Started #
Add this package to your pubspec.yaml:
dependencies:
littlefish_analytics_sentry: ^1.0.0
Usage #
import 'package:littlefish_analytics_sentry/sentry_analytics_service.dart';
// Initialize the service
final analyticsService = SentryAnalyticsService();
await analyticsService.initialize(
settings: AnalyticsSettings(
enabled: true,
),
);
// Log events
await analyticsService.logEvent(
e: AnalyticsEvent('button_click', parameters: {'button_id': 'submit'}),
);
// Set user context
await analyticsService.setUserId(userId: 'user123');
await analyticsService.setUserProperty(name: 'plan', value: 'premium');
// Track screens
await analyticsService.setScreenName(name: 'HomeScreen');
// Get navigation observer for automatic screen tracking
final observer = await analyticsService.getAnalyticsObserver();
Note #
Sentry must be initialized before using this service. You can either:
- Initialize Sentry via
littlefish_observability_sentryfirst - Initialize Sentry directly in your application using
SentryFlutter.init()
If Sentry is not initialized, the service will mark itself as not ready and analytics operations will be skipped.