mixpanel_analytics
一个用于 Flutter 应用程序的 Mixpanel REST API 的 Dart 包装器。
- 星标
- 19
- 复刻
- 29
- 最近推送(UTC)
- 2023年8月18日
- 项目状态
- 已归档
原始 README
以下为英文项目原文快照,最新内容请访问 GitHub。
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,
ip: 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).
Project Setup
This project is written in Flutter using the stable channel.
> flutter channel stable
> flutter upgrade
Install Dependencies
> flutter pub get
Build generated files (for Mockito)
> flutter pub run build_runner build --delete-conflicting-outputs
Note: During development this can be set to monitor for changes
> flutter pub run build_runner watch --delete-conflicting-outputs
Running tests
> flutter test --coverage
使用的依赖
依赖清单 6 项
- flutter
{"sdk":"flutter"} - http
^0.13.0 - shared_preferences
^2.0.3 - flutter_test开发依赖
{"sdk":"flutter"} - build_runner开发依赖
^1.10.0 - mockito开发依赖
^5.0.0
如何选择适合项目的代码仓?
先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。
- 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
- 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
- 使用前在 GitHub 核对 README、许可证与 Issues。
来源与维护
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗