-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from amardeshbd/develop
Release 1.5 prep
- Loading branch information
Showing
16 changed files
with
374 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
53 changes: 53 additions & 0 deletions
53
android-app/app/src/main/java/com/blacklivesmatter/policebrutality/analytics/Analytics.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,53 @@ | ||
package com.blacklivesmatter.policebrutality.analytics | ||
|
||
import android.app.Activity | ||
|
||
/** | ||
* Interface to log events for the app. | ||
*/ | ||
interface Analytics { | ||
companion object { | ||
const val SCREEN_REPORT_INCIDENT = "ReportNewIncident" | ||
const val SCREEN_INCIDENT_LOCATION = "IncidentLocations" | ||
const val SCREEN_INCIDENT_LIST_BY_DATE = "IncidentsByDate" | ||
const val SCREEN_INCIDENT_LIST_BY_LOCATION = "IncidentsByLocation" | ||
const val SCREEN_INCIDENT_DATE_FILTER = "FilterIncidentsByDate" | ||
const val SCREEN_MORE_INFO = "MoreInformation" | ||
const val SCREEN_ABOUT_APP = "AboutApplication" | ||
|
||
const val ACTION_INCIDENT_REFRESH = "RefreshIncidents" | ||
const val ACTION_INCIDENT_REPORT_NEW = "MakeIncidentReport" | ||
const val ACTION_SHARE_APP = "ShareApplication" | ||
|
||
const val CONTENT_TYPE_LOCATION = "TypeLocation" | ||
const val CONTENT_TYPE_INCIDENT = "TypeIncident" | ||
const val CONTENT_TYPE_INCIDENT_SHARE = "TypeShareIncident" | ||
const val CONTENT_TYPE_HASHTAG = "TypeHashtag" | ||
const val CONTENT_TYPE_PB2020_LINK = "TypePBLink" | ||
} | ||
|
||
/** | ||
* Log event when a user views a page. | ||
*/ | ||
fun logPageView(activity: Activity, screenName: String) | ||
|
||
/** | ||
* Log event when a user searches in the app | ||
*/ | ||
fun logSearch(searchTerm: String) | ||
|
||
/** | ||
* Log event when a user has selected content in an app | ||
*/ | ||
fun logSelectItem(type: String, id: String, name: String) | ||
|
||
/** | ||
* Log event when a user has shared content in an app | ||
*/ | ||
fun logShare(type: String, id: String) | ||
|
||
/** | ||
* Log event when a user action is taken. | ||
*/ | ||
fun logEvent(name: String) | ||
} |
49 changes: 49 additions & 0 deletions
49
android-app/app/src/main/java/com/blacklivesmatter/policebrutality/analytics/AppAnalytics.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,49 @@ | ||
package com.blacklivesmatter.policebrutality.analytics | ||
|
||
import android.app.Activity | ||
import com.google.firebase.analytics.FirebaseAnalytics | ||
import com.google.firebase.analytics.FirebaseAnalytics.Event | ||
import com.google.firebase.analytics.FirebaseAnalytics.Event.SEARCH | ||
import com.google.firebase.analytics.FirebaseAnalytics.Param.CONTENT_TYPE | ||
import com.google.firebase.analytics.FirebaseAnalytics.Param.ITEM_ID | ||
import com.google.firebase.analytics.FirebaseAnalytics.Param.ITEM_NAME | ||
import com.google.firebase.analytics.FirebaseAnalytics.Param.SEARCH_TERM | ||
import com.google.firebase.analytics.ktx.logEvent | ||
import javax.inject.Inject | ||
|
||
/** | ||
* App analytics that uses [FirebaseAnalytics] as backbone. | ||
* See https://firebase.google.com/docs/analytics/get-started?platform=android | ||
*/ | ||
class AppAnalytics @Inject constructor( | ||
private val firebaseAnalytics: FirebaseAnalytics | ||
) : Analytics { | ||
override fun logPageView(activity: Activity, screenName: String) { | ||
firebaseAnalytics.setCurrentScreen(activity, screenName, null) | ||
} | ||
|
||
override fun logSearch(searchTerm: String) { | ||
firebaseAnalytics.logEvent(SEARCH) { | ||
param(SEARCH_TERM, searchTerm) | ||
} | ||
} | ||
|
||
override fun logSelectItem(type: String, id: String, name: String) { | ||
firebaseAnalytics.logEvent(Event.SELECT_CONTENT) { | ||
param(ITEM_ID, id) | ||
param(ITEM_NAME, name) | ||
param(CONTENT_TYPE, type) | ||
} | ||
} | ||
|
||
override fun logShare(type: String, id: String) { | ||
firebaseAnalytics.logEvent(Event.SHARE) { | ||
param(ITEM_ID, id) | ||
param(CONTENT_TYPE, type) | ||
} | ||
} | ||
|
||
override fun logEvent(name: String) { | ||
firebaseAnalytics.logEvent(name, null) | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
...d-app/app/src/main/java/com/blacklivesmatter/policebrutality/di/module/AnalyticsModule.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,28 @@ | ||
package com.blacklivesmatter.policebrutality.di.module | ||
|
||
import android.content.Context | ||
import com.blacklivesmatter.policebrutality.analytics.Analytics | ||
import com.blacklivesmatter.policebrutality.analytics.AppAnalytics | ||
import com.google.firebase.analytics.FirebaseAnalytics | ||
import dagger.Module | ||
import dagger.Provides | ||
import timber.log.Timber | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
class AnalyticsModule { | ||
@Singleton | ||
@Provides | ||
fun provideAnalytics(context: Context): FirebaseAnalytics { | ||
// https://firebase.google.com/docs/analytics/get-started?platform=android | ||
val instance = FirebaseAnalytics.getInstance(context) | ||
Timber.d("Providing firebase analytics instance: $instance") | ||
return instance | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
fun provideAppAnalytics(firebaseAnalytics: FirebaseAnalytics): Analytics { | ||
return AppAnalytics(firebaseAnalytics) | ||
} | ||
} |
30 changes: 29 additions & 1 deletion
30
...p/app/src/main/java/com/blacklivesmatter/policebrutality/ui/incident/IncidentViewModel.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
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
Oops, something went wrong.