feat(MSDK-3172): Consume and expose DPS metadata in AppSDK#193
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 · |
📝 WalkthroughWalkthroughA new Changes
Sequence Diagram(s)sequenceDiagram
participant JS as JavaScript Client
participant RNBridge as React Native Bridge
participant NativeManager as Native Manager<br/>(iOS/Android)
participant Core as Usercentrics Core
JS->>RNBridge: getDpsMetadata(templateId)
activate RNBridge
RNBridge->>NativeManager: getDpsMetadata(templateId)
activate NativeManager
NativeManager->>Core: getDpsMetadata(templateId)
activate Core
Core-->>NativeManager: [metadata] or null
deactivate Core
NativeManager-->>RNBridge: [metadata] or null
deactivate NativeManager
RNBridge-->>JS: Promise<metadata | null>
deactivate RNBridge
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 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)
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 |
Review Summary by QodoAdd getDpsMetadata method to consume and expose DPS metadata
WalkthroughsDescription• Add getDpsMetadata method to retrieve DPS metadata by template ID • Implement method across Android and iOS native modules • Add comprehensive unit tests for valid, null, and empty metadata cases • Expose method through TypeScript interfaces and Usercentrics SDK Diagramflowchart LR
A["Native Layer<br/>Android/iOS"] -->|getDpsMetadata| B["Manager Implementation<br/>UsercentricsManager"]
B -->|expose| C["React Native Module<br/>RNUsercentricsModule"]
C -->|bridge| D["TypeScript API<br/>Usercentrics.tsx"]
D -->|return| E["Metadata Dictionary<br/>Record or null"]
File Changes1. android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.kt
|
Code Review by Qodo
1. Metadata serialization loses fields
|
Sequence DiagramThis PR adds a new getDpsMetadata API to the App SDK and wires it end to end from JavaScript to the native Usercentrics core layer. The flow returns either a metadata object for a template id or null when no metadata is available. sequenceDiagram
participant App
participant UsercentricsAPI
participant NativeModule
participant UsercentricsCore
App->>UsercentricsAPI: Request DPS metadata with template id
UsercentricsAPI->>NativeModule: Ensure ready and call getDpsMetadata
NativeModule->>UsercentricsCore: Fetch DPS metadata for template id
UsercentricsCore-->>NativeModule: Metadata map or null
alt Metadata found
NativeModule-->>UsercentricsAPI: Resolve metadata object
else No metadata
NativeModule-->>UsercentricsAPI: Resolve null
end
UsercentricsAPI-->>App: Return DPS metadata result
Generated by CodeAnt AI |
|
PR Summary: Add support to retrieve DPS (data processor) metadata by templateId from native SDKs and expose it through the React Native bridge and TypeScript API.
|
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
|
Reviewed up to commit:8c529d1bb006b4275633046aefe94f9d09c866c2 |
android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.kt
Show resolved
Hide resolved
|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
example/ios/exampleTests/RNUsercentricsModuleTests.swift (1)
566-601: Add descriptive messages toXCTFailcalls.Static analysis flagged missing assertion messages. Adding descriptions helps identify which assertion failed when debugging test failures.
🔧 Proposed fix
func testGetDpsMetadataWithValidData() { fakeUsercentrics.getDpsMetadataResponse = ["partner": "appsflyer", "source": "campaign_1"] module.getDpsMetadata("template123") { result in guard let result = result as? NSDictionary else { - XCTFail() + XCTFail("Expected NSDictionary result") return } XCTAssertEqual("appsflyer", result["partner"] as! String) XCTAssertEqual("campaign_1", result["source"] as! String) } reject: { _, _, _ in XCTFail("Should not go here") } XCTAssertEqual("template123", fakeUsercentrics.getDpsMetadataTemplateId) }func testGetDpsMetadataWithEmptyMap() { fakeUsercentrics.getDpsMetadataResponse = [:] module.getDpsMetadata("template123") { result in guard let result = result as? NSDictionary else { - XCTFail() + XCTFail("Expected NSDictionary result") return } XCTAssertEqual(0, result.count) } reject: { _, _, _ in XCTFail("Should not go here") } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@example/ios/exampleTests/RNUsercentricsModuleTests.swift` around lines 566 - 601, Tests have XCTFail calls without descriptive messages which makes failures hard to diagnose; update the XCTFail usages in testGetDpsMetadataWithValidData, testGetDpsMetadataWhenNull, and testGetDpsMetadataWithEmptyMap to include clear descriptions (e.g., for reject closures use "Unexpected rejection in testGetDpsMetadataWithValidData/testGetDpsMetadataWhenNull/testGetDpsMetadataWithEmptyMap", and for guard failure use "Expected NSDictionary result in testGetDpsMetadataWithValidData"); ensure each XCTFail call across these functions includes a concise message identifying the test and failure reason.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.kt`:
- Around line 88-96: The getDpsMetadata ReactMethod references a non-existent
Usercentrics SDK method and will crash; either remove the entire getDpsMetadata
method from RNUsercentricsModule or replace its implementation by calling a
supported API (e.g., usercentricsProxy.instance.getCMPData() or
usercentricsProxy.instance.getConsents()) after confirming which API returns the
equivalent DPS metadata with Usercentrics support, then convert that result to a
WritableMap (using metadata.toWritableMap() or equivalent) and resolve the
promise; if you cannot confirm immediately, remove the method to prevent runtime
crashes and open a follow-up to reintroduce it once Usercentrics confirms the
correct API.
In `@sample/ios/sampleTests/RNUsercentricsModuleTests.swift`:
- Around line 570-572: Update the bare XCTFail() calls in
RNUsercentricsModuleTests.swift to include descriptive failure messages so
failures are actionable; specifically, modify the guard blocks that check "guard
let result = result as? NSDictionary else { XCTFail(); return }" (and the
similar guard at the other occurrence) to call XCTFail(...) with a short message
such as "expected 'result' to be NSDictionary but was nil or wrong type" or
test-specific context so the test output identifies what went wrong.
---
Nitpick comments:
In `@example/ios/exampleTests/RNUsercentricsModuleTests.swift`:
- Around line 566-601: Tests have XCTFail calls without descriptive messages
which makes failures hard to diagnose; update the XCTFail usages in
testGetDpsMetadataWithValidData, testGetDpsMetadataWhenNull, and
testGetDpsMetadataWithEmptyMap to include clear descriptions (e.g., for reject
closures use "Unexpected rejection in
testGetDpsMetadataWithValidData/testGetDpsMetadataWhenNull/testGetDpsMetadataWithEmptyMap",
and for guard failure use "Expected NSDictionary result in
testGetDpsMetadataWithValidData"); ensure each XCTFail call across these
functions includes a concise message identifying the test and failure reason.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c20c5ab4-9c6b-4591-bf9a-1596ddd9e455
📒 Files selected for processing (13)
android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.ktandroid/src/main/java/com/usercentrics/reactnative/RNUsercentricsModuleSpec.ktexample/ios/exampleTests/Fake/FakeUsercentricsManager.swiftexample/ios/exampleTests/RNUsercentricsModuleTests.swiftios/Manager/UsercentricsManager.swiftios/RNUsercentricsModule.swiftios/RNUsercentricsModuleSpec.hsample/ios/sampleTests/Fake/FakeUsercentricsManager.swiftsample/ios/sampleTests/RNUsercentricsModuleTests.swiftsrc/NativeUsercentrics.tssrc/Usercentrics.tsxsrc/__tests__/index.test.tssrc/fabric/NativeUsercentricsModule.ts
android/src/main/java/com/usercentrics/reactnative/RNUsercentricsModule.kt
Show resolved
Hide resolved
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
|
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 · |
|
CodeAnt AI Incremental review completed. |
User description
Summary by CodeRabbit
New Features
getDpsMetadata(templateId)method to retrieve metadata for a specified template ID. Returns metadata object or null if unavailable. Now available on iOS and Android platforms.CodeAnt-AI Description
Expose DPS metadata by template ID in the app SDK
What Changed
nullwhen no data exists.Impact
✅ Retrieve DPS metadata by template ID✅ Clear null responses for missing templates✅ Safer metadata handling in apps💡 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.