beacon_amplitude 0.0.1 copy "beacon_amplitude: ^0.0.1" to clipboard
beacon_amplitude: ^0.0.1 copied to clipboard

Amplitude integration package for Beacon analytics library.

beacon_amplitude #

Amplitude integration package for the Beacon analytics library.

Installation #

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

dependencies:
  beacon_amplitude:
    path: path/to/beacon/integrations/beacon_amplitude

Usage #

1. Initialize Amplitude #

First, initialize the Amplitude SDK with your API key:

import 'package:amplitude_flutter/amplitude.dart';
import 'package:amplitude_flutter/configuration.dart';

final amplitude = Amplitude(Configuration(apiKey: 'YOUR_API_KEY'));
await amplitude.isBuilt;

2. Create and Attach the Receiver #

Create an AmplitudeReceiver and attach it to Beacon:

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

final receiver = AmplitudeReceiver(amplitude: amplitude);
Beacon().attach(receiver);

3. Track Events #

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

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 = AmplitudeReceiver(
  amplitude: amplitude,
  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 #

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

Advanced Configuration #

For advanced Amplitude configuration, configure the Amplitude instance before passing it to the receiver:

import 'package:amplitude_flutter/configuration.dart';
import 'package:amplitude_flutter/events/identify.dart';

final configuration = Configuration(
  apiKey: 'YOUR_API_KEY',
  defaultTracking: DefaultTrackingOptions(sessions: true),
);

final amplitude = Amplitude(configuration);
await amplitude.isBuilt;

// Optional: Set user properties
final identify = Identify()
  ..set('plan', 'premium')
  ..set('signup_date', '2024-01-01');
amplitude.identify(identify);

final receiver = AmplitudeReceiver(amplitude: amplitude);

Error Handling #

The receiver handles errors gracefully and logs them without interrupting the analytics flow. If Amplitude 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.

0
likes
150
points
15
downloads

Publisher

unverified uploader

Weekly Downloads

Amplitude integration package for Beacon analytics library.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

amplitude_flutter, beacon_core, flutter

More

Packages that depend on beacon_amplitude