-
Notifications
You must be signed in to change notification settings - Fork 1
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
[RFC] feat: add support for strongly typed exp/gates #1
Open
daniel-statsig
wants to merge
6
commits into
main
Choose a base branch
from
statsig-typed
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
daniel-statsig
commented
Oct 22, 2024
@@ -0,0 +1,59 @@ | |||
import Foundation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: manually written by the implementor, but could be code generated by Statsig
daniel-statsig
commented
Oct 22, 2024
setupConstraints(for: labels) | ||
} | ||
|
||
private func evalAndAppendResults(texts: inout [String]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is where the actual strict types are used
daniel-statsig
force-pushed
the
statsig-typed
branch
from
October 22, 2024 22:53
10f2987
to
d07edbe
Compare
daniel-statsig
changed the title
feat: add support for strongly typed exp/gates
[RFC] feat: add support for strongly typed exp/gates
Oct 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Update - Oct 28
2d36d5d Added support for Feature Gate memoization. You can now specify that a gate should be memoized, as well as what UnitID to memoize on (Defaults to
userID
).e25676d Added default memoized experiment types for UserID (
TypedExperimentMemoizedByUserID
) and StableID (TypedExperimentMemoizedByStableID
). This removes the need to specify isisMemoizable
andmemoUnitIdType
Note:
SdkDemoSimpleGroupName
is an enum that only has two groups. It can be shared among many experiments since this is a common setup pattern.With this change, a developer can write their own type definitions for Statsig.
Usage
Gates
A type file is defined by the implementor.
Then the gates can be checked using
Statsig.typed
:Experiments
A type file is defined by the implementor.
Then the experiment can be checked using
Statsig.typed
:Strictly Typed Experiment Values
Its also possible to define the value object to be of a given type by adding a decodable type to the definition
Then you can use the value with the strict typing:
Experiment Memoization (Freezing/Locking)
By setting the
isMemoizable
field in yourTypedExperiment
to returntrue
. Statsig typed will only evaluate the experiment once, repeated calls to the same experiment will return the same result.If you would like the memoization to break when a specific ID type is changed in the StatsigUser, you can set the
memoUnitIdType
field in yourTypedExperiment
.For example, if you set the
memoUnitIdType
to 'userID':