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

Refactor Analytics code.

parent b4cb004e
......@@ -9,7 +9,8 @@ import chat.rocket.android.BuildConfig
import chat.rocket.android.R
import chat.rocket.android.main.ui.MainActivity
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import kotlinx.android.synthetic.main.app_bar.*
import kotlinx.android.synthetic.main.fragment_about.*
import javax.inject.Inject
......@@ -32,7 +33,7 @@ class AboutFragment : Fragment() {
setupViews()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_ABOUT_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.About)
}
}
......
......@@ -18,7 +18,8 @@ import chat.rocket.android.util.extensions.parseColor
import chat.rocket.android.util.extensions.registerPushToken
import chat.rocket.android.util.extensions.samlUrl
import chat.rocket.android.util.extensions.serverLogoUrl
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.AuthenticationEvent
import chat.rocket.android.util.retryIO
import chat.rocket.common.RocketChatAuthException
import chat.rocket.common.RocketChatException
......@@ -77,7 +78,7 @@ class LoginPresenter @Inject constructor(
private lateinit var credentialSecret: String
private lateinit var deepLinkUserId: String
private lateinit var deepLinkToken: String
private lateinit var loginMethod: String // For Answers Log In event.
private lateinit var loginMethod: AuthenticationEvent
fun setupView() {
setupConnectionInfo(currentServer)
......@@ -99,7 +100,7 @@ class LoginPresenter @Inject constructor(
else -> {
this.usernameOrEmail = usernameOrEmail
this.password = password
loginMethod = AnswersEvent.LOGIN_OR_SIGN_UP_BY_USER_AND_PASSWORD
loginMethod = AuthenticationEvent.AuthenticationWithUserAndPassword
doAuthentication(TYPE_LOGIN_USER_EMAIL)
}
}
......@@ -107,20 +108,20 @@ class LoginPresenter @Inject constructor(
fun authenticateWithCas(casToken: String) {
credentialToken = casToken
loginMethod = AnswersEvent.LOGIN_BY_CAS
loginMethod = AuthenticationEvent.AuthenticationWithCas
doAuthentication(TYPE_LOGIN_CAS)
}
fun authenticateWithSaml(samlToken: String) {
credentialToken = samlToken
loginMethod = AnswersEvent.LOGIN_BY_SAML
loginMethod = AuthenticationEvent.AuthenticationWithSaml
doAuthentication(TYPE_LOGIN_SAML)
}
fun authenticateWithOauth(oauthToken: String, oauthSecret: String) {
credentialToken = oauthToken
credentialSecret = oauthSecret
loginMethod = AnswersEvent.LOGIN_OR_SIGN_UP_BY_OAUTH
loginMethod = AuthenticationEvent.AuthenticationWithOauth
doAuthentication(TYPE_LOGIN_OAUTH)
}
......@@ -131,7 +132,7 @@ class LoginPresenter @Inject constructor(
deepLinkUserId = deepLinkInfo.userId
deepLinkToken = deepLinkInfo.token
tokenRepository.save(serverUrl, Token(deepLinkUserId, deepLinkToken))
loginMethod = AnswersEvent.LOGIN_BY_DEEP_LINK
loginMethod = AuthenticationEvent.AuthenticationWithDeeplink
doAuthentication(TYPE_LOGIN_DEEP_LINK)
} else {
// If we don't have the login credentials, just go through normal setup and user input.
......@@ -432,7 +433,7 @@ class LoginPresenter @Inject constructor(
if (myself.id == deepLinkUserId) {
Token(deepLinkUserId, deepLinkToken)
} else {
throw RocketChatAuthException("Invalid Authentication Deep Link Credentials...")
throw RocketChatAuthException("Invalid AuthenticationEvent Deep Link Credentials...")
}
}
else -> {
......@@ -457,7 +458,7 @@ class LoginPresenter @Inject constructor(
saveToken(token)
registerPushToken()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logLogin(loginMethod, true)
AnalyticsManager.logLogin(loginMethod, true)
}
if (loginType == TYPE_LOGIN_USER_EMAIL) {
view.saveSmartLockCredentials(usernameOrEmail, password)
......@@ -473,7 +474,7 @@ class LoginPresenter @Inject constructor(
}
else -> {
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logLogin(loginMethod, false)
AnalyticsManager.logLogin(loginMethod, false)
}
exception.message?.let {
view.showMessage(it)
......
......@@ -25,7 +25,8 @@ import chat.rocket.android.authentication.login.presentation.LoginView
import chat.rocket.android.helper.*
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.*
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import chat.rocket.android.webview.sso.ui.INTENT_SSO_TOKEN
import chat.rocket.android.webview.sso.ui.ssoWebViewIntent
import chat.rocket.android.webview.oauth.ui.INTENT_OAUTH_CREDENTIAL_SECRET
......@@ -97,7 +98,7 @@ class LoginFragment : Fragment(), LoginView {
}
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_LOGIN_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.Login)
}
}
......
......@@ -3,14 +3,24 @@ package chat.rocket.android.authentication.registerusername.presentation
import chat.rocket.android.authentication.presentation.AuthenticationNavigator
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.infrastructure.LocalRepository
import chat.rocket.android.server.domain.*
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.server.domain.GetAccountsInteractor
import chat.rocket.android.server.domain.GetConnectingServerInteractor
import chat.rocket.android.server.domain.GetSettingsInteractor
import chat.rocket.android.server.domain.PublicSettings
import chat.rocket.android.server.domain.SaveAccountInteractor
import chat.rocket.android.server.domain.SaveCurrentServerInteractor
import chat.rocket.android.server.domain.TokenRepository
import chat.rocket.android.server.domain.favicon
import chat.rocket.android.server.domain.model.Account
import chat.rocket.android.server.domain.wideTile
import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.extensions.avatarUrl
import chat.rocket.android.util.extensions.registerPushToken
import chat.rocket.android.util.extensions.serverLogoUrl
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.AuthenticationEvent
import chat.rocket.android.util.retryIO
import chat.rocket.common.RocketChatException
import chat.rocket.common.model.Token
......@@ -54,13 +64,13 @@ class RegisterUsernamePresenter @Inject constructor(
tokenRepository.save(currentServer, Token(userId, authToken))
registerPushToken()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logSignUp(AnswersEvent.LOGIN_OR_SIGN_UP_BY_OAUTH, true)
AnalyticsManager.logSignUp(AuthenticationEvent.AuthenticationWithOauth, true)
}
navigator.toChatList()
}
} catch (exception: RocketChatException) {
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logSignUp(AnswersEvent.LOGIN_OR_SIGN_UP_BY_OAUTH, false)
AnalyticsManager.logSignUp(AuthenticationEvent.AuthenticationWithOauth, false)
}
exception.message?.let {
view.showMessage(it)
......
......@@ -12,7 +12,8 @@ import chat.rocket.android.authentication.registerusername.presentation.Register
import chat.rocket.android.authentication.registerusername.presentation.RegisterUsernameView
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.*
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_authentication_register_username.*
import javax.inject.Inject
......@@ -69,7 +70,7 @@ class RegisterUsernameFragment : Fragment(), RegisterUsernameView {
setupOnClickListener()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_REGISTER_USERNAME_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.RegisterUsername)
}
}
......
......@@ -13,7 +13,8 @@ import chat.rocket.android.authentication.resetpassword.presentation.ResetPasswo
import chat.rocket.android.authentication.resetpassword.presentation.ResetPasswordView
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.*
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_authentication_reset_password.*
import javax.inject.Inject
......@@ -52,7 +53,7 @@ class ResetPasswordFragment : Fragment(), ResetPasswordView {
setupOnClickListener()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_RESET_PASSWORD_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.ResetPassword)
}
}
......
......@@ -18,7 +18,8 @@ import chat.rocket.android.authentication.server.presentation.ServerView
import chat.rocket.android.helper.KeyboardHelper
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.*
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import chat.rocket.common.util.ifNull
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_authentication_server.*
......@@ -97,7 +98,7 @@ class ServerFragment : Fragment(), ServerView {
}
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_SERVER_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.Server)
}
}
......
......@@ -3,12 +3,25 @@ package chat.rocket.android.authentication.signup.presentation
import chat.rocket.android.authentication.presentation.AuthenticationNavigator
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.infrastructure.LocalRepository
import chat.rocket.android.server.domain.*
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.server.domain.GetAccountsInteractor
import chat.rocket.android.server.domain.GetConnectingServerInteractor
import chat.rocket.android.server.domain.GetSettingsInteractor
import chat.rocket.android.server.domain.PublicSettings
import chat.rocket.android.server.domain.SaveAccountInteractor
import chat.rocket.android.server.domain.SaveCurrentServerInteractor
import chat.rocket.android.server.domain.favicon
import chat.rocket.android.server.domain.model.Account
import chat.rocket.android.server.domain.wideTile
import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.extensions.*
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.extensions.avatarUrl
import chat.rocket.android.util.extensions.privacyPolicyUrl
import chat.rocket.android.util.extensions.registerPushToken
import chat.rocket.android.util.extensions.serverLogoUrl
import chat.rocket.android.util.extensions.termsOfServiceUrl
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.AuthenticationEvent
import chat.rocket.android.util.retryIO
import chat.rocket.common.RocketChatException
import chat.rocket.common.util.ifNull
......@@ -69,8 +82,8 @@ class SignupPresenter @Inject constructor(
saveAccount(me)
registerPushToken()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logSignUp(
AnswersEvent.LOGIN_OR_SIGN_UP_BY_USER_AND_PASSWORD,
AnalyticsManager.logSignUp(
AuthenticationEvent.AuthenticationWithUserAndPassword,
true
)
}
......@@ -78,8 +91,8 @@ class SignupPresenter @Inject constructor(
navigator.toChatList()
} catch (exception: RocketChatException) {
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logSignUp(
AnswersEvent.LOGIN_OR_SIGN_UP_BY_USER_AND_PASSWORD,
AnalyticsManager.logSignUp(
AuthenticationEvent.AuthenticationWithUserAndPassword,
false
)
}
......
......@@ -5,12 +5,12 @@ import android.app.Activity
import android.content.Intent
import android.os.Build
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.text.style.ClickableSpan
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import androidx.fragment.app.Fragment
import chat.rocket.android.R
import chat.rocket.android.R.string.message_credentials_saved_successfully
import chat.rocket.android.authentication.signup.presentation.SignupPresenter
......@@ -19,8 +19,14 @@ import chat.rocket.android.helper.KeyboardHelper
import chat.rocket.android.helper.TextHelper
import chat.rocket.android.helper.saveCredentials
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.*
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.shake
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.textContent
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.extensions.vibrateSmartPhone
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_authentication_sign_up.*
import javax.inject.Inject
......@@ -76,8 +82,8 @@ class SignupFragment : Fragment(), SignupView {
)
}
if(analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_SIGNUP_FRAGMENT)
if (analyticsTrackingInteractor.get()) {
AnalyticsManager.logScreenView(ScreenViewEvent.SignUp)
}
}
......
......@@ -10,7 +10,8 @@ import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.extensions.avatarUrl
import chat.rocket.android.util.extensions.registerPushToken
import chat.rocket.android.util.extensions.serverLogoUrl
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.AuthenticationEvent
import chat.rocket.android.util.retryIO
import chat.rocket.common.RocketChatAuthException
import chat.rocket.common.RocketChatException
......@@ -68,8 +69,8 @@ class TwoFAPresenter @Inject constructor(
tokenRepository.save(server, token)
registerPushToken()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logLogin(
AnswersEvent.LOGIN_OR_SIGN_UP_BY_USER_AND_PASSWORD,
AnalyticsManager.logLogin(
AuthenticationEvent.AuthenticationWithUserAndPassword,
true
)
}
......@@ -79,8 +80,8 @@ class TwoFAPresenter @Inject constructor(
view.alertInvalidTwoFactorAuthenticationCode()
} else {
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logLogin(
AnswersEvent.LOGIN_OR_SIGN_UP_BY_USER_AND_PASSWORD,
AnalyticsManager.logLogin(
AuthenticationEvent.AuthenticationWithUserAndPassword,
false
)
}
......
......@@ -4,17 +4,24 @@ import DrawableHelper
import android.content.Context
import android.os.Build
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.fragment.app.Fragment
import chat.rocket.android.R
import chat.rocket.android.authentication.twofactor.presentation.TwoFAPresenter
import chat.rocket.android.authentication.twofactor.presentation.TwoFAView
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.*
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.shake
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.textContent
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.extensions.vibrateSmartPhone
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_authentication_two_fa.*
import javax.inject.Inject
......@@ -38,7 +45,11 @@ class TwoFAFragment : Fragment(), TwoFAView {
password = arguments?.getString(PASSWORD) ?: ""
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = container?.inflate(R.layout.fragment_authentication_two_fa)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = container?.inflate(R.layout.fragment_authentication_two_fa)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
......@@ -55,8 +66,8 @@ class TwoFAFragment : Fragment(), TwoFAView {
setupOnClickListener()
if(analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_TWO_FA_FRAGMENT)
if (analyticsTrackingInteractor.get()) {
AnalyticsManager.logScreenView(ScreenViewEvent.TwoFa)
}
}
......@@ -101,7 +112,8 @@ class TwoFAFragment : Fragment(), TwoFAView {
private fun tintEditTextDrawableStart() {
ui {
val lockDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_vpn_key_black_24dp, it)
val lockDrawable =
DrawableHelper.getDrawableFromId(R.drawable.ic_vpn_key_black_24dp, it)
DrawableHelper.wrapDrawable(lockDrawable)
DrawableHelper.tintDrawable(lockDrawable, it, R.color.colorDrawableTintGrey)
DrawableHelper.compoundDrawable(text_two_factor_auth, lockDrawable)
......
......@@ -13,12 +13,11 @@ import chat.rocket.android.chatinformation.adapter.ReadReceiptAdapter
import chat.rocket.android.chatinformation.presentation.MessageInfoPresenter
import chat.rocket.android.chatinformation.presentation.MessageInfoView
import chat.rocket.android.chatinformation.viewmodel.ReadReceiptViewModel
import chat.rocket.android.helper.EndlessRecyclerViewScrollListener
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.core.model.ReadReceipt
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_message_info.*
import javax.inject.Inject
......@@ -69,7 +68,7 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
presenter.loadReadReceipts(messageId = messageId)
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_MESSAGE_INFO_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.MessageInfo)
}
}
......
......@@ -34,7 +34,8 @@ import chat.rocket.android.server.infraestructure.state
import chat.rocket.android.util.extension.compressImageAndGetInputStream
import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.extensions.avatarUrl
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.SubscriptionTypeEvent
import chat.rocket.android.util.retryIO
import chat.rocket.common.RocketChatException
import chat.rocket.common.model.RoomType
......@@ -300,7 +301,7 @@ class ChatRoomPresenter @Inject constructor(
)
client.sendMessage(id, chatRoomId, text)
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logMessageSent(chatRoomType, currentServer)
logMessageSent(currentServer)
}
} catch (ex: Exception) {
// Ok, not very beautiful, but the backend sends us a not valid response
......@@ -370,7 +371,7 @@ class ChatRoomPresenter @Inject constructor(
}
}
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logMediaUploaded(chatRoomType, mimeType)
logMediaUploaded(mimeType)
}
}
}
......@@ -944,7 +945,7 @@ class ChatRoomPresenter @Inject constructor(
client.toggleReaction(messageId, emoji.removeSurrounding(":"))
}
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logReaction(chatRoomType)
logReactionEvent()
}
} catch (ex: RocketChatException) {
Timber.e(ex)
......@@ -952,6 +953,36 @@ class ChatRoomPresenter @Inject constructor(
}
}
private fun logReactionEvent() {
when {
roomTypeOf(chatRoomType) is RoomType.DirectMessage ->
AnalyticsManager.logReaction(SubscriptionTypeEvent.DirectMessage)
roomTypeOf(chatRoomType) is RoomType.Channel ->
AnalyticsManager.logReaction(SubscriptionTypeEvent.Channel)
else -> AnalyticsManager.logReaction(SubscriptionTypeEvent.Group)
}
}
private fun logMediaUploaded(mimeType: String) {
when {
roomTypeOf(chatRoomType) is RoomType.DirectMessage ->
AnalyticsManager.logMediaUploaded(SubscriptionTypeEvent.DirectMessage, mimeType)
roomTypeOf(chatRoomType) is RoomType.Channel ->
AnalyticsManager.logMediaUploaded(SubscriptionTypeEvent.Channel, mimeType)
else -> AnalyticsManager.logMediaUploaded(SubscriptionTypeEvent.Group, mimeType)
}
}
private fun logMessageSent(serverUrl: String) {
when {
roomTypeOf(chatRoomType) is RoomType.DirectMessage ->
AnalyticsManager.logMessageSent(SubscriptionTypeEvent.DirectMessage, serverUrl)
roomTypeOf(chatRoomType) is RoomType.Channel ->
AnalyticsManager.logMessageSent(SubscriptionTypeEvent.Channel, serverUrl)
else -> AnalyticsManager.logMessageSent(SubscriptionTypeEvent.Group, serverUrl)
}
}
fun showReactions(messageId: String) {
view.showReactionsPopup(messageId)
}
......
......@@ -66,7 +66,8 @@ import chat.rocket.android.util.extensions.rotateBy
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.textContent
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import chat.rocket.common.model.RoomType
import chat.rocket.common.model.roomTypeOf
import chat.rocket.core.internal.realtime.socket.model.State
......@@ -236,7 +237,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_CHAT_ROOM_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.ChatRoom)
}
}
......
......@@ -39,7 +39,8 @@ import chat.rocket.android.util.extensions.fadeOut
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import chat.rocket.android.widget.DividerItemDecoration
import chat.rocket.core.internal.realtime.socket.model.State
import dagger.android.support.AndroidSupportInjection
......@@ -112,7 +113,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
setupToolbar()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_CHAT_ROOMS_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.ChatRooms)
}
}
......
......@@ -25,7 +25,8 @@ import chat.rocket.android.util.extension.asObservable
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import chat.rocket.common.model.RoomType
import chat.rocket.common.model.roomTypeOf
import com.google.android.material.chip.Chip
......@@ -77,7 +78,7 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback
subscribeEditTexts()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_CREATE_CHANNEL_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.CreateChannel)
}
}
......
......@@ -20,7 +20,8 @@ import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_favorite_messages.*
import javax.inject.Inject
......@@ -68,7 +69,7 @@ class FavoriteMessagesFragment : Fragment(), FavoriteMessagesView {
presenter.loadFavoriteMessages(chatRoomId)
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_FAVORITE_MESSAGES_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.FavoriteMessages)
}
}
......
......@@ -25,7 +25,8 @@ import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_files.*
import javax.inject.Inject
......@@ -75,7 +76,7 @@ class FilesFragment : Fragment(), FilesView {
presenter.loadFiles(chatRoomId)
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_FILES_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.Files)
}
}
......
package chat.rocket.android.members.ui
import android.os.Bundle
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -10,15 +9,19 @@ import chat.rocket.android.R
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.content
import chat.rocket.android.util.extensions.textContent
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import kotlinx.android.synthetic.main.fragment_member_bottom_sheet.*
import javax.inject.Inject
fun newInstance(avatarUri: String,
fun newInstance(
avatarUri: String,
realName: String,
username: String,
email: String,
utcOffset: String): BottomSheetDialogFragment {
utcOffset: String
): BottomSheetDialogFragment {
return MemberBottomSheetFragment().apply {
arguments = Bundle(1).apply {
putString(BUNDLE_AVATAR_URI, avatarUri)
......@@ -38,7 +41,7 @@ private const val BUNDLE_USERNAME = "username"
private const val BUNDLE_EMAIL = "email"
private const val BUNDLE_UTC_OFFSET = "utc_offset"
class MemberBottomSheetFragment: BottomSheetDialogFragment() {
class MemberBottomSheetFragment : BottomSheetDialogFragment() {
@Inject
lateinit var analyticsTrackingInteractor: AnalyticsTrackingInteractor
private lateinit var avatarUri: String
......@@ -61,7 +64,12 @@ class MemberBottomSheetFragment: BottomSheetDialogFragment() {
requireNotNull(bundle) { "no arguments supplied when the fragment was instantiated" }
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? =
inflater.inflate(R.layout.fragment_member_bottom_sheet, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
......@@ -69,7 +77,7 @@ class MemberBottomSheetFragment: BottomSheetDialogFragment() {
showMemberDetails()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_MEMBER_BOTTOM_SHEET_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.MemberBottomSheet)
}
}
......@@ -85,7 +93,7 @@ class MemberBottomSheetFragment: BottomSheetDialogFragment() {
text_member_email_address.isVisible = false
}
if (utcOffset.isNotEmpty()){
if (utcOffset.isNotEmpty()) {
text_member_utc.content = utcOffset
} else {
text_utc.isVisible = false
......
......@@ -20,7 +20,8 @@ import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_members.*
import javax.inject.Inject
......@@ -70,7 +71,7 @@ class MembersFragment : Fragment(), MembersView {
presenter.loadChatRoomsMembers(chatRoomId)
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_MEMBERS_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.Members)
}
}
......
......@@ -20,7 +20,8 @@ import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_mentions.*
import javax.inject.Inject
......@@ -70,7 +71,7 @@ class MentionsFragment : Fragment(), MentionsView {
presenter.loadMentions(chatRoomId)
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_MENTIONS_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.Mentions)
}
}
......
package chat.rocket.android.pinnedmessages.ui
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import chat.rocket.android.R
import chat.rocket.android.chatroom.adapter.ChatRoomAdapter
import chat.rocket.android.chatroom.ui.ChatRoomActivity
......@@ -20,7 +20,8 @@ import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_pinned_messages.*
import javax.inject.Inject
......@@ -69,7 +70,7 @@ class PinnedMessagesFragment : Fragment(), PinnedMessagesView {
presenter.loadPinnedMessages(chatRoomId)
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_PINNED_MESSAGES_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.PinnedMessages)
}
}
......
......@@ -11,7 +11,8 @@ import chat.rocket.android.main.ui.MainActivity
import chat.rocket.android.preferences.presentation.PreferencesPresenter
import chat.rocket.android.preferences.presentation.PreferencesView
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.app_bar.*
import kotlinx.android.synthetic.main.fragment_preferences.*
......@@ -42,8 +43,8 @@ class PreferencesFragment : Fragment(), PreferencesView {
setupListeners()
presenter.loadAnalyticsTrackingInformation()
if(analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_PREFERENCES_FRAGMENT)
if (analyticsTrackingInteractor.get()) {
AnalyticsManager.logScreenView(ScreenViewEvent.Preferences)
}
}
......
......@@ -6,7 +6,11 @@ import android.content.Intent
import android.graphics.Bitmap
import android.os.Build
import android.os.Bundle
import android.view.*
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode
import androidx.core.net.toUri
......@@ -24,7 +28,8 @@ import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.textContent
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import com.facebook.drawee.backends.pipeline.Fresco
import dagger.android.support.AndroidSupportInjection
import io.reactivex.disposables.CompositeDisposable
......@@ -77,7 +82,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
subscribeEditTexts()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_PROFILE_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.Profile)
}
}
......
......@@ -2,10 +2,16 @@ package chat.rocket.android.server.presentation
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.infrastructure.LocalRepository
import chat.rocket.android.server.domain.*
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.server.domain.GetAccountInteractor
import chat.rocket.android.server.domain.GetAccountsInteractor
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.SaveCurrentServerInteractor
import chat.rocket.android.server.domain.SettingsRepository
import chat.rocket.android.server.domain.TokenRepository
import chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.common.util.ifNull
import javax.inject.Inject
......@@ -61,7 +67,7 @@ class ChangeServerPresenter @Inject constructor(
saveCurrentServerInteractor.save(serverUrl)
view.hideProgress()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logServerSwitch(serverUrl, accounts.size)
AnalyticsManager.logServerSwitch(serverUrl, accounts.size)
}
navigator.toChatRooms(chatRoomId)
}.ifNull {
......
package chat.rocket.android.settings.password.ui
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.*
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.view.ActionMode
import androidx.fragment.app.Fragment
import chat.rocket.android.R
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.settings.password.presentation.PasswordPresenter
import chat.rocket.android.settings.password.presentation.PasswordView
import chat.rocket.android.util.extensions.inflate
import androidx.appcompat.view.ActionMode
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import chat.rocket.android.util.extension.asObservable
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.textContent
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import dagger.android.support.AndroidSupportInjection
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
......@@ -23,7 +28,7 @@ import javax.inject.Inject
internal const val TAG_PASSWORD_FRAGMENT = "PasswordFragment"
class PasswordFragment: Fragment(), PasswordView, ActionMode.Callback {
class PasswordFragment : Fragment(), PasswordView, ActionMode.Callback {
@Inject
lateinit var presenter: PasswordPresenter
@Inject
......@@ -40,7 +45,11 @@ class PasswordFragment: Fragment(), PasswordView, ActionMode.Callback {
super.onCreate(savedInstanceState)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = container?.inflate(R.layout.fragment_password)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = container?.inflate(R.layout.fragment_password)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
......@@ -48,7 +57,7 @@ class PasswordFragment: Fragment(), PasswordView, ActionMode.Callback {
disposables.add(listenToChanges())
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_PASSWORD_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.Password)
}
}
......@@ -109,12 +118,17 @@ class PasswordFragment: Fragment(), PasswordView, ActionMode.Callback {
private fun finishActionMode() = actionMode?.finish()
private fun listenToChanges(): Disposable {
return Observables.combineLatest(text_new_password.asObservable(),
text_confirm_password.asObservable()).subscribe {
return Observables.combineLatest(
text_new_password.asObservable(),
text_confirm_password.asObservable()
).subscribe {
val textPassword = text_new_password.textContent
val textConfirmPassword = text_confirm_password.textContent
if (textPassword.length > 5 && textConfirmPassword.length > 5 && textPassword.equals(textConfirmPassword))
if (textPassword.length > 5 && textConfirmPassword.length > 5 && textPassword.equals(
textConfirmPassword
)
)
startActionMode()
else
finishActionMode()
......
......@@ -19,7 +19,8 @@ import chat.rocket.android.settings.password.ui.PasswordActivity
import chat.rocket.android.settings.presentation.SettingsView
import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.helper.AnswersEvent
import chat.rocket.android.util.helper.analytics.AnalyticsManager
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import kotlinx.android.synthetic.main.fragment_settings.*
import javax.inject.Inject
import kotlin.reflect.KClass
......@@ -42,7 +43,7 @@ class SettingsFragment : Fragment(), SettingsView, AdapterView.OnItemClickListen
setupListView()
if (analyticsTrackingInteractor.get()) {
AnswersEvent.logScreenView(TAG_SETTINGS_FRAGMENT)
AnalyticsManager.logScreenView(ScreenViewEvent.Settings)
}
}
......
package chat.rocket.android.util.helper
object AnswersEvent {
const val LOGIN_OR_SIGN_UP_BY_USER_AND_PASSWORD = "USER-AND-PASSWORD"
const val LOGIN_BY_CAS = "CAS"
const val LOGIN_BY_SAML = "SAML"
const val LOGIN_OR_SIGN_UP_BY_OAUTH = "OAUTH"
const val LOGIN_BY_DEEP_LINK = "DEEP-LINK"
/**
* Logs the Log In event.
*
* @param loginMethod The method that the user used to log in.
* @param loginSucceeded True if the user successful logged in, false otherwise.
*/
fun logLogin(loginMethod: String, loginSucceeded: Boolean) {
// Do absolutely nothing
}
/**
* Logs the Sign Up event.
*
* @param signUpMethod The method that the user used to sign up.
* @param signUpSucceeded True if the user successful signed up, false otherwise.
*/
fun logSignUp(signUpMethod: String, signUpSucceeded: Boolean) {
// Do absolutely nothing
}
/**
* Logs the screen view custom event.
*
* @param screenName The name of the screen to log.
*/
fun logScreenView(screenName: String) {
// Do absolutely nothing
}
/**
* Logs the message sent custom event.
*
* @param roomType The room type to log.
* @param serverUrl The server URL to log.
*/
fun logMessageSent(roomType: String, serverUrl: String) {
// Do absolutely nothing
}
/**
* Logs the media upload custom event.
*
* @param roomType The room type to log.
* @param mimeType The mime type of the media to log.
*/
fun logMediaUploaded(roomType: String, mimeType: String) {
// Do absolutely nothing
}
/**
* Logs the reaction custom event.
*
* @param roomType The room type to log.
*/
fun logReaction(roomType: String) {
// Do absolutely nothing
}
/**
* Logs the server switch custom event.
*
* @param serverUrl The server URL to log.
* @param serverCount The number of server(s) the use own.
*/
fun logServerSwitch(serverUrl: String, serverCount: Int) {
// Do absolutely nothing
}
}
\ No newline at end of file
package chat.rocket.android.util.helper.analytics
object AnalyticsManager : Analytics {
override fun logLogin(event: AuthenticationEvent, loginSucceeded: Boolean) {
// Do absolutely nothing
}
override fun logSignUp(event: AuthenticationEvent, signUpSucceeded: Boolean) {
// Do absolutely nothing
}
override fun logScreenView(event: ScreenViewEvent) {
// Do absolutely nothing
}
override fun logMessageSent(event: SubscriptionTypeEvent, serverUrl: String) {
// Do absolutely nothing
}
override fun logMediaUploaded(event: SubscriptionTypeEvent, mimeType: String) {
// Do absolutely nothing
}
override fun logReaction(event: SubscriptionTypeEvent) {
// Do absolutely nothing
}
override fun logServerSwitch(serverUrl: String, serverCount: Int) {
// Do absolutely nothing
}
}
package chat.rocket.android.util.helper.analytics
import chat.rocket.android.util.helper.analytics.event.AuthenticationEvent
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import chat.rocket.android.util.helper.analytics.event.SubscriptionTypeEvent
interface Analytics {
/**
* Logs the login event.
*
* @param event The [AuthenticationEvent] used to log in.
* @param loginSucceeded True if successful logged in, false otherwise.
*/
fun logLogin(event: AuthenticationEvent, loginSucceeded: Boolean)
/**
* Logs the sign up event.
*
* @param event The [AuthenticationEvent] used to sign up.
* @param signUpSucceeded True if successful signed up, false otherwise.
*/
fun logSignUp(event: AuthenticationEvent, signUpSucceeded: Boolean)
/**
* Logs the screen view event.
*
* @param event The [ScreenViewEvent] to log.
*/
fun logScreenView(event: ScreenViewEvent)
/**
* Logs the message sent event.
*
* @param event The [SubscriptionTypeEvent] to log.
* @param serverUrl The server URL to log.
*/
fun logMessageSent(event: SubscriptionTypeEvent, serverUrl: String)
/**
* Logs the media upload event.
*
* @param event The [SubscriptionTypeEvent] to log.
* @param mimeType The mime type of the media uploaded to log.
*/
fun logMediaUploaded(event: SubscriptionTypeEvent, mimeType: String)
/**
* Logs the reaction event.
*
* @param event The [SubscriptionTypeEvent] to log.
*/
fun logReaction(event: SubscriptionTypeEvent)
/**
* Logs the server switch event.
*
* @param serverUrl The server URL to log.
* @param serverCount The number of server(s) the use own.
*/
fun logServerSwitch(serverUrl: String, serverCount: Int)
}
package chat.rocket.android.util.helper
package chat.rocket.android.util.helper.analytics
import chat.rocket.android.util.helper.analytics.event.AuthenticationEvent
import chat.rocket.android.util.helper.analytics.event.ScreenViewEvent
import chat.rocket.android.util.helper.analytics.event.SubscriptionTypeEvent
import com.crashlytics.android.answers.Answers
import com.crashlytics.android.answers.CustomEvent
import com.crashlytics.android.answers.LoginEvent
import com.crashlytics.android.answers.SignUpEvent
object AnswersEvent {
const val LOGIN_OR_SIGN_UP_BY_USER_AND_PASSWORD = "USER-AND-PASSWORD"
const val LOGIN_BY_CAS = "CAS"
const val LOGIN_BY_SAML = "SAML"
const val LOGIN_OR_SIGN_UP_BY_OAUTH = "OAUTH"
const val LOGIN_BY_DEEP_LINK = "DEEP-LINK"
// TODO inject the and analyticsTrackingInteractor and GetCurrentServerInteractor
object AnalyticsManager : Analytics {
/**
* Logs the Log In event.
*
* @param loginMethod The method that the user used to log in.
* @param loginSucceeded True if the user successful logged in, false otherwise.
*/
fun logLogin(loginMethod: String, loginSucceeded: Boolean) =
override fun logLogin(event: AuthenticationEvent, loginSucceeded: Boolean) =
Answers.getInstance()
.logLogin(
LoginEvent()
.putMethod(loginMethod)
.putMethod(event.methodName)
.putSuccess(loginSucceeded)
)
/**
* Logs the Sign Up event.
*
* @param signUpMethod The method that the user used to sign up.
* @param signUpSucceeded True if the user successful signed up, false otherwise.
*/
fun logSignUp(signUpMethod: String, signUpSucceeded: Boolean) =
override fun logSignUp(event: AuthenticationEvent, signUpSucceeded: Boolean) =
Answers.getInstance()
.logSignUp(
SignUpEvent()
.putMethod(signUpMethod)
.putMethod(event.methodName)
.putSuccess(signUpSucceeded)
)
/**
* Logs the screen view custom event.
*
* @param screenName The name of the screen to log.
*/
fun logScreenView(screenName: String) =
override fun logScreenView(event: ScreenViewEvent) =
Answers.getInstance()
.logCustom(CustomEvent("screen_view").putCustomAttribute("screen", screenName))
.logCustom(CustomEvent("screen_view").putCustomAttribute("screen", event.screenName))
/**
* Logs the message sent custom event.
*
* @param roomType The room type to log.
* @param serverUrl The server URL to log.
*/
fun logMessageSent(roomType: String, serverUrl: String) =
override fun logMessageSent(event: SubscriptionTypeEvent, serverUrl: String) =
Answers.getInstance()
.logCustom(
CustomEvent("message_sent")
.putCustomAttribute("subscription_type", roomType)
.putCustomAttribute("subscription_type", event.subscriptionTypeName)
.putCustomAttribute("server", serverUrl)
)
/**
* Logs the media upload custom event.
*
* @param roomType The room type to log.
* @param mimeType The mime type of the media to log.
*/
fun logMediaUploaded(roomType: String, mimeType: String) =
override fun logMediaUploaded(event: SubscriptionTypeEvent, mimeType: String) =
Answers.getInstance()
.logCustom(
CustomEvent("media_upload")
.putCustomAttribute("subscription_type", roomType)
.putCustomAttribute("subscription_type", event.subscriptionTypeName)
.putCustomAttribute("media_type", mimeType)
)
/**
* Logs the reaction custom event.
*
* @param roomType The room type to log.
*/
fun logReaction(roomType: String) =
override fun logReaction(event: SubscriptionTypeEvent) =
Answers.getInstance()
.logCustom(
CustomEvent("reaction").putCustomAttribute("subscription_type", roomType)
CustomEvent("reaction")
.putCustomAttribute("subscription_type", event.subscriptionTypeName)
)
/**
* Logs the server switch custom event.
*
* @param serverUrl The server URL to log.
* @param serverCount The number of server(s) the use own.
*/
fun logServerSwitch(serverUrl: String, serverCount: Int) =
override fun logServerSwitch(serverUrl: String, serverCount: Int) =
Answers.getInstance()
.logCustom(
CustomEvent("server_switch")
......
package chat.rocket.android.util.helper.analytics.event
sealed class AuthenticationEvent(val methodName: String) {
object AuthenticationWithUserAndPassword : AuthenticationEvent("User and password")
object AuthenticationWithCas : AuthenticationEvent("CAS")
object AuthenticationWithSaml : AuthenticationEvent("SAML")
object AuthenticationWithOauth : AuthenticationEvent("Oauth")
object AuthenticationWithDeeplink : AuthenticationEvent("Deep link")
}
package chat.rocket.android.util.helper.analytics.event
sealed class ScreenViewEvent(val screenName: String) {
object About : ScreenViewEvent("AboutFragment")
object ChatRoom : ScreenViewEvent("ChatRoomFragment")
object ChatRooms : ScreenViewEvent("ChatRoomsFragment")
object CreateChannel : ScreenViewEvent("CreateChannelFragment")
object FavoriteMessages : ScreenViewEvent("FavoriteMessagesFragment")
object Files : ScreenViewEvent("FilesFragment")
object Login : ScreenViewEvent("LoginFragment")
object MemberBottomSheet : ScreenViewEvent("MemberBottomSheetFragment")
object Members : ScreenViewEvent("MembersFragment")
object Mentions : ScreenViewEvent("MentionsFragment")
object MessageInfo : ScreenViewEvent("MessageInfoFragment")
object Password : ScreenViewEvent("PasswordFragment")
object PinnedMessages : ScreenViewEvent("PinnedMessagesFragment")
object Preferences : ScreenViewEvent("PreferencesFragment")
object Profile : ScreenViewEvent("ProfileFragment")
object RegisterUsername : ScreenViewEvent("RegisterUsernameFragment")
object ResetPassword : ScreenViewEvent("ResetPasswordFragment")
object Server : ScreenViewEvent("ServerFragment")
object Settings : ScreenViewEvent("SettingsFragment")
object SignUp : ScreenViewEvent("SignupFragment")
object TwoFa : ScreenViewEvent("TwoFAFragment")
}
\ No newline at end of file
package chat.rocket.android.util.helper.analytics.event
sealed class SubscriptionTypeEvent(val subscriptionTypeName: String) {
object DirectMessage : SubscriptionTypeEvent("Direct Message")
object Channel : SubscriptionTypeEvent("Channel")
object Group : SubscriptionTypeEvent("Group")
}
\ No newline at end of file
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