Skip to content

feat: Support getExperimentFlag, trackEvent and trackExposure methods - #252

Closed
flagsmithsmith[bot] wants to merge 4 commits into
mainfrom
openhands/sdk-spec-v0.8.0
Closed

flagsmithsmith[bot] wants to merge 4 commits into
mainfrom
openhands/sdk-spec-v0.8.0

Conversation

@flagsmithsmith

Copy link
Copy Markdown
Contributor

Contributes to Flagsmith/sdk-spec#13
Contributes to Flagsmith/sdk-spec#23

renovate Bot and others added 3 commits November 11, 2026 12:15
Its entry in Flagsmith/sdk-spec's compatibility matrix at v0.8.0: `core or events or local-evaluation`.
Spec v0.7.1 runs the `@events` scenarios for this SDK: getting an
experiment flag, tracking an event and tracking an exposure event, all
with events enabled. The SDK already implements these (#226), so the
steps file wires each step to FlagsmithClient.getExperimentFlag,
trackEvent and trackExposureEvent, and creates the events-enabled client
through FlagsmithConfig, next to the local evaluation client.

(cherry picked from commit 0c48af8)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 29cbe7b)
@flagsmithsmith flagsmithsmith Bot added the sdk-spec Bumps of the Flagsmith SDK behavioural spec label Nov 11, 2026
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 4daf4898-45aa-4db2-bedf-2d56b21659cf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@codspeed

codspeed Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 15 untouched benchmarks


Comparing openhands/sdk-spec-v0.8.0 (88fa258) with main (1c633a1)

Open in CodSpeed

Spec v0.8.0 specifies how SDKs deliver events. The event processor now:

- Times out each events request after 3 s, and gives a batch 3 attempts,
  backing off from 1 s, doubling, with full jitter. Network errors,
  timeouts, 408, 429, 500, 502, 503 and 504 are retried.
- Keeps a batch whose last attempt failed transiently in the buffer,
  ahead of newer events, for the next flush, unless that attempt got a
  500. Any other error response drops the batch.
- Stops event tracking, dropping the buffer, on a 401 or 403.
- Sends one batch at a time, and caps the buffer at 1000 events by
  dropping the oldest, kept events included.
- Never fails `flushEvents()`, which waits for the send, retries
  included.

`FlagsmithClient.close(timeout, unit)` sends the buffered events for at
most the timeout, then abandons the request in flight. `close()` waits
for one batch's worst case, 12 s.

The spec steps file wires the new steps: flushing events, closing with
a timeout, tracking a range of events, and a client with both local
evaluation and events enabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@flagsmithsmith

Copy link
Copy Markdown
Contributor Author

Pushed 88fa258 to fix the sdk-spec / Spec v0.8.0 check. It was failing because 15 scenarios use steps the SDK did not implement: flushing events, closing with a timeout, tracking a range of events, and creating a client with local evaluation and events enabled.

SDK changes (EventProcessor), following Flagsmith/sdk-spec#23 and the v0.8.0 event_delivery and event_shutdown features:

  • Each events request times out after 3 s. OkHttp's own connection retry is turned off, so every attempt is one request.
  • A batch gets 3 attempts. The wait before each retry backs off from 1 s, doubling, with full jitter. Network errors, timeouts, 408, 429, 500, 502, 503 and 504 are retried.
  • If the last attempt fails transiently, the batch stays in the buffer, ahead of newer events, for the next flush. The exception is a 500 on the last attempt: then the batch is dropped. Any other error status drops the batch at once.
  • A 401 or 403 drops the buffer and stops event tracking.
  • One batch is in flight at a time (before, it was 2). The buffer holds at most 1000 events and drops the oldest when full, kept events included.
  • flushEvents() waits for the send, retries included, and never completes exceptionally.

Client: new FlagsmithClient.close(long timeout, TimeUnit unit). It sends the buffered events for at most the timeout, then cancels the request in flight and drops what is left. close() waits for one batch's worst case, 12 s.

Steps: sdk-spec/Steps.java wires the four new steps to flushEvents(), close(timeout, SECONDS), trackEvent and a client built with both withLocalEvaluation(true) and withEnableEvents(true). Local experiment exposures already worked (#251), so they only needed the client step.

Tests: EventProcessorTest now covers the retry classification, the backoff sequence, the jitter bounds, the keep/drop rule for the last attempt, stopping on 401/403, dropping the oldest kept event when the buffer is full, and close(timeout) abandoning a hung request. I rewrote the tests that assumed 2 batches in flight for 1. FlagsmithClientTest covers the new close overload.

Locally, mvn clean install passes (except EngineTest, which needs the engine-test-data submodule I did not check out) and so does the release build. The spec at v0.8.0 with core or events or local-evaluation passes all 24 scenarios.

@flagsmithsmith
flagsmithsmith Bot marked this pull request as ready for review November 11, 2026 13:26
@flagsmithsmith
flagsmithsmith Bot requested a review from a team as a code owner November 11, 2026 13:26
@flagsmithsmith
flagsmithsmith Bot requested review from emyller and removed request for a team November 11, 2026 13:26
@flagsmithsmith

Copy link
Copy Markdown
Contributor Author

Superseded by #253, which carries this pull request's work over to the SDK spec's latest version.

@flagsmithsmith flagsmithsmith Bot closed this Nov 11, 2026
@flagsmithsmith
flagsmithsmith Bot deleted the openhands/sdk-spec-v0.8.0 branch November 11, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk-spec Bumps of the Flagsmith SDK behavioural spec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant