feat: inline user attribute removal in onRemoveUserAttribute#687
Conversation
Introduce KitIntegration.BaseAttributeListener as the common superinterface for AttributeListener and UserAttributeListener. Document it as a temporary contract to enable incremental migration and smaller PRs. Made-with: Cursor
Resolve via BaseAttributeListener before AttributeListener/UserAttributeListener branches in onUserAttributesReceived and setUserAttribute(list). Made-with: Cursor
UserAttributeListener.onRemoveUserAttribute now forwards to the existing AttributeListener.removeUserAttribute implementation for braze-38 through braze-41. Made-with: Cursor
Declare onRemoveUserAttribute on KitIntegration.BaseAttributeListener so AttributeListener and UserAttributeListener implementors must implement it. KitManagerImpl now dispatches removal once via BaseAttributeListener. AttributeListener-only kits delegate onRemoveUserAttribute to removeUserAttribute; AttributeListenerTestKit updated accordingly. Made-with: Cursor
Drop void removeUserAttribute(String) from KitIntegration.AttributeListener. Kits keep the same logic as private-style helpers (fun removeUserAttribute without override) and still satisfy BaseAttributeListener via onRemoveUserAttribute. AdobeKitBase implements onRemoveUserAttribute by delegating to removeUserAttribute. Made-with: Cursor
Move kit-specific handling from removed helper methods into BaseAttributeListener.onRemoveUserAttribute implementations. Rename AttributeListenerTestKit callback to removeUserAttributeListener. Fix Braze custom-key branch for Kotlin smart-cast in Braze callback. Made-with: Cursor
Document intentional empty overrides in Adobe, AppsFlyer, Branch, Braze, and Kochava kits to satisfy SonarQube analysis. Made-with: Cursor
PR SummaryMedium Risk Overview Updates multiple kits and test kits to implement the new removal callback signature (and adjusts dataplan-blocking tests accordingly), plus minor no-op/comment cleanups in several kit overrides. Written by Cursor Bugbot for commit 7ad01d4. This will update automatically on new commits. Configure here. |
Made-with: Cursor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| if (provider instanceof KitIntegration.UserAttributeListener) { | ||
| ((KitIntegration.UserAttributeListener) provider).onRemoveUserAttribute(key, FilteredMParticleUser.getInstance(mpid, provider)); | ||
| } | ||
| listener.onRemoveUserAttribute(key, FilteredMParticleUser.getInstance(mpid, provider)); |
There was a problem hiding this comment.
Nullable user passed to non-null Kotlin parameter
Medium Severity
FilteredMParticleUser.getInstance(mpid, provider) can return null (e.g. if MParticle.getInstance() is null or user lookup fails), but several AttributeListener-only kits (Adobe, Apptimize, Branch, Comscore, Kochava, Localytics, Urban Airship) now declare onRemoveUserAttribute with a non-null user: FilteredMParticleUser parameter. Kotlin's intrinsic null check on non-null parameters will throw a runtime exception if null is passed from the Java caller. Previously these kits received removeUserAttribute(String) with no user parameter, so this crash path is newly introduced.
Additional Locations (2)
Replace if/else chain with when for standard vs custom user attribute removal; behavior unchanged across braze 38-41 kits. Made-with: Cursor
|




Background
Attribute removal for kits is consolidated on
BaseAttributeListener.onRemoveUserAttributeso the SDK does not rely on a separateAttributeListener.removeUserAttributecontract. Kits now implement removal in one place, which aligns with the broader move towardUserAttributeListener-style APIs.What Has Changed
removeUserAttributefromAttributeListener; kits keep removal logic only inonRemoveUserAttribute.AttributeListenerTestKittest hook toremoveUserAttributeListenerand adjusted dataplan blocking tests.Screenshots/Video
N/A (SDK behavior change, no UI).
Checklist
Additional Notes
Target branch:
workstation/6.0-Release. Kits were validated withpublishMavenPublicationToMavenLocalandtestReleaseusing-Pmparticle.kit.mparticleFromMavenLocalOnly=true.Branch renamed to
feat/user-attribute-listener-on-remove-user-attribute(CI requiresfeat/notfeature/).