Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ open class AttributeListenerTestKit :

override fun supportsAttributeLists() = supportsAttributeLists?.invoke() ?: true

override fun setUserAttributeList(
override fun onSetUserAttributeList(
attributeKey: String,
attributeValueList: MutableList<String>,
attributeValueList: List<String>,
user: FilteredMParticleUser,
) {
setUserAttributeList?.invoke(attributeKey, attributeValueList)
onAttributeReceived?.invoke(attributeKey, attributeValueList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,19 @@ public interface BaseAttributeListener {
* @param user filtered user context for this kit
*/
void onSetUserAttribute(String key, Object value, FilteredMParticleUser user);

/**
* Called when a list-valued user attribute is set and {@link #supportsAttributeLists()} returns true.
*
* @param attributeKey attribute key
* @param attributeValueList attribute values
* @param user filtered user context for this kit
*/
void onSetUserAttributeList(String attributeKey, List<String> attributeValueList, FilteredMParticleUser user);
Comment thread
denischilik marked this conversation as resolved.
Outdated
}

public interface AttributeListener extends BaseAttributeListener {

void setUserAttributeList(String attributeKey, List<String> attributeValueList);

void setAllUserAttributes(Map<String, String> userAttributes, Map<String, List<String>> userAttributeLists);

void setUserIdentity(MParticle.IdentityType identityType, String identity);
Expand Down Expand Up @@ -565,8 +572,6 @@ public interface UserAttributeListener extends BaseAttributeListener {

void onSetUserTag(String key, FilteredMParticleUser user);

void onSetUserAttributeList(String attributeKey, List<String> attributeValueList, FilteredMParticleUser user);

void onSetAllUserAttributes(Map<String, String> userAttributes, Map<String, List<String>> userAttributeLists, FilteredMParticleUser user);

void onConsentStateUpdated(ConsentState oldState, ConsentState newState, FilteredMParticleUser user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,24 +681,15 @@ public void setUserAttributeList(String attributeKey, List<String> valuesList, l
}

private void setUserAttribute(KitIntegration provider, String attributeKey, List<String> valueList, long mpid) {
if ((provider instanceof KitIntegration.AttributeListener || provider instanceof KitIntegration.UserAttributeListener)
if ((provider instanceof KitIntegration.BaseAttributeListener listener)
&& !provider.isDisabled()
&& KitConfiguration.shouldForwardAttribute(provider.getConfiguration().getUserAttributeFilters(), attributeKey)) {
boolean supportsAttributeLists = ((KitIntegration.BaseAttributeListener) provider).supportsAttributeLists();
boolean supportsAttributeLists = listener.supportsAttributeLists();
FilteredMParticleUser user = FilteredMParticleUser.getInstance(mpid, provider);
if (provider instanceof KitIntegration.AttributeListener) {
if (supportsAttributeLists) {
((KitIntegration.AttributeListener) provider).setUserAttributeList(attributeKey, valueList);
} else {
((KitIntegration.BaseAttributeListener) provider).onSetUserAttribute(attributeKey, KitUtils.join(valueList), user);
}
}
if (provider instanceof KitIntegration.UserAttributeListener) {
if (supportsAttributeLists) {
((KitIntegration.UserAttributeListener) provider).onSetUserAttributeList(attributeKey, valueList, user);
} else {
((KitIntegration.UserAttributeListener) provider).onSetUserAttribute(attributeKey, KitUtils.join(valueList), user);
}
if (supportsAttributeLists) {
listener.onSetUserAttributeList(attributeKey, valueList, user);
} else {
listener.onSetUserAttribute(attributeKey, KitUtils.join(valueList), user);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ class KitManagerImplTest {
attributeList.add("2")
attributeList.add("3")
manager.setUserAttributeList("test key", attributeList, 1)
verify(integration as AttributeListener, Mockito.times(1))
.setUserAttributeList("test key", attributeList)
verify(integration as BaseAttributeListener, Mockito.times(1))
.onSetUserAttributeList(eq("test key"), eq(attributeList), any())
verify(integration2 as BaseAttributeListener, Mockito.times(1))
.onSetUserAttribute(eq("test key"), eq("1,2,3"), isNull())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ abstract class AdobeKitBase :
syncIds()
}

override fun setUserAttributeList(
s: String,
list: List<String>,
override fun onSetUserAttributeList(
attributeKey: String,
attributeValueList: List<String>,
user: FilteredMParticleUser,
) {
syncIds()
}
Comment thread
cursor[bot] marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ open class AdobeKit :
syncIds()
}

override fun setUserAttributeList(
s: String,
list: List<String>,
override fun onSetUserAttributeList(
attributeKey: String,
attributeValueList: List<String>,
user: FilteredMParticleUser,
) {
syncIds()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,6 @@ class AppsFlyerKit :
return messageList
}

override fun setUserAttributeList(
s: String,
list: List<String>,
) {}

override fun onIncrementUserAttribute(
key: String?,
incrementedBy: Number?,
Expand Down Expand Up @@ -286,6 +281,7 @@ class AppsFlyerKit :
attributeValueList: MutableList<String>?,
user: FilteredMParticleUser?,
) {
// No-op: this kit does not implement this feature.
}

override fun onSetAllUserAttributes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,12 @@ class ApptimizeKit :

override fun getName(): String = KIT_NAME

/**
* Not supported by the Apptimize kit.
*/
override fun setUserAttributeList(
key: String,
list: List<String>,
override fun onSetUserAttributeList(
attributeKey: String,
attributeValueList: List<String>,
user: FilteredMParticleUser,
) {
// not supported
// not supported by the Apptimize kit
}

override fun supportsAttributeLists(): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@
)
}

override fun setUserAttributeList(
s: String,
list: List<String>,
) {}
override fun onSetUserAttributeList(
attributeKey: String,
attributeValueList: List<String>,
user: FilteredMParticleUser,
) {
}

Check failure on line 182 in kits/branch/branch-5/src/main/kotlin/com/mparticle/kits/BranchMetricsKit.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a nested comment explaining why this function is empty or complete the implementation.

See more on https://sonarcloud.io/project/issues?id=mParticle_mparticle-android-sdk&issues=AZ1FIUxjARYADZ5gUV0E&open=AZ1FIUxjARYADZ5gUV0E&pullRequest=690

override fun supportsAttributeLists(): Boolean = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ open class AppboyKit :
}
}

override fun setUserAttributeList(
private fun setUserAttributeList(
key: String,
list: List<String>,
) {
Expand Down Expand Up @@ -529,7 +529,10 @@ open class AppboyKit :
attributeValueList: MutableList<String>?,
user: FilteredMParticleUser?,
) {
// No-op: this kit does not implement this feature.
if (attributeKey == null || attributeValueList == null) {
return
}
setUserAttributeList(attributeKey, attributeValueList)
}

override fun onSetAllUserAttributes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ open class AppboyKit :
}
}

override fun setUserAttributeList(
private fun setUserAttributeList(
key: String,
list: List<String>,
) {
Expand Down Expand Up @@ -529,7 +529,10 @@ open class AppboyKit :
attributeValueList: MutableList<String>?,
user: FilteredMParticleUser?,
) {
// No-op: this kit does not implement this feature.
if (attributeKey == null || attributeValueList == null) {
return
}
setUserAttributeList(attributeKey, attributeValueList)
}

override fun onSetAllUserAttributes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ open class AppboyKit :
}
}

override fun setUserAttributeList(
private fun setUserAttributeList(
key: String,
list: List<String>,
) {
Expand Down Expand Up @@ -529,7 +529,10 @@ open class AppboyKit :
attributeValueList: MutableList<String>?,
user: FilteredMParticleUser?,
) {
// No-op: this kit does not implement this feature.
if (attributeKey == null || attributeValueList == null) {
return
}
setUserAttributeList(attributeKey, attributeValueList)
}

override fun onSetAllUserAttributes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ open class AppboyKit :
}
}

override fun setUserAttributeList(
private fun setUserAttributeList(
key: String,
list: List<String>,
) {
Expand Down Expand Up @@ -529,7 +529,10 @@ open class AppboyKit :
attributeValueList: MutableList<String>?,
user: FilteredMParticleUser?,
) {
// No-op: this kit does not implement this feature.
if (attributeKey == null || attributeValueList == null) {
return
}
setUserAttributeList(attributeKey, attributeValueList)
}

override fun onSetAllUserAttributes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@
}
}

override fun setUserAttributeList(
key: String,
list: List<String>,
) {}
override fun onSetUserAttributeList(
attributeKey: String,
attributeValueList: List<String>,
user: FilteredMParticleUser,
) {
}

Check failure on line 102 in kits/comscore/comscore-6/src/main/kotlin/com/mparticle/kits/ComscoreKit.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a nested comment explaining why this function is empty or complete the implementation.

See more on https://sonarcloud.io/project/issues?id=mParticle_mparticle-android-sdk&issues=AZ1FIU22ARYADZ5gUV0G&open=AZ1FIU22ARYADZ5gUV0G&pullRequest=690

override fun supportsAttributeLists(): Boolean = !isEnterprise

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@
// No-op: this kit does not implement this feature.
}

override fun setUserAttributeList(
s: String,
list: List<String>,
) {}
override fun onSetUserAttributeList(
attributeKey: String,
attributeValueList: List<String>,
user: FilteredMParticleUser,
) {
}

Check failure on line 90 in kits/kochava/kochava-5/src/main/kotlin/com/mparticle/kits/KochavaKit.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a nested comment explaining why this function is empty or complete the implementation.

See more on https://sonarcloud.io/project/issues?id=mParticle_mparticle-android-sdk&issues=AZ1FIU2DARYADZ5gUV0F&open=AZ1FIU2DARYADZ5gUV0F&pullRequest=690

override fun supportsAttributeLists(): Boolean = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,22 @@ class LocalyticsKit :
}
}

override fun setUserAttributeList(
private fun setUserAttributeList(
key: String,
list: List<String>,
) {
val array = list.toTypedArray()
Localytics.setProfileAttribute(key, array)
}

override fun onSetUserAttributeList(
attributeKey: String,
attributeValueList: List<String>,
user: FilteredMParticleUser,
) {
setUserAttributeList(attributeKey, attributeValueList)
}

override fun supportsAttributeLists(): Boolean = true

override fun setAllUserAttributes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,6 @@ open class SingularKit :
): List<ReportingMessage> = emptyList()

//endregion
//endregion
//region Deprecated Attribute Listener
override fun setUserAttributeList(
s: String,
list: List<String>,
) {}

override fun onIncrementUserAttribute(
key: String?,
incrementedBy: Number?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,10 @@ class UrbanAirshipKit :
}
}

override fun setUserAttributeList(
s: String,
list: List<String>,
override fun onSetUserAttributeList(
attributeKey: String,
attributeValueList: List<String>,
user: FilteredMParticleUser,
) {
// not supported
}
Expand Down
Loading