init static method

Future<Mixpanel> init(
  1. String token, {
  2. bool optOutTrackingDefault = false,
  3. required bool trackAutomaticEvents,
  4. Map<String, dynamic>? superProperties,
  5. Map<String, dynamic>? config,
  6. FeatureFlagsConfig? featureFlags,
})

Initializes an instance of the API with the given project token.

  • token your project token.
  • optOutTrackingDefault Optional Whether or not Mixpanel can start tracking by default. See optOutTracking()
  • trackAutomaticEvents Required Whether or not to collect common mobile events include app sessions, first app opens, app updated, etc.
  • superProperties Optional super properties to register
  • config Optional A dictionary of config options to override (WEB ONLY)
  • featureFlags Optional Feature flags configuration

Implementation

static Future<Mixpanel> init(String token,
    {bool optOutTrackingDefault = false,
    required bool trackAutomaticEvents,
    Map<String, dynamic>? superProperties,
    Map<String, dynamic>? config,
    FeatureFlagsConfig? featureFlags}) async {
  var allProperties = <String, dynamic>{'token': token};
  allProperties['optOutTrackingDefault'] = optOutTrackingDefault;
  allProperties['trackAutomaticEvents'] = trackAutomaticEvents;
  allProperties['mixpanelProperties'] = _mixpanelProperties;
  allProperties['superProperties'] = _MixpanelHelper.ensureSerializableProperties(superProperties);
  allProperties['config'] = _MixpanelHelper.ensureSerializableProperties(config);
  if (featureFlags != null) {
    allProperties['featureFlags'] = featureFlags.toMap();
  }
  await _channel.invokeMethod<void>('initialize', allProperties);
  return Mixpanel(token);
}