flutter_growingio_track 0.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 66

flutter_growingio_track #

VersionPub

GrowingIO的埋点版本flutter插件.

一: 集成 #

1. Flutter插件获取安装 #

根据dart pub 文档获取安装

2. Android集成(Native部分) #

此Flutter插件可支持track版本与auto-track版本的GrowingIO SDK使用, 请根据需要自行选择搭配

1.1 添加Android依赖 #

依赖纯打点版本 #

纯打点版本(track)版本, 需要依赖track版本的SDK

dependencies{
    implementation 'com.growingio.android:vds-android-agent:track-2.6.0'
}

1.2 无埋点版本 #

无埋点版本(auto-track)版本, 需要依赖于auto-track版本的SDK并且需要配置Gradle插件

配置ClassPath:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        //gradle建议版本
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.growingio.android:vds-gradle-plugin:autotrack-2.6.0'
    }
}

使用插件:

apply plugin: 'com.android.application'
//添加插件
apply plugin: 'com.growingio.android'
​
dependencies {
        compile 'com.growingio.android:vds-android-agent:autotrack-2.6.0@aar'
}

2. 获取projectId与UrlScheme #

在GrowingIO官网应用管理创建Android应用, 跳转界面后可以发现包含projectId与UrlSchema的代码片段, 请粘贴到项目对应位置:

android {
  defaultConfig {
	// xxxx
	resValue("string", "growingio_project_id", "9926fc6c1189e2fb")
	resValue("string", "growingio_url_scheme", "growing.da7e6c2879469314")
	// xxxx
  }
}

另外为了可以从浏览器直接跳转App, 需要在Manifest中配置UrlSchema

<intent-filter>
  <data android:scheme="growing.da7e6c2879469314"/>
  <action android:name="android.intent.action.VIEW" />

  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

同时也需要配置权限(比如网络权限)

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

具体配置请参见项目的example配置

3. 初始化SDK #

GrowingIO的SDK需要在Application的onCreate中初始化:

GrowingIO.startWithConfiguration( this,
		new Configuration()
				.setChannel("渠道名")
				.setRnMode(true)     // 这个必须设置
				.setDebugMode(true)   // 显示日志, release环境请关闭
				.setTestMode(true));  // 即时发送, release环境请关闭

如果flutter项目没有自定义Application, 需要用户自己手动添加一个AndroidApplication, 可参照example

4. tip #

  1. 为什么Android项目里面高亮GrowingIO的类会出现报红色

    这个应该是Flutter项目结构问题,不过并不影响运行, 可以放心编译

  2. 为什么不在flutter中初始化:

    • 因为GrowingIO需要获取Android的Activity生命周期, 为了数据的准确性, 需要在Activity出现前就初始化完成
    • 开发者相信很多用户都会使用flutter + native形式的进行开发, 为了同时服务flutter于native

3. iOS集成(Native部分) #

集成方式见Word文档:Flutter-iOS集成文档

二: API #

在dart中调用GrowingIO的函数, 需要先import对应的包

import 'package:flutter_growingio_track/growingio_track.dart';

具体参数限制请参见GrowingIO官网文档。

  1. track发送自定义事件, 对应于cstm事件

    参数是否必填说明
    eventId事件Id
    num数值, double型
    variable变量, Map型

    调用示例:

    import 'package:growingioflutter/growingio_track.dart';
    
    GrowingIO.track('eventId');
    GrowingIO.track('testEventId', num: 23.0, variable: {'testKey': 'testValue', 'testNumKey': 233});
    GrowingIO.track('eventId', num: 23.0);
    GrowingIO.track('eventId', variable: {'testkey': 'testValue', 'testNumKey': 2333});
    
  2. setEvar发送转化变量, 对应于evar事件

    函数原型为: setEvar(Map<String, dynamic> variable), 调用示例:

    GrowingIO.setEvar({
      'testKey': 'testValue', 'testNumKey': 2333.0
    });
    
  3. setPeopleVariable发送用户变量, 对应于ppl事件

    函数原型为: setPeopleVariable(Map<String, dynamic> variable)

    调用示例:

    GrowingIO.setPeopleVariable({
      'testKey': 'testValue', 'testNumKey': 2333.0
    });
    
  4. setUserId设置登录用户Id, 对应于cs1字段

    参数类型描述
    userIdString登录用户Id

    函数原型: setUserId(String userId)

    调用示例:

    GrowingIO.setUserId("testUserId");
    
  5. clearUserId清楚登录用户Id

    函数原型: clearUserId()

    调用示例:

    GrowingIO.clearUserId();
    
  6. setVisitor设置访问用户变量, 对应于vstr事件

    函数原型: setVisitor(Map<String, dynamic> variable)

    调用示例:

    GrowingIO.setVisitor({
          "visitorKey": 'key', "visitorValue": 34
        });
    

0.0.1 #

  • TODO: Describe initial release.

example/README.md

flutter_growingio_track_example #

Demonstrates how to use the flutter_growingio_track plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_growingio_track: ^0.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_growingio_track/flutter_growingio_track.dart';
  
Version Uploaded Documentation Archive
2.6.0 Nov 8, 2018 Go to the documentation of flutter_growingio_track 2.6.0 Download flutter_growingio_track 2.6.0 archive
0.0.3 Nov 6, 2018 Go to the documentation of flutter_growingio_track 0.0.3 Download flutter_growingio_track 0.0.3 archive
0.0.2 Nov 6, 2018 Go to the documentation of flutter_growingio_track 0.0.2 Download flutter_growingio_track 0.0.2 archive
0.0.1 Nov 6, 2018 Go to the documentation of flutter_growingio_track 0.0.1 Download flutter_growingio_track 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
44
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13+1
  • Flutter: 1.2.1

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

9 out of 9 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/flutter_growingio_track.dart.

Run flutter format to format lib/flutter_growingio_track.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8