beacon_mixpanel

Mixpanel integration package for the Beacon analytics library.

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  beacon_mixpanel:
    path: path/to/beacon/integrations/beacon_mixpanel

Usage

1. Initialize Mixpanel

First, initialize the Mixpanel SDK with your project token:

import 'package:mixpanel_flutter/mixpanel_flutter.dart';

final mixpanel = await Mixpanel.init(
  'YOUR_PROJECT_TOKEN',
  trackAutomaticEvents: true,
);

2. Create and Attach the Receiver

Create a MixpanelReceiver and attach it to Beacon:

import 'package:beacon_core/beacon.dart';
import 'package:beacon_mixpanel/beacon_mixpanel.dart';

final receiver = MixpanelReceiver(mixpanel: mixpanel);
Beacon().attach(receiver);

3. Track Events

Now all events sent through Beacon will be forwarded to Mixpanel:

Beacon().emit('button_clicked', params: {
  'button_name': 'subscribe',
  'screen': 'home',
});

Default Parameters

You can specify default parameters that will be included with every event:

final receiver = MixpanelReceiver(
  mixpanel: mixpanel,
  defaultParams: {
    'app_version': '1.0.0',
    'platform': 'mobile',
  },
);

These default parameters will be merged with event-specific parameters. Event parameters take precedence if there are conflicts.

Configuration Options

Constructor Parameters

  • mixpanel (required): The initialized Mixpanel instance
  • defaultParams (optional): Default parameters to include with every event

Error Handling

The receiver handles errors gracefully and logs them without interrupting the analytics flow. If Mixpanel tracking fails, the error is caught and logged, but other receivers will continue to work normally.

License

MIT License - see the LICENSE file for details.

Libraries

beacon_mixpanel