-
Notifications
You must be signed in to change notification settings - Fork 28
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
fix: LEARNER-9667
- Loading branch information
1 parent
a6fd21c
commit a06939f
Showing
6 changed files
with
91 additions
and
11 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
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) { | ||
Log.d("Analytics", "Firebase log Event $eventName: $bundle") | ||
tracker?.logEvent(eventName, bundle) | ||
} | ||
|
||
override fun logUserId(userId: Long) { | ||
tracker?.setUserId(userId.toString()) | ||
Log.d("Analytics", "Firebase User Id log Event") | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/openedx/app/analytics/SegmentAnalytics.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,26 @@ | ||
package org.openedx.app.analytics | ||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import android.util.Log | ||
|
||
class SegmentAnalytics(context: Context) : Analytics { | ||
|
||
// private lateinit var tracker: com.segment.analytics.Analytics | ||
|
||
init { | ||
Log.d("Analytics", "Segment Builder Initialised") | ||
} | ||
|
||
override fun logScreenEvent(screenName: String, bundle: Bundle) { | ||
Log.d("Analytics", "Segment log Screen Event: $screenName + $bundle") | ||
} | ||
|
||
override fun logEvent(eventName: String, bundle: Bundle) { | ||
Log.d("Analytics", "Segment log Event $eventName: $bundle") | ||
} | ||
|
||
override fun logUserId(userId: Long) { | ||
Log.d("Analytics", "Segment User Id log Event") | ||
} | ||
} |
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