项目作者: busybusy

项目描述 :
Analytics framework for Android
高级语言: Kotlin
项目地址: git://github.com/busybusy/AnalyticsKit-Android.git
创建时间: 2016-03-04T22:56:42Z
项目社区:https://github.com/busybusy/AnalyticsKit-Android

开源协议:Apache License 2.0

下载


AnalyticsKit-Android

Analytics framework for Android

Installation

Add the JitPack repository to the end of your root build.gradle:

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url "https://jitpack.io" }
  5. }
  6. }

In your module’s build.gradle file, add the dependency:

  1. dependencies {
  2. implementation "com.github.busybusy.AnalyticsKit-Android:analyticskit:0.10.0"
  3. ...
  4. }

You can include the implemented providers you want by adding them to the same dependency block:

  1. dependencies {
  2. ...
  3. implementation "com.github.busybusy.AnalyticsKit-Android:mixpanel-provider:0.10.0"
  4. }

Usage

In your Application’s onCreate() method, register your provider SDKs as normal with your API keys.
Then initialize AnalyticsKit-Android to work with those providers.

  1. AnalyticsKit.getInstance()
  2. .registerProvider(MixpanelProvider(MixpanelAPI.getInstance(this, MIXPANEL_TOKEN)))

Send events where appropriate in your application code.

  1. AnalyticsEvent("Your Event Name")
  2. .putAttribute("key", "value")
  3. .send()

The framework provides a ContentViewEvent to facilitate capturing content views:

  1. ContentViewEvent()
  2. .putAttribute("screen_name", "Dashboard")
  3. .putAttribute("category", "navigation")
  4. .send()

Event Priorities

By default, AnalyticsEvent objects have priority 0. However, you can
set any integer priority on your events. It is up to you to decide on your priority scheme
and provider filtering.

  1. AnalyticsEvent("Readme Read Event")
  2. .putAttribute("read", true)
  3. .setPriority(7)
  4. .send()

By default, providers will log all events regardless of priority. If desired, you can
configure providers with a PriorityFilter so that only events that pass the
PriorityFilter‘s shouldLog() filter function will be logged by that provider.
In the following example, only AnalyticsEvent objects with priority less than 10 will be
logged by the Mixpanel provider:

  1. myMixpanelApi = MixpanelAPI.getInstance(this, "YOUR MIXPANEL API TOKEN")
  2. val filter = PriorityFilter { priorityLevel -> priorityLevel < 10 }
  3. val filteringProvider = MixpanelProvider(mixpanelApi = myMixpanelApi, priorityFilter = filter)
  4. AnalyticsKit.getInstance().registerProvider(filteringProvider)

License

  1. Licensed under the Apache License, Version 2.0 (the "License");
  2. you may not use this file except in compliance with the License.
  3. You may obtain a copy of the License at
  4. http://www.apache.org/licenses/LICENSE-2.0
  5. Unless required by applicable law or agreed to in writing, software
  6. distributed under the License is distributed on an "AS IS" BASIS,
  7. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  8. See the License for the specific language governing permissions and
  9. limitations under the License.