diff --git a/.cursor/rules/feature_flags.mdc b/.cursor/rules/feature_flags.mdc new file mode 100644 index 0000000000..6ced606429 --- /dev/null +++ b/.cursor/rules/feature_flags.mdc @@ -0,0 +1,24 @@ +--- +alwaysApply: false +description: Feature Flags +--- +# Java SDK Feature Flags + +There is a scope based and a span based API for tracking feature flag evaluations. + +## Scope Based API + +The `addFeatureFlag` method can be used to track feature flag evaluations. It exists on `Sentry` static API as well as `IScopes` and `IScope`. + +The `maxFeatureFlags` option controls how many flags are tracked per scope and also how many are sent to Sentry as part of events. +Scope based feature flags can also be disabled by setting the value to 0. Defaults to 100 feature flag evaluations. + +Order of feature flag evaluations is important as we only keep track of the last {maxFeatureFlag} items. + +When a feature flag evluation with the same name is added, the previous one is removed and the new one is stored so that it'll be dropped last. + +When sending out an error event, feature flag buffers from all three scope types (global, isolation and current scope) are merged, chosing the newest {maxFeatureFlag} entries across all scope types. Feature flags are sent as part of the `flags` context. + +## Span Based API + +tbd diff --git a/.cursor/rules/overview_dev.mdc b/.cursor/rules/overview_dev.mdc index 89c70e2c15..12ac73a844 100644 --- a/.cursor/rules/overview_dev.mdc +++ b/.cursor/rules/overview_dev.mdc @@ -34,6 +34,14 @@ Use the `fetch_rules` tool to include these rules when working on specific areas - Rate limiting, cache rotation - Android vs JVM caching differences +- **`feature_flags`**: Use when working with: + - Feature flag tracking and evaluation + - `addFeatureFlag()`, `getFeatureFlags()` methods + - `FeatureFlagBuffer`, `FeatureFlag` protocol + - `maxFeatureFlags` option and buffer management + - Feature flag merging across scope types + - Scope-based vs span-based feature flag APIs + ### Integration & Infrastructure - **`opentelemetry`**: Use when working with: - OpenTelemetry modules (`sentry-opentelemetry-*`) @@ -63,3 +71,4 @@ Use the `fetch_rules` tool to include these rules when working on specific areas - new module/integration/sample → `new_module` - Cache/offline/network → `offline` - System test/e2e/sample → `e2e_tests` + - Feature flag/addFeatureFlag/flag evaluation → `feature_flags`