Skip to content
Permalink
Browse files

1.1.0 Update

Added new predefined events.
  • Loading branch information...
Fritsbie committed May 6, 2019
1 parent b6bd7a7 commit a1936b11dffbdc51b11ca34b827ec6659f976527
Showing with 148 additions and 2 deletions.
  1. +148 −2 android/gmdevbloggamemakerfirebaseanalytics.java
@@ -45,10 +45,10 @@ 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/");

Log.i("yoyo", "For any questions and suggestions, please comment to the post. You can add me to the credits if you wish to. I'd be so happy :)");
if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Initiated!");
Log.i("yoyo", "Game Maker Firebase | Analytics : Initiated and Debug mode enabled!");
}
/* The Following Functions are deprecated with the latest API. Just leaving them here.
if (arg0 != "")
@@ -134,5 +134,151 @@ public void firebase_analytics_event_real(String arg0, double arg1, String arg2)
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged [REAL] " + arg0 + " : " + arg1 + " to the event " + arg2);
}
}

public void firebase_analytics_event_post_score(double arg0, double arg1, String arg2) {

double d = arg0;
long score = (long) d;

Bundle bundle = new Bundle();
bundle.putLong(FirebaseAnalytics.Param.SCORE, score);

//Log Level >> Long
if (arg1 > 0.5)
{
double da = arg1;
long level = (long) da;
bundle.putLong(FirebaseAnalytics.Param.LEVEL, level);
}

//Log Character >> String
if (arg2 != "") {

bundle.putString(FirebaseAnalytics.Param.CHARACTER, arg2);
}
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.POST_SCORE, bundle);

if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged POST_SCORE event");
}

}

public void firebase_analytics_event_earn_virtual_currency(String arg0, double arg1) {

Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.VIRTUAL_CURRENCY_NAME, arg0);
bundle.putDouble(FirebaseAnalytics.Param.VALUE, arg1);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.EARN_VIRTUAL_CURRENCY, bundle);

if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged EARN_VIRTUAL_CURRENCY event");
}
}

public void firebase_analytics_event_spend_virtual_currency(String arg0, String arg1, double arg2) {

Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.VIRTUAL_CURRENCY_NAME, arg0);
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, arg1);
bundle.putDouble(FirebaseAnalytics.Param.VALUE, arg2);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SPEND_VIRTUAL_CURRENCY, bundle);

if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged SPEND_VIRTUAL_CURRENCY event");
}
}

public void firebase_analytics_event_unlock_achievement(String arg0) {

Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ACHIEVEMENT_ID, arg0);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.UNLOCK_ACHIEVEMENT, bundle);

if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged UNLOCK_ACHIEVEMENT event");
}

}

public void firebase_analytics_event_select_content(String arg0, String arg1) {

Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, arg0);
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, arg0);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);

if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged SELECT_CONTENT event");
}

}

public void firebase_analytics_event_login(String arg0) {

Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.METHOD, arg0);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.LOGIN, bundle);

if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged LOGIN event");
}

}

public void firebase_analytics_event_level_start(String arg0) {

Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.LEVEL_NAME, arg0);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.LEVEL_START, bundle);

if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged LEVEL_START event");
}

}

public void firebase_analytics_event_level_end(String arg0, double arg1) {

Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.LEVEL_NAME, arg0);
if (arg1 >= 0.5)
{
bundle.putLong(FirebaseAnalytics.Param.SUCCESS, 1);
}
else
{
bundle.putLong(FirebaseAnalytics.Param.SUCCESS, 0);
}

mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.LEVEL_END, bundle);

if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged LEVEL_END event");
}

}

public void firebase_analytics_event_share(String arg0, String arg1, String arg2) {

Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, arg0);
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, arg1);
bundle.putString(FirebaseAnalytics.Param.METHOD, arg2);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SHARE, bundle);

if (debugMode==true)
{
Log.i("yoyo", "Game Maker Firebase | Analytics : Logged SHARE event");
}
}

}

0 comments on commit a1936b1

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