Skip to content

Commit c746ea8

Browse files
authored
Upgrade to Prebid 3 (#129)
Upgrade to Prebid 3, which includes some [breaking changes](https://docs.prebid.org/prebid-mobile/updates-3.0/android/api-changes.html) in how external IDs (the UID2) are set. Agent type (`aType`) is now a required parameter. use the value `3` which matches the UID2 iOS implementation, and indicates ["A person-based ID, i.e., that is the same across devices."](https://github.com/InteractiveAdvertisingBureau/AdCOM/blob/main/AdCOM%20v1.0%20FINAL.md#list_agenttypes).
1 parent 49483e5 commit c746ea8

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

dev-app/src/main/java/com/uid2/dev/DevApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DevApplication : Application() {
3838
// UID2Manager.init(this, INTEG_SERVER_URL, OkNetworkSession(), true)
3939

4040
// Create the Prebid integration and allow it to start observing the UID2Manager instance.
41-
PrebidMobile.initializeSdk(this) { Log.i(TAG, "Prebid: $it") }
41+
PrebidMobile.initializeSdk(this, "") { Log.i(TAG, "Prebid: $it") }
4242
prebid = UID2Prebid(
4343
if (isEnvironmentEUID) EUIDManager.getInstance() else UID2Manager.getInstance(),
4444
).apply {

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
agp = "8.11.0"
2+
agp = "8.11.1"
33
kotlin = "2.1.21"
44
core-ktx = "1.16.0"
55
junit = "4.13.2"
@@ -11,7 +11,7 @@ compose-tooling = "1.8.2"
1111
gma = "24.4.0"
1212
ima = "3.36.0"
1313
mockkVersion = "1.14.4"
14-
prebid = "2.2.1"
14+
prebid = "3.0.2"
1515
ktlint = "1.0.1"
1616

1717
[libraries]

prebid/src/main/java/com/uid2/prebid/UID2Prebid.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import kotlinx.coroutines.cancel
1212
import kotlinx.coroutines.launch
1313
import org.prebid.mobile.ExternalUserId
1414
import org.prebid.mobile.PrebidMobile
15+
import org.prebid.mobile.TargetingParams
1516

1617
/**
1718
* Interface to wrap access to [PrebidMobile]. This is used to improve testability, rather than having the [UID2Prebid]
@@ -50,7 +51,7 @@ public class UID2Prebid internal constructor(
5051
) : this(
5152
manager,
5253
externalUserIdFactory,
53-
PrebidExternalUserIdInteractor { ids -> PrebidMobile.setExternalUserIds(ids) },
54+
PrebidExternalUserIdInteractor { ids -> TargetingParams.setExternalUserIds(ids) },
5455
Dispatchers.Default,
5556
)
5657

@@ -121,12 +122,18 @@ public class UID2Prebid internal constructor(
121122
*/
122123
private fun String.toExternalUserIdList(): List<ExternalUserId> {
123124
return listOf(
124-
ExternalUserId(USER_ID_SOURCE, this, null, null),
125+
ExternalUserId(USER_ID_SOURCE, listOf(ExternalUserId.UniqueId(this, AGENT_TYPE_PERSON_ID))),
125126
)
126127
}
127128

128129
private companion object {
129130
const val TAG = "UID2Prebid"
130131
const val USER_ID_SOURCE = "uidapi.com"
132+
133+
/**
134+
* "A person-based ID, i.e., that is the same across devices."
135+
* https://github.com/InteractiveAdvertisingBureau/AdCOM/blob/main/AdCOM%20v1.0%20FINAL.md#list_agenttypes
136+
*/
137+
const val AGENT_TYPE_PERSON_ID = 3
131138
}
132139
}

prebid/src/test/java/com/uid2/prebid/UID2PrebidTest.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class UID2PrebidTest {
5858

5959
// Verify that immediately after being initialized, the available advertising token is set on Prebid.
6060
assertEquals(1, prebidExternalUserIdInteractor.lastIds.size)
61-
assertEquals(currentAdvertisingToken, prebidExternalUserIdInteractor.lastIds[0].identifier)
61+
assertEquals(currentAdvertisingToken, prebidExternalUserIdInteractor.lastIds[0].uniqueIds[0].id)
6262
}
6363

6464
@Test
@@ -151,9 +151,11 @@ class UID2PrebidTest {
151151
private fun FakePrebidExternalUserIdInteractor.assertLastToken(advertisingToken: String) {
152152
assertTrue(lastIds.isNotEmpty())
153153
lastIds.last().let {
154-
assertEquals(advertisingToken, it.identifier)
155154
assertEquals("uidapi.com", it.source)
156-
assertNull(it.atype)
155+
assertEquals(1, it.uniqueIds.size)
156+
val id = it.uniqueIds[0]
157+
assertEquals(advertisingToken, id.id)
158+
assertEquals(3, id.atype)
157159
assertNull(it.ext)
158160
}
159161
}

0 commit comments

Comments
 (0)