Skip to content

Commit

Permalink
release/7.2.1 (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
carmelo-iriti authored May 10, 2023
1 parent 7787bd2 commit f0a8d05
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 77 deletions.
2 changes: 1 addition & 1 deletion cmplibrary/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME = 7.2.0
VERSION_NAME = 7.2.1

POM_NAME = cmplibrary
POM_REPO = sourcepoint
Expand Down
14 changes: 3 additions & 11 deletions cmplibrary/release_note.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
* [DIA-2134](https://sourcepoint.atlassian.net/browse/DIA-2134) Trigger the timeout for RenderingApp from the onConsentReady callback (#630)
* [DIA-2135](https://sourcepoint.atlassian.net/browse/DIA-2135) Enum with error codes for timeout and invalid response (#629)
* [DIA-1988](https://sourcepoint.atlassian.net/browse/DIA-1988) Call the custom-metrics for incoming errors from the RenderingApp. (#628)
* [DIA-1981](https://sourcepoint.atlassian.net/browse/DIA-1981) Write a more meaningful message for the timeout exception (#627)
* [DIA-2102](https://sourcepoint.atlassian.net/browse/DIA-2102) Added `scriptVersion` and `scriptType` to all `Url`s and logger requests (#626)
* [DIA-2104](https://sourcepoint.atlassian.net/browse/DIA-2104) Metaapptv Add a button to layout the CCPA Pm (#625)
* [DIA-1990](https://sourcepoint.atlassian.net/browse/DIA-1990) Preloading always enabled (#623)
* [DIA-2055](https://sourcepoint.atlassian.net/browse/DIA-2055) Add custom consent for the preloading feature (#624)
* [DIA-1792](https://sourcepoint.atlassian.net/browse/DIA-1792) Upgraded okHttp lib to 4.9.0 (#588)
* [DIA-1730](https://sourcepoint.atlassian.net/browse/DIA-1730) Authid fix (#622)
* [DIA-1949](https://sourcepoint.atlassian.net/browse/DIA-1949) Fix campaign env parameter (#620)
* [DIA-2119](https://sourcepoint.atlassian.net/browse/DIA-2119) Wait on pv-data before sending POST choice request (#633)
* [DIA-2121](https://sourcepoint.atlassian.net/browse/DIA-2121) Added ViewManagerException (#632)

Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,26 @@ internal class SpConsentLibImpl(
}

override fun loadMessage() {
localLoadMessageOptimized(authId = null, pubData = null, cmpViewId = null)
localLoadMessage(authId = null, pubData = null, cmpViewId = null)
}

override fun loadMessage(cmpViewId: Int) {
localLoadMessageOptimized(authId = null, pubData = null, cmpViewId = cmpViewId)
localLoadMessage(authId = null, pubData = null, cmpViewId = cmpViewId)
}

override fun loadMessage(authId: String?, pubData: JSONObject?, cmpViewId: Int?) {
localLoadMessageOptimized(authId = authId, pubData = pubData, cmpViewId = cmpViewId)
localLoadMessage(authId = authId, pubData = pubData, cmpViewId = cmpViewId)
}

override fun loadMessage(pubData: JSONObject?) {
localLoadMessageOptimized(authId = null, pubData = pubData, cmpViewId = null)
localLoadMessage(authId = null, pubData = pubData, cmpViewId = null)
}

override fun loadMessage(authId: String?) {
localLoadMessageOptimized(authId = authId, pubData = null, cmpViewId = null)
localLoadMessage(authId = authId, pubData = null, cmpViewId = null)
}

private fun localLoadMessageOptimized(authId: String?, pubData: JSONObject?, cmpViewId: Int?) {
private fun localLoadMessage(authId: String?, pubData: JSONObject?, cmpViewId: Int?) {

val param = check { campaignManager.getMessageOptimizedReq(authId, pubData) }
.executeOnLeft {
Expand All @@ -142,14 +142,14 @@ internal class SpConsentLibImpl(
service.getMessages(
messageReq = param,
showConsent = {
consentManager.sendStoredConsentToClientOptimized()
consentManager.sendStoredConsentToClient()
clientEventManager.setAction(NativeMessageActionType.GET_MSG_NOT_CALLED)
},
pSuccess = {
val list = it.toCampaignModelList(logger = pLogger)
clientEventManager.setCampaignNumber(list.size)
if (list.isEmpty()) {
consentManager.sendStoredConsentToClientOptimized()
consentManager.sendStoredConsentToClient()
return@getMessages
}
val firstCampaign2Process: CampaignModel = list.first()
Expand Down Expand Up @@ -195,7 +195,7 @@ internal class SpConsentLibImpl(
pError = { throwable ->
if (consentManager.storedConsent) {
executor.executeOnSingleThread {
consentManager.sendStoredConsentToClientOptimized()
consentManager.sendStoredConsentToClient()
clientEventManager.setAction(NativeMessageActionType.GET_MSG_ERROR)
}
} else {
Expand Down Expand Up @@ -569,7 +569,7 @@ internal class SpConsentLibImpl(
executor.executeOnSingleThread {
val editedAction = spClient.onAction(view, actionImpl) as? ConsentActionImpl
editedAction?.let {
consentManager.enqueueConsentOptimized(consentActionImpl = editedAction)
consentManager.enqueueConsent(consentActionImpl = editedAction)
}
}
}
Expand Down Expand Up @@ -753,7 +753,7 @@ internal class SpConsentLibImpl(
}
NativeMessageActionType.ACCEPT_ALL,
NativeMessageActionType.REJECT_ALL -> {
consentManager.enqueueConsentOptimized(nativeConsentAction = nca)
consentManager.enqueueConsent(nativeConsentAction = nca)
moveToNextCampaign(remainingCampaigns, viewManager, spClient)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ internal interface CampaignManager {
// var ccpaStatus: CcpaStatus?

var metaDataResp: MetaDataResp?
var pvDataResp: PvDataResp?
var choiceResp: ChoiceResp?
var dataRecordedConsent: Instant?
var authId: String?
Expand Down Expand Up @@ -697,22 +696,13 @@ private class CampaignManagerImpl(
dataStorage.metaDataResp = serialised
}

override var pvDataResp: PvDataResp?
get() {
return dataStorage.pvDataResp?.let { JsonConverter.converter.decodeFromString<PvDataResp>(it) }
}
set(value) {
val serialised = value?.let { JsonConverter.converter.encodeToString(value) }
dataStorage.pvDataResp = serialised
}

override var choiceResp: ChoiceResp?
get() {
return dataStorage.choiceResp?.let { JsonConverter.converter.decodeFromString<ChoiceResp>(it) }
}
set(value) {
val serialised = value?.let { JsonConverter.converter.encodeToString(value) }
dataStorage.pvDataResp = serialised
dataStorage.choiceResp = serialised
}

override var dataRecordedConsent: Instant?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import com.sourcepoint.cmplibrary.model.toConsentAction
import com.sourcepoint.cmplibrary.util.check

internal interface ConsentManager {
fun enqueueConsentOptimized(consentActionImpl: ConsentActionImpl)
fun enqueueConsentOptimized(nativeConsentAction: NativeConsentAction)
fun sendStoredConsentToClientOptimized()
fun sendConsentOptimized(
fun enqueueConsent(consentActionImpl: ConsentActionImpl)
fun enqueueConsent(nativeConsentAction: NativeConsentAction)
fun sendStoredConsentToClient()
fun sendConsent(
actionImpl: ConsentActionImpl
)

Expand Down Expand Up @@ -87,15 +87,15 @@ private class ConsentManagerImpl(
get() = dataStorage.getCcpaConsentResp() != null ||
dataStorage.getGdprConsentResp() != null

override fun enqueueConsentOptimized(consentActionImpl: ConsentActionImpl) {
sendConsentOptimized(consentActionImpl)
override fun enqueueConsent(consentActionImpl: ConsentActionImpl) {
sendConsent(consentActionImpl)
}

override fun enqueueConsentOptimized(nativeConsentAction: NativeConsentAction) {
sendConsentOptimized(nativeConsentAction.toConsentAction())
override fun enqueueConsent(nativeConsentAction: NativeConsentAction) {
sendConsent(nativeConsentAction.toConsentAction())
}

override fun sendStoredConsentToClientOptimized() {
override fun sendStoredConsentToClient() {
check {
val ccpaCached = consentManagerUtils.ccpaConsentOptimized.getOrNull()
val gdprCached = consentManagerUtils.gdprConsentOptimized.getOrNull()
Expand All @@ -106,9 +106,9 @@ private class ConsentManagerImpl(
}
}

override fun sendConsentOptimized(actionImpl: ConsentActionImpl) {
override fun sendConsent(actionImpl: ConsentActionImpl) {
executorManager.executeOnSingleThread {
service.sendConsentOptimized(actionImpl, env, sPConsentsSuccess, actionImpl.privacyManagerId)
service.sendConsent(actionImpl, env, sPConsentsSuccess, actionImpl.privacyManagerId)
.executeOnLeft { sPConsentsError?.invoke(it) }
.executeOnRight {
clientEventManager.storedConsent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal interface ConsentManagerUtils {
val gdprConsentOptimized: Either<GDPRConsentInternal>
val ccpaConsentOptimized: Either<CCPAConsentInternal>

fun updateGdprConsentOptimized(
fun updateGdprConsent(
dataRecordedConsent: String,
gdprConsentStatus: ConsentStatus,
additionsChangeDate: String,
Expand Down Expand Up @@ -52,7 +52,7 @@ private class ConsentManagerUtilsImpl(
val uuid: String = UUID.randomUUID().toString()
) : ConsentManagerUtils {

override fun updateGdprConsentOptimized(
override fun updateGdprConsent(
dataRecordedConsent: String,
gdprConsentStatus: ConsentStatus,
additionsChangeDate: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.sourcepoint.cmplibrary.model.exposed.SPConsents
*/
internal interface Service : NetworkClient, CampaignManager {

fun sendConsentOptimized(
fun sendConsent(
consentActionImpl: ConsentActionImpl,
env: Env,
sPConsentsSuccess: ((SPConsents) -> Unit)?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private class ServiceImpl(
additionsChangeDate != null &&
legalBasisChangeDate != null
) {
val consentStatus = consentManagerUtils.updateGdprConsentOptimized(
val consentStatus = consentManagerUtils.updateGdprConsent(
dataRecordedConsent = dataRecordedConsent,
gdprConsentStatus = gdprConsentStatus,
additionsChangeDate = additionsChangeDate,
Expand Down Expand Up @@ -246,7 +246,7 @@ private class ServiceImpl(
return@executeOnWorkerThread
}
.executeOnRight {
campaignManager.pvDataResp = it
it.gdpr?.uuid?.let { u -> campaignManager.gdprUuid = u }
}
}

Expand Down Expand Up @@ -275,28 +275,28 @@ private class ServiceImpl(
return@executeOnWorkerThread
}
.executeOnRight {
campaignManager.pvDataResp = it
it.ccpa?.uuid?.let { u -> campaignManager.ccpaUuid = u }
}
}
}
}

override fun sendConsentOptimized(
override fun sendConsent(
consentActionImpl: ConsentActionImpl,
env: Env,
sPConsentsSuccess: ((SPConsents) -> Unit)?,
pmId: String?
): Either<ChoiceResp> {
return when (consentActionImpl.campaignType) {
GDPR -> {
sendConsentGdprOptimized(
sendConsentGdpr(
consentActionImpl,
env,
sPConsentsSuccess
).map { ChoiceResp(gdpr = it) }
}
CCPA -> {
sendConsentCcpaOptimized(
sendConsentCcpa(
consentActionImpl,
env,
sPConsentsSuccess
Expand All @@ -305,7 +305,7 @@ private class ServiceImpl(
}
}

fun sendConsentGdprOptimized(
fun sendConsentGdpr(
consentActionImpl: ConsentActionImpl,
env: Env,
sPConsentsSuccess: ((SPConsents) -> Unit)?
Expand Down Expand Up @@ -382,7 +382,7 @@ private class ServiceImpl(
)
}

fun sendConsentCcpaOptimized(
fun sendConsentCcpa(
consentActionImpl: ConsentActionImpl,
env: Env,
sPConsentsSuccess: ((SPConsents) -> Unit)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ internal interface DataStorage : DataStorageGdpr, DataStorageCcpa {
var messagesOptimized: String?
var consentStatus: String?
var metaDataResp: String?
var pvDataResp: String?
var choiceResp: String?
var dataRecordedConsent: String?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,6 @@ private class DataStorageImpl(
.apply()
}

override var pvDataResp: String?
get() = preference.getString(PV_DATA_RESP, null)
set(value) {
preference
.edit()
.putString(PV_DATA_RESP, value)
.apply()
}

override var choiceResp: String?
get() = preference.getString(CHOICE_RESP, null)
set(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal object CodeList {
val INVALID_ON_ACTION_EVENT_PAYLOAD = ExceptionCodes("sp_metric_invalid_onAction_event_payload")
val URL_LOADING_ERROR = ExceptionCodes("sp_metric_url_loading_error")
val WEB_VIEW_ERROR = ExceptionCodes("sp_metric_web_view_error")
val WEB_VIEW_CREATION_ERROR = ExceptionCodes("sp_metric_webview_creation_error")
val INTERNAL_SERVER_ERROR = ExceptionCodes("sp_metric_internal_server_error_5xx")
val RESOURCE_NOT_FOUND = ExceptionCodes("sp_metric_resource_not_found_4xx")
val CONNECTION_TIMEOUT = ExceptionCodes("sp_metric_connection_timeout")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ internal class WebViewException @JvmOverloads constructor(
override val code: ExceptionCodes = CodeList.WEB_VIEW_ERROR
}

/**
* This exception is thrown when in the ViewManager a problem has occurred
*/
internal class WebViewCreationException @JvmOverloads constructor(
cause: Throwable? = null,
description: String,
isConsumed: Boolean = false
) : ConsentLibExceptionK(
cause = cause,
description = description,
isConsumed = isConsumed
) {
override val code: ExceptionCodes = CodeList.WEB_VIEW_CREATION_ERROR
}

/**
* This exception is thrown when the WebView cannot load the url received
*/
Expand Down Expand Up @@ -242,11 +257,9 @@ internal class InvalidArgumentException @JvmOverloads constructor(
* This exception is thrown when we receive a request timeout
*/

val TIMEOUT_MESSAGE = """
A timeout has occurred when requesting the message data.
Please check your internet connection.
You can extend the timeout using the messageTimeout config parameter.
""".trimIndent()
val TIMEOUT_MESSAGE = "A timeout has occurred when requesting the message data. " +
"Please check your internet connection. " +
"You can extend the timeout using the messageTimeout config parameter."

internal class ConnectionTimeoutException @JvmOverloads constructor(
cause: Throwable? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.sourcepoint.cmplibrary.core.web.CampaignModel
import com.sourcepoint.cmplibrary.core.web.ConsentWebView
import com.sourcepoint.cmplibrary.core.web.IConsentWebView
import com.sourcepoint.cmplibrary.data.network.connection.ConnectionManager
import com.sourcepoint.cmplibrary.exception.GenericSDKException
import com.sourcepoint.cmplibrary.exception.WebViewCreationException
import com.sourcepoint.cmplibrary.model.exposed.MessageSubCategory
import java.lang.ref.WeakReference
import java.util.* // ktlint-disable
Expand Down Expand Up @@ -141,7 +141,7 @@ private class ViewsManagerImpl(
viewId = cmpViewId
)
}
} ?: Either.Left(GenericSDKException(description = "The activity reference in the ViewManager is null!!!"))
} ?: Either.Left(WebViewCreationException(description = "The activity reference in the ViewManager is null!!!"))
}

override fun createWebView(
Expand All @@ -165,7 +165,7 @@ private class ViewsManagerImpl(
viewId = cmpViewId
)
}
} ?: Either.Left(GenericSDKException(description = "The activity reference in the ViewManager is null!!!"))
} ?: Either.Left(WebViewCreationException(description = "The activity reference in the ViewManager is null!!!"))
}

override fun dispose() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ConsentManagerUtilsImplTest {
""".trimIndent()
)
sut
.updateGdprConsentOptimized(dataRecordedConsent, gdprConsentStatus, additionsChangeDate, legalBasisChangeDate)
.updateGdprConsent(dataRecordedConsent, gdprConsentStatus, additionsChangeDate, legalBasisChangeDate)
.run {
vendorListAdditions.assertNull()
legalBasisChanges!!.assertTrue()
Expand Down Expand Up @@ -97,7 +97,7 @@ class ConsentManagerUtilsImplTest {
""".trimIndent()
)
sut
.updateGdprConsentOptimized(dataRecordedConsent, gdprConsentStatus, additionsChangeDate, legalBasisChangeDate)
.updateGdprConsent(dataRecordedConsent, gdprConsentStatus, additionsChangeDate, legalBasisChangeDate)
.run {
vendorListAdditions!!.assertTrue()
legalBasisChanges.assertNull()
Expand Down Expand Up @@ -131,7 +131,7 @@ class ConsentManagerUtilsImplTest {
""".trimIndent()
)
sut
.updateGdprConsentOptimized(dataRecordedConsent, gdprConsentStatus, additionsChangeDate, legalBasisChangeDate)
.updateGdprConsent(dataRecordedConsent, gdprConsentStatus, additionsChangeDate, legalBasisChangeDate)
.run {
vendorListAdditions.assertNull()
legalBasisChanges.assertNull()
Expand Down
Loading

0 comments on commit f0a8d05

Please sign in to comment.