forked from openedx/openedx-app-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Analytics architecture for multiple libraries (openedx#91)
- Introduced a way to implement multiple analytics libraries with only a little effort - Write a base class to manage analytics with limited methods - Also added the support to add analytics using feature flag implementation fix: LEARNER-9667
- Loading branch information
1 parent
01b5960
commit c7fa5d3
Showing
3 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.openedx.app.analytics | ||
|
||
import android.os.Bundle | ||
|
||
interface Analytics { | ||
fun logScreenEvent(screenName: String, bundle: Bundle) | ||
fun logEvent(eventName: String, bundle: Bundle) | ||
fun logUserId(userId: Long) | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/org/openedx/app/analytics/FirebaseAnalytics.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.openedx.app.analytics | ||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import android.util.Log | ||
import com.google.firebase.analytics.FirebaseAnalytics | ||
|
||
class FirebaseAnalytics(context: Context) : Analytics { | ||
|
||
private var tracker: FirebaseAnalytics? = null | ||
|
||
init { | ||
tracker = FirebaseAnalytics.getInstance(context) | ||
Log.d("Analytics", "Firebase Builder Initialised") | ||
} | ||
|
||
override fun logScreenEvent(screenName: String, bundle: Bundle) { | ||
Log.d("Analytics", "Firebase log Screen Event: $screenName + $bundle") | ||
} | ||
|
||
override fun logEvent(eventName: String, bundle: Bundle) { | ||
tracker?.logEvent(eventName, bundle) | ||
Log.d("Analytics", "Firebase log Event $eventName: $bundle") | ||
} | ||
|
||
override fun logUserId(userId: Long) { | ||
tracker?.setUserId(userId.toString()) | ||
Log.d("Analytics", "Firebase User Id log Event") | ||
} | ||
} |