Skip to content

Commit ec840e5

Browse files
committed
[MOD/#386] ReviewTrackingModel 생성
1 parent 3842fbc commit ec840e5

6 files changed

Lines changed: 226 additions & 287 deletions

File tree

app/src/main/java/com/spoony/spoony/core/analytics/MixPanelTracker.kt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.content.Context
44
import com.mixpanel.android.mpmetrics.MixpanelAPI
55
import com.spoony.spoony.BuildConfig.MIXPANEL_KEY
66
import dagger.hilt.android.qualifiers.ApplicationContext
7-
import javax.inject.Inject
7+
import jakarta.inject.Inject
88
import org.json.JSONObject
99
import timber.log.Timber
1010

@@ -33,22 +33,8 @@ class MixPanelTracker @Inject constructor(
3333
mixpanel.track(eventName)
3434
}
3535

36-
fun track(eventName: String, properties: String) {
37-
Timber.tag("mixpanel").d("$eventName $properties")
38-
mixpanel.track(eventName, properties.toJsonObject())
39-
}
40-
4136
fun track(eventName: String, properties: JSONObject) {
4237
Timber.tag("mixpanel").d("$eventName $properties")
4338
mixpanel.track(eventName, properties)
4439
}
45-
46-
private fun String.toJsonObject(): JSONObject {
47-
return try {
48-
JSONObject(this)
49-
} catch (e: Exception) {
50-
Timber.e(e)
51-
JSONObject()
52-
}
53-
}
5440
}

app/src/main/java/com/spoony/spoony/core/analytics/events/CommonEvents.kt

Lines changed: 45 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.spoony.spoony.core.analytics.events
22

33
import com.spoony.spoony.core.analytics.MixPanelTracker
4+
import com.spoony.spoony.core.analytics.model.ReviewTrackingModel
45
import jakarta.inject.Inject
56
import org.json.JSONArray
67
import org.json.JSONObject
@@ -18,34 +19,24 @@ class CommonEvents @Inject constructor(
1819
}
1920

2021
fun reviewViewed(
21-
reviewId: Int,
22-
authorUserId: Int,
23-
placeName: String,
24-
category: String,
25-
menuCount: Int,
26-
satisfactionScore: Double,
27-
reviewLength: Int,
28-
photoCount: Int,
29-
hasDisappointment: Boolean,
30-
savedCount: Int,
22+
reviewTrackingModel: ReviewTrackingModel,
3123
isSelfReview: Boolean,
3224
isFollowedUserReview: Boolean,
3325
isSavedReview: Boolean
34-
// entryPoint: String
3526
) {
3627
tracker.track(
3728
eventName = "review_viewed",
3829
properties = JSONObject().apply {
39-
put("review_id", reviewId)
40-
put("author_user_id", authorUserId)
41-
put("place_name", placeName)
42-
put("category", category)
43-
put("menu_count", menuCount)
44-
put("satisfaction_score", satisfactionScore)
45-
put("review_length", reviewLength)
46-
put("photo_count", photoCount)
47-
put("has_disappointment", hasDisappointment)
48-
put("saved_count", savedCount)
30+
put("review_id", reviewTrackingModel.reviewId)
31+
put("author_user_id", reviewTrackingModel.authorUserId)
32+
put("place_name", reviewTrackingModel.placeName)
33+
put("category", reviewTrackingModel.category)
34+
put("menu_count", reviewTrackingModel.menuCount)
35+
put("satisfaction_score", reviewTrackingModel.satisfactionScore)
36+
put("review_length", reviewTrackingModel.reviewLength)
37+
put("photo_count", reviewTrackingModel.photoCount)
38+
put("has_disappointment", reviewTrackingModel.hasDisappointment)
39+
put("saved_count", reviewTrackingModel.savedCount)
4940
put("is_self_review", isSelfReview)
5041
put("is_followed_user_review", isFollowedUserReview)
5142
put("is_saved_review", isSavedReview)
@@ -54,31 +45,21 @@ class CommonEvents @Inject constructor(
5445
}
5546

5647
fun reviewEdited(
57-
reviewId: Int,
58-
authorUserId: Int,
59-
placeName: String,
60-
category: String,
61-
menuCount: Int,
62-
satisfactionScore: Float,
63-
reviewLength: Int,
64-
photoCount: Int,
65-
hasDisappointment: Boolean,
66-
savedCount: Int
67-
// entryPoint: String
48+
reviewTrackingModel: ReviewTrackingModel
6849
) {
6950
tracker.track(
7051
eventName = "review_edited",
7152
properties = JSONObject().apply {
72-
put("review_id", reviewId)
73-
put("author_user_id", authorUserId)
74-
put("place_name", placeName)
75-
put("category", category)
76-
put("menu_count", menuCount)
77-
put("satisfaction_score", satisfactionScore)
78-
put("review_length", reviewLength)
79-
put("photo_count", photoCount)
80-
put("has_disappointment", hasDisappointment)
81-
put("saved_count", savedCount)
53+
put("review_id", reviewTrackingModel.reviewId)
54+
put("author_user_id", reviewTrackingModel.authorUserId)
55+
put("place_name", reviewTrackingModel.placeName)
56+
put("category", reviewTrackingModel.category)
57+
put("menu_count", reviewTrackingModel.menuCount)
58+
put("satisfaction_score", reviewTrackingModel.satisfactionScore)
59+
put("review_length", reviewTrackingModel.reviewLength)
60+
put("photo_count", reviewTrackingModel.photoCount)
61+
put("has_disappointment", reviewTrackingModel.hasDisappointment)
62+
put("saved_count", reviewTrackingModel.savedCount)
8263
}
8364
)
8465
}
@@ -126,60 +107,42 @@ class CommonEvents @Inject constructor(
126107
}
127108

128109
fun followUserFromReview(
129-
reviewId: Int,
130-
authorUserId: Int,
131-
placeName: String,
132-
category: String,
133-
menuCount: Int,
134-
satisfactionScore: Double,
135-
reviewLength: Int,
136-
photoCount: Int,
137-
hasDisappointment: Boolean,
138-
savedCount: Int
110+
reviewTrackingModel: ReviewTrackingModel
139111
) {
140112
tracker.track(
141113
eventName = "follow_user_from_review",
142114
properties = JSONObject().apply {
143-
put("review_id", reviewId)
144-
put("author_user_id", authorUserId)
145-
put("place_name", placeName)
146-
put("category", category)
147-
put("menu_count", menuCount)
148-
put("satisfaction_score", satisfactionScore)
149-
put("review_length", reviewLength)
150-
put("photo_count", photoCount)
151-
put("has_disappointment", hasDisappointment)
152-
put("saved_count", savedCount)
115+
put("review_id", reviewTrackingModel.reviewId)
116+
put("author_user_id", reviewTrackingModel.authorUserId)
117+
put("place_name", reviewTrackingModel.placeName)
118+
put("category", reviewTrackingModel.category)
119+
put("menu_count", reviewTrackingModel.menuCount)
120+
put("satisfaction_score", reviewTrackingModel.satisfactionScore)
121+
put("review_length", reviewTrackingModel.reviewLength)
122+
put("photo_count", reviewTrackingModel.photoCount)
123+
put("has_disappointment", reviewTrackingModel.hasDisappointment)
124+
put("saved_count", reviewTrackingModel.savedCount)
153125
put("entry_point", "review")
154126
}
155127
)
156128
}
157129

158130
fun unfollowUserFromReview(
159-
reviewId: Int,
160-
authorUserId: Int,
161-
placeName: String,
162-
category: String,
163-
menuCount: Int,
164-
satisfactionScore: Double,
165-
reviewLength: Int,
166-
photoCount: Int,
167-
hasDisappointment: Boolean,
168-
savedCount: Int
131+
reviewTrackingModel: ReviewTrackingModel
169132
) {
170133
tracker.track(
171134
eventName = "unfollow_user_from_review",
172135
properties = JSONObject().apply {
173-
put("review_id", reviewId)
174-
put("author_user_id", authorUserId)
175-
put("place_name", placeName)
176-
put("category", category)
177-
put("menu_count", menuCount)
178-
put("satisfaction_score", satisfactionScore)
179-
put("review_length", reviewLength)
180-
put("photo_count", photoCount)
181-
put("has_disappointment", hasDisappointment)
182-
put("saved_count", savedCount)
136+
put("review_id", reviewTrackingModel.reviewId)
137+
put("author_user_id", reviewTrackingModel.authorUserId)
138+
put("place_name", reviewTrackingModel.placeName)
139+
put("category", reviewTrackingModel.category)
140+
put("menu_count", reviewTrackingModel.menuCount)
141+
put("satisfaction_score", reviewTrackingModel.satisfactionScore)
142+
put("review_length", reviewTrackingModel.reviewLength)
143+
put("photo_count", reviewTrackingModel.photoCount)
144+
put("has_disappointment", reviewTrackingModel.hasDisappointment)
145+
put("saved_count", reviewTrackingModel.savedCount)
183146
put("entry_point", "review")
184147
}
185148
)

0 commit comments

Comments
 (0)