-
Notifications
You must be signed in to change notification settings - Fork 1
feat/#105: Mixpanel 기반 이벤트 로깅 연동 (피드/투표 생성 흐름) #106
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d42beaf
feat/#105: core/analytics 모듈 추가 (Mixpanel + DebugAnalytics)
DongChyeon 70cc81a
feat/#105: feature/home Analytics 연동 (feed_viewed, feed_exited, vote_…
DongChyeon 1386a29
feat/#105: feature/upload Analytics 연동 (vote_create_started, complete…
DongChyeon 8546b0d
feat/#105: app 모듈에 core:analytics 의존성 추가 (Hilt 그래프)
DongChyeon 95acdce
refactor/#105: entrySource 속성 제거 (단일 진입 경로로 분석 가치 없음)
DongChyeon b68fc35
refactor/#105: FeedViewed에서 entrySource 제거 (단일 진입 경로)
DongChyeon b81e213
chore/#105: GitHub Actions에 MIXPANEL_TOKEN secret 추가
DongChyeon 3f1162d
fix/#105: VoteSubmitted 이벤트를 API 성공 시점으로 이동
DongChyeon a299808
fix/#105: analytics.track 호출을 상태 업데이트/화면 이동 이후로 이동
DongChyeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import java.util.Properties | ||
|
|
||
| plugins { | ||
| id("buyornot.android.library") | ||
| alias(libs.plugins.hilt) | ||
| alias(libs.plugins.ksp) | ||
| } | ||
|
|
||
| val localProperties = | ||
| Properties().apply { | ||
| val localPropertiesFile = rootProject.file("local.properties") | ||
| if (localPropertiesFile.exists()) { | ||
| localPropertiesFile.inputStream().use { load(it) } | ||
| } | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.sseotdabwa.buyornot.core.analytics" | ||
|
|
||
| buildFeatures { | ||
| buildConfig = true | ||
| } | ||
|
|
||
| buildTypes { | ||
| debug { | ||
| buildConfigField("String", "MIXPANEL_TOKEN", "\"\"") | ||
| } | ||
| release { | ||
| buildConfigField( | ||
| "String", | ||
| "MIXPANEL_TOKEN", | ||
| "\"${localProperties.getProperty("mixpanel.token", "")}\"", | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(libs.mixpanel.android) | ||
|
|
||
| implementation(libs.hilt.android) | ||
| ksp(libs.hilt.compiler) | ||
| } |
5 changes: 5 additions & 0 deletions
5
core/analytics/src/main/java/com/sseotdabwa/buyornot/core/analytics/Analytics.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.sseotdabwa.buyornot.core.analytics | ||
|
|
||
| interface Analytics { | ||
| fun track(event: AnalyticsEvent) | ||
| } |
34 changes: 34 additions & 0 deletions
34
core/analytics/src/main/java/com/sseotdabwa/buyornot/core/analytics/AnalyticsEvent.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package com.sseotdabwa.buyornot.core.analytics | ||
|
|
||
| sealed class AnalyticsEvent { | ||
| data class FeedViewed( | ||
| val firstVisibleItemIndex: Int, | ||
| ) : AnalyticsEvent() | ||
|
|
||
| data class FeedExited( | ||
| val timeSpentSeconds: Float, | ||
| val lastVisibleItemIndex: Int, | ||
| ) : AnalyticsEvent() | ||
|
|
||
| data class VoteSubmitted( | ||
| val feedId: Long, | ||
| val voteChoice: String, | ||
| val feedCategory: String, | ||
| ) : AnalyticsEvent() | ||
|
|
||
| data class VoteCreateStarted( | ||
| val entrySource: String, | ||
| val isLoggedIn: Boolean, | ||
| ) : AnalyticsEvent() | ||
|
|
||
| data class VoteCreateCompleted( | ||
| val itemId: Long, | ||
| val voteTitle: String, | ||
| val optionCount: Int, | ||
| ) : AnalyticsEvent() | ||
|
|
||
| data class VoteCreateAbandoned( | ||
| val filledFields: List<String>, | ||
| val lastStep: String?, | ||
| ) : AnalyticsEvent() | ||
| } | ||
9 changes: 9 additions & 0 deletions
9
core/analytics/src/main/java/com/sseotdabwa/buyornot/core/analytics/DebugAnalytics.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.sseotdabwa.buyornot.core.analytics | ||
|
|
||
| import android.util.Log | ||
|
|
||
| class DebugAnalytics : Analytics { | ||
| override fun track(event: AnalyticsEvent) { | ||
| Log.d("Analytics", event.toString()) | ||
| } | ||
| } |
53 changes: 53 additions & 0 deletions
53
core/analytics/src/main/java/com/sseotdabwa/buyornot/core/analytics/MixpanelAnalytics.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package com.sseotdabwa.buyornot.core.analytics | ||
|
|
||
| import com.mixpanel.android.mpmetrics.MixpanelAPI | ||
| import org.json.JSONArray | ||
| import org.json.JSONObject | ||
|
|
||
| class MixpanelAnalytics( | ||
| private val mixpanel: MixpanelAPI, | ||
| ) : Analytics { | ||
| override fun track(event: AnalyticsEvent) { | ||
| val (name, props) = event.toMixpanel() | ||
| mixpanel.track(name, props) | ||
| } | ||
|
|
||
| private fun AnalyticsEvent.toMixpanel(): Pair<String, JSONObject> { | ||
| val props = JSONObject() | ||
| val name = | ||
| when (this) { | ||
| is AnalyticsEvent.FeedViewed -> { | ||
| props.put("first_visible_item_index", firstVisibleItemIndex) | ||
| "feed_viewed" | ||
| } | ||
| is AnalyticsEvent.FeedExited -> { | ||
| props.put("time_spent_seconds", timeSpentSeconds) | ||
| props.put("last_visible_item_index", lastVisibleItemIndex) | ||
| "feed_exited" | ||
| } | ||
| is AnalyticsEvent.VoteSubmitted -> { | ||
| props.put("feed_id", feedId) | ||
| props.put("vote_choice", voteChoice) | ||
| props.put("feed_category", feedCategory) | ||
| "vote_submitted" | ||
| } | ||
| is AnalyticsEvent.VoteCreateStarted -> { | ||
| props.put("entry_source", entrySource) | ||
| props.put("is_logged_in", isLoggedIn) | ||
| "vote_create_started" | ||
| } | ||
| is AnalyticsEvent.VoteCreateCompleted -> { | ||
| props.put("item_id", itemId) | ||
| props.put("vote_title", voteTitle) | ||
| props.put("option_count", optionCount) | ||
|
DongChyeon marked this conversation as resolved.
|
||
| "vote_create_completed" | ||
| } | ||
| is AnalyticsEvent.VoteCreateAbandoned -> { | ||
| props.put("filled_fields", JSONArray(filledFields)) | ||
| if (lastStep != null) props.put("last_step", lastStep) | ||
| "vote_create_abandoned" | ||
| } | ||
| } | ||
| return name to props | ||
| } | ||
| } | ||
35 changes: 35 additions & 0 deletions
35
core/analytics/src/main/java/com/sseotdabwa/buyornot/core/analytics/di/AnalyticsModule.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.sseotdabwa.buyornot.core.analytics.di | ||
|
|
||
| import android.content.Context | ||
| import com.mixpanel.android.mpmetrics.MixpanelAPI | ||
| import com.sseotdabwa.buyornot.core.analytics.Analytics | ||
| import com.sseotdabwa.buyornot.core.analytics.BuildConfig | ||
| import com.sseotdabwa.buyornot.core.analytics.DebugAnalytics | ||
| import com.sseotdabwa.buyornot.core.analytics.MixpanelAnalytics | ||
| import dagger.Module | ||
| import dagger.Provides | ||
| import dagger.hilt.InstallIn | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
| import dagger.hilt.components.SingletonComponent | ||
| import javax.inject.Singleton | ||
|
|
||
| @Module | ||
| @InstallIn(SingletonComponent::class) | ||
| object AnalyticsModule { | ||
| @Provides | ||
| @Singleton | ||
| fun provideAnalytics( | ||
| @ApplicationContext context: Context, | ||
| ): Analytics = | ||
| if (BuildConfig.DEBUG) { | ||
| DebugAnalytics() | ||
| } else { | ||
| val mixpanel = | ||
| MixpanelAPI.getInstance( | ||
| context, | ||
| BuildConfig.MIXPANEL_TOKEN, | ||
| true, | ||
| ) | ||
| MixpanelAnalytics(mixpanel) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.