Create interface for the coming plan
This commit is contained in:
parent
f05ed4c6cc
commit
729d9ce815
|
@ -16,6 +16,8 @@
|
|||
|
||||
package im.vector.app.features.analytics
|
||||
|
||||
import im.vector.app.features.analytics.itf.VectorAnalyticsEvent
|
||||
import im.vector.app.features.analytics.itf.VectorAnalyticsScreen
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface VectorAnalytics {
|
||||
|
@ -62,10 +64,10 @@ interface VectorAnalytics {
|
|||
/**
|
||||
* Capture an Event
|
||||
*/
|
||||
fun capture(event: String, properties: Map<String, Any>? = null)
|
||||
fun capture(event: VectorAnalyticsEvent)
|
||||
|
||||
/**
|
||||
* Track a displayed screen
|
||||
*/
|
||||
fun screen(name: String, properties: Map<String, Any>? = null)
|
||||
fun screen(screen: VectorAnalyticsScreen)
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import im.vector.app.BuildConfig
|
|||
import im.vector.app.features.analytics.AnalyticsConfig
|
||||
import im.vector.app.features.analytics.VectorAnalytics
|
||||
import im.vector.app.features.analytics.log.analyticsTag
|
||||
import im.vector.app.features.analytics.itf.VectorAnalyticsEvent
|
||||
import im.vector.app.features.analytics.itf.VectorAnalyticsScreen
|
||||
import im.vector.app.features.analytics.store.AnalyticsStore
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
@ -152,18 +154,18 @@ class DefaultVectorAnalytics @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun capture(event: String, properties: Map<String, Any>?) {
|
||||
override fun capture(event: VectorAnalyticsEvent) {
|
||||
Timber.tag(analyticsTag.value).d("capture($event)")
|
||||
posthog
|
||||
?.takeIf { userConsent == true }
|
||||
?.capture(event, properties.toPostHogProperties())
|
||||
?.capture(event.getName(), event.getProperties()?.toPostHogProperties())
|
||||
}
|
||||
|
||||
override fun screen(name: String, properties: Map<String, Any>?) {
|
||||
Timber.tag(analyticsTag.value).d("screen($name)")
|
||||
override fun screen(screen: VectorAnalyticsScreen) {
|
||||
Timber.tag(analyticsTag.value).d("screen($screen)")
|
||||
posthog
|
||||
?.takeIf { userConsent == true }
|
||||
?.screen(name, properties.toPostHogProperties())
|
||||
?.screen(screen.getName(), screen.getProperties()?.toPostHogProperties())
|
||||
}
|
||||
|
||||
private fun Map<String, Any>?.toPostHogProperties(): Properties? {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.analytics.itf
|
||||
|
||||
interface VectorAnalyticsEvent {
|
||||
fun getName(): String
|
||||
fun getProperties(): Map<String, Any>?
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.analytics.itf
|
||||
|
||||
interface VectorAnalyticsScreen {
|
||||
fun getName(): String
|
||||
fun getProperties(): Map<String, Any>?
|
||||
}
|
Loading…
Reference in New Issue