Skip to content
Permalink
Browse files

Create gmdevbloggamemakerfirebaseperformancemonitoring.java

  • Loading branch information...
Fritsbie committed Oct 31, 2019
1 parent 493d1c3 commit 38a07d41f54106c32d6a097ffed73f7fa3353c68
Showing with 98 additions and 0 deletions.
  1. +98 −0 android/gmdevbloggamemakerfirebaseperformancemonitoring.java
@@ -0,0 +1,98 @@
package ${YYAndroidPackageName};

//Game Maker Studio 2 Packages
import ${YYAndroidPackageName}.R;
import com.yoyogames.runner.RunnerJNILib;
import ${YYAndroidPackageName}.RunnerActivity;

//Firebase Performance Monitoring Packages
import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.metrics.AddTrace;
import com.google.firebase.perf.metrics.HttpMetric;
import com.google.firebase.perf.metrics.Trace;

//Java & Android Packages
import java.lang.String;
import android.util.Log;

public class gmdevbloggamemakerfirebaseperformancemonitoring extends RunnerActivity {

final static int EVENT_OTHER_SOCIAL = 70;
//Debug Modifier
public static boolean perfDebug = false;

public static Trace traceVal;


public void firebase_performance_monitoring_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)
{
perfDebug = true;
}
else
{
perfDebug = false;
}


}



public void firebase_performance_monitoring_init() {

Log.i("yoyo", "Game Maker Firebase Performance Monitoring Extension. For more information check the blog post : https://gmdevblog.com/game-maker-firebase-analytics/");
Log.i("yoyo", "For any questions and suggestions, please comment to the post. Credits would be appreciated. Have fun!");

}



public void firebase_performance_monitoring_trace_start(String traceName) {
traceVal = FirebasePerformance.getInstance().newTrace(traceName);
traceVal.start();

if (perfDebug==true)
{
Log.i("yoyo", "Game Maker Firebase | Performance Monitoring : Trace <" + traceName + "> is started!");
}
}

public void firebase_performance_monitoring_trace_stop() {
traceVal.stop();

if (perfDebug==true)
{
Log.i("yoyo", "Game Maker Firebase | Performance Monitoring : Trace stopped!");
}

}

public void firebase_performance_monitoring_trace_increment_metric(String metricName, double metricIncrementValue) {
long value = (long) metricIncrementValue;

traceVal.incrementMetric(metricName, value);

if (perfDebug==true)
{
Log.i("yoyo", "Game Maker Firebase | Performance Monitoring : Metric name " + metricName + " is increased by " + metricIncrementValue);
}

}

public void firebase_performance_monitoring_trace_put_attribute_string(String attributeName, String metricIncrementValue) {

traceVal.putAttribute(attributeName, metricIncrementValue);

if (perfDebug==true)
{
Log.i("yoyo", "Game Maker Firebase | Performance Monitoring : Attribute name " + attributeName + " is set as " + metricIncrementValue);
}

}



}

0 comments on commit 38a07d4

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