Analytics Hub Mixpanel Provider
Ukrainian version: README.ua.md
analytics_hub_mixpanel connects analytics_hub to Mixpanel.
Current scope is log-only: this package maps LogEvent to Mixpanel.track.
It uses the core EventResolver contract with ResolvedEvent payload.
Installation
dependencies:
analytics_hub: ^0.4.0
analytics_hub_mixpanel: ^0.4.0
mixpanel_flutter: ^2.0.0
Usage
final mixpanel = await Mixpanel.init(
'YOUR_MIXPANEL_TOKEN',
trackAutomaticEvents: false,
);
final hub = AnalyticsHub(
sessionDelegate: yourSessionDelegate,
providers: [
MixpanelAnalyticsHubProvider(mixpanel: mixpanel),
],
);
await hub.initialize();
await hub.sendEvent(const SignupEvent('email'));
Event example:
class SignupEvent extends LogEvent {
const SignupEvent(this.method) : super('sign_up');
final String method;
@override
Map<String, Object?> get properties => {'method': method};
@override
List<EventProvider> get providers => const [
EventProvider(MixpanelAnalyticsHubIdentifier()),
];
}
Session handling
MixpanelAnalyticsHubProvider behavior:
- If session is present: calls
identify(session.id). - If session is null and
getAnonymousIdcallback is provided: identifies with that ID. - Otherwise: calls
reset(). flush()is supported and delegates toMixpanel.flush().
Libraries
- analytics_hub_mixpanel
- Mixpanel implementation for
AnalyticsHub.