mzanalytics_mybmw 0.3.0
mzanalytics_mybmw: ^0.3.0 copied to clipboard
One for BMW Group to use flutter plug-in, data collection and analysis.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:mzanalytics_mybmw/mzanalytics_mybmw.dart';
// import 'package:uni_links/uni_links.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _cid = 'Unknown';
String _oaid = 'Unknown';
String _myevent = '自定义事件';
@override
void initState() {
super.initState();
}
// Platform messages are asynchronous, so we initialize in an async method.
void getcid() async {
// callback function
String cid = await MzanalyticsMybmw.getCid();
setState(() {
_cid = cid;
});
}
// void getoaid() async {
// // callback function
// String oaid = await MzanalyticsMybmw.getOaid();
// setState(() {
// _oaid = oaid;
// });
// }
@override
Widget build(BuildContext context) {
return MaterialApp(
// navigatorObservers: [MZNavigationHistoryObserver()],
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Container(
padding: EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
RaisedButton(
key: Key("key1"),
onPressed: () {
MzanalyticsMybmw.appid("2814");
},
child: Text('初始化'),
),
RaisedButton(
key: Key("key2"),
onPressed: () {
MzanalyticsMybmw.trackPageView({
'dt': "首页",
'CustomDimMetrics': {
"cd1": "点击信用卡",
"cd2": "查看商品详情",
"cm1": "点击信用卡总用户数",
"cm2": "查看商品详情总用户数"
}
});
},
child: Text('页面事件'),
),
RaisedButton(
key: Key("key3"),
onPressed: () {
MzanalyticsMybmw.trackEvent({
"ec": '点击热⻔banner',
"ea": 'Click',
"el": '点击',
"ev": '0',
});
},
child: Text('自定义事件监测'),
),
RaisedButton(
key: Key("key4"),
onPressed: () {
MzanalyticsMybmw.trackSiteCustomEvent({
'CustomEvent': {
"caid": "1",
"cal1": "2020/01/10",
"cal2": "15728749249",
"cal3": "北京",
"cav1": "2"
},
'CustomDimMetrics': {
"cd1": "点击信用卡",
"cd2": "查看商品详情",
"cm1": "点击信用卡总用户数",
"cm2": "查看商品详情总用户数"
}
});
},
child: Text('高级自定义事件'),
),
RaisedButton(
key: Key("key5"),
onPressed: () {
MzanalyticsMybmw.trackPulse();
},
child: Text('心跳事件'),
),
RaisedButton(
key: Key("key6"),
onPressed: () {
getcid();
},
child: Text('cid: $_cid\n'),
),
// RaisedButton(
// key: Key("key7"),
// onPressed: () {
// getoaid();
// },
// child: Text('oaid: $_oaid\n'),
// ),
// //自定义事件IO操作
// RaisedButton(
// onPressed: () {
// MzanalyticsMybmw.getCdAndCm();
// Navigator.push(
// context,
// new MaterialPageRoute(
// builder: (context) => new AboutPage()),
// );
// },
// child: Text("自定义事件-读:$_myevent\n"),
// ),
RaisedButton(
key: Key("key8"),
onPressed: () {
MzanalyticsMybmw.setCd("cd2", "cd2qqqqqq");
},
child: Text("设置cd"),
),
RaisedButton(
key: Key("key9"),
onPressed: () {
MzanalyticsMybmw.setCm("cm2", "cm22222qqqq");
},
child: Text("设置cm"),
),
RaisedButton(
key: Key("key10"),
onPressed: () {
MzanalyticsMybmw.deleteCd("cd2");
},
child: Text("删除cd"),
),
RaisedButton(
key: Key("key11"),
onPressed: () {
MzanalyticsMybmw.deleteCd("cm2");
},
child: Text("删除cm"),
),
],
),
),
),
);
}
}