Skip to content

Commit

Permalink
[#1009] AmplitudeTracker 추상화 및 패키지 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
l2hyunwoo committed Dec 31, 2024
1 parent d719334 commit 53f6f2c
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.official.R
import org.sopt.official.analytics.AmplitudeTracker
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.auth.model.UserActiveState
import org.sopt.official.auth.model.UserStatus
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.sopt.official.analytics

interface Tracker {
fun track(type: EventType, name: String, properties: Map<String, Any?> = emptyMap())
fun setNotificationStateToUserProperties(value: Boolean)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.sopt.official.analytics

interface TrackerModule {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.sopt.official.analytics

annotation class TrackerType()
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.sopt.official.analytics
package org.sopt.official.analytics.impl

import android.content.Context
import com.amplitude.android.Amplitude
import com.amplitude.android.Configuration
import com.amplitude.android.events.Identify
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import org.sopt.official.analytics.BuildConfig
import org.sopt.official.analytics.EventType
import org.sopt.official.analytics.Tracker
import timber.log.Timber
import javax.inject.Inject

class AmplitudeTracker @Inject constructor(
@ApplicationContext private val context: Context
) {
) : Tracker {
private val amplitude = Amplitude(
Configuration(
apiKey = if (BuildConfig.DEBUG) {
Expand All @@ -46,14 +49,14 @@ class AmplitudeTracker @Inject constructor(
)
)

fun track(type: EventType, name: String, properties: Map<String, Any?> = emptyMap()) {
override fun track(type: EventType, name: String, properties: Map<String, Any?>) {
if (BuildConfig.DEBUG) {
Timber.d("Amplitude: ${type.prefix}_$name properties: $properties")
}
amplitude.track(eventType = "${type.prefix}_$name", eventProperties = properties)
}

fun setNotificationStateToUserProperties(value: Boolean) {
override fun setNotificationStateToUserProperties(value: Boolean) {
val identify = Identify()
identify.setOnce("state_of_push_notification", value)
amplitude.identify(identify)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import androidx.compose.runtime.staticCompositionLocalOf
import com.airbnb.deeplinkdispatch.DeepLink
import dagger.hilt.android.AndroidEntryPoint
import dagger.hilt.android.EntryPointAccessors
import org.sopt.official.analytics.AmplitudeTracker
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.common.context.appContext
import org.sopt.official.common.navigator.NavigatorEntryPoint
import org.sopt.official.designsystem.SoptTheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.official.analytics.AmplitudeTracker
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.common.util.colorOf
import org.sopt.official.common.util.dp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.official.analytics.AmplitudeTracker
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.auth.model.UserStatus
import org.sopt.official.common.util.colorOf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.official.analytics.AmplitudeTracker
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.auth.model.UserStatus
import org.sopt.official.common.util.serializableExtra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.official.analytics.AmplitudeTracker
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.common.util.serializableExtra
import org.sopt.official.common.util.viewBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import java.io.Serializable
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.official.analytics.AmplitudeTracker
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.common.util.serializableExtra
import org.sopt.official.common.util.viewBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.official.analytics.AmplitudeTracker
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.common.util.serializableArgs
import org.sopt.official.domain.poke.entity.PokeRandomUserList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import androidx.core.view.WindowCompat
import com.ramcosta.composedestinations.DestinationsNavHost
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import org.sopt.official.analytics.AmplitudeTracker
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.stamp.feature.NavGraphs

val LocalTracker = staticCompositionLocalOf<AmplitudeTracker> {
Expand Down

0 comments on commit 53f6f2c

Please sign in to comment.