Skip to content
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

integrate statsig #215

Merged
merged 15 commits into from
Jul 27, 2024
Merged

integrate statsig #215

merged 15 commits into from
Jul 27, 2024

Conversation

mike-dydx
Copy link
Contributor

@mike-dydx mike-dydx commented Jul 25, 2024

Description / Intuition

  • replaces firebase feature flags with statsig
  • controls skip/squid flag with statsig
  • cleans up some unused code bloat around feature flagging
  • improves static typing for better readability
  • renames key to credential

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring or Technical Debt
  • Documentation update
  • Other (please describe: )

@mike-dydx mike-dydx requested a review from ruixhuang July 25, 2024 21:47
@mike-dydx mike-dydx force-pushed the statsig-integration branch from 45e5b98 to 6dc0507 Compare July 26, 2024 19:54
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruixhuang lmk if you don't think this should be removed. But it doesn't seem to have any effect based on current feature flags

Comment on lines -44 to -47
if parser.asBoolean(FeatureService.shared?.flag(feature: "webview_popup"))?.boolValue ?? false {
configuration.preferences.javaScriptEnabled = true
configuration.preferences.javaScriptCanOpenWindowsAutomatically = true
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed since I haven't seen this feature flag, ever

Comment on lines -23 to -28
switch self {
case .enable_app_rating:
return Self.obj.parser.asBoolean(FeatureService.shared?.flag(feature: rawValue))?.boolValue ?? true
case .push_notification, .force_mainnet:
return Self.obj.parser.asBoolean(FeatureService.shared?.flag(feature: rawValue))?.boolValue ?? false
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferring more statically typed version of this

@@ -17,7 +17,7 @@ open class JsonCredentialsProvider: NSObject {

private var entity: DictionaryEntity?

public func key(for lookupKey: String) -> String? {
public func credential(for lookupKey: String) -> String? {
Copy link
Contributor Author

@mike-dydx mike-dydx Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to credential since key is confusing to me. The credential is not always an api key

Comment on lines +79 to +82
private let newValuesSubject = PassthroughSubject<Void, Never>()
public var newValuesAvailablePublisher: AnyPublisher<Void, Never> {
newValuesSubject.eraseToAnyPublisher()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note this publisher which is made available in the FeatureFlags protocol

Comment on lines +88 to +91
public func value(feature: String) -> String? {
// not yet implemented for Statsig feature flags since it is not yet needed
return nil
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

statsig supports non-bool feature flags, but they require more configuration. I figured we can tackle that when we get there


public protocol FeatureFlagsProtocol {
var featureFlags: [String: Any]? { get }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The statsig SDK does not expose a list of feature flags, so this pattern had to change

Comment on lines +16 to +17
func value(feature: String) -> String?
func isOn(feature: String) -> Bool?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer this more statically typed

Comment on lines -11 to -29
public class FeatureFlaggedParser: ConditionalParser {
@objc override public func conditioned(_ data: Any?) -> Any? {
var conditions = self.conditions ?? [String: String]()
if let features = FeatureService.shared?.featureFlags {
for arg0 in features {
let (key, value) = arg0
conditions[key] = parser.asString(value)
}
}
self.conditions = conditions
return super.conditioned(data)
}
}

extension Parser {
@objc public static var featureFlagged: Parser = {
FeatureFlaggedParser()
}()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruixhuang this is what was removed, but I could not see any use case for it. Let me know if I should add back

ruixhuang
ruixhuang previously approved these changes Jul 26, 2024
@mike-dydx mike-dydx merged commit ccdd69c into develop Jul 27, 2024
2 checks passed
@mike-dydx mike-dydx deleted the statsig-integration branch July 27, 2024 01:25
mike-dydx added a commit that referenced this pull request Aug 20, 2024
* integrate statsig

* comment

* remove FirebaseRemoteConfig

* add skip to features.json

* change inputs to on/off

* integrate statsig with featureflag protocol

* comment

* change assertion failure to log

* delete file

* deleted code

* comment

* Update PodFile

* bump abacus

* fix pods?

* remove unnecessary import

---------

Co-authored-by: Mike <[email protected]>
mike-dydx added a commit that referenced this pull request Aug 21, 2024
* integrate statsig

* comment

* remove FirebaseRemoteConfig

* add skip to features.json

* change inputs to on/off

* integrate statsig with featureflag protocol

* comment

* change assertion failure to log

* delete file

* deleted code

* comment

* Update PodFile

* bump abacus

* fix pods?

* remove unnecessary import

---------

Co-authored-by: Mike <[email protected]>
mike-dydx added a commit that referenced this pull request Aug 21, 2024
* integrate statsig

* comment

* remove FirebaseRemoteConfig

* add skip to features.json

* change inputs to on/off

* integrate statsig with featureflag protocol

* comment

* change assertion failure to log

* delete file

* deleted code

* comment

* Update PodFile

* bump abacus

* fix pods?

* remove unnecessary import

---------

Co-authored-by: Mike <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants