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

Mixpanel destination for liquid_analytics — product analytics with People and Group profiles, EU residency, and built-in opt-out.

example/main.dart

// Mixpanel as a liquid destination — People profiles, Group Analytics,
// EU/India residency and client-side opt-out.
import 'package:liquid_analytics/liquid_analytics.dart';
import 'package:liquid_mixpanel/liquid_mixpanel.dart';

class CheckoutStarted extends LiquidEvent {
  const CheckoutStarted({required this.cartValue, required this.items});

  final double cartValue;
  final List<String> items;

  @override
  String get name => 'checkout_started';

  @override
  Map<String, Object?> get properties => {
        'cart_value': cartValue,
        'items': items, // nested lists/maps arrive intact
      };
}

/// Declaring the category on the event routes it to the marketing gate.
class PromoTapped extends LiquidEvent {
  const PromoTapped({required this.campaign});

  final String campaign;

  @override
  String get name => 'promo_tapped';

  @override
  ConsentCategory get category => ConsentCategory.marketing;

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

Future<void> main() async {
  final mixpanel = MixpanelSink(
    token: 'YOUR_PROJECT_TOKEN',
    serverURL: 'https://api-eu.mixpanel.com', // optional residency / proxy
    optOutTrackingDefault: true, // start opted out until consent arrives
    groupKey: 'company',
  );

  final liquid = Liquid(
    sinks: [mixpanel],
    consent: const ConsentPolicy(
      requireOptIn: true,
      map: {
        ConsentCategory.marketing: ['mixpanel'],
      },
    ),
  );
  await liquid.init();

  // Mirror the decision into Mixpanel's own opt-in/opt-out.
  liquid.consent.addListener(() {
    mixpanel.applyConsent(
      granted: liquid.consent.statusOf(ConsentCategory.marketing) ==
          ConsentStatus.granted,
    );
  });

  liquid.log(const CheckoutStarted(cartValue: 42, items: ['sku_1', 'sku_2']));
  liquid.log(const PromoTapped(campaign: 'summer_sale'));
  liquid.consent.grant(ConsentCategory.marketing); // buffered events replay

  liquid.identify('user_123', {'plan': 'pro'}); // identify + People.set
  liquid.group('acme_inc', {'seats': 40}); // setGroup + MixpanelGroup.set

  await liquid.flush();
  await liquid.dispose();
}
0
likes
150
points
10
downloads

Documentation

API reference

Publisher

verified publisherketok.id

Weekly Downloads

Mixpanel destination for liquid_analytics — product analytics with People and Group profiles, EU residency, and built-in opt-out.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#analytics #mixpanel #flutter

License

MIT (license)

Dependencies

flutter, liquid_analytics, meta, mixpanel_flutter

More

Packages that depend on liquid_mixpanel