Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD/#123] 푸시 알림 관련 앰플리튜드 추가 #124

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,17 @@ class SignupActivity : BaseActivity<ActivitySignupBinding>(R.layout.activity_sig
private fun setAmplitudeUserProperty(state: UiState.Success<SignUpUserModel>) {
AmplitudeManager.apply {
trackEvent("complete_infoget")
updateProperties("user_email", state.data.email)
updateProperties("user_platform", state.data.lastLoginOauthPlatform)
updateProperties("user_nickname", state.data.nickname)
updateProperties("user_birth_year", state.data.birthYear)
updateProperties("user_sex", state.data.sex)
updateStringProperties("user_email", state.data.email)
updateStringProperties("user_platform", state.data.lastLoginOauthPlatform)
updateStringProperties("user_nickname", state.data.nickname)
updateStringProperties("user_birth_year", state.data.birthYear)
updateStringProperties("user_sex", state.data.sex)
updateIntProperties("user_share", 0)
updateIntProperties("user_picturedownload", 0)
updateIntProperties("user_main_scroll", 0)
updateIntProperties("user_promptsuggest_refresh", 0)
updateIntProperties("user_piccreate", 0)
updateBooleanProperties("user_alarm", false)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(R.layout.activity_main) {
when (status) {
GenerateStatus.AWAIT_USER_VERIFICATION -> {
if (viewModel.checkNewPictureInitialized()) {
AmplitudeManager.trackEvent(
"click_push_notification",
mapOf("push_type" to "creating_success"),
)
with(viewModel.newPicture.pictureGenerateResponse) {
FinishedActivity.createIntent(
this@MainActivity,
Expand All @@ -147,6 +151,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(R.layout.activity_main) {
}

GenerateStatus.CANCELED -> {
AmplitudeManager.trackEvent(
"click_push_notification",
mapOf("push_type" to "creating_fail"),
)
createErrorDialog = CreateErrorDialog()
createErrorDialog?.show(supportFragmentManager, DIALOG_ERROR)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ class SelfieFragment() : BaseFragment<FragmentSelfieBinding>(R.layout.fragment_s
viewModel.totalGeneratingState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
is UiState.Success -> {
AmplitudeManager.plusIntProperties("user_piccreate")
waitingResult.launch(Intent(requireContext(), WaitingActivity::class.java))
with(viewModel) {
modCurrentPercent(-67)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class FinishedActivity : BaseActivity<ActivityFinishedBinding>(R.layout.activity
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initView()
initImageBtnListener()
initSaveBtnListener()
initShareBtnListener()
Expand All @@ -62,6 +63,10 @@ class FinishedActivity : BaseActivity<ActivityFinishedBinding>(R.layout.activity
setStatusBarTransparent()
}

private fun initView() {
AmplitudeManager.trackEvent("view_picdone")
}

private fun initImageBtnListener() {
with(binding) {
ivFinishedImage32.setOnSingleClickListener { showImageDialog() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import kr.genti.core.base.BaseDialog
import kr.genti.core.extension.setOnSingleClickListener
import kr.genti.presentation.R
import kr.genti.presentation.databinding.DialogPushBinding
import timber.log.Timber
import kr.genti.presentation.util.AmplitudeManager

class PushDialog :
BaseDialog<DialogPushBinding>(R.layout.dialog_push) {
Expand Down Expand Up @@ -55,14 +55,23 @@ class PushDialog :

private fun initGetAlarmBtnListener() {
binding.btnGetAlarm.setOnSingleClickListener {
AmplitudeManager.trackEvent(
AmplitudeManager.EVENT_CLICK_BTN,
mapOf(AmplitudeManager.PROPERTY_PAGE to "alarmagree"),
mapOf(AmplitudeManager.PROPERTY_BTN to "goalarm"),
)
requestAlarmPermission()
}
}

private fun setRequestPermissionLauncher() {
requestPermissionLauncher =
registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
Timber.d(isGranted.toString())
if (isGranted) {
AmplitudeManager.updateBooleanProperties("user_alarm", true)
} else {
AmplitudeManager.updateBooleanProperties("user_alarm", false)
}
dismiss()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class WaitingActivity : BaseActivity<ActivityWaitBinding>(R.layout.activity_wait
pushDialog = PushDialog()
pushDialog?.show(supportFragmentManager, DIALOG_PUSH)
} else {
AmplitudeManager.updateBooleanProperties("user_alarm", true)
setResult(Activity.RESULT_OK)
finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object AmplitudeManager {
}
}

fun updateProperties(
fun updateStringProperties(
propertyName: String,
values: String,
) {
Expand All @@ -58,6 +58,13 @@ object AmplitudeManager {
amplitude.identify(Identify().set(propertyName, intValues))
}

fun updateBooleanProperties(
propertyName: String,
booleanValue: Boolean,
) {
amplitude.identify(Identify().set(propertyName, booleanValue))
}

fun plusIntProperties(propertyName: String) {
amplitude.identify(Identify().add(propertyName, 1))
}
Expand Down
Loading