Skip to content

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

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

flagsmithsmith[bot] wants to merge 4 commits into
mainfrom
openhands/sdk-spec-v0.9.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 2 commits November 12, 2026 09:38
Its entry in Flagsmith/sdk-spec's compatibility matrix at v0.9.0: `core events`.
@flagsmithsmith flagsmithsmith Bot added the sdk-spec Bumps of the Flagsmith SDK behavioural spec label Nov 12, 2026
@coderabbitai

coderabbitai Bot commented Nov 12, 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: a7b3ee48-7777-48ab-a1ca-2e656baca2c5

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

Retry transient failures and 5xx up to 3 attempts with full-jitter backoff
from 1 s, time each events request out after 3 s, keep a batch that still
fails transiently for the next flush ahead of newer events, drop rejected
batches and those whose last attempt gets a 500, stop event tracking on
401/403, cap the buffer by dropping the oldest event, and send one batch
at a time.

Wire the spec's new flush, close and numbered-events steps, and silence
Flutter 3.47's deprecation of package:flutter/material.dart in the example,
whose replacement needs a newer Flutter than the example supports.

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

Copy link
Copy Markdown
Contributor Author

Pushed d5a47f6 to fix both red checks.

sdk-spec / Spec v0.9.0: 11 new @events scenarios failed because the steps file lacked flushes events, closes the client with a timeout of {timeout} seconds and tracks events "event_{first}" to "event_{last}". Wiring those steps was not enough: the SDK's delivery rules also differed from the spec, because it retried once with a fixed 1 s wait, used the shared 20 s receive timeout, and had no buffer cap or 401/403 handling. EventProcessor now follows the rules from Flagsmith/sdk-spec#23 and #24:

  • Each events request times out after 3 s. A CancelToken deadline aborts the request and closes the connection.
  • Network errors, timeouts and 408/429/502/503/504 are transient. Other 5xx are server errors. Both are retried, up to 3 attempts, with a full-jitter backoff from 1 s that doubles each time.
  • If the last attempt fails transiently, the batch is kept ahead of newer events for the next flush. If the last attempt gets a server error such as 500, the batch is dropped.
  • Any other error status, such as 400, drops the batch at once. 401/403 drops the buffer and makes tracking a no-op.
  • The buffer holds eventsMaxBuffer events and drops the oldest when full. One batch is in flight at a time.
  • flush() sends the events buffered when it is called, retries included, after any batch already in flight. close(timeout) already returned within its timeout.

Unit tests in test/fg/flagsmith_experiments_test.dart cover each rule using a scripted Dio adapter. That includes the cases the spec says it cannot observe: doubling jitter bounds, one batch in flight, and a kept batch going ahead of events tracked during the send. Two existing tests encoded the old "retry once" behaviour, so I updated them. The README's flushing section now describes the new rules.

Locally: flutter analyze is clean on Flutter 3.44 and 3.50, all 219 flutter test tests pass, and the spec at v0.9.0 with TAGS="core events" passes 18 of 18 (6 deselected).

Dart Analyze: Flutter 3.50 (3.x in CI) deprecates package:flutter/material.dart in favour of package:material_ui, which flagged the example app. I tried migrating, but material_ui and google_fonts 9 need Flutter ≥ 3.47. The spec image runs Flutter 3.44 and resolves ./example in flutter pub get, so the migration would break the spec build. Instead, the example's imports get an // ignore: deprecated_member_use with a comment explaining why.

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

Copy link
Copy Markdown
Contributor Author

Pushed 64343ba: Flutter Test failed in one test, When POST fails once then succeeds. It swaps the mock to success 20 ms into the retry wait. The wait is now jittered (0–100 ms there), so it sometimes retried before the swap and got a third request. The test now picks the longest wait through the injectable Random, so it is deterministic. The experiments tests passed 5 runs in a row locally. The spec and Dart Analyze checks were already green on the previous push.

@flagsmithsmith
flagsmithsmith Bot marked this pull request as ready for review November 12, 2026 11:37
@flagsmithsmith
flagsmithsmith Bot requested a review from a team as a code owner November 12, 2026 11:37
@flagsmithsmith
flagsmithsmith Bot requested review from kyle-ssg and removed request for a team November 12, 2026 11: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