analytics_hub_mixpanel 0.2.0 copy "analytics_hub_mixpanel: ^0.2.0" to clipboard
analytics_hub_mixpanel: ^0.2.0 copied to clipboard

Mixpanel provider for analytics_hub. Forwards LogEvents to Mixpanel.track with optional properties and supports identify/reset for session and anonymous users.

example/main.dart

import 'package:analytics_hub/analytics_hub.dart';
import 'package:analytics_hub_mixpanel/analytics_hub_mixpanel.dart';
import 'package:mixpanel_flutter/mixpanel_flutter.dart';

class EmptySessionDelegate implements HubSessionDelegate {
  @override
  Stream<Session?> get sessionStream => Stream.value(null);

  @override
  Future<Session?> getSession() async => null;
}

class ExampleLogEvent extends LogEvent {
  const ExampleLogEvent({required this.exampleProperty})
      : super('example_log_event');

  final String exampleProperty;

  @override
  Map<String, Object>? get properties => {'example_property': exampleProperty};

  @override
  List<EventProvider<LogEventResolver, LogEventOptions>> get providers => [
        const EventProvider(MixpanelAnalyticsHubProviderKey()),
      ];
}

Future<void> main() async {
  final mixpanel = await Mixpanel.init(
    'YOUR_MIXPANEL_TOKEN',
    trackAutomaticEvents: false,
  );

  final hub = AnalyticsHub(
    sessionDelegate: EmptySessionDelegate(),
    providers: [
      MixpanelAnalyticsHubProvider(mixpanel: mixpanel),
    ],
  );

  await hub.initialize();

  await hub.sendEvent(
    const ExampleLogEvent(exampleProperty: 'example_property'),
  );

  await hub.dispose();
}
0
likes
0
points
430
downloads

Publisher

unverified uploader

Weekly Downloads

Mixpanel provider for analytics_hub. Forwards LogEvents to Mixpanel.track with optional properties and supports identify/reset for session and anonymous users.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analytics_hub, mixpanel_flutter

More

Packages that depend on analytics_hub_mixpanel