From 231873f6ab3f5db8c06036287392608854274dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaquim=20St=C3=A4hli?= Date: Mon, 11 Sep 2023 14:39:48 +0200 Subject: [PATCH] 233 add user consent (#235) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Samuel Défago --- .../pillarbox/analytics/TestComScoreSrg.kt | 25 ++++++ .../pillarbox/analytics/TestCommandersAct.kt | 9 ++ .../pillarbox/analytics/AnalyticsConfig.kt | 14 ++- .../pillarbox/analytics/SRGAnalytics.kt | 90 +++++++++++++++++++ .../srgssr/pillarbox/analytics/UserConsent.kt | 18 ++++ .../analytics/commandersact/CommandersAct.kt | 29 ++++++ .../commandersact/CommandersActLabels.kt | 3 + .../commandersact/CommandersActSrg.kt | 23 +++++ .../pillarbox/analytics/comscore/ComScore.kt | 29 ++++++ .../analytics/comscore/ComScoreLabel.kt | 1 + .../analytics/comscore/ComScoreSrg.kt | 39 ++++++++ .../analytics/comscore/ComScoreUserConsent.kt | 32 +++++++ .../analytics/TestSRGAnalyticsPageViews.kt | 35 ++++++++ .../core/business/CommandersActTrackerTest.kt | 19 +++- .../srgssr/pillarbox/demo/DemoApplication.kt | 10 ++- 15 files changed, 370 insertions(+), 6 deletions(-) create mode 100644 pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/UserConsent.kt create mode 100644 pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreUserConsent.kt diff --git a/pillarbox-analytics/src/androidTest/java/ch/srgssr/pillarbox/analytics/TestComScoreSrg.kt b/pillarbox-analytics/src/androidTest/java/ch/srgssr/pillarbox/analytics/TestComScoreSrg.kt index 3ffcfb050..c0dfb1db4 100644 --- a/pillarbox-analytics/src/androidTest/java/ch/srgssr/pillarbox/analytics/TestComScoreSrg.kt +++ b/pillarbox-analytics/src/androidTest/java/ch/srgssr/pillarbox/analytics/TestComScoreSrg.kt @@ -8,6 +8,7 @@ import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import ch.srgssr.pillarbox.analytics.comscore.ComScoreLabel import ch.srgssr.pillarbox.analytics.comscore.ComScorePageView import ch.srgssr.pillarbox.analytics.comscore.ComScoreSrg +import ch.srgssr.pillarbox.analytics.comscore.ComScoreUserConsent import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableSharedFlow @@ -67,6 +68,30 @@ class TestComScoreSrg { job.cancel() } + @Test + fun testUserConsentGiven() { + val userConsent = ComScoreUserConsent.ACCEPTED + val expectedLabel = "1" + comScore.setUserConsent(userConsent) + Assert.assertEquals(expectedLabel, comScore.getPersistentLabel(ComScoreLabel.CS_UC_FR.label)) + } + + @Test + fun testUserConsentNotGiven() { + val userConsent = ComScoreUserConsent.DECLINED + val expectedLabel = "0" + comScore.setUserConsent(userConsent) + Assert.assertEquals(expectedLabel, comScore.getPersistentLabel(ComScoreLabel.CS_UC_FR.label)) + } + + @Test + fun testUserConsentUnknown() { + val userConsent = ComScoreUserConsent.UNKNOWN + val expectedLabel = "" + comScore.setUserConsent(userConsent) + Assert.assertEquals(expectedLabel, comScore.getPersistentLabel(ComScoreLabel.CS_UC_FR.label)) + } + private class PageViewTracking : ComScoreSrg.DebugListener { val pageViewFlow = MutableSharedFlow>(extraBufferCapacity = 1, replay = 1) diff --git a/pillarbox-analytics/src/androidTest/java/ch/srgssr/pillarbox/analytics/TestCommandersAct.kt b/pillarbox-analytics/src/androidTest/java/ch/srgssr/pillarbox/analytics/TestCommandersAct.kt index 101e49681..4c5debc38 100644 --- a/pillarbox-analytics/src/androidTest/java/ch/srgssr/pillarbox/analytics/TestCommandersAct.kt +++ b/pillarbox-analytics/src/androidTest/java/ch/srgssr/pillarbox/analytics/TestCommandersAct.kt @@ -6,6 +6,7 @@ package ch.srgssr.pillarbox.analytics import androidx.test.platform.app.InstrumentationRegistry import ch.srgssr.pillarbox.analytics.commandersact.CommandersActEvent +import ch.srgssr.pillarbox.analytics.commandersact.CommandersActLabels import ch.srgssr.pillarbox.analytics.commandersact.CommandersActPageView import ch.srgssr.pillarbox.analytics.commandersact.CommandersActSrg import org.junit.Assert @@ -39,4 +40,12 @@ class TestCommandersAct { ) Assert.assertTrue(true) } + + @Test + fun testConsentServices() { + val services = listOf("service1", "service2") + val expected = "service1,service2" + commandersAct.setConsentServices(services) + Assert.assertEquals(expected, commandersAct.getPermanentDataLabel(CommandersActLabels.CONSENT_SERVICES.label)) + } } diff --git a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/AnalyticsConfig.kt b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/AnalyticsConfig.kt index 6f51b20f4..7993c6f8d 100644 --- a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/AnalyticsConfig.kt +++ b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/AnalyticsConfig.kt @@ -8,16 +8,22 @@ package ch.srgssr.pillarbox.analytics * SRG Analytics config * * @property vendor business unit. - * @property nonLocalizedApplicationName Application name for the analytics, by default the application name defined in the manifest. You can set - * it to null if the application name is not localized. * @property appSiteName The App/Site name given by the analytics team. * @property sourceKey The CommandersAct sourceKey given by the analytics team. + * @property nonLocalizedApplicationName Application name for the analytics, by default the application name defined in the manifest. You can set + * it to null if the application name is not localized. + * @property userConsent User consent to transmit to ComScore and CommandersAct. + * @property comScorePersistentLabels initial ComScore persistent labels. + * @property commandersActPersistentLabels initial CommandersAct persistent labels. */ data class AnalyticsConfig( val vendor: Vendor, - val nonLocalizedApplicationName: String? = null, val appSiteName: String, - val sourceKey: String + val sourceKey: String, + val nonLocalizedApplicationName: String? = null, + val userConsent: UserConsent = UserConsent(), + val comScorePersistentLabels: Map? = null, + val commandersActPersistentLabels: Map? = null, ) { /** diff --git a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/SRGAnalytics.kt b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/SRGAnalytics.kt index 35eeb0eb6..3561f3411 100644 --- a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/SRGAnalytics.kt +++ b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/SRGAnalytics.kt @@ -92,6 +92,70 @@ object SRGAnalytics { instance?.sendEvent(event) } + /** + * Put persistent labels + * + * @param commandersActLabels CommandersAct specific persistent label. + * @param comScoreLabels ComScore specific persistent label. + */ + fun putPersistentLabels( + commandersActLabels: Map, + comScoreLabels: Map + ) { + instance?.putPersistentLabels(commandersActLabels = commandersActLabels, comScoreLabels = comScoreLabels) + } + + /** + * Remove persistent label for CommandersAct and/or ComScore. + * + * @param label The label to remove. + */ + fun removePersistentLabel(label: String) { + instance?.removePersistentLabel(label) + } + + /** + * Remove multiple persistent labels. + * + * @param labels List of labels to remove. + */ + fun removePersistentLabels(labels: List) { + instance?.let { analytics -> + for (label in labels) { + analytics.removePersistentLabel(label) + } + } + } + + /** + * Get ComScore persistent label + * + * @param label The label to get. + * @return associated ComScore label or null if not found. + */ + fun getComScorePersistentLabel(label: String): String? { + return instance?.getComScorePersistentLabel(label) + } + + /** + * Get CommandersAct persistent label + * + * @param label The label to get. + * @return associated CommandersAct label or null if not found. + */ + fun getCommandersActPersistentLabel(label: String): String? { + return instance?.getCommandersActPermanentData(label) + } + + /** + * Set user consent + * + * @param userConsent The user consent to apply. + */ + fun setUserConsent(userConsent: UserConsent) { + instance?.setUserConsent(userConsent) + } + /** * Init SRGAnalytics * @@ -115,5 +179,31 @@ object SRGAnalytics { this.commandersAct.sendEvent(commandersAct) // Business decision to not send those event to comScore. } + + fun putPersistentLabels( + commandersActLabels: Map, + comScoreLabels: Map + ) { + comScore.putPersistentLabels(comScoreLabels) + commandersAct.putPermanentData(commandersActLabels) + } + + fun removePersistentLabel(label: String) { + comScore.removePersistentLabel(label) + commandersAct.removePermanentData(label) + } + + fun getComScorePersistentLabel(label: String): String? { + return comScore.getPersistentLabel(label) + } + + fun getCommandersActPermanentData(label: String): String? { + return commandersAct.getPermanentDataLabel(label) + } + + fun setUserConsent(userConsent: UserConsent) { + comScore.setUserConsent(userConsent.comScore) + commandersAct.setConsentServices(userConsent.commandersActConsentServices) + } } } diff --git a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/UserConsent.kt b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/UserConsent.kt new file mode 100644 index 000000000..c17109dbc --- /dev/null +++ b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/UserConsent.kt @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023. SRG SSR. All rights reserved. + * License information is available from the LICENSE file. + */ +package ch.srgssr.pillarbox.analytics + +import ch.srgssr.pillarbox.analytics.comscore.ComScoreUserConsent + +/** + * User consent + * + * @property comScore ComScore user consent. + * @property commandersActConsentServices CommandersAct consent services list. + */ +data class UserConsent( + val comScore: ComScoreUserConsent = ComScoreUserConsent.UNKNOWN, + val commandersActConsentServices: List = emptyList() +) diff --git a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersAct.kt b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersAct.kt index 51a7b5e67..fad119868 100644 --- a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersAct.kt +++ b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersAct.kt @@ -33,4 +33,33 @@ interface CommandersAct { * Enable running in background */ fun enableRunningInBackground() {} + + /** + * Put permanent data + * + * @param labels The values to put. + */ + fun putPermanentData(labels: Map) + + /** + * Remove permanent data + * + * @param label The label to remove. + */ + fun removePermanentData(label: String) + + /** + * Get permanent label + * + * @param label The label to get. + * @return null if not found. + */ + fun getPermanentDataLabel(label: String): String? + + /** + * Set consent services + * + * @param consentServices The list of consent services by the user. + */ + fun setConsentServices(consentServices: List) } diff --git a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersActLabels.kt b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersActLabels.kt index f0beffa4c..7139f46e1 100644 --- a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersActLabels.kt +++ b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersActLabels.kt @@ -23,4 +23,7 @@ enum class CommandersActLabels(val label: String) { // Page View NAVIGATION_LEVEL_I("navigation_level_"), NAVIGATION_BU_DISTRIBUTER("navigation_bu_distributer"), + + // User consent + CONSENT_SERVICES("consent_services") } diff --git a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersActSrg.kt b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersActSrg.kt index d866a0da2..d37f81c58 100644 --- a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersActSrg.kt +++ b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/commandersact/CommandersActSrg.kt @@ -47,6 +47,10 @@ internal class CommandersActSrg( tcServerSide = TCServerSide(SITE_SRG, config.sourceKey, appContext) TCDebug.setDebugLevel(if (BuildConfig.DEBUG) Log.DEBUG else Log.INFO) + config.commandersActPersistentLabels?.let { + putPermanentData(it) + } + // Data send with all events that never change tcServerSide.addPermanentData(APP_LIBRARY_VERSION, "${BuildConfig.VERSION_NAME} ${BuildConfig.BUILD_DATE}") tcServerSide.addPermanentData(NAVIGATION_APP_SITE_NAME, config.appSiteName) @@ -84,6 +88,25 @@ internal class CommandersActSrg( tcServerSide.enableRunningInBackground() } + override fun putPermanentData(labels: Map) { + if (labels == null) return + for (entry in labels.entries) { + tcServerSide.addPermanentData(entry.key, entry.value) + } + } + + override fun removePermanentData(label: String) { + tcServerSide.removePermanentData(label) + } + + override fun getPermanentDataLabel(label: String): String? { + return tcServerSide.getPermanentData(label) + } + + override fun setConsentServices(consentServices: List) { + tcServerSide.addPermanentData(CommandersActLabels.CONSENT_SERVICES.label, consentServices.joinToString(",")) + } + /** * Override application name if [AnalyticsConfig.nonLocalizedApplicationName] is not empty. * Useful for application that localized their application name and want to have same name for analytics. diff --git a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScore.kt b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScore.kt index 99f3c0c79..a1b2d568d 100644 --- a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScore.kt +++ b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScore.kt @@ -15,4 +15,33 @@ interface ComScore { * @param pageView The [ComScorePageView] to send. */ fun sendPageView(pageView: ComScorePageView) + + /** + * Put persistent labels + * + * @param labels The values to put. + */ + fun putPersistentLabels(labels: Map) + + /** + * Remove persistent label + * + * @param label The label to remove. + */ + fun removePersistentLabel(label: String) + + /** + * Get persistent label + * + * @param label The label to get. + * @return null if not found. + */ + fun getPersistentLabel(label: String): String? + + /** + * Set user consent + * + * @param userConsent + */ + fun setUserConsent(userConsent: ComScoreUserConsent) } diff --git a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreLabel.kt b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreLabel.kt index d001949b8..24c20ba55 100644 --- a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreLabel.kt +++ b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreLabel.kt @@ -8,4 +8,5 @@ internal enum class ComScoreLabel(val label: String) { C8("c8"), MP_BRAND("mp_brand"), MP_V("mp_v"), + CS_UC_FR("cs_ucfr") } diff --git a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreSrg.kt b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreSrg.kt index bc6eed7be..b9d41e051 100644 --- a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreSrg.kt +++ b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreSrg.kt @@ -53,7 +53,15 @@ internal object ComScoreSrg : ComScore { return this } this.config = config + val persistentLabels = HashMap() + config.comScorePersistentLabels?.let { labels -> + persistentLabels.putAll(labels) + } + + val userConsentLabel = getUserConsentPair(config.userConsent.comScore) + persistentLabels[userConsentLabel.first] = userConsentLabel.second + val versionName: String = try { // When unit testing from library packageInfo.versionName is null! context.applicationContext.packageManager.getPackageInfo(context.applicationContext.packageName, 0).versionName @@ -102,6 +110,37 @@ internal object ComScoreSrg : ComScore { } } + override fun putPersistentLabels(labels: Map) { + val configuration = Analytics.getConfiguration().getPublisherConfiguration(publisherId) + configuration.addPersistentLabels(labels) + } + + override fun removePersistentLabel(label: String) { + val configuration = Analytics.getConfiguration().getPublisherConfiguration(publisherId) + configuration.removePersistentLabel(label) + } + + override fun getPersistentLabel(label: String): String? { + val configuration = Analytics.getConfiguration().getPublisherConfiguration(publisherId) + return configuration.getPersistentLabel(label) + } + + override fun setUserConsent(userConsent: ComScoreUserConsent) { + putPersistentLabels(mapOf(getUserConsentPair(userConsent))) + } + + /** + * Values from ComScore documentation section 2.5.2 + */ + private fun getUserConsentPair(userConsent: ComScoreUserConsent): Pair { + val value = when (userConsent) { + ComScoreUserConsent.ACCEPTED -> "1" + ComScoreUserConsent.DECLINED -> "0" + ComScoreUserConsent.UNKNOWN -> "" + } + return Pair(ComScoreLabel.CS_UC_FR.label, value) + } + private fun checkInitialized() { requireNotNull(config) { "ComScore init has to be called before start." } } diff --git a/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreUserConsent.kt b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreUserConsent.kt new file mode 100644 index 000000000..111485a4b --- /dev/null +++ b/pillarbox-analytics/src/main/java/ch/srgssr/pillarbox/analytics/comscore/ComScoreUserConsent.kt @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023. SRG SSR. All rights reserved. + * License information is available from the LICENSE file. + */ +package ch.srgssr.pillarbox.analytics.comscore + +/** + * Com score user consent + */ +enum class ComScoreUserConsent { + /** + * Unknown + * + * User has not taken an action. + */ + UNKNOWN, + + /** + * Accepted + * + * User has given consent. + */ + ACCEPTED, + + /** + * Declined + * + * User has not given consent or has opted out. + */ + DECLINED, + ; +} diff --git a/pillarbox-analytics/src/test/java/ch/srgssr/pillarbox/analytics/TestSRGAnalyticsPageViews.kt b/pillarbox-analytics/src/test/java/ch/srgssr/pillarbox/analytics/TestSRGAnalyticsPageViews.kt index dde26fca1..89900a348 100644 --- a/pillarbox-analytics/src/test/java/ch/srgssr/pillarbox/analytics/TestSRGAnalyticsPageViews.kt +++ b/pillarbox-analytics/src/test/java/ch/srgssr/pillarbox/analytics/TestSRGAnalyticsPageViews.kt @@ -10,6 +10,7 @@ import ch.srgssr.pillarbox.analytics.commandersact.CommandersActPageView import ch.srgssr.pillarbox.analytics.commandersact.TCMediaEvent import ch.srgssr.pillarbox.analytics.comscore.ComScore import ch.srgssr.pillarbox.analytics.comscore.ComScorePageView +import ch.srgssr.pillarbox.analytics.comscore.ComScoreUserConsent import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableSharedFlow @@ -70,6 +71,23 @@ class TestSRGAnalyticsPageViews { override fun sendPageView(pageView: ComScorePageView) { Assert.assertTrue(pageViewFlow.tryEmit(pageView)) } + + override fun putPersistentLabels(labels: Map) { + // Nothing + } + + override fun removePersistentLabel(label: String) { + // Nothing + } + + override fun getPersistentLabel(label: String): String? { + // Nothing + return null + } + + override fun setUserConsent(userConsent: ComScoreUserConsent) { + // Nothing + } } private class DummyCommandersAct : CommandersAct { @@ -87,5 +105,22 @@ class TestSRGAnalyticsPageViews { } + override fun putPermanentData(labels: Map) { + // Nothing + } + + override fun removePermanentData(label: String) { + // Nothing + } + + override fun getPermanentDataLabel(label: String): String? { + // Nothing + return null + } + + override fun setConsentServices(consentServices: List) { + // Nothing + } + } } diff --git a/pillarbox-core-business/src/androidTest/java/ch/srgssr/pillarbox/core/business/CommandersActTrackerTest.kt b/pillarbox-core-business/src/androidTest/java/ch/srgssr/pillarbox/core/business/CommandersActTrackerTest.kt index b2b7cf6af..a7d137b8a 100644 --- a/pillarbox-core-business/src/androidTest/java/ch/srgssr/pillarbox/core/business/CommandersActTrackerTest.kt +++ b/pillarbox-core-business/src/androidTest/java/ch/srgssr/pillarbox/core/business/CommandersActTrackerTest.kt @@ -148,7 +148,7 @@ class CommandersActTrackerTest { @FlakyTest(detail = "POS and UPTIME not always send due to timers") @Test - fun testPosTime() =runTest(timeout = TEST_TIMEOUT) { + fun testPosTime() = runTest(timeout = TEST_TIMEOUT) { val expected = listOf( MediaEventType.Pos.toString(), MediaEventType.Pos.toString(), @@ -272,10 +272,27 @@ class CommandersActTrackerTest { events.add(Event(name = event.name, position = position, timeshift = timeshift)) } + override fun putPermanentData(labels: Map) { + // Nothing + } + + override fun removePermanentData(label: String) { + // Nothing + } + + override fun getPermanentDataLabel(label: String): String? { + // Nothing + return null + } + override fun sendPageView(pageView: CommandersActPageView) { // Ignored } + override fun setConsentServices(consentServices: List) { + // Nothing + } + override fun sendEvent(event: ch.srgssr.pillarbox.analytics.commandersact.CommandersActEvent) { // Ignored } diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/DemoApplication.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/DemoApplication.kt index 487f616e1..b650de040 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/DemoApplication.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/DemoApplication.kt @@ -7,6 +7,8 @@ package ch.srgssr.pillarbox.demo import android.app.Application import ch.srgssr.pillarbox.analytics.AnalyticsConfig import ch.srgssr.pillarbox.analytics.SRGAnalytics.initSRGAnalytics +import ch.srgssr.pillarbox.analytics.UserConsent +import ch.srgssr.pillarbox.analytics.comscore.ComScoreUserConsent /** * Demo application @@ -16,11 +18,17 @@ class DemoApplication : Application() { override fun onCreate() { super.onCreate() + // Defaults values + val initialUserConsent = UserConsent( + comScore = ComScoreUserConsent.UNKNOWN, + commandersActConsentServices = emptyList() + ) val config = AnalyticsConfig( vendor = AnalyticsConfig.Vendor.SRG, nonLocalizedApplicationName = "Pillarbox", appSiteName = "pillarbox-demo-android", - sourceKey = AnalyticsConfig.SOURCE_KEY_SRG_DEBUG + sourceKey = AnalyticsConfig.SOURCE_KEY_SRG_DEBUG, + userConsent = initialUserConsent ) initSRGAnalytics(config = config) }