feat: Add FlagOptions for consolidated feature flag configuration - #896
Conversation
Introduces FlagOptions with builder pattern to group feature flag settings (enabled, context, loadOnFirstForeground) into a single configuration object. Deprecates the flat featureFlagsEnabled/featureFlagsContext params on MixpanelOptions in favor of the new setFlagOptions() builder method. The new loadOnFirstForeground option allows callers to control whether flags are automatically fetched on the first app foreground event. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@dillon-mce here's the Android version of the option to not load flags on first foreground! |
| * or an empty JSONObject if the source is {@code null} or copying fails. | ||
| */ | ||
| @NonNull | ||
| public static JSONObject defensiveCopy(@Nullable JSONObject source) { |
There was a problem hiding this comment.
This seems unnecessary with proper nullability annotations and being defensive elsewhere before attempting to convert. Just feels like a utility function that will be forgotten about, used in some places, but not others.
| * @param enabled {@code true} to enable feature flags, {@code false} to disable. | ||
| * @return This Builder instance for chaining. | ||
| */ | ||
| public Builder setEnabled(boolean enabled) { |
There was a problem hiding this comment.
current builder pattern is to not use set at the start of these as setting should be obvious given that we are in builder pattern. We don't use set for the mixpanel options
| private FlagOptions(Builder builder) { | ||
| this.mEnabled = builder.mEnabled; | ||
| this.mLoadOnFirstForeground = builder.mLoadOnFirstForeground; | ||
| this.mContext = builder.mContext != null ? builder.mContext : new JSONObject(); |
There was a problem hiding this comment.
See argument against defensive copy utility since this would be a good way to ensure not null.
|
K @tylerjroach, I think I've addressed your concerns by:
|
… prefetchFlags Improves naming clarity for the feature flag configuration class and its auto-load parameter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
FlagOptionsclass (builder pattern) that groups feature flag settings (enabled,context,loadOnFirstForeground) into a single configuration objectsetFlagOptions(FlagOptions)toMixpanelOptions.Builder, deprecating the flatfeatureFlagsEnabled()andfeatureFlagsContext()methods (backward compatible — flat params are auto-wrapped into aFlagOptionswhen the new API isn't used)loadOnFirstForegroundoption so callers can control whether flags are automatically fetched on the first app foreground event🤖 Generated with Claude Code