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
class Event( | |
val name: String, | |
val params: MutableMap<String, Any>? = null | |
) |
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
interface EventsStreamProvider { | |
val eventStream: PublishSubject<Event> | |
} |
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
class Analytics: EventsStreamProvider { | |
override var eventStream = PublishSubject.create<Event>() | |
fun trackEvent(e: Event) { | |
eventStream.onNext(e) | |
} | |
} |
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
class FirebaseEvent( | |
val name: String, | |
val params: Bundle? = null | |
) |
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
class FirebaseMapper: Mapper<Event, FirebaseEvent> { | |
override fun mapFrom(e: Event): FirebaseEvent { | |
val firebaseEvent = FirebaseEvent(e.name) | |
e.params?.let { | |
val bundle = Bundle() | |
for (param in it) { | |
bundle.putString(param.key, param.value as String) |
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
interface Mapper<in E, out C> { | |
fun mapFrom(event: E): C | |
} |
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
class FirebaseTracker @Inject constructor( | |
private val context: Context, | |
private val eventsStreamProvider: EventsStreamProvider, | |
private val mapper: FirebaseMapper | |
) { | |
private val compositeDisposable = CompositeDisposable() | |
init { | |
subscribeToEvents() |
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
class FirstPageEvents { | |
companion object { | |
private const val FIRST_PAGE_BUTTON_A = "first_page_button_a" | |
private const val FIRST_PAGE_BUTTON_B = "first_page_button_b" | |
fun onFirstButtonClicked() = Event(FIRST_PAGE_BUTTON_A) | |
fun onSecondButtonClicked() = Event(FIRST_PAGE_BUTTON_B) | |
} | |
} |
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
class FirstPageActivity : AppCompatActivity() { | |
@Inject | |
lateinit var analytics: Analytics | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
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
class FirstPageActivity : AppCompatActivity() { | |
@Inject | |
lateinit var analytics: Analytics | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
(applicationContext.applicationContext as App) |
OlderNewer