mixpanel_analytics 1.2.1
Mixpanel Analytics #
A dart wrapper on the mixpanel REST API to be used in Flutter applications. As this is using the http REST API it works both with Android and iOS.
How to use it #
There is an example app that demonstrates how to use the plugin,
You just need to instantiate the class and you'll be ready to send track
or engage
events.
Make sure to check mixpanel documentation for the REST API to know the options available.
MixpanelAnalytics(
token: 'XXXXXXXXX',
userId$: _user$.stream,
verbose: true,
shouldAnonymize: true,
shaFn: (value) => value,
onError: (e) => setState(() {
_error = e;
_success = null;
}),
);
There are two different constructors, the regular one which will send events on the fly and the batch
mode which will group the requests (by type) and send them every X seconds (configurable).
MixpanelAnalytics.batch(
token: 'XXXXXXXXX',
userId$: _user$.stream,
uploadInterval: Duration(seconds: 30),
shouldAnonymize: true,
shaFn: (value) => value,
verbose: true,
onError: (e) => setState(() {
_error = e;
_success = null;
}),
);
Not supported yet #
Check the documentation for more information on the features not yet supported https://developer.mixpanel.com/docs/http
Event Request Parameters #
In addition to the data
parameter, https://api.mixpanel.com/track
supports a number of optional parameters. For the most part, these optional parameters are useful only in special situations.
Parameters |
---|
ip |
redirect |
img |
callback |
Update Request Parameters #
In addition to the data
parameter, https://api.mixpanel.com/engage
supports a number of optional parameters. For the most part, these optional parameters are useful only in special situations.
Parameters |
---|
redirect |
callback |
Invalid requests #
When sending batch requests, if one of them is invalid the whole batch operation will fail and the batch will be saved to retry the next iteration. This could become a problem as the whole batch could be stored and retried over and over. A strategy for this would be either to send individually the requests and ditch the only invalid one or just dith the whole lot (TBD).
[1.2.1] - 2019-11-07
- Fix an error when sending batch requests for engage.
[1.2.0] - 2019-09-10
- Allow encoding function to be passed.
[1.1.0] - 2019-09-10
- Add option to encode sensitive information to mixpanel.
[1.0.1] - 2019-08-05
- Add some unit tests.
[1.0.0] - 2019-08-02
- Initial release.
example #
A new Flutter project.
Getting Started #
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
mixpanel_analytics: ^1.2.1
2. Install it
You can install packages from the command line:
with Flutter:
$ flutter pub get
Alternatively, your editor might support flutter pub get
.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:mixpanel_analytics/mixpanel_analytics.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
82
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
91
|
We analyzed this package on Dec 13, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.7.0
- pana: 0.13.1+4
- Flutter: 1.12.13+hotfix.4
Dependencies
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.2.2 <3.0.0 | ||
flutter | 0.0.0 | ||
http | ^0.12.0+2 | 0.12.0+2 | |
shared_preferences | ^0.5.3+1 | 0.5.6 | |
Transitive dependencies | |||
async | 2.4.0 | ||
charcode | 1.1.2 | ||
collection | 1.14.11 | 1.14.12 | |
flutter_web_plugins | 0.0.0 | ||
http_parser | 3.1.3 | ||
meta | 1.1.8 | ||
path | 1.6.4 | ||
pedantic | 1.9.0 | ||
shared_preferences_macos | 0.0.1+3 | ||
shared_preferences_platform_interface | 1.0.1 | ||
shared_preferences_web | 0.1.2+2 | ||
sky_engine | 0.0.99 | ||
source_span | 1.5.5 | ||
string_scanner | 1.0.5 | ||
term_glyph | 1.1.0 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 | ||
Dev dependencies | |||
flutter_test | |||
mockito | ^4.1.0 |