-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
docs(feature-flags): Document Apple, Java, and Android APIs #18755
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
6 commits
Select commit
Hold shift + click to select a range
f1e4629
docs(feature-flags): Document Apple, Java, and Android APIs
denrase 0e94c37
Merge branch 'master' into denrase/cocoa-feature-flags
denrase b3ef3f3
Merge branch 'master' into denrase/cocoa-feature-flags
denrase 3327db7
remove forking language on cocoa
denrase 1a5367c
sync andorid.java message behaviour with apple
denrase 0e87243
define „unique“ bahaviour more precisely
denrase 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| title: Set Up Feature Flags | ||
| sidebar_title: Feature Flags | ||
| sidebar_order: 5750 | ||
| sidebar_section: features | ||
| description: With Feature Flags, Sentry tracks feature flag evaluations in your application, keeps an audit log of feature flag changes, and reports any suspicious updates that may have caused an error. | ||
| --- | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - You have version 9.22.0 or later of the <PlatformLink to="/">Apple SDK installed</PlatformLink>. | ||
|
|
||
| ## Enable Evaluation Tracking | ||
|
|
||
| <PlatformContent includePath="feature-flags/evaluation-tracking-index" /> | ||
|
|
||
| ## Enable Change Tracking | ||
|
|
||
| <PlatformContent includePath="feature-flags/change-tracking-index" /> | ||
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
75 changes: 75 additions & 0 deletions
75
platform-includes/feature-flags/evaluation-tracking-index/apple.mdx
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,75 @@ | ||
| If you use a third-party SDK to evaluate feature flags, use the generic API to manually track feature flag evaluations. The SDK stores each evaluation on the current scope. If a span or transaction is active, the SDK also records the evaluation on that active span or transaction. Only boolean flag evaluations are supported. | ||
|
|
||
| ### Generic API | ||
|
|
||
| Call `SentrySDK.addFeatureFlag` after evaluating a feature flag: | ||
|
|
||
| ```swift {tabTitle:Swift} {mdExpandTabs} | ||
| import Sentry | ||
|
|
||
| SentrySDK.addFeatureFlag(name: "test-flag", result: false) | ||
| SentrySDK.capture(error: error) | ||
| ``` | ||
|
|
||
| ```objc {tabTitle:Objective-C (SentryObjC)} | ||
| #import <SentryObjC/SentryObjC.h> | ||
|
|
||
| [SentryObjCSDK addFeatureFlagWithName:@"test-flag" result:NO]; | ||
| [SentryObjCSDK captureError:error]; | ||
| ``` | ||
|
|
||
| Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false". | ||
|
|
||
| ### Custom Hub | ||
|
|
||
| If you use a custom hub, add the feature flag evaluation to that hub. This updates the custom hub's scope and active span or transaction, without changing the global `SentrySDK` scope: | ||
|
|
||
| ```swift {tabTitle:Swift} {mdExpandTabs} | ||
| hub.addFeatureFlag(name: "test-flag", result: false) | ||
| hub.capture(error: error) | ||
| ``` | ||
|
|
||
| ```objc {tabTitle:Objective-C (SentryObjC)} | ||
| [hub addFeatureFlagWithName:@"test-flag" result:NO]; | ||
| [hub captureError:error]; | ||
| ``` | ||
|
|
||
| ### Scope Callback | ||
|
|
||
| Use a scope callback when the evaluation should apply to this capture's local scope instead of remaining on the current scope: | ||
|
|
||
| ```swift {tabTitle:Swift} {mdExpandTabs} | ||
| SentrySDK.capture(error: error) { scope in | ||
| scope.addFeatureFlag(name: "test-flag", result: false) | ||
| } | ||
| ``` | ||
|
|
||
| ```objc {tabTitle:Objective-C (SentryObjC)} | ||
| [SentryObjCSDK captureError:error withScopeBlock:^(SentryObjCScope * _Nonnull scope) { | ||
| [scope addFeatureFlagWithName:@"test-flag" result:NO]; | ||
| }]; | ||
| ``` | ||
|
|
||
| Feature flags added in a scope callback don't persist on the current scope. If a span or transaction is active, the SDK still records the evaluation on that active span or transaction. | ||
|
|
||
| ### Clear Feature Flags | ||
|
|
||
| Clear feature flags when they no longer apply, such as after a user signs out or switches accounts: | ||
|
|
||
| ```swift {tabTitle:Swift} {mdExpandTabs} | ||
| SentrySDK.configureScope { scope in | ||
| scope.clearFeatureFlags() | ||
| } | ||
| ``` | ||
|
|
||
| ```objc {tabTitle:Objective-C (SentryObjC)} | ||
| [SentryObjCSDK configureScope:^(SentryObjCScope * _Nonnull scope) { | ||
| [scope clearFeatureFlags]; | ||
| }]; | ||
| ``` | ||
|
|
||
| `clearFeatureFlags()` removes evaluations from the current scope. It doesn't remove evaluations already recorded on an active span or transaction. | ||
|
|
||
| Scope evaluations are attached to error and message events. The current scope keeps the latest evaluation for up to 100 flag names. Re-evaluating a flag updates its stored value and makes it the most recent evaluation. | ||
|
|
||
| Active spans and transactions record evaluations for up to 10 flag names as span attributes using the `flag.evaluation.<name>` key. Re-evaluating a recorded flag updates its value. After 10 flag names are recorded, evaluations for new flag names are ignored. Spans don't inherit evaluations from their parent span. |
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.
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.