mixpanel/mixpanel-android-build

Name: mixpanel-android-build

Owner: Mixpanel, Inc

Description: null

Created: 2015-03-06 23:10:06.0

Updated: 2018-04-17 07:22:53.0

Pushed: 2015-05-19 17:55:39.0

Homepage: null

Size: 346

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Mixpanel Build Tools for Android

This project contains tools that make it easier to to integrate Mixpanel into your application using Gradle and Android Studio.

Mixpanel Tweaks Annotations

Mixpanel Tweaks are a way for you to A/B test different settings and configuration values in your application. You can use tweaks directly in your code using the Mixpanel library, but you can also take advantage of tweaks using the @Tweak annotation on your Java methods.

To use @Tweak, annotate a public method of a public class in your code like this:

rt com.mixpanel.android.build.Tweak;

ic class MyGreatClass {
public MyGreatClass() {
    mixpanel.registerForTweaks(this);
}

@Tweak(name="greeting")
public void setGreeting(String greeting) {
    ...
}
...

That's it!

Building with Tweak Annotations

Tweak annotations are currently supported in Gradle and Android Studio via a Gradle plugin.

To add Tweak annotations to your build, add the following buildscript dependency to your build.gradle file

dscript {
repositories {
    mavenCentral()
}
dependencies {
    // Add the line below as a dependency of your buildscript
    classpath 'com.mixpanel.android:annotations-compiler:0.1.0'
}

This adds the annotations compiler tools to the classpath that gradle will use when finding plugins and running it's own scripts. The buildscript dependencies are different from the dependencies of your app - they're for build time only.

Then, apply the Mixpanel annotations plugin to your project by adding the following line to your gradle file

y plugin: 'mixpanel-android-annotations'

That's all you have to do! The mixpanel-android-annotations plugin will use your annotations and call your methods when new tweak values are received from the Mixpanel API.

Setting custom default values

Tweaks can be set on any public method that takes a single String, double, long, or boolean argument. You can set up defaults in your code using @BooleanDefault, @DoubleDefault, @LongDefault, or @StringDefault. For example

rt com.mixpanel.android.build.Tweak;
rt com.mixpanel.android.build.LongDefault;

ic class MyOtherGreatClass {
@Tweak(name="Number of Pages to Show")
@LongDefault(4)
public void setNumberOfPages(long pages) {
    ...
}


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.