Skip to content

Commit

Permalink
416 use legacy uniqueid after migration commanders act v4x to v5x (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ authored Jan 25, 2024
1 parent a15c479 commit 89ee9de
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ ktor = "2.3.7"
mockk = "1.13.9"
okhttp = "4.12.0"
srg-data-provider = "0.8.0"
tag-commander-core = "5.4.1"
tag-commander-server-side = "5.5.1"
tag-commander-core = "5.4.2"
tag-commander-server-side = "5.5.2"

[libraries]
accompanist-navigation-material = { module = "com.google.accompanist:accompanist-navigation-material", version.ref = "accompanist" }
Expand Down
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 89ee9de

Please sign in to comment.