mixpanel_analytics_impl Free
Mixpanel Analytics vendor implementation for the analytics_api contract.
Version: 1.0.0
Variables
| Variable | Type | Default | Description |
|---|---|---|---|
| appName | string | — | The name of your application |
| isForMonorepo | boolean | true | Whether this is being generated as part of a monorepo |
Architecture
This brick generates a single vendor implementation package that plugs into the analytics_sdk orchestration layer:
MixpanelAnalyticsVendor— ImplementsAnalyticVendorusingMixpanel, registered as@Named(AnalyticInjectorKey.mixpanelImpl)MixpanelRegisterModule— Injectable module that asynchronously initializes Mixpanel viaMixpanel.init(AppEnv.mixpanelToken), using@preResolveto ensure the instance is ready before the DI graph is built- MicroPackage DI — Standard
@InjectableInit.microPackage()entry point for modular registration
The vendor reads the project token from app_config (AppEnv.mixpanelToken). Automatic event tracking is enabled by default via trackAutomaticEvents: true.
Async Initialization
Mixpanel requires async initialization (Mixpanel.init returns a Future<Mixpanel>). The @preResolve annotation on the MixpanelRegisterModule ensures injectable awaits the future before injecting the instance anywhere in the app.
Generated Structure
infrastructure/
└── mixpanel_analytics_impl/
├── lib/
│ ├── mixpanel_analytics_impl.dart # Package barrel export
│ └── src/
│ ├── mixpanel_analytics_vendor.dart # AnalyticVendor impl
│ └── di/
│ ├── injector.dart # microPackage DI entry
│ └── register_module.dart # Mixpanel async provider
└── pubspec.yamlKey Features
- People API integration —
setUserPropertyuses_mixpanel.getPeople().set(key, value), writing directly to Mixpanel's People profiles for user-level analytics - User identification —
setUserIdcallsmixpanel.identify(userId), linking events to a known user in Mixpanel - Properties pass-through —
data.paramsare forwarded directly tomixpanel.trackwith no transformation - Reset —
mixpanel.reset()clears the current user identity and starts a new anonymous session - Automatic events — SDK-level automatic event collection is enabled (
trackAutomaticEvents: true) - Named DI — Registered under
AnalyticInjectorKey.mixpanelImplfor unambiguous resolution alongside other vendors
Configuration
The following environment value must be present in app_config (AppEnv):
| Key | Description |
|---|---|
mixpanelToken | Mixpanel project token from the Mixpanel dashboard |
This is injected at build time via app_config — no runtime secrets are needed in this package.
Dependencies
| Package | Version | Purpose |
|---|---|---|
mixpanel_flutter | ^2.4.4 | Mixpanel Flutter SDK |
analytics_api | workspace | Vendor contract (AnalyticVendor, TrackData) |
app_config | workspace | Access to AppEnv for the project token |
dependencies | workspace | Shared DI annotations (injectable) |