Skip to content

feat(MSDK-4525): add controllerId to Flutter bridge options - #202

Open
uc-brunosilva wants to merge 2 commits into
masterfrom
feat/MSDK-4525-controllerid-bridge-support
Open

feat(MSDK-4525): add controllerId to Flutter bridge options#202
uc-brunosilva wants to merge 2 commits into
masterfrom
feat/MSDK-4525-controllerid-bridge-support

Conversation

@uc-brunosilva

Copy link
Copy Markdown
Contributor

Summary

Follow-up to MSDK-4525 — adds an optional controllerId parameter to Usercentrics.initialize(), mirroring the native mobile-sdk's new UsercentricsOptions.controllerId (landed in mobile-sdk PR #2440).

This lets Advanced-tier customers inject a previously-issued controllerID at SDK init to preserve identity across login/logout flows that clear local consent storage (shared-device / GDPR DSR compliance scenario).

Changes

Threaded controllerId: String? through the full Dart call chain:

  • lib/src/usercentrics.dart (public API + doc comment mirroring native semantics)
  • lib/src/platform/usercentrics_platform.dart
  • lib/src/internal/platform/method_channel_usercentrics.dart
  • lib/src/internal/bridge/initialize_bridge.dart
  • lib/src/internal/serializer/initialize_options_serializer.dart (Map key)

And into the native bridges:

  • Android (android/.../serializer/OptionsSerializer.kt) — forwards controllerId into native UsercentricsOptions.
  • iOS (ios/usercentrics_sdk/.../Serializer/InitializeOptionsSerializer.swift) — same, from the dictionary.

Extended existing Dart tests (fakes + assertions) and the Android bridge unit test to cover the new field.

Note: master is the repo's integration branch — there is no develop branch here. There's also no dedicated UsercentricsOptions Dart model class or build_runner codegen in this repo — options are passed as named parameters and serialized to a plain Map, so no .g.dart regeneration was needed.

Validation

  • flutter test — 64/64 passing.
  • flutter analyze lib/ test/ — no issues.
  • Android/iOS native test edits were hand-written to match existing conventions but not compiled/run in this session (no Gradle/Xcode build attempted, per scope).

Open items for reviewer

  • CHANGELOG.md has no "Unreleased" section (latest entry 2.30.0 is already released) — an entry should be added when release notes are prepared.
  • The native SDK version this repo currently pins may not yet publish controllerId — this bridge code is correct but inert until the native mobile-sdk release with the field is consumed.

🤖 Generated with Claude Code

Adds an optional controllerId String parameter to Usercentrics.initialize(),
mirroring the native SDK's UsercentricsOptions.controllerId (MSDK-4160/4525).
Lets Advanced-tier customers inject a previously-issued controllerID at SDK
init to preserve identity across login/logout flows that clear local
consent storage.

Threaded through the full Dart call chain:
- lib/src/usercentrics.dart (public API + doc comment)
- lib/src/platform/usercentrics_platform.dart (abstract platform interface)
- lib/src/internal/platform/method_channel_usercentrics.dart
- lib/src/internal/bridge/initialize_bridge.dart
- lib/src/internal/serializer/initialize_options_serializer.dart (Map key)

And into the native bridges:
- android/src/main/kotlin/.../serializer/OptionsSerializer.kt - forwards
  "controllerId" into UsercentricsOptions.controllerId
- ios/usercentrics_sdk/.../Serializer/InitializeOptionsSerializer.swift -
  forwards "controllerId" into UsercentricsOptions.controllerId

Extended existing tests (fakes + assertions) for the Dart layer and the
Android bridge unit test to cover the new field. No Dart model class or
build_runner codegen exists for options - they are passed as named
parameters and serialized to a plain Map, so no .g.dart regeneration was
needed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…trics

CI Lint job was failing: FakeUsercentrics (example/test/fake_usercentrics.dart)
also implements UsercentricsPlatform and was missed when controllerId was
added to the interface — flutter analyze flagged it as invalid_override.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@uc-brunosilva

Copy link
Copy Markdown
Contributor Author

Heads up — CI Test Android / Test iOS jobs are expected to fail (not a bug in this PR).

This bridge compiles android/.../OptionsSerializer.kt and ios/.../InitializeOptionsSerializer.swift directly against the native SDK, pinned here at 2.30.0 (android/build.gradle:1, ios/usercentrics_sdk.podspec). controllerId only exists on the unreleased native mobile-sdk branch (mobile-sdk PR #2440, not yet merged to develop) — so options.controllerId = ... will fail with Unresolved reference 'controllerId' against the published 2.30.0 artifact (same root cause already confirmed failing in the React Native bridge's equivalent CI job).

This isn't fixable by editing this PR further — it needs, in order:

  1. mobile-sdk PR #2440 merged to develop
  2. A new native SDK version released (e.g. 2.31.0) with controllerId
  3. This repo's usercentrics_version (Android) and podspec/pubspec version bumped to that release

Leaving this PR open as-is per team decision — CI will go green once the native SDK release lands and the version pin is bumped. Please don't merge before that. (The Lint/Format/Publish Dry Run jobs already pass — those don't touch native code.)

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants