Skip to content
Permalink
Browse files

Version 1.0.0

Completed & Tested
  • Loading branch information...
Fritsbie committed Feb 26, 2019
1 parent 20daa5d commit b6bd7a737b19d3c5a794c60f6505f28fae899beb
Showing with 54 additions and 2 deletions.
  1. +54 −2 android/gmdevbloggamemakerfirebaseanalytics.java
@@ -10,6 +10,7 @@
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.util.Log;

//Firebase Core Library (Analytics)
import com.google.firebase.analytics.FirebaseAnalytics;
@@ -18,14 +19,37 @@
//Starts Here
public class gmdevbloggamemakerfirebaseanalytics extends RunnerActivity {


//Debug Modifier
public static boolean debugMode = false;

//Firebase Instances
private FirebaseAnalytics mFirebaseAnalytics;

public void firebase_analytics_debug_mode(double arg0) {

//You might ask wtf is this code. With this function, I imitate converting GML boolean to Java boolean.
if (arg0 >= 0.5)
{
debugMode = true;
}
else
{
debugMode = false;
}


}

/////--------- ANALYTICS INIT ----------////
public void firebase_analytics_init() {
mFirebaseAnalytics = FirebaseAnalytics.getInstance(RunnerActivity.CurrentActivity.getApplicationContext());
mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);
Log.i("yoyo", "Game Maker Firebase Analytics Extension. For more information check the blog post : https://gmdevblog.com/game-maker-firebase-analytics/");

if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Initiated!");
}
/* The Following Functions are deprecated with the latest API. Just leaving them here.
if (arg0 != "")
{
@@ -43,29 +67,49 @@ public void firebase_analytics_init() {
//Disable Analytics
public void firebase_analytics_disable() {
mFirebaseAnalytics.setAnalyticsCollectionEnabled(false);
if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Disabled data collection on the runtime.");
}
}

//Enable Analytics
public void firebase_analytics_enable() {
mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);
if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Enabled data collection on the runtime.");
}
}

//Set User ID
public void firebase_analytics_set_userid(String arg0) {
mFirebaseAnalytics.setUserId(arg0);
if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : The User ID is set as : " + arg0);
}
}

//Set User Property
public void firebase_analytics_set_userproperty(String arg0, String arg1) {
mFirebaseAnalytics.setUserProperty(arg0, arg1);
if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : The User Property " + arg0 + " is set as " + arg1);
}
}

//Set Current Screen
public void firebase_analytics_set_current_screen(final String arg0) {
RunnerActivity.CurrentActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
mFirebaseAnalytics.setCurrentScreen(RunnerActivity.CurrentActivity, arg0, null);
mFirebaseAnalytics.setCurrentScreen(RunnerActivity.CurrentActivity, arg0, null);
if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : The current screen is set as " + arg0);
}
}//public void run() {
});
}
@@ -75,12 +119,20 @@ public void firebase_analytics_event_string(String arg0, String arg1, String arg
Bundle bundle = new Bundle();
bundle.putString(arg0, arg1);
mFirebaseAnalytics.logEvent(arg2, bundle);
if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged [STRING] " + arg0 + " : " + arg1 + " to the event " + arg2);
}
}

public void firebase_analytics_event_real(String arg0, double arg1, String arg2) {
Bundle bundle = new Bundle();
bundle.putDouble(arg0, arg1);
mFirebaseAnalytics.logEvent(arg2, bundle);
if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged [REAL] " + arg0 + " : " + arg1 + " to the event " + arg2);
}
}

}

0 comments on commit b6bd7a7

Please sign in to comment.
You can’t perform that action at this time.