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

PostHog (product analytics, session replay, feature flags) destination for liquid_analytics.

example/main.dart

// PostHog as a liquid destination — product analytics, session replay and
// feature flags, cloud or self-hosted.
import 'package:liquid_analytics/liquid_analytics.dart';
import 'package:liquid_posthog/liquid_posthog.dart';

/// PostHog preserves the nested shapes a typed event naturally produces.
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, // lists and nested maps arrive intact
      };
}

Future<void> main() async {
  final liquid = Liquid(
    sinks: [
      PostHogSink(
        apiKey: 'phc_xxx',
        host: 'https://eu.i.posthog.com', // or your self-hosted instance
        configure: (config) => config.captureApplicationLifecycleEvents = true,
        defaultGroupType: 'organization',
      ),
    ],
    consent: const ConsentPolicy(
      requireOptIn: true,
      map: {
        ConsentCategory.analytics: ['posthog'],
      },
    ),
  );
  await liquid.init();

  // Held until the user opts in, then replayed.
  liquid.log(const CheckoutStarted(cartValue: 42, items: ['sku_1', 'sku_2']));
  liquid.consent.grant(ConsentCategory.analytics);

  // PostHog models liquid's full surface natively.
  liquid.screen('Cart');
  liquid.identify('user_123', {'plan': 'pro'});
  liquid.group('acme_inc', {'seats': 40});
  liquid.alias('user_123');

  await liquid.flush();
  await liquid.reset();
  await liquid.dispose();
}
0
likes
160
points
24
downloads

Documentation

API reference

Publisher

verified publisherketok.id

Weekly Downloads

PostHog (product analytics, session replay, feature flags) destination for liquid_analytics.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#analytics #posthog #flutter

License

MIT (license)

Dependencies

flutter, liquid_analytics, meta, posthog_flutter

More

Packages that depend on liquid_posthog