zhugeio 1.0.1 copy "zhugeio: ^1.0.1" to clipboard
zhugeio: ^1.0.1 copied to clipboard

outdated

This is the official flutter plugin for Zhugeio,with this plugin you can easily collect your app data on Android and iOS.

zhugeio #

诸葛io 插件,封装了 iOS & Android SDK 常用 API ,使用此插件,可以完成埋点的统计上报。

1. 在项目中添加安装插件 #

在 Flutter 项目的 pubspec.yam 文件中添加 zhugeio 依赖

dependencies:
  # zhugeio flutter plugin 
  zhugeio: ^1.0.0

执行 flutter packages get 命令安装插件

  flutter packages get  

Flutter 官网文档

2. Android 端 #

添加所需权限

<!--需要网络权限-->
<uses-permission  
  android:name="android.permission.INTERNET"/>
<!--需要获取网络状态-->
<uses-permission  
  android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission  
  android:name="android.permission.ACCESS_WIFI_STATE"/>
<!--获取设备唯一标识-->
<uses-permission  
  android:name="android.permission.READ_PHONE_STATE"/>

项目中添加依赖

dependencies {
    implementation 'com.ZhugeioAnalytic:zhugeio:3.4.1'
}

初始化

import com.zhuge.analysis.stat.ZhugeParam;
import com.zhuge.analysis.stat.ZhugeSDK;


public class MainActivity extends FlutterActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GeneratedPluginRegistrant.registerWith(this);

    ZhugeParam param = new ZhugeParam.Builder().appKey("appkey")
            .appChannel("channel")
            .build();
    ZhugeSDK.getInstance().initWithParam(getApplicationContext(), param);
  }

}

3. iOS 端 #

首先执行

cd ios
pod install

用应用的AppKey启动诸葛io SDK

#import "Zhuge.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   [[Zhuge sharedInstance] startWithAppKey:@"Your App Key" launchOptions:launchOptions];
}

如果你需要修改SDK的默认设置,如设置版本渠道时,一定要在startWithAppKey前执行;代码如下:

    Zhuge *zhuge = [Zhuge sharedInstance];

    // 实时调试开关
    // 设置为YES,可在诸葛io的「实时调试」页面实时观察事件数据上传
    // 建议仅在需要时打开,调试完成后,请及时关闭
    [zhuge.config setDebug : NO];

    // 自定义应用版本
    [zhuge.config setAppVersion:@"0.9-beta"]; // 默认是info.plist中CFBundleShortVersionString值

    // 自定义渠道
    [zhuge.config setChannel:@"My App Store"]; // 默认是@"App Store"

    // 开启行为追踪
    [zhuge startWithAppKey:@"Your App Key" launchOptions:launchOptions];

4. Flutter 中使用插件 #

在具体 dart 文件中导入 zhugeio.dart

import 'package:zhugeio/zhugeio.dart';

4.1 普通埋点事件 #

Zhugeio.track("购买", {"商品名称":"iPhone","内存":"128g"});

4.2 识别用户 #

Zhugeio.identify("zhangsan", {"age":18});

4.3 收入事件 #

Map product = {"price":5400,  
               "productQuantity":2,
               "productID":"abcd",
               "revenueType":"手机"};
Zhugeio.trackRevenue(product);
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

This is the official flutter plugin for Zhugeio,with this plugin you can easily collect your app data on Android and iOS.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on zhugeio