Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build and improve Analytics #9

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ buildscript {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
}

android {
Expand Down Expand Up @@ -34,7 +47,7 @@ dependencies {
compileOnly fileTree(dir: 'libs', include: ['godot-lib*.aar'])

// Firebase Core (needs Analytics implementation) (https://firebase.google.com/support/release-notes/android)
implementation 'com.google.firebase:firebase-analytics:17.4.0'
implementation 'com.google.firebase:firebase-analytics:17.5.0'
// Firebase Ads (AdMob) (https://firebase.google.com/support/release-notes/android)
implementation 'com.google.android.gms:play-services-ads:19.1.0'
// Firebase Ads (AdMob) Unity Mediation (https://github.com/googleads/googleads-mobile-android-mediation/blob/master/ThirdPartyAdapters/unity/CHANGELOG.md#version-3422)
Expand Down
Binary file modified downloads/Firebase.release.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion downloads/Firebase.release.gdap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ binary="Firebase.release.aar"

[dependencies]
remote=[
"com.google.firebase:firebase-analytics:17.4.0",
"com.google.firebase:firebase-analytics:17.5.0",
"com.google.android.gms:play-services-ads:19.1.0",
"com.google.ads.mediation:unity:3.4.2.2",
"com.google.firebase:firebase-auth:19.3.1",
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,12 @@ public void sendCustom(final String key, final String value) {
// firebaseAnalytics = FirebaseAnalytics.getInstance(activity);
firebaseAnalytics.logEvent("appEvent", bundle);
}
}

public void setCollectionEnabled(final boolean enabled) {
firebaseAnalytics.setAnalyticsCollectionEnabled(enabled);
}

public void resetData() {
firebaseAnalytics.resetAnalyticsData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public List<String> getPluginMethods() {
// ===== Analytics
methods.add("analytics_send_custom");
methods.add("analytics_send_events");
methods.add("analytics_set_collection_enabled");
methods.add("analytics_reset_data");

// ===== Authentication
methods.add("authentication_get_id_token");
Expand Down Expand Up @@ -243,7 +245,7 @@ public void run() {
}

public void analytics_send_events(final String key, final Dictionary data) {
if (key.length() <= 0 || data.size() <= 0) {
if (key.length() <= 0) {
return;
}

Expand All @@ -253,6 +255,22 @@ public void run() {
}
});
}

public void analytics_set_collection_enabled(final boolean enabled) {
godot.runOnUiThread(new Runnable() {
public void run() {
Analytics.getInstance(godot).setCollectionEnabled(enabled);
}
});
}

public void analytics_reset_data() {
godot.runOnUiThread(new Runnable() {
public void run() {
Analytics.getInstance(godot).resetData();
}
});
}
// ===== Analytics ================================================================================================

// ===== Authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ public static void putGodotValue(Bundle bundle, String key, Object value) {
if (value instanceof Boolean) {
bundle.putBoolean(key, (Boolean) value);
} else if (value instanceof Integer) {
bundle.putInt(key, (Integer) value);
// Storing as long since that's often expected
bundle.putLong(key, (Integer) value);
} else if (value instanceof Double) {
bundle.putDouble(key, (Double) value);
} else if (value instanceof String) {
Expand Down