Skip to content

Do not merge before v2 release feat: register plugin dynamically#278

Open
abelonogov-ld wants to merge 15 commits into
mainfrom
andrey/register-plugin
Open

Do not merge before v2 release feat: register plugin dynamically#278
abelonogov-ld wants to merge 15 commits into
mainfrom
andrey/register-plugin

Conversation

@abelonogov-ld
Copy link
Copy Markdown
Contributor

@abelonogov-ld abelonogov-ld commented May 28, 2026

Summary

Adds runtime plugin registration through LDClient.registerPlugin. This API is not supposed to be used by Customers.

  • Stores plugin environment metadata during client construction so runtime plugins receive the same SDK, application, and credential metadata as config-time plugins.
  • Registers plugin-provided hooks before invoking plugin.register, so hooks are active during registration.
  • Skips plugin registration if reading plugin.hooks fails, while preserving existing safe handling for registration exceptions.

Test Plan

  • Added tests for runtime plugin registration metadata.
  • Added tests verifying runtime plugin hooks are active after registration.
  • Added coverage that hooks are installed before plugin.register runs.
  • Added failure coverage for throwing hooks getters and throwing register methods.
  • Ran:
flutter test test/ld_client_plugin_test.dart


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches SDK plugin/hook registration and evaluation order during `register`, which can affect observability plugins; changes are covered by tests and failures are contained via existing safe-registration helpers.
> 
> **Overview**
> Adds **`LDClient.registerPlugin`** so plugins can be attached after the client is built (intended for internal use, not customer-facing). The client now keeps **`PluginEnvironmentMetadata`** from construction and reuses it for runtime plugins so they get the same SDK, app, and credential metadata as config-time plugins.
> 
> **`registerPlugin`** installs bundled hooks via **`addHook`** before calling **`Plugin.register`**, skips registration if **`plugin.hooks`** throws, and logs (without rethrowing) if **`register`** throws. Tests cover metadata, hook activation, hook-before-register ordering, and both failure paths.
> 
> Also bumps **`launchdarkly_flutter_client_sdk`** to **4.16.0** / **`launchdarkly_common_client`** **1.10.0**, refreshes contract-test **`pubspec.lock`** files, and ignores regenerated CocoaPods **`Podfile`** / **`Podfile.lock`** in the Flutter example **ios** and **macos** trees.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c815251ba62a9bba334e13d4481ef704218dbaca. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

@abelonogov-ld abelonogov-ld requested a review from a team as a code owner May 28, 2026 23:48
Comment thread packages/flutter_client_sdk/lib/src/ld_client.dart Outdated
…y/flutter-client-sdk into andrey/register-plugin

* 'andrey/register-plugin' of ssh://github.com/launchdarkly/flutter-client-sdk:
  fix: Update launchdarkly_dart_common to version 1.8.1 (#277)
  chore(main): release launchdarkly_dart_common 1.8.1 (#273)
  feat: Update launchdarkly_event_source_client to version 2.1.0 (#276)
Comment thread packages/common_client/lib/launchdarkly_common_client.dart
Comment thread packages/flutter_client_sdk/example/ios/Podfile Outdated
Comment thread packages/flutter_client_sdk/lib/src/ld_client.dart Outdated
Comment thread apps/flutter_client_contract_test_service/pubspec.lock
abelonogov-ld and others added 5 commits May 29, 2026 13:51
Add safeGetPluginHooks to handle a single plugin and return null on
error, and reuse it within safeGetHooks. Export the new helper (and
safeGetPluginName) from the package barrel file.

Co-authored-by: Cursor <cursoragent@cursor.com>
* andrey/safe-get-plugin-hooks:
  refactor: extract safeGetPluginHooks helper in common_client
Co-authored-by: Cursor <cursoragent@cursor.com>
* andrey/safe-get-plugin-hooks:
  chore: apply dart format
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0ea85db. Configure here.

Comment thread packages/common_client/lib/launchdarkly_common_client.dart
abelonogov-ld and others added 4 commits May 29, 2026 14:28
Co-authored-by: Cursor <cursoragent@cursor.com>
Roll back the CocoaPods integration and Flutter-migration changes that
leaked in from running the example on iOS/macOS locally, and ignore the
regenerated Podfile/Podfile.lock so they are not committed again.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld abelonogov-ld reopened this May 29, 2026
@abelonogov-ld abelonogov-ld changed the title feat: register plugin dynamically Do not merge before v2 release feat: register plugin dynamically May 29, 2026
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