Created
December 13, 2020 15:13
-
-
Save RageshAntony/a3a68d427ae5dc419a1abb7c05b94148 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package `in`.techrova.dbconnector.utils | |
import android.util.Log | |
import com.google.firebase.analytics.FirebaseAnalytics | |
import com.google.firebase.analytics.ktx.analytics | |
import com.google.firebase.analytics.ktx.logEvent | |
import com.google.firebase.database.DatabaseError | |
import com.google.firebase.database.DatabaseReference | |
import com.google.firebase.database.ktx.database | |
import com.google.firebase.ktx.Firebase | |
class FBUtils { | |
private var firebaseAnalytics: FirebaseAnalytics = Firebase.analytics | |
private val database = Firebase.database | |
val myRef: DatabaseReference = database.getReference("logd") | |
public fun logEvent(title: String, data: String) { | |
Log.d(this@FBUtils.javaClass.simpleName, "logevent: ") | |
myRef.child(title).setValue(data) | |
.addOnSuccessListener { | |
Log.d(this@FBUtils.javaClass.simpleName, "logevent: fb compl") | |
} | |
.addOnFailureListener { | |
Log.d( | |
this@FBUtils.javaClass.simpleName, | |
"logevent: fb fall ${it.localizedMessage} \n ${it.cause}" | |
) | |
} | |
.addOnCompleteListener { | |
if (it.isSuccessful) Log.d(this@FBUtils.javaClass.simpleName, "logevent: fb suc") | |
else Log.d( | |
this@FBUtils.javaClass.simpleName, | |
"logevent: fb not compl ${it.exception?.message}" | |
) | |
} | |
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM) { | |
param(FirebaseAnalytics.Param.ITEM_ID, 1001) | |
param(FirebaseAnalytics.Param.ITEM_NAME, title) | |
param(FirebaseAnalytics.Param.CONTENT, data) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The setvalue in line 20 not firing any listeners !!