Skip to content

tutoruniverse/giap_android

Repository files navigation

GIAP

Example App

Example app is under example directory, use Android Studio to build and run the app.

Make sure to update serverUrl and token in GIAP.initialize() before running.

Installation

Step 1: Add this repository as a submodule

git submodule add https://github.com/tutoruniverse/giap_android.git

Step 2: Import giap_android/giap as a module

  • In Adnroid Studio, select File -> New -> Import Module...
  • Choose giap_android/giap

Step 3: Implement giap in build.gradle

  • Open build.gradle of your app
  • Add this line
...
dependencies {
    ...
    implementation project(':giap')
    ...
}

Usage

Initialize

final GIAP giap = GIAP.initialize(
    "http://server-url.example",
    "your_project_token",
    MainActivity.this
);

Create alias

Use this method right after user has just signed up.

giap.alias(userId);

Identify

Use this method right after user has just logged in.

giap.identify(userId);

Track event

Use a string to represent the event name and a JSONObject to contain all custom properties.

// With custom props
try {
    JSONObject props = new JSONObject();
    props.put("price", 100);
    props.put("package_sku", "package_1_free");
    giap.track("Purchase", props);
} catch (JSONException e) {
    e.printStackTrace();
}

// Without custom props
giap.track("End session");

Set properties for current profile

At any moment after initializing the lib, you can set custom properties for current tracking profile.

try {
    JSONObject props = new JSONObject();
    props.put("full_name", "John Doe");
    giap.updateProfile(props);
} catch (JSONException e) {
    e.printStackTrace();
}

Update profile properties atomically

Increase/Decrease a numeric property

giap.increaseProperty("count", 1);

Append new elements to a list property

JSONArray array = new JSONArray();
array.put("red");
array.put("blue");
giap.appendToProperty("tags", array);

Remove elements from a list property

JSONArray array = new JSONArray();
array.put("red");
array.put("blue");
giap.removeFromProperty("tags", array);

Reset

Use this method right after user has just logged out. It will generate new distinct ID for new visitor.

giap.reset();

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published