Commit c1389ae9 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Adds analytics when opening the admin panel.

parent 5a472099
......@@ -59,4 +59,9 @@ interface Analytics {
* @param serverCount The number of server(s) the use own.
*/
fun logServerSwitch(serverUrl: String, serverCount: Int)
/**
* Logs the admin opening.
*/
fun logOpenAdmin()
}
......@@ -64,4 +64,10 @@ class AnalyticsManager @Inject constructor(
analytics.forEach { it.logServerSwitch(serverUrl, accounts.size) }
}
}
fun logOpenAdmin() {
if (analyticsTrackingInteractor.get()) {
analytics.forEach { it.logOpenAdmin() }
}
}
}
......@@ -10,9 +10,11 @@ import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import chat.rocket.android.R
import chat.rocket.android.analytics.AnalyticsManager
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.ui
import kotlinx.android.synthetic.main.fragment_admin_panel_web_view.*
import javax.inject.Inject
private const val BUNDLE_WEB_PAGE_URL = "web_page_url"
private const val BUNDLE_USER_TOKEN = "user_token"
......@@ -20,6 +22,8 @@ private const val BUNDLE_USER_TOKEN = "user_token"
class AdminPanelWebViewFragment : Fragment() {
private lateinit var webPageUrl: String
private lateinit var userToken: String
@Inject
lateinit var analyticsManager: AnalyticsManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
......@@ -42,6 +46,8 @@ class AdminPanelWebViewFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
setupToolbar()
setupWebView()
analyticsManager.logOpenAdmin()
}
private fun setupToolbar() {
......
......@@ -65,4 +65,6 @@ class AnswersAnalytics : Analytics {
.putCustomAttribute("server_url", serverUrl)
.putCustomAttribute("server_count", serverCount)
)
override fun logOpenAdmin() = Answers.getInstance().logCustom(CustomEvent("open_admin"))
}
......@@ -58,4 +58,6 @@ class GoogleAnalyticsForFirebase @Inject constructor(val context: Context) :
putInt("server_count", serverCount)
})
}
override fun logOpenAdmin() = firebaseAnalytics.logEvent("open_admin", null)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment