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

Nc/custom signal #13976

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Nc/custom signal #13976

wants to merge 8 commits into from

Conversation

tusharkhandelwal8
Copy link

feat(rc): Add custom signals support

@google-oss-bot
Copy link

1 Warning
⚠️ Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.)

Generated by 🚫 Danger

Copy link
Contributor

github-actions bot commented Oct 27, 2024

Apple API Diff Report

Commit: 907789c
Last updated: Wed Oct 30 00:51 PDT 2024
View workflow logs & download artifacts


FirebaseRemoteConfig

Enumerations

[ADDED] FIRRemoteConfigCustomSignalsError
[ADDED] FIRRemoteConfigCustomSignalsError
Swift:
+  typealias RemoteConfigCustomSignalsError . Code . _ErrorType = RemoteConfigCustomSignalsError
+    case unknown = 8001
+    case invalidValueType = 8002
Objective-C:
+  enum FIRRemoteConfigCustomSignalsError : NSInteger {}
+    FIRRemoteConfigCustomSignalsErrorUnknown = 8001
+    FIRRemoteConfigCustomSignalsErrorInvalidValueType = 8002

Classes

FIRRemoteConfig
[ADDED] -setCustomSignals:WithCompletion:
Objective-C:
+  - ( void ) setCustomSignals :( nullable NSDictionary < NSString * , NSObject *> * ) customSignals WithCompletion :( void ( ^ _Nullable )( NSError * _Nullable error )) completionHandler NS_REFINED_FOR_SWIFT ;

Constants

[ADDED] FIRRemoteConfigCustomSignalsErrorDomain
[ADDED] FIRRemoteConfigCustomSignalsErrorDomain
Swift:
+  let RemoteConfigCustomSignalsErrorDomain : String
Objective-C:
+  extern NS_SWIFT_NAME ( RemoteConfigCustomSignalsErrorDomain ) NSString * const FIRRemoteConfigCustomSignalsErrorDomain

void (^setCustomSignalsBlock)(void) = ^{
if (!customSignals) {
if (completionHandler) {
dispatch_async(dispatch_get_main_queue(), ^{
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason we have to dispatch the completion block back to main thread? Ideally if SDK work does not involve UI we should try stay away from main as much as possible.

if (value && ![value isKindOfClass:[NSString class]] &&
![value isKindOfClass:[NSNumber class]]) {
if (completionHandler) {
dispatch_async(dispatch_get_main_queue(), ^{
Copy link
Contributor

@themiswang themiswang Oct 29, 2024

Choose a reason for hiding this comment

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

Same here, any reason we have to dispatch the completion block back to main? Also, the logic here seems like, if there is one invalid value type we send error back the completion block. Wonder do we want to check all and send all invalid entries as error instead?

}
}

self->_settings.customSignals = newCustomSignals;
Copy link
Contributor

@themiswang themiswang Oct 29, 2024

Choose a reason for hiding this comment

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

Hmmmm I don't see any synchronization strategy on _settings.customSignals, assuming this is the in memory record for customSignals, how do we maintain the update order if setCustomSignals getting called multiple time?

@@ -1834,6 +1834,32 @@ - (void)testFetchAndActivateRolloutsNotifyInterop {
[self waitForExpectations:@[ notificationExpectation ] timeout:_expectationTimeout];
}

- (void)testSetCustomSingals {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have another test case where within one rc instance call setCustomSignals multiple times?

@@ -237,6 +240,61 @@ - (void)callListeners:(NSString *)key config:(NSDictionary *)config {
}
}

- (void)setCustomSignals:(nullable NSDictionary<NSString *, NSObject *> *)customSignals
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just take in NSDictionary<NSString *, NSString *>? then it becomes impossible to set something invalid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants