Skip to content

Commit

Permalink
Firebase添加用户行为分析
Browse files Browse the repository at this point in the history
Change-Id: Idf1a2b885cf62bcdbce46f5f937bcecb3012c59f
  • Loading branch information
archurcode committed Sep 18, 2020
1 parent dda98c9 commit b43efa1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Intent
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.tencent.iot.explorer.link.App
import com.tencent.iot.explorer.link.ErrorCode
Expand Down Expand Up @@ -39,6 +40,7 @@ class LoginActivity : PActivity(), LoginView, View.OnClickListener, WeChatLogin

private lateinit var accoutPasswdLoginView: View
private lateinit var verifyCodeLoginView: View
private var mFirebaseAnalytics: FirebaseAnalytics? = null
private var fromTag = ""
private var accountType = false //true为手机号,false为邮箱
private var accountForAutoFill = ""
Expand Down Expand Up @@ -76,6 +78,7 @@ class LoginActivity : PActivity(), LoginView, View.OnClickListener, WeChatLogin
intent.getStringExtra("from")?.let {
fromTag = it
}
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this@LoginActivity)
presenter = LoginPresenter(this)
iv_back.setColorFilter(resources.getColor(R.color.black_333333))
tv_title.text = getString(R.string.verify_code_login)
Expand All @@ -84,6 +87,7 @@ class LoginActivity : PActivity(), LoginView, View.OnClickListener, WeChatLogin
if (!TextUtils.isEmpty(App.data.getToken())) {
val userId = SharePreferenceUtil.getString(this@LoginActivity, App.CONFIG, CommonField.USER_ID)
FirebaseCrashlytics.getInstance().setUserId(userId)
mFirebaseAnalytics!!.setUserId(userId)
startActivity(Intent(this, MainActivity::class.java))
finish()
return
Expand Down Expand Up @@ -240,6 +244,7 @@ class LoginActivity : PActivity(), LoginView, View.OnClickListener, WeChatLogin
App.data.userInfo = this
SharePreferenceUtil.saveString(this@LoginActivity, App.CONFIG, CommonField.USER_ID, App.data.userInfo.UserID)
FirebaseCrashlytics.getInstance().setUserId(App.data.userInfo.UserID)
mFirebaseAnalytics?.setUserId(App.data.userInfo.UserID)
saveUser(user)
T.show(getString(R.string.login_success))
if (TextUtils.isEmpty(fromTag)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.text.TextUtils
import android.view.View
import androidx.fragment.app.Fragment
import com.alibaba.fastjson.JSONObject
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.tencent.iot.explorer.link.App
import com.tencent.iot.explorer.link.R
Expand Down Expand Up @@ -110,6 +111,7 @@ class MainActivity : PActivity(), MyCallback {
override fun initView() {
val userId = SharePreferenceUtil.getString(this@MainActivity, App.CONFIG, CommonField.USER_ID)
FirebaseCrashlytics.getInstance().setUserId(userId)
FirebaseAnalytics.getInstance(this).setUserId(userId)
openXGPush()
home_bottom_view.addMenu(
BottomItemEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.tencent.iot.explorer.link.core.demo.activity

import android.text.TextUtils
import android.widget.Toast
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.tencent.iot.explorer.link.core.auth.IoTAuth
import com.tencent.iot.explorer.link.core.auth.callback.LoginCallback
Expand Down Expand Up @@ -69,6 +70,7 @@ class LoginActivity : BaseActivity(), LoginCallback {
response.parse(UserInfoResponse::class.java)?.Data?.run {
App.data.userInfo = this
FirebaseCrashlytics.getInstance().setUserId(App.data.userInfo.UserID)
FirebaseAnalytics.getInstance(this@LoginActivity).setUserId(App.data.userInfo.UserID)
jumpActivity(MainActivity::class.java, true)
}
}
Expand Down

0 comments on commit b43efa1

Please sign in to comment.