### Install Flutter Dependencies Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/AGENTS.md Commands to install Flutter dependencies for the main SDK and the example app, followed by environment verification. ```bash # Install Flutter dependencies flutter pub get # Install example app dependencies cd example && flutter pub get && cd .. # Verify environment flutter doctor flutter analyze flutter test # Additional tools for validation dart format --set-exit-if-changed . ``` -------------------------------- ### Setup Mixpanel Mocks for Tests Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/example/test/AGENTS.md Standard mock setup for platform channel interactions in tests. Returns mock responses for various Mixpanel SDK methods. ```dart void setupMixpanelMocks() { TestWidgetsFlutterBinding.ensureInitialized(); const MethodChannel channel = MethodChannel('mixpanel_flutter'); final List log = []; TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .setMockMethodCallHandler(channel, (MethodCall methodCall) async { log.add(methodCall); // Return appropriate mock responses switch (methodCall.method) { case 'getDistinctId': return 'test_distinct_id'; case 'getDeviceId': return 'test_device_id'; case 'track': case 'trackWithGroups': case 'timeEvent': case 'eventElapsedTime': case 'identify': case 'alias': case 'registerSuperProperties': case 'registerSuperPropertiesOnce': case 'unregisterSuperProperty': case 'reset': case 'clearSuperProperties': case 'flush': return null; // void methods case 'getSuperProperties': return {}; case 'optInTracking': case 'optOutTracking': case 'hasOptedOutTracking': return methodCall.arguments['hasOptedOutTracking'] ?? false; default: return null; } }); } ``` -------------------------------- ### Install Mixpanel Flutter Package Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/index.html After adding the dependency to pubspec.yaml, run this command in your terminal to install the package and its dependencies. ```bash $ flutter pub get ``` -------------------------------- ### Flutter Development Commands Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/CLAUDE.md Common commands for managing Flutter projects, including dependency installation, testing, running the example app, building for platforms, code analysis, formatting, and documentation generation. ```bash # Install dependencies flutter pub get # Run tests flutter test # Run the example app (from project root) cd example flutter run # Build for specific platform flutter build apk # Android flutter build ios # iOS flutter build web # Web # Analyze code flutter analyze # Format code dart format . # Generate documentation flutter pub run dartdoc ``` -------------------------------- ### Basic Widget Test Setup Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/example/test/AGENTS.md Provides a template for setting up a basic widget test, including necessary imports and a placeholder for test implementation. Assumes Mixpanel mocks are set up. ```dart import 'package:flutter_test/flutter_test.dart'; import 'package:example/main.dart'; void main() { setUpAll(() => setupMixpanelMocks()); testWidgets('description', (WidgetTester tester) async { await tester.pumpWidget(MyApp()); // Test implementation }); } ``` -------------------------------- ### Integration Test Setup and User Journey Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/example/test/AGENTS.md Sets up the Mixpanel SDK for integration tests and outlines a full user journey test flow. ```dart void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Mixpanel Integration', () { setUpAll(() async { // Initialize real Mixpanel instance await Mixpanel.init('YOUR_TOKEN'); }); testWidgets('full user journey', (WidgetTester tester) async { await tester.pumpWidget(MyApp()); // Test complete user flow // 1. Track app open // 2. Identify user // 3. Track feature usage // 4. Update profile // 5. Join group // 6. Track conversion }); }); } ``` -------------------------------- ### handleTimeEvent Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin-class.html Starts timing an event. ```APIDOC ## handleTimeEvent ### Description Starts timing an event. ### Method void handleTimeEvent(MethodCall call) ``` -------------------------------- ### Mixpanel Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel/Mixpanel.html Initializes the Mixpanel SDK with your project token. This is the primary way to start using Mixpanel in your Flutter application. ```APIDOC ## Mixpanel Constructor ### Description Initializes the Mixpanel SDK with your project token. ### Method Signature Mixpanel(String token) ### Parameters #### Path Parameters - **token** (String) - Required - Your Mixpanel project token. ``` -------------------------------- ### time_event Function Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/time_event.html Records the start time for an event. This should be called before the actual event is tracked. ```APIDOC ## time_event ### Description Records the start time for an event. This should be called before the actual event is tracked. ### Method Dart function call (maps to JS `mixpanel.time_event`) ### Parameters #### Path Parameters - **event_name** (String) - Required - The name of the event to time. ### Implementation Example ```dart import "package:mixpanel_flutter/mixpanel_flutter.dart"; // Assuming mixpanel is initialized // Mixpanel mixpanel = await Mixpanel.init("YOUR_PROJECT_TOKEN", trackAutomaticEvents: true); void startTimeEvent(String eventName) { mixpanel.time_event(eventName); } ``` ### Underlying JavaScript Call ```javascript mixpanel.time_event(eventName); ``` ``` -------------------------------- ### Time Event Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/web_mixpanel_js_bindings-library-sidebar.html Starts timing for a specific event. ```APIDOC ## time_event ### Description Starts timing for a specific event. ### Method `time_event(eventName: string)` ### Parameters - **eventName** (string) - Required - The name of the event to start timing for. ``` -------------------------------- ### iOS Platform Handler for Method Invocation Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/AGENTS.md Example of handling a platform channel method call in iOS (Swift). Includes argument validation and returning errors or success. ```swift case "methodName": guard let args = call.arguments as? [String: Any], let param = args["param"] as? String, !param.isEmpty else { result(FlutterError(code: "INVALID_ARGUMENT", message: "param cannot be empty", details: nil)) return } // Implementation using Mixpanel iOS SDK result(nil) ``` -------------------------------- ### Android Platform Handler for Method Invocation Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/AGENTS.md Example of handling a platform channel method call in Android (Java). Includes argument validation and returning errors or success. ```java case "methodName": String param = call.argument("param"); if (TextUtils.isEmpty(param)) { result.error("INVALID_ARGUMENT", "param cannot be empty", null); return; } // Implementation using Mixpanel Android SDK result.success(null); break; ``` -------------------------------- ### Flags - Get Variant Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/web_mixpanel_js_bindings-library-sidebar.html Gets the variant of a feature flag for the current user. ```APIDOC ## flags_get_variant ### Description Gets the variant of a feature flag for the current user. ### Method `flags_get_variant(flagKey: string, defaultValue?: any)` ### Parameters - **flagKey** (string) - Required - The key of the feature flag. - **defaultValue** (any) - Optional - The default value to return if the flag is not found or not ready. ``` -------------------------------- ### initialize Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin-class-sidebar.html Initializes the Mixpanel SDK with the provided project token and options. ```APIDOC ## initialize(String projectToken, {MixpanelOptions? options}) ### Description Initializes the Mixpanel SDK. This method should be called once when your application starts. ### Parameters - **projectToken** (String) - Required - Your Mixpanel project token. - **options** (MixpanelOptions) - Optional - Configuration options for the Mixpanel SDK. ``` -------------------------------- ### Mixpanel.init Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel/init.html Initializes an instance of the API with the given project token and tracking configurations. ```APIDOC ## Mixpanel.init ### Description Initializes an instance of the API with the given project token. ### Method Signature `static Future init(String token, {bool optOutTrackingDefault = false, required bool trackAutomaticEvents, Map? superProperties, Map? config, FeatureFlagsConfig? featureFlags})` ### Parameters #### Positional Parameters - **token** (String) - Required - Your project token. #### Optional Named Parameters - **optOutTrackingDefault** (bool) - Optional - Whether or not Mixpanel can start tracking by default. See optOutTracking(). Defaults to `false`. - **trackAutomaticEvents** (bool) - Required - Whether or not to collect common mobile events include app sessions, first app opens, app updated, etc. - **superProperties** (Map) - Optional - Super properties to register. - **config** (Map) - Optional - A dictionary of config options to override (WEB ONLY). - **featureFlags** (FeatureFlagsConfig) - Optional - Feature flags configuration. ### Returns A `Future` that completes with an initialized `Mixpanel` instance. ``` -------------------------------- ### init function Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/init.html Initializes the Mixpanel tracker with a given token and configuration object. ```APIDOC ## init ### Description Initializes the Mixpanel tracker with a given token and configuration object. ### Signature ```dart void init(String token, JSAny? config) ``` ### Parameters * **token** (String) - The Mixpanel project token. * **config** (JSAny?) - An optional configuration object for Mixpanel. ### Implementation ```dart @JS('mixpanel.init') external void init(String token, JSAny? config); ``` ``` -------------------------------- ### Start Timing an Event - Mixpanel Flutter Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel/timeEvent.html Call this method to start timing an event. The event will not be sent until a corresponding track call is made. Ensure the eventName is a valid string. ```dart void timeEvent(String eventName) { if (_MixpanelHelper.isValidString(eventName)) { _channel.invokeMethod( 'timeEvent', {'eventName': eventName}); } else { developer.log('`timeEvent` failed: eventName cannot be blank', name: 'Mixpanel'); } } ``` -------------------------------- ### Mixpanel Initialization Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel-class-sidebar.html Initializes the Mixpanel SDK with your project token and optionally sets the server URL. ```APIDOC ## Mixpanel.init ### Description Initializes the Mixpanel SDK. This method must be called before any other Mixpanel methods. ### Method `static Future init(String token, {String? serverURL})` ### Parameters - **token** (String) - Required - Your Mixpanel project token. - **serverURL** (String?) - Optional - The custom server URL to use for sending data to Mixpanel. ``` -------------------------------- ### Mixpanel.init Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel-class.html Initializes the Mixpanel SDK with your project token and configuration options. This method must be called before any other Mixpanel functions. ```APIDOC ## Mixpanel.init ### Description Initializes an instance of the API with the given project token. ### Method `static Future init(String token, {bool optOutTrackingDefault = false, required bool trackAutomaticEvents, Map? superProperties, Map? config, FeatureFlagsConfig? featureFlags}) ` ### Parameters * **token** (String) - Required - Your Mixpanel project token. * **optOutTrackingDefault** (bool) - Optional - Default value is false. If true, tracking is opted out by default. * **trackAutomaticEvents** (bool) - Required - If true, automatic events like app open and session start will be tracked. * **superProperties** (Map) - Optional - A map of properties to be sent with every event. * **config** (Map) - Optional - Configuration options for the SDK. * **featureFlags** (FeatureFlagsConfig) - Optional - Configuration for feature flags. ``` -------------------------------- ### NetworkSource.hashCode Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/NetworkSource-class.html Gets the hash code for this object. ```APIDOC ## hashCode ### Description Returns the hash code for this object. ### Type `int` ``` -------------------------------- ### Mixpanel Initialization Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/index.html Initializes the Mixpanel tracker with your project token and optional configuration. ```APIDOC ## init ### Description Initializes the Mixpanel tracker with your project token and optional configuration. ### Function Signature `init(String token, JSAny? config)` ### Parameters - **token** (String) - Required - Your Mixpanel project token. - **config** (JSAny?) - Optional - Configuration object for Mixpanel. ``` -------------------------------- ### Handle Get Variant Value Implementation Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin/handleGetVariantValue.html This method processes incoming MethodCalls to fetch variant values. It converts arguments to Dart types, calls a JavaScript function to get the variant, and returns the result or a fallback value if an error occurs. ```dart Future handleGetVariantValue(MethodCall call) async { Map args = call.arguments as Map; String flagName = args['flagName'] as String; dynamic fallbackValue = args['fallbackValue']; JSAny? fallbackJs = safeJsify({ 'key': flagName, 'value': fallbackValue, }); try { JSPromise promise = flags_get_variant(flagName, fallbackJs); JSAny? jsResult = await promise.toDart; Map variant = _jsVariantToMap(jsResult, {'key': flagName, 'value': fallbackValue}); return variant['value'] ?? fallbackValue; } catch (e) { debugPrint('[Mixpanel] getVariantValue failed with error: $e, returning fallback'); return fallbackValue; } } ``` -------------------------------- ### Mixpanel Initialization Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/web_mixpanel_js_bindings-library-sidebar.html Initializes the Mixpanel library with your project token and configuration options. ```APIDOC ## init ### Description Initializes the Mixpanel library. ### Method `init(token: string, config?: object)` ### Parameters - **token** (string) - Required - Your Mixpanel project token. - **config** (object) - Optional - Configuration options for Mixpanel. ``` -------------------------------- ### Get Group Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/web_mixpanel_js_bindings-library-sidebar.html Retrieves the groups associated with the current user. ```APIDOC ## get_group ### Description Retrieves the groups associated with the current user. ### Method `get_group(groupKey: string): Array` ### Parameters - **groupKey** (string) - Required - The key identifying the group type. ``` -------------------------------- ### persistedAt Property Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/PersistenceSource-class-sidebar.html Gets the timestamp when the data was last persisted. ```APIDOC ## persistedAt ### Description Represents the timestamp indicating when the data was last persisted. ### Type `DateTime?` ``` -------------------------------- ### FeatureFlagsConfig.context Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/FeatureFlagsConfig-class-sidebar.html Gets the context associated with the feature flags configuration. ```APIDOC ## context ### Description Provides access to the context for feature flag configurations. ### Property context ### Type `BuildContext` ### Access Read-only ``` -------------------------------- ### Configuration Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel-class-sidebar.html Configures SDK behavior. ```APIDOC ## Mixpanel.setFlushBatchSize ### Description Sets the batch size for flushing events to the Mixpanel server. ### Method `Future setFlushBatchSize(int batchSize)` ### Parameters - **batchSize** (int) - Required - The number of events to send in a single batch. ``` ```APIDOC ## Mixpanel.setLoggingEnabled ### Description Enables or disables logging of SDK events and information. ### Method `Future setLoggingEnabled(bool enabled)` ### Parameters - **enabled** (bool) - Required - True to enable logging, false to disable. ``` ```APIDOC ## Mixpanel.setServerURL ### Description Sets a custom server URL for sending data to Mixpanel. ### Method `Future setServerURL(String url)` ### Parameters - **url** (String) - Required - The custom server URL. ``` ```APIDOC ## Mixpanel.setUseIpAddressForGeolocation ### Description Configures whether to use the IP address for geolocation. ### Method `Future setUseIpAddressForGeolocation(bool useIp)` ### Parameters - **useIp** (bool) - Required - True to use IP address for geolocation, false otherwise. ``` -------------------------------- ### Get Distinct ID Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/index.html Retrieves the current distinct ID for the user. ```APIDOC ## get_distinct_id ### Description Retrieves the current distinct ID for the user. ### Function Signature `get_distinct_id() → String` ### Returns - **String** - The current distinct ID. ``` -------------------------------- ### Mixpanel Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel-class.html Initializes the Mixpanel SDK with your project's token. ```APIDOC ## Mixpanel Constructor ### Description Initializes the Mixpanel SDK with your project's token. ### Parameters #### Path Parameters - **token** (String) - Required - Your Mixpanel project token. ``` -------------------------------- ### persistenceTtl Property Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/NetworkFirstPolicy-class-sidebar.html Gets or sets the time-to-live for persisted data in the NetworkFirstPolicy. ```APIDOC ## persistenceTtl ### Description Represents the time duration for which data is considered valid or persisted. ### Type `Duration` ``` -------------------------------- ### initialize method Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin/initialize.html Initializes the Mixpanel SDK. It takes a MethodCall object which contains the arguments for initialization, including the project token and configuration options. ```APIDOC ## initialize ### Description Initializes the Mixpanel SDK with the provided token and configuration. ### Method Signature `void initialize(MethodCall call)` ### Parameters - `call` (MethodCall): A `MethodCall` object containing the arguments for initialization. - `arguments` (Map): A map containing: - `token` (String): The Mixpanel project token. - `config` (dynamic): Optional configuration object for initialization. - `featureFlags` (dynamic): Optional configuration for feature flags. ``` -------------------------------- ### Get Flag Variant (Sync) Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/index.html Synchronously retrieves the variant of a feature flag. ```APIDOC ## flags_get_variant_sync ### Description Synchronously retrieves the variant of a feature flag. ### Function Signature `flags_get_variant_sync(String name, JSAny? fallback) → JSAny?` ### Parameters - **name** (String) - Required - The name of the feature flag. - **fallback** (JSAny?) - Optional - A fallback value if the flag is not found. ### Returns - **JSAny?** - The flag variant or fallback value. ``` -------------------------------- ### Initialize Mixpanel SDK Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/README.md Initialize the Mixpanel SDK with your project token and a boolean to track automatic events. This should be done once, typically during application startup. ```dart import 'package:mixpanel_flutter/mixpanel_flutter.dart'; ... class _YourClassState extends State { Mixpanel mixpanel; @override void initState() { super.initState(); initMixpanel(); } Future initMixpanel() async { mixpanel = await Mixpanel.init("Your Mixpanel Token", trackAutomaticEvents: false); } ... ``` -------------------------------- ### Get Flag Variant (Async) Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/index.html Asynchronously retrieves the variant of a feature flag. ```APIDOC ## flags_get_variant ### Description Asynchronously retrieves the variant of a feature flag. ### Function Signature `flags_get_variant(String name, JSAny? fallback) → JSPromise` ### Parameters - **name** (String) - Required - The name of the feature flag. - **fallback** (JSAny?) - Optional - A fallback value if the flag is not found. ### Returns - **JSPromise** - A promise that resolves with the flag variant. ``` -------------------------------- ### Get Group Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/index.html Retrieves a MixpanelGroup object for a given group key and ID. ```APIDOC ## get_group ### Description Retrieves a MixpanelGroup object for a given group key and ID. ### Function Signature `get_group(String group_key, JSAny? group_id) → MixpanelGroup` ### Parameters - **group_key** (String) - Required - The key for the group. - **group_id** (JSAny?) - Optional - The ID of the group. ### Returns - **MixpanelGroup** - The MixpanelGroup object. ``` -------------------------------- ### NetworkFirstPolicy Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/NetworkFirstPolicy-class-sidebar.html Initializes a new instance of the NetworkFirstPolicy class. ```APIDOC ## NetworkFirstPolicy() ### Description Constructs a new NetworkFirstPolicy instance. ### Method `NetworkFirstPolicy()` ### Parameters None ``` -------------------------------- ### NetworkSource Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/NetworkSource-class-sidebar.html Initializes a new instance of the NetworkSource class. ```APIDOC ## NetworkSource() ### Description Constructs a new NetworkSource instance. ### Method Constructor ### Endpoint N/A ### Parameters None ### Request Example ```dart var networkSource = NetworkSource(); ``` ### Response N/A ``` -------------------------------- ### persistenceTtl Property Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/PersistenceUntilNetworkSuccessPolicy-class-sidebar.html Gets or sets the time-to-live for persisted events. Events older than this duration may be discarded. ```APIDOC ## PersistenceUntilNetworkSuccessPolicy.persistenceTtl ### Description Gets or sets the time-to-live for persisted events in seconds. ### Type `Duration` ``` -------------------------------- ### NetworkSource Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/NetworkSource-class.html Initializes a new instance of the NetworkSource class. ```APIDOC ## NetworkSource() ### Description Constructs a new NetworkSource instance. ### Method NetworkSource() ### Parameters None ``` -------------------------------- ### handleOptInTracking Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin/handleOptInTracking.html This method initiates the opt-in tracking process for Mixpanel. It calls the internal opt_in_tracking function. ```APIDOC ## handleOptInTracking() ### Description Initiates the opt-in tracking process for Mixpanel. This method is part of the MixpanelFlutterPlugin and is designed to be called by the user to manage tracking preferences. ### Method Signature `void handleOptInTracking()` ### Implementation Details This method internally calls the `opt_in_tracking()` function to perform the actual tracking opt-in logic. ### Usage Example ```dart // Assuming you have an instance of MixpanelFlutterPlugin MixpanelFlutterPlugin mixpanelPlugin = MixpanelFlutterPlugin(); // Call the method to opt-in for tracking mixpanelPlugin.handleOptInTracking(); ``` ``` -------------------------------- ### NetworkFirstPolicy.persistenceTtl Property Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/NetworkFirstPolicy-class.html Gets the maximum age of a persisted variant set before it is ignored on read. Defaults to 24 hours. ```APIDOC ## NetworkFirstPolicy.persistenceTtl ### Description Maximum age of a persisted variant set before it is ignored on read. Defaults to 24 hours. ### Type [Duration](https://api.flutter.dev/flutter/dart-core/Duration-class.html) ``` -------------------------------- ### Registration and Configuration Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/index.html Functions for registering properties, groups, and configuring Mixpanel. ```APIDOC ## register ### Description Registers properties that will be added to all subsequent events. ### Method register ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **properties** (JSAny?) - An object containing the properties to register. ### Request Example ```json { "properties": { "plan": "free" } } ``` ### Response #### Success Response (200) - void #### Response Example ```json null ``` ``` ```APIDOC ## register_once ### Description Registers properties that will be added to all subsequent events, only if they have not been registered before. ### Method register_once ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **properties** (JSAny?) - An object containing the properties to register once. ### Request Example ```json { "properties": { "first_seen": "2023-01-01" } } ``` ### Response #### Success Response (200) - void #### Response Example ```json null ``` ``` ```APIDOC ## remove_group ### Description Removes a user from a group. ### Method remove_group ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **group_key** (String) - The key of the group. - **group_id** (JSAny?) - The ID of the group to remove the user from. ### Request Example ```json { "group_key": "company", "group_id": "Acme Corp" } ``` ### Response #### Success Response (200) - void #### Response Example ```json null ``` ``` ```APIDOC ## reset ### Description Resets all Mixpanel data for the current user. ### Method reset ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```json null ``` ### Response #### Success Response (200) - void #### Response Example ```json null ``` ``` ```APIDOC ## set_config ### Description Sets the configuration for Mixpanel. ### Method set_config ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **config** (JSAny?) - An object containing the configuration settings. ### Request Example ```json { "config": { "debug": true } } ``` ### Response #### Success Response (200) - void #### Response Example ```json null ``` ``` ```APIDOC ## set_group ### Description Sets the group for a user. ### Method set_group ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **group_key** (String) - The key of the group. - **group_ids** (JSAny?) - The ID(s) of the group(s) to set. ### Request Example ```json { "group_key": "company", "group_ids": ["Acme Corp", "Beta Inc"] } ``` ### Response #### Success Response (200) - void #### Response Example ```json null ``` ``` -------------------------------- ### Import Mixpanel Flutter SDK Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/README.md Import the Mixpanel Flutter SDK into your Dart code to start using its functionalities. ```dart import 'package:mixpanel_flutter/mixpanel_flutter.dart'; ``` -------------------------------- ### handleOptInTracking Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin-class.html Enables tracking for the user. ```APIDOC ## handleOptInTracking ### Description Enables tracking for the user. ### Method void handleOptInTracking() ``` -------------------------------- ### Constructors Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/MixpanelFlagVariantSource-class-sidebar.html Provides information on how to create instances of MixpanelFlagVariantSource. ```APIDOC ## Constructors ### `MixpanelFlagVariantSource()` Default constructor for MixpanelFlagVariantSource. ### `MixpanelFlagVariantSource.fallback()` Constructor for creating a MixpanelFlagVariantSource with fallback behavior. ### `MixpanelFlagVariantSource.network()` Constructor for creating a MixpanelFlagVariantSource using network data. ### `MixpanelFlagVariantSource.persistence()` Constructor for creating a MixpanelFlagVariantSource using persistent storage. ``` -------------------------------- ### Get Mixpanel People Object Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel/getPeople.html Returns an instance of the People object. This object is used to update records in Mixpanel People Analytics. ```dart People getPeople() { return _people; } ``` -------------------------------- ### Constructors Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/MixpanelFlagVariant-class-sidebar.html Provides information on how to create instances of MixpanelFlagVariant. ```APIDOC ## Constructors ### `MixpanelFlagVariant()` Creates a new MixpanelFlagVariant instance. ### `MixpanelFlagVariant.fallback()` Creates a fallback MixpanelFlagVariant instance. ### `MixpanelFlagVariant.fromMap(Map map)` Creates a MixpanelFlagVariant instance from a map. ``` -------------------------------- ### Handle Get Distinct ID in MixpanelFlutterPlugin Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin/handleGetDistinctId.html This method retrieves the distinct ID by calling the internal get_distinct_id() function. It is part of the MixpanelFlutterPlugin class. ```dart String handleGetDistinctId() { return get_distinct_id(); } ``` -------------------------------- ### Mixpanel Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/Mixpanel-class-sidebar.html Initializes a new instance of the Mixpanel class. ```APIDOC ## Mixpanel() ### Description Initializes a new instance of the Mixpanel class. ### Method `Mixpanel()` ### Parameters None ``` -------------------------------- ### handleAreFlagsReady Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin-class-sidebar.html Handles the check for feature flag readiness. ```APIDOC ## handleAreFlagsReady(Map arguments) ### Description Handles the internal method call to check if feature flags are ready. ### Parameters - **arguments** (Map) - Required - The arguments for the check. ``` -------------------------------- ### Get Feature Flag Variant - Dart Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/flags_get_variant.html Use this function to retrieve the variant of a feature flag. Provide the flag name and an optional fallback value. ```dart @JS('mixpanel.flags.get_variant') external JSPromise flags_get_variant(String name, JSAny? fallback); ``` -------------------------------- ### Get Feature Flags - Mixpanel Flutter Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel/getFeatureFlags.html Call this method to retrieve the FeatureFlags object. This object allows you to access feature flag values and metadata. ```dart FeatureFlags getFeatureFlags() { return _featureFlags; } ``` -------------------------------- ### Initialize Mixpanel and Load Flutter App Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/example/web/index.html This script initializes the Mixpanel tracking library and sets up the Flutter engine to load the main application. It configures the service worker and ensures the app runs after the engine is initialized. ```javascript const serviceWorkerVersion = null; (function (f, b) { if (!b.__SV) { var e, g, i, h; window.mixpanel = b; b._i = []; b.init = function (e, f, c) { function g(a, d) { var b = d.split("."); 2 == b.length && ((a = a[b[0]]),(d = b[1])); a[d] = function() { a.push([d].concat(Array.prototype.slice.call(arguments, 0))); }; } var a = b; "undefined" !== typeof c ? (a = b[c] = []) : (c = "mixpanel"); a.people = a.people || []; a.toString = function(a) { var d = "mixpanel"; "mixpanel" !== c && (d += "." + c); a || (d += " (stub)"); return d; }; a.people.toString = function() { return a.toString(1) + ".people (stub)"; }; i = "disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(" "); for (h = 0; h < i.length; h++) g(a, i[h]); var j = "set set_once union unset remove delete".split(" "); a.get_group = function() { function b(c) { d[c] = function() { call2_args = arguments; call2 = [c].concat(Array.prototype.slice.call(call2_args, 0)); a.push([e, call2]); }; } for (var d = {}, e = ["get_group"].concat(Array.prototype.slice.call(arguments, 0)), c = 0; c < j.length; c++) b(j[c]); return d; }; b._i.push([e, f, c]); }; b.__SV = 1.2; e = f.createElement("script"); e.type = "text/javascript"; e.async = !0; e.src = "undefined" !== typeof MIXPANEL_CUSTOM_LIB_URL ? MIXPANEL_CUSTOM_LIB_URL : "file:" === f.location.protocol && "//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\\/\\//) ? "https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js" : "//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js"; g = f.getElementsByTagName("script")[0]; g.parentNode.insertBefore(e, g); } })(document, window.mixpanel || []); window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function(engineInitializer) { engineInitializer.initializeEngine().then(function(appRunner) { appRunner.runApp(); }); } }); }); ``` -------------------------------- ### setOnce Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin-class-sidebar.html Sets user properties only if they have not been set before. ```APIDOC ## setOnce(Map properties) ### Description Sets properties for the current user, but only if they have not been set previously. ### Parameters - **properties** (Map) - Required - A map of user properties to set. ``` -------------------------------- ### handleReset Method Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin/handleReset.html Clears all data associated with the current user session in Mixpanel. This is useful for resetting the user's state, for example, when a user logs out. ```APIDOC ## handleReset() ### Description Clears all data associated with the current user session in Mixpanel. This is useful for resetting the user's state, for example, when a user logs out. ### Method Signature `void handleReset()` ### Implementation Details This method internally calls the `reset()` function to perform the data clearing operation. ``` -------------------------------- ### Mixpanel Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel/Mixpanel.html Initialize the Mixpanel SDK with your project token. This token is essential for identifying your project and sending data to Mixpanel. ```dart Mixpanel(String token) ``` ```dart Mixpanel(String token) : _token = token, _people = People(token), _featureFlags = FeatureFlags(token); ``` -------------------------------- ### Mixpanel alias method usage Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel/alias.html Example of how to use the alias method to create an alias for a user. This method renames the current distinctId to a new alias. ```dart mixpanel.alias("New ID", mixpanel.distinctId) mixpanel.alias("Newer ID", mixpanel.distinctId) ``` -------------------------------- ### Get Distinct ID Function Signature Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/get_distinct_id.html Defines the external Dart function signature for `mixpanel.get_distinct_id`. This is used to bridge Dart code with the JavaScript Mixpanel API. ```dart @JS('mixpanel.get_distinct_id') external String get_distinct_id(); ``` -------------------------------- ### People Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/People/People.html Initializes a new instance of the People class with the provided project token. ```APIDOC ## People Constructor ### Description Initializes a new instance of the People class. ### Parameters #### Path Parameters - **token** (String) - Required - The Mixpanel project token. ``` -------------------------------- ### NetworkFirstPolicy Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/NetworkFirstPolicy/NetworkFirstPolicy.html Initializes a new instance of the NetworkFirstPolicy class. This policy manages network requests with a focus on network-first retrieval. ```APIDOC ## NetworkFirstPolicy() ### Description Constructs a new NetworkFirstPolicy with an optional persistence TTL. ### Parameters #### Named Parameters - **persistenceTtl** (`Duration`) - Optional - The time-to-live for persisted data. Defaults to 24 hours. ### Request Example ```dart final policy = NetworkFirstPolicy(persistenceTtl: Duration(hours: 48)); ``` ### Response This constructor does not return a value, it initializes an object. ``` -------------------------------- ### Get MixpanelGroup Object Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel/getGroup.html Use this method to obtain a MixpanelGroup object for setting and incrementing Group Analytics properties. It requires a group key and a group ID. ```dart MixpanelGroup getGroup(String groupKey, dynamic groupID) { return MixpanelGroup(_token, groupKey, _MixpanelHelper.ensureSerializableValue(groupID)); } ``` -------------------------------- ### Handle Time Event Implementation Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin/handleTimeEvent.html This method is called when a time event needs to be processed. It parses the arguments from the MethodCall to get the event name and then calls the time_event function. ```Dart void handleTimeEvent(MethodCall call) { Map args = call.arguments as Map; String eventName = args['eventName'] as String; time_event(eventName); } ``` -------------------------------- ### registerWith static method Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin/registerWith.html This static method registers the MixpanelFlutterPlugin for web. It initializes a MethodChannel and sets up the handler for method calls. ```APIDOC ## registerWith static method ### Description Registers the MixpanelFlutterPlugin with the Flutter platform's registrar for web implementations. This method sets up the necessary communication channel for the plugin. ### Method Signature `static void registerWith(Registrar registrar)` ### Parameters #### registrar - **Registrar** (Registrar) - Required - The registrar provided by the Flutter platform to register the plugin. ### Implementation Details ```dart static void registerWith(Registrar registrar) { // Web platform doesn't need the custom codec since safeJsify handles type conversions final MethodChannel channel = MethodChannel( 'mixpanel_flutter', const StandardMethodCodec(), registrar, ); final pluginInstance = MixpanelFlutterPlugin(); channel.setMethodCallHandler(pluginInstance.handleMethodCall); } ``` ``` -------------------------------- ### PersistenceSource Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/PersistenceSource-class.html Initializes a new instance of the PersistenceSource class. ```APIDOC ## PersistenceSource ### Description Initializes a new instance of the PersistenceSource class. ### Parameters #### Named Parameters - **persistedAt** (DateTime) - Required - Time the variant set was originally written to disk. ``` -------------------------------- ### Get Super Properties - Mixpanel Flutter Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel/getSuperProperties.html Retrieves the current super properties for the Mixpanel instance. These properties are sent with every event and persist across application sessions. ```dart Future getSuperProperties() async { return await _channel.invokeMethod('getSuperProperties'); } ``` -------------------------------- ### PersistenceSource Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/PersistenceSource-class-sidebar.html Initializes a new instance of the PersistenceSource class. ```APIDOC ## PersistenceSource() ### Description Constructs a new PersistenceSource object. ### Method `PersistenceSource()` ### Parameters None ``` -------------------------------- ### Retrieve Event Elapsed Time - Dart Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel/eventElapsedTime.html Use this method to get the duration between calling timeEvent() and the current moment for a specific event. Ensure the eventName is a valid string. ```dart Future eventElapsedTime(String eventName) async { if (_MixpanelHelper.isValidString(eventName)) { return await _channel.invokeMethod( 'eventElapsedTime', {'eventName': eventName}); } else { return 0; } } ``` -------------------------------- ### Initialize Mixpanel JS Bindings Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/init.html Use this function to initialize the Mixpanel tracking library with your project token and an optional configuration object. This is the primary entry point for using Mixpanel in a web context via Dart. ```dart @JS('mixpanel.init') external void init(String token, JSAny? config); ``` -------------------------------- ### handleSetOnce Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin-class.html Sets properties for the current user's profile, only if they haven't been set before. ```APIDOC ## handleSetOnce ### Description Sets properties for the current user's profile, only if they haven't been set before. ### Method void handleSetOnce(MethodCall call) ``` -------------------------------- ### Synchronously Get Feature Flag Variant Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/flags_get_variant_sync.html Use this function to retrieve the current variant of a feature flag by its name. Provide a fallback value to be returned if the flag is not found or cannot be determined. ```dart @JS('mixpanel.flags.get_variant_sync') external JSAny? flags_get_variant_sync(String name, JSAny? fallback); ``` -------------------------------- ### handleSetServerURL Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin-class-sidebar.html Handles setting the server URL. ```APIDOC ## handleSetServerURL(Map arguments) ### Description Handles the internal method call for setting the server URL. ### Parameters - **arguments** (Map) - Required - The arguments for the set server URL operation. ``` -------------------------------- ### optInTracking Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel-class.html Enables tracking for the user. ```APIDOC ## optInTracking ### Description Enables tracking for the user. ``` -------------------------------- ### Handle Identify Method Implementation - MixpanelFlutterPlugin Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin/handleIdentify.html This method is part of the MixpanelFlutterPlugin and is responsible for handling identify calls. It parses the arguments from a MethodCall to get the distinctId and then calls the identify function. ```dart void handleIdentify(MethodCall call) { Map args = call.arguments as Map; String distinctId = args['distinctId'] as String; identify(distinctId); } ``` -------------------------------- ### Get Feature Flag Variant Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/FeatureFlags/getVariant.html Retrieves the full variant for a feature flag, including metadata. Provide a fallback variant to be used if the flag is not found or not ready. This method is asynchronous. ```dart Future getVariant( String flagName, MixpanelFlagVariant fallback) async { if (!_MixpanelHelper.isValidString(flagName)) { developer.log('`getVariant` failed: flagName cannot be blank', name: 'Mixpanel'); return fallback; } final result = await _channel.invokeMethod('getVariant', { 'token': _token, 'flagName': flagName, 'fallback': fallback.toMap(), }); if (result != null) { return MixpanelFlagVariant.fromMap(result); } return fallback; } ``` -------------------------------- ### Handle Opt-In Tracking in MixpanelFlutterPlugin Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin/handleOptInTracking.html Call this method to enable tracking opt-in. It directly invokes the internal opt_in_tracking function. ```dart void handleOptInTracking() { opt_in_tracking(); } ``` -------------------------------- ### VariantLookupPolicy.persistenceUntilNetworkSuccess Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/VariantLookupPolicy/VariantLookupPolicy.persistenceUntilNetworkSuccess.html Initializes the VariantLookupPolicy to serve persisted variants immediately, refreshing from the network in the background. Note: This feature is not supported on web and is treated as networkOnly. ```APIDOC ## VariantLookupPolicy.persistenceUntilNetworkSuccess ### Description Serve persisted variants immediately on init (within `persistenceTtl`), then refresh from the network in the background. **Web:** not yet supported by the Mixpanel JS SDK at the time of this release. On web this policy is silently treated as [networkOnly](../../mixpanel_flutter/VariantLookupPolicy/VariantLookupPolicy.networkOnly.html) until JS SDK support ships. Check the Mixpanel JS docs for availability. ### Constructor Signature ```dart const factory VariantLookupPolicy.persistenceUntilNetworkSuccess({ Duration persistenceTtl, }) ``` ### Parameters #### Named Parameters - **persistenceTtl** (`Duration`) - The duration for which persisted variants will be served immediately. After this duration, the policy will attempt to refresh from the network. ``` -------------------------------- ### Select Languages for highlight.js Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/static-assets/readme.md Use this JavaScript code in your browser's developer console to select specific languages for highlight.js download. Verify the selections before downloading. ```javascript var selected = [ 'bash', 'c', 'css', 'dart', 'diff', 'java', 'javascript', 'json', 'kotlin', 'markdown', 'objectivec', 'plaintext', 'shell', 'swift', 'xml', // also includes html 'yaml', ]; document.querySelectorAll('input[type=checkbox]').forEach(function (elem) {elem.checked = selected.includes(elem.value);}); ``` -------------------------------- ### Handle Alias Method Implementation Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin/handleAlias.html This method is part of the MixpanelFlutterPlugin and is responsible for handling alias calls. It parses the arguments from a MethodCall to get the alias name and distinct ID, then invokes the alias function. ```dart void handleAlias(MethodCall call) { Map args = call.arguments as Map; String aliasName = args['alias'] as String; String distinctId = args['distinctId'] as String; alias(aliasName, distinctId); } ``` -------------------------------- ### Get Feature Flag Variant Value Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/FeatureFlags/getVariantValue.html Retrieves the value of a feature flag. Provide the flag name and a fallback value to be used if the flag is not found or not ready. Ensure the flagName is a valid string. ```dart Future getVariantValue(String flagName, dynamic fallbackValue) async { if (!_MixpanelHelper.isValidString(flagName)) { developer.log('`getVariantValue` failed: flagName cannot be blank', name: 'Mixpanel'); return fallbackValue; } final result = await _channel.invokeMethod('getVariantValue', { 'token': _token, 'flagName': flagName, 'fallbackValue': _MixpanelHelper.ensureSerializableValue(fallbackValue), }); return result ?? fallbackValue; } ``` -------------------------------- ### Get Distinct ID - mixpanel_flutter Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/Mixpanel/getDistinctId.html Call this method to retrieve the current distinct ID associated with the user. This ID is used for tracking events and People Analytics. Ensure Mixpanel has been initialized before calling this method. ```dart const distinctId = await mixpanel.getDistinctId(); ``` -------------------------------- ### handleSet Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin-class.html Sets properties for the current user's profile. ```APIDOC ## handleSet ### Description Sets properties for the current user's profile. ### Method void handleSet(MethodCall call) ``` -------------------------------- ### FallbackSource Constructor Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter/FallbackSource-class-sidebar.html Initializes a new instance of the FallbackSource class. ```APIDOC ## new FallbackSource() ### Description Constructs a new instance of the FallbackSource class. ### Method `FallbackSource()` ``` -------------------------------- ### Initialize MixpanelFlutterPlugin Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/mixpanel_flutter_web/MixpanelFlutterPlugin/initialize.html This method is called internally by the Flutter plugin to initialize Mixpanel. It parses the token and configuration from the MethodCall arguments and prepares them for the init function. It also handles the setup of feature flags if provided. ```dart void initialize( MethodCall call ) { Map args = call.arguments as Map; String token = args['token'] as String; dynamic config = args['config']; Map initConfig = Map.from(config ?? {}); // Handle feature flags configuration dynamic featureFlags = args['featureFlags']; if (featureFlags != null && featureFlags is Map) { bool enabled = featureFlags['enabled'] == true; if (enabled) { final flagsConfig = {}; dynamic context = featureFlags['context']; if (context != null && context is Map && context.isNotEmpty) { flagsConfig['context'] = context; } final persistence = _flagsPersistenceFromPolicy(featureFlags['variantLookupPolicy']); if (persistence != null) { flagsConfig['persistence'] = persistence; } initConfig['flags'] = flagsConfig.isEmpty ? true : flagsConfig; } } init(token, safeJsify(initConfig)); } ``` -------------------------------- ### Mixpanel() Source: https://github.com/mixpanel/mixpanel-flutter/blob/main/docs/web_mixpanel_js_bindings/Mixpanel/Mixpanel.html Initializes a new instance of the Mixpanel class. This is the primary way to create a Mixpanel object for use in your web application. ```APIDOC ## Mixpanel() ### Description Initializes a new instance of the Mixpanel class. ### Method Constructor ### Parameters This constructor does not take any parameters. ### Request Example ```dart var mixpanel = Mixpanel(); ``` ### Response Returns a new Mixpanel instance. ```