init static method
Initializes an instance of the API with the given project token.
tokenyour project token.optOutTrackingDefaultOptional Whether or not Mixpanel can start tracking by default. See optOutTracking()trackAutomaticEventsRequired Whether or not to collect common mobile events include app sessions, first app opens, app updated, etc.superPropertiesOptional super properties to registerconfigOptional A dictionary of config options to override (WEB ONLY)featureFlagsOptional 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);
}