dart_mp_analytics 1.0.0 copy "dart_mp_analytics: ^1.0.0" to clipboard
dart_mp_analytics: ^1.0.0 copied to clipboard

A dart only package for wrapper around the Firebase Measurement Protocol API.

example/lib/main.dart

import 'dart:io';

import 'package:dart_mp_analytics/dart_mp_analytics.dart';

void main() async {
  // Initialize MPAnalytics options
  // or use MPAnalyticsOptions.mobileStream()
  const options = MPAnalyticsOptions.webStream(
    clientId: 'your_client_id',
    measurementId: 'your_measurement_id',
    apiSecret: 'your_api_secret',
  );

  // Create an instance of MPAnalytics
  final analytics = MPAnalytics(
    options: options,
    debugAnalytics: true, // Enable debug mode for testing
    verbose: true, // Enable verbose logging
  )..initialize();

  // Log an event
  await analytics.logEvent(
    'button_click',
    parameters: {
      'button_id': 'submit_button',
      'page_name': 'home',
    },
  );

  // Set user ID
  analytics
    ..setUserId('user123')
    // Log another event with user properties
    ..setUserProperty('membership', 'gold');
  await analytics.logEvent(
    'purchase',
    parameters: {
      'product_id': 'product123',
      'price': 19.99,
    },
  );

  // Clear user ID and user property
  analytics
    ..clearUserId()
    ..removeUserProperty('membership');

  exit(0);
}
4
likes
160
pub points
70%
popularity

Publisher

unverified uploader

A dart only package for wrapper around the Firebase Measurement Protocol API.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

http, logger, meta, mocktail, platform_info, uuid

More

Packages that depend on dart_mp_analytics