Skip to content

Commit

Permalink
🔖 Bump to version 7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliy-pavlenko committed Jul 30, 2024
1 parent 5758799 commit 42b7bf7
Show file tree
Hide file tree
Showing 21 changed files with 215 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Next Version

# Version 7.0.0
- Add inventoryGroupId parameter

# Version 6.0.0
- Add support of Android 14 (API level 34)
- Add support for MRAID 2.0 specification
Expand Down
11 changes: 3 additions & 8 deletions app/src/main/java/com/criteo/testapp/AdMobMediationActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,9 @@ import java.security.MessageDigest
class AdMobMediationActivity : AppCompatActivity() {

private companion object {
/** This AdMob AdUnit is mapped to this Criteo AdUnit: /140800857/Endeavour_320x50 */
const val ADMOB_BANNER = "ca-app-pub-8459323526901202/2832836926"

/** This AdMob AdUnit is mapped to this Criteo AdUnit: /140800857/Endeavour_320x480 */
const val ADMOB_INTERSTITIAL = "ca-app-pub-8459323526901202/6462812944"

/** This AdMob AdUnit is mapped to this Criteo AdUnit: /140800857/Endeavour_Native */
const val ADMOB_NATIVE = "ca-app-pub-8459323526901202/2863808899"
const val ADMOB_BANNER = "ca-app-pub-3940256099942544/9214589741"
const val ADMOB_INTERSTITIAL = "ca-app-pub-3940256099942544/1033173712"
const val ADMOB_NATIVE = "ca-app-pub-3940256099942544/2247696110"
}

private val tag = javaClass.simpleName
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/criteo/testapp/DfpActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
public class DfpActivity extends AppCompatActivity {

private static final String TAG = DfpActivity.class.getSimpleName();
private static final String DFP_INTERSTITIAL_AD_UNIT_ID = "/140800857/Endeavour_Interstitial_320x480";
private static final String DFP_BANNER_AD_UNIT_ID = "/140800857/Endeavour_320x50";
private static final String DFP_NATIVE_AD_UNIT_ID = "/140800857/Endeavour_Native";
private static final String DFP_INTERSTITIAL_VIDEO_ID = INTERSTITIAL_VIDEO.getAdUnitId();
private static final String DFP_REWARDED_VIDEO_ID = DFP_INTERSTITIAL_VIDEO_ID; // TODO?
private static final String DFP_INTERSTITIAL_AD_UNIT_ID = "/21775744923/example/interstitial";
private static final String DFP_BANNER_AD_UNIT_ID = "/6499/example/banner";
private static final String DFP_NATIVE_AD_UNIT_ID = "/6499/example/native";
private static final String DFP_INTERSTITIAL_VIDEO_ID = "/21775744923/example/rewarded-interstitial";
private static final String DFP_REWARDED_VIDEO_ID = "/21775744923/example/rewarded";

private LinearLayout linearLayout;
private Criteo criteo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class PubSdkDemoApplication : MultiDexApplication() {

val builder = Criteo.Builder(this, "B-000000")
.adUnits(adUnits)
.inventoryGroupId("myInventoryGroupId")

if ("release" == BuildConfig.BUILD_TYPE) {
// Enable debug logs only on release build.
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_in_house.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
android:layout_height="match_parent"
app:criteoAdUnitHeight="50"
app:criteoAdUnitWidth="320"
app:criteoAdUnitId="/140800857/Endeavour_320x50"
app:criteoAdUnitId="/6499/example/banner"
app:layout_constraintStart_toStartOf="parent"
/>
<FrameLayout
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/SdkVersion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.gradle.api.Project
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

private const val sdkBaseVersion = "6.0.0"
private const val sdkBaseVersion = "7.0.0"

private val timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd.HHmm"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ private void callingCdb_GivenAdUnitAndGlobalInformation_ShouldCallCdbWithExpecte
Publisher expectedPublisher = new Publisher(
"bundle.id",
CriteoUtil.TEST_CP_ID,
CriteoUtil.TEST_INVENTORY_GROUP_ID,
new HashMap<>()
);

Expand Down
9 changes: 9 additions & 0 deletions publisher-sdk/src/main/java/com/criteo/publisher/Criteo.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public static class Builder {
@Nullable
private Boolean tagForChildDirectedTreatment = null;

@Nullable
private String inventoryGroupId = null;

public Builder(@NonNull Application application, @NonNull String criteoPublisherId) {
this.application = application;
this.criteoPublisherId = criteoPublisherId;
Expand Down Expand Up @@ -105,6 +108,11 @@ public Builder tagForChildDirectedTreatment(@Nullable Boolean tagForChildDirecte
return this;
}

public Builder inventoryGroupId(@Nullable String inventoryGroupId) {
this.inventoryGroupId = inventoryGroupId;
return this;
}

public Criteo init() throws CriteoInitException {
return Criteo.init(this);
}
Expand All @@ -119,6 +127,7 @@ private static Criteo init(@NonNull Builder builder) throws CriteoInitException
DependencyProvider dependencyProvider = DependencyProvider.getInstance();
dependencyProvider.setApplication(builder.application);
dependencyProvider.setCriteoPublisherId(builder.criteoPublisherId);
dependencyProvider.setInventoryGroupId(builder.inventoryGroupId);

if (builder.isDebugLogsEnabled) {
dependencyProvider.provideConsoleHandler().setMinLogLevel(Log.INFO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public class DependencyProvider {

private Application application;
private String criteoPublisherId;
private String inventoryGroupId;

protected DependencyProvider() {
}
Expand Down Expand Up @@ -169,6 +170,10 @@ public void setCriteoPublisherId(@NonNull String criteoPublisherId) {
checkCriteoPublisherIdIsSet();
}

public void setInventoryGroupId(@Nullable String inventoryGroupId) {
this.inventoryGroupId = inventoryGroupId;
}

boolean isApplicationSet() {
try {
DependencyProvider.getInstance().checkApplicationIsSet();
Expand Down Expand Up @@ -207,6 +212,11 @@ public String provideCriteoPublisherId() {
return criteoPublisherId;
}

@Nullable
public String provideInventoryGroupId() {
return inventoryGroupId;
}

@NonNull
public PubSdkApi providePubSdkApi() {
return getOrCreate(PubSdkApi.class, () -> new PubSdkApi(
Expand Down Expand Up @@ -351,6 +361,7 @@ public CdbRequestFactory provideCdbRequestFactory() {
return getOrCreate(CdbRequestFactory.class, () -> new CdbRequestFactory(
provideContext(),
provideCriteoPublisherId(),
provideInventoryGroupId(),
provideDeviceInfo(),
provideAdvertisingInfo(),
provideUserPrivacyUtil(),
Expand All @@ -375,6 +386,7 @@ public RemoteConfigRequestFactory provideRemoteConfigRequestFactory() {
return getOrCreate(RemoteConfigRequestFactory.class, () -> new RemoteConfigRequestFactory(
provideContext(),
provideCriteoPublisherId(),
provideInventoryGroupId(),
provideBuildConfigWrapper(),
provideIntegrationRegistry()
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class CdbRequestFactory {
@NonNull
private final String criteoPublisherId;

@Nullable
private final String inventoryGroupId;

@NonNull
private final DeviceInfo deviceInfo;

Expand Down Expand Up @@ -79,6 +82,7 @@ public class CdbRequestFactory {
public CdbRequestFactory(
@NonNull Context context,
@NonNull String criteoPublisherId,
@Nullable String inventoryGroupId,
@NonNull DeviceInfo deviceInfo,
@NonNull AdvertisingInfo advertisingInfo,
@NonNull UserPrivacyUtil userPrivacyUtil,
Expand All @@ -91,6 +95,7 @@ public CdbRequestFactory(
) {
this.context = context;
this.criteoPublisherId = criteoPublisherId;
this.inventoryGroupId = inventoryGroupId;
this.deviceInfo = deviceInfo;
this.advertisingInfo = advertisingInfo;
this.userPrivacyUtil = userPrivacyUtil;
Expand All @@ -112,6 +117,7 @@ public CdbRequest createRequest(
Publisher publisher = new Publisher(
context.getPackageName(),
criteoPublisherId,
inventoryGroupId,
publisherExt
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ data class Publisher(
val bundleId: String,
@Json(name = "cpId")
val criteoPublisherId: String,
@Json(name = "inventoryGroupId")
val inventoryGroupId: String?,
@Json(name = "ext")
val ext: Map<String, Any>
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import com.squareup.moshi.JsonClass
data class RemoteConfigRequest @JvmOverloads constructor(
@Json(name = "cpId")
val criteoPublisherId: String,
@Json(name = "inventoryGroupId")
val inventoryGroupId: String?,
@Json(name = "bundleId")
val bundleId: String,
@Json(name = "sdkVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import com.criteo.publisher.util.BuildConfigWrapper
class RemoteConfigRequestFactory(
private val context: Context,
private val criteoPublisherId: String,
private val inventoryGroupId: String?,
private val buildConfigWrapper: BuildConfigWrapper,
private val integrationRegistry: IntegrationRegistry
private val integrationRegistry: IntegrationRegistry,
) {
fun createRequest(): RemoteConfigRequest {
return RemoteConfigRequest(
criteoPublisherId,
inventoryGroupId,
context.packageName,
buildConfigWrapper.sdkVersion,
integrationRegistry.profileId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ public void provideMraidController_WhenMraidEnabledIsTrueAndMraid2EnabledIsTrueA
});
}

@Test
public void setInventoryGroupId_GivenNullIsOk() {
dependencyProvider = DependencyProvider.getInstance();
dependencyProvider.setInventoryGroupId(null);
}

private void givenMraidIsEnabledEquals(Boolean isMraidEnabled, Boolean isMraid2Enabled, Function<DependencyProvider, Void> providing) {
DependencyProvider instance = spy(DependencyProvider.getInstance());
instance.setApplication(ApplicationMock.newMock());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class CdbRequestFactoryTest {
factory = CdbRequestFactory(
context,
cpId,
null,
deviceInfo,
advertisingInfo,
userPrivacyUtil,
Expand Down Expand Up @@ -153,6 +154,7 @@ class CdbRequestFactoryTest {
val expectedPublisher = Publisher(
"bundle.id",
"myCpId",
null,
mapOf(
"a" to mapOf("a" to "foo"),
"b" to "bar"
Expand Down Expand Up @@ -213,7 +215,7 @@ class CdbRequestFactoryTest {
var request = factory.createRequest(adUnits, contextData)

assertThat(request.id).isEqualTo("myRequestId")
assertThat(request.publisher).isEqualTo(Publisher("bundle.id", "myCpId", mapOf()))
assertThat(request.publisher).isEqualTo(Publisher("bundle.id", "myCpId", null, mapOf()))
assertThat(request.sdkVersion).isEqualTo("1.2.3")
assertThat(request.profileId).isEqualTo(1337)
assertThat(request.gdprData).isEqualTo(expectedGdpr)
Expand Down Expand Up @@ -413,6 +415,50 @@ class CdbRequestFactoryTest {
}
}

@Test
fun createRequest_GivenInput_BuildRequestWithInventoryGroupId() {
val adUnit = createAdUnit()
val adUnits: List<CacheAdUnit> = listOf(adUnit)
val contextData: ContextData = ContextData().set("a.a", "foo").set("b", "bar")

buildConfigWrapper.stub {
on { sdkVersion } doReturn "1.2.3"
}

whenever(context.packageName).thenReturn("bundle.id")
whenever(uniqueIdGenerator.generateId())
.thenReturn("myRequestId")
.thenReturn("impId")

val expectedPublisher = Publisher(
"bundle.id",
"myCpId",
"myInventoryGroupId",
mapOf(
"a" to mapOf("a" to "foo"),
"b" to "bar"
)
)

val factory = CdbRequestFactory(
context,
cpId,
"myInventoryGroupId",
deviceInfo,
advertisingInfo,
userPrivacyUtil,
uniqueIdGenerator,
buildConfigWrapper,
integrationRegistry,
contextProvider,
userDataHolder,
config
)
val request = factory.createRequest(adUnits, contextData)

assertThat(request.publisher).isEqualTo(expectedPublisher)
}

private fun mockRequiredObjects() {
whenever(userPrivacyUtil.tagForChildDirectedTreatment).thenReturn(true)
whenever(context.packageName).thenReturn("bundle.id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CdbRequestTest {
Publisher(
"myBundleId",
"myCpId",
"myInventoryGroupId",
mapOf(
"content" to mapOf(
"url" to "https://www.criteo.com"
Expand Down Expand Up @@ -82,6 +83,7 @@ class CdbRequestTest {
"publisher": {
"bundleId": "myBundleId",
"cpId": "myCpId",
"inventoryGroupId": "myInventoryGroupId",
"ext": {
"content": {
"url": "https://www.criteo.com"
Expand Down Expand Up @@ -126,7 +128,7 @@ class CdbRequestTest {
fun toJson_GivenNoGdpr_DoesNotMapIt() {
val request = CdbRequest(
"myRequestId",
Publisher("myBundleId", "myCpId", mapOf()),
Publisher("myBundleId", "myCpId", "myInventoryGroupId", mapOf()),
User(null, null, null, mapOf()),
"1.2.3",
456,
Expand All @@ -144,7 +146,7 @@ class CdbRequestTest {
fun toJson_GivenCdbRegsObjectIsNull_DoesNotMapIt() {
val request = CdbRequest(
"myRequestId",
Publisher("myBundleId", "myCpId", mapOf()),
Publisher("myBundleId", "myCpId", "myInventoryGroupId", mapOf()),
User(null, null, null, mapOf()),
"1.2.3",
456,
Expand All @@ -157,4 +159,22 @@ class CdbRequestTest {

assertThat(json).doesNotContain("regs")
}

@Test
fun toJson_GivenInventoryGroupIdIsNull_DoesNotMapIt() {
val request = CdbRequest(
"myRequestId",
Publisher("myBundleId", "myCpId", null, mapOf()),
User(null, null, null, mapOf()),
"1.2.3",
456,
null,
listOf(),
null
)

val json = serializer.writeIntoString(request)

assertThat(json).doesNotContain("inventoryGroupId")
}
}
Loading

0 comments on commit 42b7bf7

Please sign in to comment.