feat: implement tracking plugins for Flutter SDK#148
Conversation
madhuchavva
left a comment
There was a problem hiding this comment.
Inline review comments on plugin lifecycle, event delivery semantics, and documentation gaps.
|
|
||
| @override | ||
| void initialize(String clientKey) { | ||
| if (clientKey.isEmpty) return; |
There was a problem hiding this comment.
Thanks for adding the plugin foundation here. I think the overall direction makes sense, but this timer lifecycle needs to be explicit before the API lands. initialize() starts a periodic timer and the only cleanup path is user-called dispose(), which is easy to miss in Flutter app/session lifecycles, tests, and hot reload scenarios. Can we document dispose() prominently in the README/API docs and make the expected lifecycle clear?
| _flushTimer = null; | ||
| } | ||
|
|
||
| void _flushAsync() { |
There was a problem hiding this comment.
_flushAsync() drains the queue before _post(). If the request fails, the batch is permanently dropped. That may be acceptable for best-effort analytics, but it should be intentional and documented. If we expect stronger delivery, we should retry or requeue with bounds.
| @@ -96,6 +99,12 @@ class GBSDKBuilderApp { | |||
| this.featureUsageCallback = featureUsageCallback; | |||
There was a problem hiding this comment.
Since this PR adds public exports plus addPlugin()/dispose(), can we add README coverage for setup, custom ingest host, batching, dispose requirements, what attributes are sent, and failure/drop behavior? This gives users enough context to use the new API without lifecycle or privacy surprises.
madhuchavva
left a comment
There was a problem hiding this comment.
Requesting changes based on the inline review comments. The notes call out functional gaps or compatibility/documentation risks that should be addressed before merge.
Summary
Implements a plugin system for the Flutter SDK, mirroring the Swift SDK implementation.
Changes
GrowthBookPlugin— abstract class with lifecycle hooks:initialize,onExperimentViewed,onFeatureEvaluated,closePluginRegistry— manages registered plugins with per-plugin error isolationGrowthBookTrackingPlugin— built-in plugin that batches events and sends them to the GrowthBook ingest endpoint(
POST /track?client_key=...)GrowthBookTrackingPluginConfig— configuration class forGrowthBookTrackingPlugin(ingestorHost, batchSize,batchTimeout)
GBSDKBuilderApp.addPlugin()— fluent builder method for registering pluginsGrowthBookSDK.dispose()— async, flushes and closes all registered pluginsUsage