Skip to content

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

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

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

Conversation

@flagsmithsmith

@flagsmithsmith flagsmithsmith Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Contributes to Flagsmith/sdk-spec#13

Implements the SDK spec's v0.7.1 in this SDK.

It includes Renovate's bump, #213, which closes itself once this is merged.

Carries over earlier work: 8e598d8, 3b73d6a.

renovate Bot and others added 2 commits November 5, 2026 17:35
Its entry in Flagsmith/sdk-spec's compatibility matrix at v0.7.1: `core or events or local-evaluation`.
@flagsmithsmith flagsmithsmith Bot added the sdk-spec Bumps of the Flagsmith SDK behavioural spec label Nov 5, 2026
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Important

Review skipped

This PR was authored by a bot without an assigned CodeRabbit review seat. Ask an organization administrator to assign a seat to the bot. See the seat-assignment guide. After the seat is assigned, request a review again.

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: 97ac6ca3-111d-46df-a7b4-17f8d3acf48c

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

  • 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 5, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 15 untouched benchmarks


Comparing openhands/sdk-spec-v0.7.1 (7086f72) with main (745945c)

Open in CodSpeed

flagsmithsmith Bot and others added 2 commits November 5, 2026 20:11
Implements the `@events` capability of SDK spec v0.6.0, opt-in with
`EnableEvents`:

- `GetExperimentFlag` gets an identity's flag and records a
  `$flag_exposure` for the variant it was served, when the identity is
  enrolled in a running experiment on the feature.
- `TrackEvent` and `TrackExposureEvent` record application events and
  exposures; `FlushEvents` sends them now.
- Events are buffered and sent to the Flagsmith events API in batches,
  on a timer and when the buffer fills. Equal exposures are sent once
  per batch; a batch is retried once on a server or connection error,
  then dropped.
- `Flag` exposes the `Variant` and `Experiment` that remote identity
  evaluation returns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 78121ba)
…e ones

- Reject a non-positive EventsFlushInterval up front.
- FlushEvents now also waits for batches already being sent, e.g. after
  the buffer filled, so no events are lost on shutdown.
- Send logs and drops batches it cannot serialise or send for any other
  reason, instead of leaving an unobserved exception.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit eb67c78)
@flagsmithsmith

flagsmithsmith Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

The spec run failed because v0.7.1 adds the events capability to this SDK's scenarios (core or events or local-evaluation), and the steps file had no Create the SDK client with events enabled step. The SDK had no event tracking on main, so this re-applies the earlier event work.

Changes

  • Re-applied 8e598d8 (feat: Track events and experiment exposures) as 54834fa. It adds EnableEvents, GetExperimentFlag, TrackEvent, TrackExposureEvent and FlushEvents, with unit tests in EventsTests.cs. It also wires the spec's events steps in sdk-spec/steps.cs.
  • Re-applied 3b73d6a (fix: Wait for in-flight event batches on flush and drop unserialisable ones) as 40dfb66.
  • Resolved two conflicts with main:
    • SdkVersion.cs: kept the 9.1.0 release version and made it internal, because events report it as sdk_version.
    • steps.cs: kept both the local-evaluation client step and the events client step.
  • The events features have not changed since v0.6.0, the version the earlier work targeted, so the code needed no other changes.
  • v0.7.1's own change adds empty-string flag values (""). They already pass through unchanged in remote and local evaluation, so the SDK needed no change for them.

Verified locally: build and dotnet format --verify-no-changes pass, Flagsmith.Client.Test passes (72 passed, 1 skipped), and the spec at v0.7.1 passes all 9 scenarios with core or events or local-evaluation.

@flagsmithsmith
flagsmithsmith Bot marked this pull request as ready for review November 5, 2026 20:32
@flagsmithsmith
flagsmithsmith Bot requested a review from a team as a code owner November 5, 2026 20:32
@flagsmithsmith
flagsmithsmith Bot requested review from khvn26 and removed request for a team November 5, 2026 20:32
SDK spec v0.7.1 expects a flag whose value is an empty string to be
returned as "", not null or a default. Cover it for remote and local
evaluation.

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

flagsmithsmith Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

The last red run on 40dfb66 was not caused by the code. In Test (Flagsmith.Client.Test, 10.0), dotnet restore could not download Newtonsoft.Json from nuget.org ("Connection reset by peer"), so no tests ran. Test (Flagsmith.Client.Test, 9.0) passed all its tests (72 passed, 1 skipped), and the matrix then cancelled it because the other job had failed. I could not re-run the failed jobs: the token returns "Resource not accessible by integration".

Changes

  • 7086f72 adds unit tests for v0.7.1's one change: a flag whose value is an empty string is returned as "", in remote and local evaluation. The SDK already behaved this way, and the spec run confirms it, but no unit test covered it. The push also runs CI again.

Verified locally: dotnet format --verify-no-changes passes, and Flagsmith.Client.Test passes (74 passed, 1 skipped).

@flagsmithsmith flagsmithsmith Bot changed the title feat: Implement SDK spec v0.7.1 feat: Support getExperimentFlag, trackEvent and trackExposure methods Nov 6, 2026
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