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 2bbcbf884..dfd835d2f 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 @@ -9,6 +9,9 @@ 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 com.tagcommander.lib.core.TCUser +import com.tagcommander.lib.serverside.TCPredefinedVariables +import com.tagcommander.lib.serverside.schemas.TCDevice import org.junit.Assert import org.junit.Before import org.junit.Test @@ -48,4 +51,11 @@ class TestCommandersAct { commandersAct.setConsentServices(services) Assert.assertEquals(expected, commandersAct.getPermanentDataLabel(CommandersActLabels.CONSENT_SERVICES.label)) } + + @Test + fun testLegacyUniqueId() { + val legacyUniqueId: String = TCPredefinedVariables.getInstance().uniqueIdentifier + Assert.assertEquals(legacyUniqueId, TCDevice.getInstance().sdkID) + Assert.assertEquals(legacyUniqueId, TCUser.getInstance().anonymous_id) + } } 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 aca573720..04dcba52a 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 @@ -14,6 +14,7 @@ import com.tagcommander.lib.serverside.TCPredefinedVariables import com.tagcommander.lib.serverside.TCServerSide import com.tagcommander.lib.serverside.TCServerSideConstants import com.tagcommander.lib.serverside.events.base.TCEvent +import com.tagcommander.lib.serverside.schemas.TCDevice /** * CommandersAct for SRG SSR @@ -44,7 +45,9 @@ internal class CommandersActSrg( private val tcServerSide: TCServerSide init { - tcServerSide = TCServerSide(SITE_SRG, config.sourceKey, appContext) + tcServerSide = TCServerSide(SITE_SRG, config.sourceKey, appContext).also { + workaroundUniqueIdV4Tov5() + } TCDebug.setDebugLevel(if (BuildConfig.DEBUG) Log.DEBUG else Log.INFO) config.commandersActPersistentLabels?.let { @@ -117,6 +120,24 @@ internal class CommandersActSrg( } } + /* + * From issue : + * - https://github.com/SRGSSR/srgletterbox-android/issues/522 + * - https://github.com/CommandersAct/iOSV5/issues/13 + * + * And after discussion with CommandersAct teams and SRG ADI team. + */ + private fun workaroundUniqueIdV4Tov5() { + // 1. Use the TC unique id value for new `device.sdk_id` property. + useLegacyUniqueIDForSdkID() + // 2. Use the TC unique id value for the new `user.consistent_anonymous_id` property. + TCPredefinedVariables.getInstance().useLegacyUniqueIDForAnonymousID() + } + + private fun useLegacyUniqueIDForSdkID() { + TCDevice.getInstance().sdkID = TCPredefinedVariables.getInstance().uniqueIdentifier + } + companion object { private const val SITE_SRG = 3666