feat(MSDK-3297): pass unsavedVendorLIDecisions through denyAllForTCF#190
Conversation
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Review Summary by QodoPass unsavedVendorLIDecisions through denyAllForTCF on all layers
WalkthroughsDescription• Add unsavedVendorLIDecisions parameter to denyAllForTCF method across all layers • Update Android implementation to deserialize vendor LI decisions • Refactor iOS implementation with extracted helper method • Update TypeScript interfaces and implementations with vendor decisions support Diagramflowchart LR
A["denyAllForTCF API"] -->|Add Parameter| B["unsavedVendorLIDecisions"]
B -->|Android| C["Deserialize to Map"]
B -->|iOS| D["Extract LI Decisions"]
B -->|TypeScript| E["Update Interfaces"]
C --> F["Pass to Native Layer"]
D --> F
E --> F
File Changes1. android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.kt
|
Code Review by Qodo
1.
|
Sequence DiagramThis PR extends the denyAllForTCF flow to carry both purpose and vendor legitimate interest decisions from the JavaScript API through the React Native bridge into native execution. The core change is consistent parameter propagation across TypeScript, Android, and iOS layers before applying TCF deny all. sequenceDiagram
participant App
participant UsercentricsAPI
participant RNBridge
participant NativeModule
participant NativeSDK
App->>UsercentricsAPI: denyAllForTCF with purpose decisions and vendor decisions
UsercentricsAPI->>RNBridge: Forward both decision lists
RNBridge->>NativeModule: Invoke denyAllForTCF with both lists
NativeModule->>NativeSDK: Convert lists to LI maps and apply TCF deny all
NativeSDK-->>App: Return updated service consents
Generated by CodeAnt AI |
|
PR Summary: Add support for passing unsaved vendor legitimate-interest decisions into denyAllForTCF across Android, iOS, and JS interfaces.
Notes / migration impact
|
Nitpicks 🔍
|
android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.kt
Show resolved
Hide resolved
android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.kt
Show resolved
Hide resolved
|
Reviewed up to commit:054cfd53461551e74c956206f146b724df5447b7 Additional Suggestionios/RNUsercentricsModule.mm, line:57-87Objective-C bridge declarations were not updated. The RN export for denyAllForTCF currently declares only unsavedPurposeLIDecisions (see ios/RNUsercentricsModule.mm lines 57-87). Add the new parameter unsavedVendorLIDecisions:(NSArray)unsavedVendorLIDecisions to the RCT_EXTERN_METHOD declaration and regenerate the bridging headers so the JS-to-native bridge matches the Swift implementation.RCT_EXTERN_METHOD(denyAllForTCF:(double)fromLayer
consentType:(double)consentType
unsavedPurposeLIDecisions:(NSArray)unsavedPurposeLIDecisions
unsavedVendorLIDecisions:(NSArray)unsavedVendorLIDecisions
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)ios/RNUsercentricsModuleSpec.h, line:60-90The Objective-C module spec header still exposes the old denyAllForTCF signature (unsavedPurposeLIDecisions only). Update the method signature in RNUsercentricsModuleSpec.h to include unsavedVendorLIDecisions:(NSArray *)unsavedVendorLIDecisions so generated bindings and consumers have the correct signature.// Consent Actions
- (void)acceptAll:(double)consentType
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
- (void)acceptAllForTCF:(double)fromLayer
consentType:(double)consentType
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
- (void)denyAll:(double)consentType
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
- (void)denyAllForTCF:(double)fromLayer
consentType:(double)consentType
unsavedPurposeLIDecisions:(NSArray<NSDictionary *> *)unsavedPurposeLIDecisions
unsavedVendorLIDecisions:(NSArray<NSDictionary *> *)unsavedVendorLIDecisions
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
- (void)saveDecisions:(NSArray<NSDictionary *> *)decisions
consentType:(double)consentType
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
- (void)saveDecisionsForTCF:(NSDictionary *)tcfDecisions
fromLayer:(double)fromLayer
saveDecisions:(NSArray<NSDictionary *> *)saveDecisions
consentType:(double)consentType
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;ios/Manager/UsercentricsManager.swift, line:16-131The manager protocol/implementation currently declares denyAllForTCF(with only unsavedPurposeLIDecisions) (see this file lines 16-46 and 100-131 in reference). Update the protocol and all implementations to accept unsavedVendorLIDecisions: [KotlinInt: KotlinBoolean]? as an additional parameter. Update all fakes and example/samples that implement this protocol (FakeUsercentricsManager.swift in example/sample) to avoid runtime/compile failures.// ios/Manager/UsercentricsManager.swift
protocol UsercentricsManaging {
func getControllerId() -> String
func getConsents() -> [UsercentricsServiceConsent]
func getCMPData() -> UsercentricsCMPData
func getUserSessionData() -> String
func getUSPData() -> CCPAData
func getTCFData(callback: @escaping (TCFData) -> Void)
func getABTestingVariant() -> String?
func getAdditionalConsentModeData() -> AdditionalConsentModeData
func changeLanguage(language: String, onSuccess: @escaping (() -> Void), onFailure: @escaping ((Error) -> Void))
func acceptAllForTCF(fromLayer: TCFDecisionUILayer, consentType: UsercentricsConsentType) -> [UsercentricsServiceConsent]
func acceptAll(consentType: UsercentricsConsentType) -> [UsercentricsServiceConsent]
func denyAllForTCF(
fromLayer: TCFDecisionUILayer,
consentType: UsercentricsConsentType,
unsavedPurposeLIDecisions: [KotlinInt: KotlinBoolean]?,
unsavedVendorLIDecisions: [KotlinInt: KotlinBoolean]?
) -> [UsercentricsServiceConsent]
func denyAll(consentType: UsercentricsConsentType) -> [UsercentricsServiceConsent]
func saveDecisionsForTCF(
tcfDecisions: TCFUserDecisions,
fromLayer: TCFDecisionUILayer,
serviceDecisions: [UserDecision],
consentType: UsercentricsConsentType
) -> [UsercentricsServiceConsent]
func saveDecisions(decisions: [UserDecision], consentType: UsercentricsConsentType) -> [UsercentricsServiceConsent]
func saveOptOutForCCPA(isOptedOut: Bool, consentType: UsercentricsConsentType) -> [UsercentricsServiceConsent]
func setCMPId(id: Int32)
func setABTestingVariant(variant: String)
func track(event: UsercentricsAnalyticsEventType)
func clearUserSession(onSuccess: @escaping ((UsercentricsReadyStatus) -> Void), onError: @escaping ((Error) -> Void))
}
final class UsercentricsManager: UsercentricsManaging {
// ... other methods ...
func denyAllForTCF(
fromLayer: TCFDecisionUILayer,
consentType: UsercentricsConsentType,
unsavedPurposeLIDecisions: [KotlinInt: KotlinBoolean]?,
unsavedVendorLIDecisions: [KotlinInt: KotlinBoolean]?
) -> [UsercentricsServiceConsent] {
return UsercentricsCore.shared.denyAllForTCF(
fromLayer: fromLayer,
consentType: consentType,
unsavedPurposeLIDecisions: unsavedPurposeLIDecisions,
unsavedVendorLIDecisions: unsavedVendorLIDecisions
)
}
}
// example/ios/exampleTests/Fake/FakeUsercentricsManager.swift
final class FakeUsercentricsManager: UsercentricsManaging {
// ... other fakes ...
var denyAllForTCFConsentType: UsercentricsConsentType?
var denyAllForTCFFromLayer: TCFDecisionUILayer?
var denyAllForTCFUnsavedPurposeLIDecisions: [KotlinInt: KotlinBoolean]?
var denyAllForTCFUnsavedVendorLIDecisions: [KotlinInt: KotlinBoolean]?
var denyAllForTCFResponse: [UsercentricsServiceConsent]?
func denyAllForTCF(
fromLayer: TCFDecisionUILayer,
consentType: UsercentricsConsentType,
unsavedPurposeLIDecisions: [KotlinInt: KotlinBoolean]?,
unsavedVendorLIDecisions: [KotlinInt: KotlinBoolean]?
) -> [UsercentricsServiceConsent] {
self.denyAllForTCFConsentType = consentType
self.denyAllForTCFFromLayer = fromLayer
self.denyAllForTCFUnsavedPurposeLIDecisions = unsavedPurposeLIDecisions
self.denyAllForTCFUnsavedVendorLIDecisions = unsavedVendorLIDecisions
return denyAllForTCFResponse!
}
}
// sample/ios/sampleTests/Fake/FakeUsercentricsManager.swift
final class FakeUsercentricsManager: UsercentricsManaging {
// ... other fakes ...
var denyAllForTCFConsentType: UsercentricsConsentType?
var denyAllForTCFFromLayer: TCFDecisionUILayer?
var denyAllForTCFUnsavedPurposeLIDecisions: [KotlinInt: KotlinBoolean]?
var denyAllForTCFUnsavedVendorLIDecisions: [KotlinInt: KotlinBoolean]?
var denyAllForTCFResponse: [UsercentricsServiceConsent]?
func denyAllForTCF(
fromLayer: TCFDecisionUILayer,
consentType: UsercentricsConsentType,
unsavedPurposeLIDecisions: [KotlinInt: KotlinBoolean]?,
unsavedVendorLIDecisions: [KotlinInt: KotlinBoolean]?
) -> [UsercentricsServiceConsent] {
self.denyAllForTCFConsentType = consentType
self.denyAllForTCFFromLayer = fromLayer
self.denyAllForTCFUnsavedPurposeLIDecisions = unsavedPurposeLIDecisions
self.denyAllForTCFUnsavedVendorLIDecisions = unsavedVendorLIDecisions
return denyAllForTCFResponse!
}
}src/fabric/NativeUsercentricsModule.ts, line:21-51The Fabric/TurboModule declaration (src/fabric/NativeUsercentricsModule.ts) still exposes denyAllForTCF(fromLayer, consentType, unsavedPurposeLIDecisions) without the new unsavedVendorLIDecisions parameter (reference lines 21-51). Update this Fabric interface to match the changed signature so TurboModule consumers and type-checking remain consistent. After changing, rebuild TypeScript artifacts and ensure TurboModuleRegistry.get consumers are type-compatible.// src/fabric/NativeUsercentricsModule.ts
export interface Spec extends TurboModule {
// ...
// Consent Actions
acceptAll(consentType: number): Promise<Array<Object>>;
acceptAllForTCF(fromLayer: number, consentType: number): Promise<Array<Object>>;
denyAll(consentType: number): Promise<Array<Object>>;
denyAllForTCF(
fromLayer: number,
consentType: number,
unsavedPurposeLIDecisions: Array<Object>,
unsavedVendorLIDecisions: Array<Object>
): Promise<Array<Object>>;
saveDecisions(decisions: Array<Object>, consentType: number): Promise<Array<Object>>;
saveDecisionsForTCF(
tcfDecisions: Object,
fromLayer: number,
saveDecisions: Array<Object>,
consentType: number
): Promise<Array<Object>>;
// ...
}Others- Testing and example apps: many tests and example/sample code still call denyAllForTCF with the old 3-argument signature (see android test RNUsercentricsModuleTest.kt lines ~501-549 and ios RNUsercentricsModuleTests.swift lines ~304-363 in references). Update all unit tests, fakes, and example usages to include the new unsavedVendorLIDecisions parameter (use [] or null as appropriate). Run the test suites (both Android and iOS) after changes to catch regressions. |
📝 WalkthroughWalkthroughThe pull request extends the denyAllForTCF API to accept an additional unsavedVendorLIDecisions parameter and propagates vendor LI decision maps through TypeScript, native bridges (Android/iOS), manager, and core calls. Changes
Sequence Diagram(s)sequenceDiagram
participant JS as JS Layer
participant RN as RN Native Module
participant Platform as Platform Bridge (iOS/Android)
participant Core as Usercentrics Core
JS->>RN: denyAllForTCF(fromLayer, consentType, unsavedPurpose..., unsavedVendor...)
RN->>Platform: serialize arrays -> (purposeMap, vendorMap)
Platform->>Core: denyAllForTCF(fromLayer, consentType, purposeMap, vendorMap)
Core-->>Platform: updated services
Platform-->>RN: services (resolved)
RN-->>JS: Promise.resolve(services)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can generate a title for your PR based on the changes with custom instructions.Set the |
android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.kt
Show resolved
Hide resolved
android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModuleSpec.kt
Show resolved
Hide resolved
|
CodeAnt AI finished reviewing your PR. |
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ios/RNUsercentricsModule.swift`:
- Around line 175-180: The extractLIDecisionsMap helper currently drops entries
when "legitimateInterestConsent" is missing; update it so for each dict with an
"id" (function extractLIDecisionsMap), if "legitimateInterestConsent" is present
use its Bool value, otherwise treat it as false (like Android), and always
insert result[KotlinInt(int: Int32(id))] = KotlinBoolean(bool: consentValue) so
missing keys map to false instead of being omitted.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bf3278a2-345d-4905-a0a3-a7dcffaaab36
📒 Files selected for processing (5)
android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.ktandroid/src/main/java/com/usercentrics/reactnative/RNUsercentricsModuleSpec.ktios/RNUsercentricsModule.swiftsrc/NativeUsercentrics.tssrc/Usercentrics.tsx
|
CodeAnt AI is running Incremental review Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Sequence DiagramThis PR extends the denyAllForTCF flow to carry both unsaved purpose and vendor legitimate interest decisions from JavaScript through native bindings into the core SDK. As a result, returned service consents reflect both decision sets when deny all is executed. sequenceDiagram
participant App
participant JS SDK
participant Native Bridge
participant Usercentrics Core
App->>JS SDK: Call denyAllForTCF with purpose and vendor LI decisions
JS SDK->>Native Bridge: Forward fromLayer consentType and both decision lists
Native Bridge->>Native Bridge: Convert both decision lists to LI maps
Native Bridge->>Usercentrics Core: denyAllForTCF with purpose and vendor LI maps
Usercentrics Core-->>App: Return updated service consents
Generated by CodeAnt AI |
|
CodeAnt AI Incremental review completed. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ios/Manager/UsercentricsManager.swift`:
- Around line 115-117: The FakeUsercentricsManager mock's denyAllForTCF
signature doesn't match the UsercentricsManager protocol (missing
unsavedVendorLIDecisions); update FakeUsercentricsManager.den yAllForTCF to the
four-parameter signature (fromLayer: TCFDecisionUILayer, consentType:
UsercentricsConsentType, unsavedPurposeLIDecisions: [KotlinInt: KotlinBoolean]?,
unsavedVendorLIDecisions: [KotlinInt: KotlinBoolean]?) and add a stored property
denyAllForTCFUnsavedVendorLIDecisions: [KotlinInt: KotlinBoolean]? to capture
the argument; adjust any test usages to pass the new parameter and assign it
into the new property so the mock behavior matches UsercentricsCore/shared
expectations.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4fa9419a-eb72-4f24-b356-85d99f932600
📒 Files selected for processing (3)
ios/Manager/UsercentricsManager.swiftios/RNUsercentricsModule.mmsrc/fabric/NativeUsercentricsModule.ts
|
CodeAnt AI is running Incremental review Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.kt
Show resolved
Hide resolved
|
CodeAnt AI Incremental review completed. |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
ios/RNUsercentricsModule.swift (1)
205-210:⚠️ Potential issue | 🟠 MajorKeep missing LI flags consistent with Android.
android/src/main/java/com/usercentrics/reactnative/extensions/UserDecisionExtensions.kt defaults a missing
legitimateInterestConsenttofalse, but this helper drops the entry entirely. The same JS payload can therefore produce different deny-all inputs on iOS and Android.Suggested parity fix
private func extractLIDecisionsMap(_ decisions: [NSDictionary]) -> [KotlinInt: KotlinBoolean]? { guard !decisions.isEmpty else { return nil } return decisions.reduce(into: [:]) { result, dict in - if let id = dict["id"] as? Int, - let consent = dict["legitimateInterestConsent"] as? Bool { - result[KotlinInt(int: Int32(id))] = KotlinBoolean(bool: consent) - } + guard let id = dict["id"] as? Int else { return } + let consent = (dict["legitimateInterestConsent"] as? Bool) ?? false + result[KotlinInt(int: Int32(id))] = KotlinBoolean(bool: consent) } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ios/RNUsercentricsModule.swift` around lines 205 - 210, The extractLIDecisionsMap function currently drops entries when "legitimateInterestConsent" is missing, causing iOS to differ from Android; update extractLIDecisionsMap so that when a valid "id" is found but "legitimateInterestConsent" is absent or not a Bool, you still add an entry mapping KotlinInt(int: Int32(id)) to KotlinBoolean(bool: false) (retain skipping only when "id" is missing or invalid), ensuring parity with the Android UserDecisionExtensions behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@ios/RNUsercentricsModule.swift`:
- Around line 205-210: The extractLIDecisionsMap function currently drops
entries when "legitimateInterestConsent" is missing, causing iOS to differ from
Android; update extractLIDecisionsMap so that when a valid "id" is found but
"legitimateInterestConsent" is absent or not a Bool, you still add an entry
mapping KotlinInt(int: Int32(id)) to KotlinBoolean(bool: false) (retain skipping
only when "id" is missing or invalid), ensuring parity with the Android
UserDecisionExtensions behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6742151f-3703-45e9-bbeb-20cd3f485d82
📒 Files selected for processing (8)
android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.ktandroid/src/main/java/com/usercentrics/reactnative/RNUsercentricsModuleSpec.ktios/Manager/UsercentricsManager.swiftios/RNUsercentricsModule.mmios/RNUsercentricsModule.swiftsrc/NativeUsercentrics.tssrc/Usercentrics.tsxsrc/fabric/NativeUsercentricsModule.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/Usercentrics.tsx
- ios/Manager/UsercentricsManager.swift
- android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModuleSpec.kt
User description
Summary by CodeRabbit
New Features
Refactor
CodeAnt-AI Description
Pass unsaved vendor legitimate-interest decisions through TCF "Deny All"
What Changed
Impact
✅ Considers vendor legitimate-interest during TCF deny-all✅ Preserves unsaved vendor choices when denying all✅ Fewer incorrect vendor consents after deny-all💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.