Skip to content

Commit

Permalink
Use legacy UniqueID
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ committed Jan 25, 2024
1 parent e3d2aad commit bbc17ad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit bbc17ad

Please sign in to comment.