Skip to content
No description or website provided.
Java
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
library
LICENSE
README.md
build.gradle
gradle.properties
settings.gradle

README.md

SimpleFirebaseAnalytics

Simplified send firebase event for Android.

GETTING STARTED

SimpleFirebaseAnalytics releases are available via JitPack.

// Project level build.gradle
// ...
repositories {
    maven { url 'https://jitpack.io' }
}
// ...

// Module level build.gradle
dependencies {
    // Replace version with release version, e.g. 1.0.0-alpha, -SNAPSHOT
    implementation "com.github.kshdreams:SimpleFirebaseAnalytics:[VERSION]"
}
USAGE

call SimpleFirebaseAnalytics.init() method on your Application.onCreate() method

public class YourApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        SimpleFirebaseAnalytics.init(this, new Analytics() {
            @Override
            public boolean isUserAgreed() {
                // TODO : better to show dialog to agree to send event log
                return true;
            }

            @Override
            public void setCurrentScreen(Activity activity, String var1, String var2) {
                FirebaseAnalytics.getInstance(activity).setCurrentScreen(activity, var1, var2);
            }

            @Override
            public void logEvent(String event, Bundle param) {
                FirebaseAnalytics.getInstance(FirebaseApplication.this).logEvent(event, param);
            }
        });

just define @FirebaseScreen annotation to Activity, Fragment class instead of call FirebaseAnalytics.setCurrentScreen() then automatically call screen event when Activity, Fragment is created or resume.

@FirebaseScreen("main_screen")
public class MainActivity extends AppCompatActivity {
}

@FirebaseScreen("main_fragment")
public class MainFragment extends Fragmet {
}

just define @FirebaseEvent, @FirebaseParam on your data(pojo) class,

@FirebaseEvent("click_event")
public class ClickEvent {

    @FirebaseParam("view")
    public String view;

    @FirebaseParam("extra")
    public String extra;

and send firebase event using object.

    SimpleFirebaseAnalytics.sendEvent(ClickEvent.create("snackbar", "some extra here"));
    public static class User {
        @FirebaseParam("userId")
        String id;
        @FirebaseParam("userName")
        String name;
    }

    SimpleFirebaseAnalytics.sendEvent("create", user);

Limitation

  • use AppCompatActivity to use Fragment screen logging (FragmentLifeCycle observing supported since API level 26)
You can’t perform that action at this time.