Replace Firebase analytics with Plausible
This commit is contained in:
parent
33574ce5f5
commit
5af4d2028f
10 changed files with 24 additions and 70 deletions
|
@ -44,7 +44,7 @@ android {
|
|||
versionName "0.8.13"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
testInstrumentationRunnerArguments clearPackageData: 'true'
|
||||
buildConfigField "boolean", "ENABLE_CUSTOM_CSS", "false"
|
||||
buildConfigField "boolean", "ENABLE_CUSTOM_CSS", "true"
|
||||
}
|
||||
signingConfigs {
|
||||
playRelease {
|
||||
|
@ -106,6 +106,7 @@ dependencies {
|
|||
androidTestUtil "androidx.test:orchestrator:1.4.1"
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||
implementation 'com.wbrawner.plausible:plausible-android:0.1.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.5.1'
|
||||
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||
implementation "androidx.fragment:fragment-ktx:1.5.4"
|
||||
|
@ -117,7 +118,6 @@ dependencies {
|
|||
playImplementation 'com.android.billingclient:billing:5.0.0'
|
||||
playImplementation 'com.google.android.play:core-ktx:1.8.1'
|
||||
playImplementation 'com.google.firebase:firebase-crashlytics:18.3.1'
|
||||
playImplementation 'com.google.firebase:firebase-analytics:21.2.0'
|
||||
implementation "androidx.core:core-ktx:1.9.0"
|
||||
implementation 'androidx.browser:browser:1.4.0'
|
||||
def coroutines_version = "1.6.4"
|
||||
|
@ -137,6 +137,7 @@ android.productFlavors.each { flavor ->
|
|||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
jacoco {
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package com.wbrawner.simplemarkdown.utility
|
||||
|
||||
import android.content.Context
|
||||
import com.wbrawner.simplemarkdown.BuildConfig
|
||||
import timber.log.Timber
|
||||
|
||||
class NoopAnalyticsHelper(context: Context): AnalyticsHelper() {
|
||||
override fun setUserProperty(name: String, value: String) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Timber.tag("NoopAnalyticsHelper").d("setting user property $name to $value")
|
||||
}
|
||||
}
|
||||
|
||||
override fun trackPageView(name: String) {
|
||||
Timber.tag("NoopAnalyticsHelper").d("user viewed $name page")
|
||||
}
|
||||
}
|
||||
|
||||
fun AnalyticsHelper.Companion.init(context: Context) = NoopAnalyticsHelper(context)
|
|
@ -1,8 +0,0 @@
|
|||
package com.wbrawner.simplemarkdown.utility
|
||||
|
||||
abstract class AnalyticsHelper {
|
||||
abstract fun setUserProperty(name: String, value: String)
|
||||
abstract fun trackPageView(name: String)
|
||||
|
||||
companion object
|
||||
}
|
|
@ -7,24 +7,24 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.core.app.ActivityCompat
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.wbrawner.plausible.android.Plausible
|
||||
import com.wbrawner.simplemarkdown.R
|
||||
import com.wbrawner.simplemarkdown.utility.AnalyticsHelper
|
||||
import com.wbrawner.simplemarkdown.utility.init
|
||||
|
||||
class MainActivity : AppCompatActivity(), ActivityCompat.OnRequestPermissionsResultCallback {
|
||||
private val analyticsHelper = AnalyticsHelper.init(this)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
analyticsHelper.setUserProperty("autosave", sharedPreferences.getBoolean("autosave", true).toString())
|
||||
val preferences = mutableMapOf<String, String>()
|
||||
preferences["Autosave"] = sharedPreferences.getBoolean("autosave", true).toString()
|
||||
val usingCustomCss = !getStringPref(R.string.pref_custom_css, null).isNullOrBlank()
|
||||
analyticsHelper.setUserProperty("using_custom_css", usingCustomCss.toString())
|
||||
preferences["Custom CSS"] = usingCustomCss.toString()
|
||||
val darkModeSetting = getStringPref(R.string.pref_key_dark_mode, "auto").toString()
|
||||
analyticsHelper.setUserProperty("dark_mode", darkModeSetting)
|
||||
analyticsHelper.setUserProperty("error_reports_enabled", getBooleanPref(R.string.pref_key_error_reports_enabled, true).toString())
|
||||
analyticsHelper.setUserProperty("readability_enabled", getBooleanPref(R.string.readability_enabled, false).toString())
|
||||
preferences["Dark Mode"] = darkModeSetting
|
||||
preferences["Error Reports"] =
|
||||
getBooleanPref(R.string.pref_key_error_reports_enabled, true).toString()
|
||||
preferences["Readability"] = getBooleanPref(R.string.readability_enabled, false).toString()
|
||||
Plausible.event("settings", props = preferences, url = "/")
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
|
|
@ -22,11 +22,10 @@ import androidx.navigation.fragment.findNavController
|
|||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.wbrawner.plausible.android.Plausible
|
||||
import com.wbrawner.simplemarkdown.R
|
||||
import com.wbrawner.simplemarkdown.utility.AnalyticsHelper
|
||||
import com.wbrawner.simplemarkdown.utility.ErrorHandler
|
||||
import com.wbrawner.simplemarkdown.utility.errorHandlerImpl
|
||||
import com.wbrawner.simplemarkdown.utility.init
|
||||
import com.wbrawner.simplemarkdown.view.adapter.EditPagerAdapter
|
||||
import com.wbrawner.simplemarkdown.viewmodel.MarkdownViewModel
|
||||
import kotlinx.android.synthetic.main.fragment_main.*
|
||||
|
@ -82,9 +81,9 @@ class MainFragment : Fragment(), ActivityCompat.OnRequestPermissionsResultCallba
|
|||
tabLayout!!.visibility = View.GONE
|
||||
}
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
viewModel.fileName.observe(viewLifecycleOwner, {
|
||||
viewModel.fileName.observe(viewLifecycleOwner) {
|
||||
toolbar?.title = it
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
@ -146,7 +145,7 @@ class MainFragment : Fragment(), ActivityCompat.OnRequestPermissionsResultCallba
|
|||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
AnalyticsHelper.init(requireContext()).trackPageView("Edit")
|
||||
Plausible.pageView("")
|
||||
lifecycleScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
val enableErrorReports = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.fragment.app.Fragment
|
|||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.wbrawner.plausible.android.Plausible
|
||||
import com.wbrawner.simplemarkdown.R
|
||||
import com.wbrawner.simplemarkdown.utility.*
|
||||
import kotlinx.android.synthetic.main.fragment_markdown_info.*
|
||||
|
@ -19,7 +20,6 @@ import kotlinx.coroutines.launch
|
|||
|
||||
class MarkdownInfoFragment : Fragment() {
|
||||
private val errorHandler: ErrorHandler by errorHandlerImpl()
|
||||
private lateinit var analyticsHelper: AnalyticsHelper
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -75,7 +75,7 @@ class MarkdownInfoFragment : Fragment() {
|
|||
override fun onStart() {
|
||||
super.onStart()
|
||||
arguments?.getString(EXTRA_FILE)?.let {
|
||||
AnalyticsHelper.init(requireContext()).trackPageView(it)
|
||||
Plausible.pageView(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,8 @@ import android.view.ViewGroup
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.wbrawner.plausible.android.Plausible
|
||||
import com.wbrawner.simplemarkdown.R
|
||||
import com.wbrawner.simplemarkdown.utility.AnalyticsHelper
|
||||
import com.wbrawner.simplemarkdown.utility.init
|
||||
import kotlinx.android.synthetic.main.fragment_settings.*
|
||||
|
||||
class SettingsContainerFragment : Fragment() {
|
||||
|
@ -30,6 +29,6 @@ class SettingsContainerFragment : Fragment() {
|
|||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
AnalyticsHelper.init(requireContext()).trackPageView("Settings")
|
||||
Plausible.pageView("Settings")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,9 @@ import androidx.fragment.app.Fragment
|
|||
import androidx.lifecycle.Observer
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.wbrawner.plausible.android.Plausible
|
||||
import com.wbrawner.simplemarkdown.R
|
||||
import com.wbrawner.simplemarkdown.utility.AnalyticsHelper
|
||||
import com.wbrawner.simplemarkdown.utility.SupportLinkProvider
|
||||
import com.wbrawner.simplemarkdown.utility.init
|
||||
import kotlinx.android.synthetic.main.fragment_support.*
|
||||
|
||||
class SupportFragment : Fragment() {
|
||||
|
@ -55,7 +54,7 @@ class SupportFragment : Fragment() {
|
|||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
AnalyticsHelper.init(requireContext()).trackPageView("Support")
|
||||
Plausible.pageView("Support")
|
||||
}
|
||||
|
||||
// override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
|
|
@ -86,4 +86,6 @@
|
|||
<item>@string/pref_key_dark_mode_dark</item>
|
||||
<item>@string/pref_key_dark_mode_auto</item>
|
||||
</string-array>
|
||||
<string name="plausible_host">https://plausible.wbrawner.com</string>
|
||||
<string name="plausible_domain">simplemarkdown.android.wbrawner.com</string>
|
||||
</resources>
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package com.wbrawner.simplemarkdown.utility
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import com.google.firebase.analytics.FirebaseAnalytics
|
||||
|
||||
class FirebaseAnalyticsHelper(context: Context): AnalyticsHelper() {
|
||||
private val firebaseAnalytics = FirebaseAnalytics.getInstance(context)
|
||||
|
||||
override fun setUserProperty(name: String, value: String) {
|
||||
firebaseAnalytics.setUserProperty(name, value)
|
||||
}
|
||||
|
||||
override fun trackPageView(name: String) {
|
||||
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SCREEN_VIEW, Bundle().apply { putString(FirebaseAnalytics.Param.SCREEN_NAME, name) })
|
||||
}
|
||||
}
|
||||
|
||||
fun AnalyticsHelper.Companion.init(context: Context) = FirebaseAnalyticsHelper(context)
|
Loading…
Reference in a new issue