Skip to content

feat: Add eventSource to LDConfig - #359

Merged
joker23 merged 8 commits into
mainfrom
skz/sdk-3442/event-source-factory-config
Nov 12, 2026
Merged

joker23 merged 8 commits into
mainfrom
skz/sdk-3442/event-source-factory-config

Conversation

@joker23

@joker23 joker23 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds an optional eventSource to LDConfig and passes it to the common config. Exports SSEClient and SseClientBuilder from the Flutter package so an app can pass SSEClient.http.
  • The API docs describe the web default, the fallbacks it causes for useReport and usePost, and that a web build that leaves the option null does not include the HTTP-based client. Most applications do not need it.
  • Default behavior is unchanged when the option is not set.

Additional context

This PR also moves the exact pin of launchdarkly_common_client in flutter_client_sdk from 1.15.1 to 1.16.0, which ships the eventSource option on LDCommonConfig.

This PR is the bottom of a stack. #360 builds on it.

Related tickets

  • sdk-3442

Note

Overview
The Flutter SDK now exposes an optional eventSource on LDConfig, forwarding to the shared common config so apps can choose which SSE client handles flag streaming.

SSEClient and SseClientBuilder are re-exported from the package entrypoint (e.g. so web apps can pass SSEClient.http for fetch()-based streaming). API docs spell out the web default (EventSource), related fallbacks for useReport / usePost, and that leaving the option null keeps the HTTP client out of web builds.

Behavior is unchanged when eventSource is omitted; tests assert default null and that a supplied builder is retained.

Reviewed by Cursor Bugbot for commit 11a4bd3. Bugbot is set up for automated code reviews on this repo. Configure here.

@joker23
joker23 added this pull request to stack #361 November 2, 2026 20:17
@joker23
joker23 force-pushed the skz/sdk-3442/event-source-factory-config branch 5 times, most recently from 5600aed to 144b3e7 Compare November 5, 2026 18:02
@joker23 joker23 changed the title feat: Add eventSourceFactory to LDConfig feat: Add useHttpStreamingOnWeb to LDConfig Nov 5, 2026
@joker23
joker23 force-pushed the skz/sdk-3442/event-source-factory-config branch 4 times, most recently from 6f9380a to 3d8a31d Compare November 5, 2026 22:48
@joker23
joker23 marked this pull request as ready for review November 5, 2026 22:54
@joker23
joker23 requested a review from a team as a code owner November 5, 2026 22:54

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@joker23
joker23 force-pushed the skz/sdk-3442/event-source-factory-config branch 2 times, most recently from d2be8ea to 909eabb Compare November 9, 2026 14:55
devin-ai-integration[bot]

This comment was marked as resolved.

@joker23 joker23 changed the title feat: Add useHttpStreamingOnWeb to LDConfig feat: Add eventSource to LDConfig Nov 9, 2026
@joker23
joker23 force-pushed the skz/sdk-3442/event-source-factory-config branch 3 times, most recently from 2b1de79 to 9869a58 Compare November 10, 2026 20:44
Base automatically changed from skz/sdk-3441/sse-client-factory to main November 12, 2026 16:48
joker23 added a commit that referenced this pull request Nov 12, 2026
… streaming (#358)

## Summary

- Adds `eventSource` to `LDCommonConfig`, an optional
`SseClientBuilder`. When it is null, the SDK uses the default client for
the platform. On web, that is the browser `EventSource`, which cannot
send a request body or report an HTTP error. An app passes
`SSEClient.http` to stream with `fetch()` instead, so `useReport` and
`usePost` work on web. On other platforms the default client is already
`SSEClient.http`.
- The app passes the implementation, so a web build that leaves the
option null never references the HTTP SSE client and the compiler
removes it. A runtime bool would keep both clients reachable. Measured
with `dart compile js -O2` against `common_client`: 324 KB without the
option, 354 KB with `SSEClient.http`.
- `SSEClient` and `SseClientBuilder` are exported from `common_client`.
No other SSE type is exported.
- A supplied builder is treated as able to send POST and REPORT. Without
one, `useReport` on web falls back to GET with a warning, and `usePost`
on web skips the streaming sources and polls, as before.
- On web, the SDK drops the application tags header from the streaming
request. The CORS allow-list of the streaming service does not include
it. The unused `streamingReportSupported` platform getters are removed.
- FDv1 streaming uses the client-side ID as the environment ID when the
connect headers are present but lack it, as happens after CORS
filtering.
- Both streaming data sources build their client through the same
builder type, so tests inject a fake client the same way on both paths.
- Adds a Chrome test file for the web-only decisions and a CI step that
runs it with `dart test -p chrome`.

## Additional context

This PR moves the exact pin of `launchdarkly_event_source_client` in
`common_client` from 3.0.1 to 3.1.0, which ships `SSEClient.http`.

This PR is the bottom of a stack. #359 and #360 build on it.

## Related tickets

- sdk-3441

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Adds **`LDCommonConfig.eventSource`**, an optional `SseClientBuilder`,
and wires it through FDv1 `StreamingDataSource` and FDv2
`FDv2DataSystem` so apps can supply **`SSEClient.http`** on web and
enable **POST/REPORT** streaming instead of default browser **GET** or
polling fallbacks.
> 
> Introduces **`streaming_client.dart`** with shared
**`streamingRequestHeaders`** (drops **`x-launchdarkly-tags`** on web
for CORS) and **`streamingCustomMethodSupported`** to decide POST/REPORT
vs fallbacks. Platform defaults replace **`streamingReportSupported`**
with **`streamingPostSupported`** and
**`streamingTagsHeaderSupported`**. FDv1 streaming now falls back to the
client-side ID for environment ID when connect headers omit it after
CORS filtering.
> 
> Exports **`SseClientBuilder`** and **`SSEClient`**, bumps
**`launchdarkly_event_source_client`** to **3.1.0**, and adds Chrome CI
plus VM/browser tests for web-only streaming behavior.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1cfae3d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@joker23
joker23 force-pushed the skz/sdk-3442/event-source-factory-config branch from 9869a58 to 11a4bd3 Compare November 12, 2026 16:48

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 1 new potential issue.

Devin Review

…tory docs

- Event, MessageEvent and OpenEvent collide with package:web and dart:html
  in web apps. Only an SSEClient implementer needs them.
- The LDConfig doc links to the SSEClientFactory contract and warns not to
  log the request.
- The example states why it opts in to the HTTP client on web.
- Add an export test and a start-to-close test for the factory.
@joker23
joker23 force-pushed the skz/sdk-3442/event-source-factory-config branch from 11a4bd3 to 6be783a Compare November 12, 2026 19:12

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

⚠️ 1 issue in files not directly in the diff

⚠️ Custom streaming clients survive source shutdown

When a context changes or streaming stops, StreamingDataSource never closes the supplied SSEClient. Canceling its subscription does not release resources owned outside that subscription.

Devin Review

@joker23
joker23 merged commit 3f36279 into main Nov 12, 2026
10 checks passed
@joker23
joker23 deleted the skz/sdk-3442/event-source-factory-config branch November 12, 2026 20:05
joker23 pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[4.22.0](4.21.1...4.22.0)
(2026-11-12)


### Features

* Add eventSource to LDConfig
([#359](#359))
([3f36279](3f36279))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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