-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT/#288] μ ν리νλ μ€μΉ
- Loading branch information
Showing
9 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
32 changes: 32 additions & 0 deletions
32
core/src/main/java/com/terning/core/analytics/AmplitudeTracker.kt
This file contains 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,32 @@ | ||
package com.terning.core.analytics | ||
|
||
import android.content.Context | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import com.amplitude.android.Amplitude | ||
import com.amplitude.android.Configuration | ||
import com.terning.core.BuildConfig | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
val LocalTracker = staticCompositionLocalOf<AmplitudeTracker> { | ||
error("No AmplitudeTracker provided") | ||
} | ||
|
||
class AmplitudeTracker @Inject constructor( | ||
@ApplicationContext private val context: Context | ||
) { | ||
private val amplitude = Amplitude( | ||
Configuration( | ||
apiKey = BuildConfig.AMPLITUDE_KEY, | ||
context = context | ||
) | ||
) | ||
|
||
fun track(type: EventType, name: String, properties: Map<String, Any?> = emptyMap()) { | ||
if (BuildConfig.DEBUG) { | ||
Timber.d("Amplitude: ${type.prefix}_$name properties: $properties") | ||
} | ||
amplitude.track(eventType = "${type.prefix}_$name", eventProperties = properties) | ||
} | ||
} |
This file contains 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,6 @@ | ||
package com.terning.core.analytics | ||
|
||
enum class EventType(val prefix: String) { | ||
VIEW("view"), | ||
CLICK("click") | ||
} |
This file contains 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 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