Repository navigation
feat: Spec getExperimentFlag, trackEvent and trackExposureEvent #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5d4ba64
feat: Spec getExperimentFlag, trackEvent and trackExposureEvent
openhands-agent 3342bac
feat: Run @events scenarios against Flagsmith's live events pipeline
openhands-agent e6ef73b
Merge main into openhands/issue-13
flagsmithsmith[bot] 89db70c
Fix a stale comment on the events client step
flagsmithsmith[bot] 0cd8cc9
feat: Spec that getExperimentFlag records the exposure
flagsmithsmith[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| @events | ||
| Feature: Get an experiment flag | ||
| An SDK resolves a feature for an identity and records the exposure. | ||
|
|
||
| Background: | ||
| Given a Flagsmith environment | ||
| And the SDK sends events to Flagsmith | ||
|
|
||
| Scenario: An experiment flag is resolved for the identity, with its traits | ||
| Given the environment has the following features: | ||
| | feature | enabled | value | | ||
| | banner | true | "hello" | | ||
| And a segment "premium_users" where trait "plan" equals "premium" | ||
| And segment "premium_users" overrides feature "banner" with enabled true and value "hello premium user" | ||
| When the application gets the experiment flag "banner" for identity "user_123" with traits: | ||
| | trait | value | | ||
| | plan | "premium" | | ||
| Then the application receives the following flags: | ||
| | feature | enabled | value | | ||
| | banner | true | "hello premium user" | | ||
| And Flagsmith has identity "user_123" with the following traits: | ||
| | trait | value | | ||
| | plan | "premium" | | ||
|
|
||
| Scenario: An identity in a running experiment is exposed to the variant it was served | ||
| Given the environment has the following features: | ||
| | feature | enabled | value | | ||
| | banner | true | "control" | | ||
| And a running experiment on feature "banner" serving variant "treatment" with value "hello treatment" | ||
| When the application gets the experiment flag "banner" for identity "user_123" with traits: | ||
| | trait | value | | ||
| | plan | "premium" | | ||
| Then the application receives the following flags: | ||
| | feature | enabled | value | | ||
| | banner | true | "hello treatment" | | ||
| And Flagsmith has received the following events: | ||
| | event | feature | identifier | value | traits | | ||
| | $flag_exposure | banner | user_123 | "treatment" | {"plan": "premium"} | | ||
|
|
||
| Scenario: An identity outside a running experiment is not exposed | ||
| Given the environment has the following features: | ||
| | feature | enabled | value | | ||
| | banner | true | "hello" | | ||
| When the application gets the experiment flag "banner" for identity "user_123" with traits: | ||
| | trait | value | | ||
| | plan | "premium" | | ||
| Then the application receives the following flags: | ||
| | feature | enabled | value | | ||
| | banner | true | "hello" | | ||
| And Flagsmith has received no events | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| @events | ||
| Feature: Track an event | ||
| An SDK sends an application's tracking events to Flagsmith. | ||
|
|
||
| Background: | ||
| Given a Flagsmith environment | ||
| And the SDK sends events to Flagsmith | ||
|
|
||
| Scenario: A tracked event reaches Flagsmith | ||
| When the application tracks event "checkout_completed" for identity "user_123" with value 42 and metadata: | ||
| | key | value | | ||
| | currency | "GBP" | | ||
| Then Flagsmith has received the following events: | ||
| | event | identifier | value | metadata | | ||
| | checkout_completed | user_123 | "42" | {"currency": "GBP"} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| @events | ||
| Feature: Track an exposure event | ||
| An SDK records which variant of a feature an identity was shown, as a "$flag_exposure" event. | ||
|
|
||
| Background: | ||
| Given a Flagsmith environment | ||
| And the SDK sends events to Flagsmith | ||
|
|
||
| Scenario: An exposure reaches Flagsmith as a $flag_exposure event | ||
| When the application tracks an exposure of feature "banner" for identity "user_123" with value "control" and metadata: | ||
| | key | value | | ||
| | experiment_id | 1 | | ||
| Then Flagsmith has received the following events: | ||
| | event | feature | identifier | value | metadata | | ||
| | $flag_exposure | banner | user_123 | "control" | {"experiment_id": 1} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.