Initial support for Feature Flags#670
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds initial support for feature flags by persisting flag data, integrating a feature flag manager into the instance, and updating configuration and initialization methods.
- Added new keys and methods in MixpanelPersistence.swift to save/load flags.
- Updated MixpanelInstance.swift to conform to FeatureFlagDelegate and integrate FeatureFlagManager.
- Introduced a new MixpanelConfig class with flag configuration and updated initialization flows in Mixpanel.swift and the demo AppDelegate.
Reviewed Changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/MixpanelPersistence.swift | Added new key for flags and methods for archiving/unarchiving flag data. |
| Sources/MixpanelInstance.swift | Integrated FeatureFlagManager and conformed to FeatureFlagDelegate. |
| Sources/MixpanelConfig.swift | Introduced a new configuration class with flag support. |
| Sources/Mixpanel.swift | Updated initialization methods to work with the new config and flags. |
| MixpanelDemo/MixpanelDemo/AppDelegate.swift | Updated demo to initialize with MixpanelConfig including flags. |
Files not reviewed (2)
- Mixpanel.xcodeproj/project.pbxproj: Language not supported
- MixpanelDemo/MixpanelDemo.xcodeproj/project.pbxproj: Language not supported
Comments suppressed due to low confidence (2)
Sources/Mixpanel.swift:21
- The conditional block is redundant since both branches call the same initializer; simplifying this will improve code clarity.
if let proxyServerConfig = config.proxyServerConfig { return MixpanelManager.sharedInstance.initialize(config: config) } else { return MixpanelManager.sharedInstance.initialize(config: config) }
Sources/MixpanelPersistence.swift:201
- The call to 'UserDefaults.synchronize()' is deprecated and may lead to unnecessary performance overhead; consider removing it to rely on the system's automatic synchronization.
defaults.synchronize()
There was a problem hiding this comment.
Pull Request Overview
This PR introduces initial support for Feature Flags. It adds APIs for saving and loading flags in persistence, updates MixpanelOptions and MixpanelInstance to support feature flag functionality, and integrates new demo cases and project file references for feature flag testing.
- Added persistence support for feature flags in MixpanelPersistence.
- Extended MixpanelOptions and MixpanelInstance to include feature flag configurations and delegation.
- Updated demo and project configuration files to incorporate feature flag testing and new file references.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/MixpanelPersistence.swift | Adds keys and methods to save/load feature flags in UserDefaults. |
| Sources/MixpanelOptions.swift | Introduces new options for enabling and configuring feature flags. |
| Sources/MixpanelInstance.swift | Integrates feature flag API and delegate support into the instance. |
| Sources/Mixpanel.swift | Adds a new initializer to accept MixpanelOptions. |
| MixpanelDemo/TrackingViewController.swift | Adds multiple demo cases to exercise the feature flag APIs. |
| MixpanelDemo/AppDelegate.swift | Updates initialization to use the new MixpanelOptions instance. |
| MixpanelDemo/MixpanelDemo.xcodeproj/project.pbxproj & Mixpanel.xcodeproj/project.pbxproj | Updates project configuration to include new feature flag test files and related source files. |
| Mixpanel-swift.podspec | Updates podspec to include the new MixpanelOptions and FeatureFlags sources. |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces initial support for Mixpanel Feature Flags in the Swift SDK through the addition of new persistence functions, a new MixpanelOptions class with feature flag configuration, and corresponding integration into the MixpanelInstance lifecycle and tests.
- Added persistence methods for saving and loading feature flags in MixpanelPersistence.swift.
- Introduced MixpanelOptions with properties for feature flag configuration.
- Updated MixpanelInstance, Mixpanel, and tests to integrate feature flags usage.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Sources/MixpanelPersistence.swift | Added persistence methods for feature flags with minor spelling typo in a comment. |
| Sources/MixpanelOptions.swift | New class exposing feature flag options and related configurations. |
| Sources/MixpanelInstance.swift | Integrated feature flags into instance initialization and identification flows. |
| Sources/Mixpanel.swift | Updated initialization to use the new options class. |
| MixpanelDemoTests/MixpanelDemoTests.swift | Added a mock flags implementation and tests verifying flag load behavior. |
| AppDelegate.swift | Updated demo app initialization to support feature flags via options. |
| Project Files (.pbxproj, podspec) | Added new files to project configuration supporting feature flags. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR introduces initial support for Mixpanel Feature Flags in the Swift SDK. As part of this work we've introduced a new
MixpanelOptionsobject to encapsulate all of the various arguments that can be passed into the SDK initializer.Example usage: