-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add global data collection switch. #1219
Conversation
return YES; | ||
|
||
// If none of above exists, we default to the global switch that comes from FIRApp. | ||
return self.isGlobalAutomaticDataCollectionEnabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we make sure it's default true if no special action happened on the user side, so we make sure we are not breaking app's existing behavior on fetching instanceID, and other activities.
Is this global boolean value also serves the same purpose, that if developer doesn't do anything, it will be default ture?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, if nothing is set in the plist or at runtime, the default is true and we have unit tests to confirm that.
@@ -227,6 +232,7 @@ - (void)deleteApp:(FIRAppVoidBoolCallback)completion { | |||
if (sAllApps && sAllApps[self.name]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.name can be nil. We should check it before accessing the dictionary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We throw an exception if a user tries to configure the app with a nil
or empty name, which should catch this. If you're still concerned, we can add it in a separate PR since it's unrelated to this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I think we should be careful of accessing dictionary when the provided key is nil. I'm concerned that self.name might be nil at some point during the entire app life cycle.
Firebase/Core/FIRApp.m
Outdated
NSNumber *collectionEnabledPlistValue = [[self class] readDataCollectionSwitchFromPlist]; | ||
if (collectionEnabledPlistValue) { | ||
return [collectionEnabledPlistValue boolValue]; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no need for else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Firebase/Core/FIRApp.m
Outdated
#pragma mark - Reading From Plist & User Defaults | ||
|
||
/** | ||
* A wrapper to clear the data collection switch from the standard NSUserDefaults for easier testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Clears the data collection ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Firebase/Core/FIRApp.m
Outdated
} | ||
|
||
/** | ||
* A wrapper to read the data collection switch from the standard NSUserDefaults for easier testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Reads the data collection...
Please remove "A wrapper to" here and below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Firebase/Core/FIRApp.m
Outdated
id collectionEnabledDefaultsObject = [[NSUserDefaults standardUserDefaults] objectForKey:key]; | ||
if ([collectionEnabledDefaultsObject isKindOfClass:[NSNumber class]]) { | ||
return collectionEnabledDefaultsObject; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no need for else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Firebase/Core/FIRApp.m
Outdated
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
// Read the data from the `Info.plist`, only assign it if it's there and an NSNumber. | ||
id plistValue = [[NSBundle mainBundle] objectForInfoDictionaryKey:kFIRGlobalAppDataCollectionEnabledPlistKey]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ident +4 from previous line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what happened here but I think this was out of date - it's split onto two lines now, even indenting +4 leaves it over 100 chars.
Firebase/Core/Public/FIRApp.h
Outdated
* your app's Info.plist. This value is persisted across runs of the app so that it | ||
* can be set once when users have consented to collection. | ||
*/ | ||
@property(nonatomic, readwrite, getter=isAutomaticDataCollectionEnabled) BOOL automaticDataCollectionEnabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ident +4
Firebase/Core/Public/FIRApp.h
Outdated
/** | ||
* Gets or sets whether automatic data collection is enabled for all products. | ||
* Defaults to YES unless FirebaseAutomaticDataCollectionEnabled is set to NO in | ||
* your app's Info.plist. This value is persisted across runs of the app so that it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: fits previous line. Please fill the whole row up to 100 chars per line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed the comments, @baolocdo there were a few you added on an old iteration, apologies if I sent you the wrong link. Everything should be properly formatted now.
@@ -227,6 +232,7 @@ - (void)deleteApp:(FIRAppVoidBoolCallback)completion { | |||
if (sAllApps && sAllApps[self.name]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We throw an exception if a user tries to configure the app with a nil
or empty name, which should catch this. If you're still concerned, we can add it in a separate PR since it's unrelated to this change.
Firebase/Core/FIRApp.m
Outdated
NSNumber *collectionEnabledPlistValue = [[self class] readDataCollectionSwitchFromPlist]; | ||
if (collectionEnabledPlistValue) { | ||
return [collectionEnabledPlistValue boolValue]; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Firebase/Core/FIRApp.m
Outdated
#pragma mark - Reading From Plist & User Defaults | ||
|
||
/** | ||
* A wrapper to clear the data collection switch from the standard NSUserDefaults for easier testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Firebase/Core/FIRApp.m
Outdated
} | ||
|
||
/** | ||
* A wrapper to read the data collection switch from the standard NSUserDefaults for easier testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Firebase/Core/FIRApp.m
Outdated
id collectionEnabledDefaultsObject = [[NSUserDefaults standardUserDefaults] objectForKey:key]; | ||
if ([collectionEnabledDefaultsObject isKindOfClass:[NSNumber class]]) { | ||
return collectionEnabledDefaultsObject; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
return YES; | ||
|
||
// If none of above exists, we default to the global switch that comes from FIRApp. | ||
return self.isGlobalAutomaticDataCollectionEnabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, if nothing is set in the plist or at runtime, the default is true and we have unit tests to confirm that.
Firebase/Core/FIRApp.m
Outdated
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
// Read the data from the `Info.plist`, only assign it if it's there and an NSNumber. | ||
id plistValue = [[NSBundle mainBundle] objectForInfoDictionaryKey:kFIRGlobalAppDataCollectionEnabledPlistKey]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what happened here but I think this was out of date - it's split onto two lines now, even indenting +4 leaves it over 100 chars.
* Addition of global data collection switch. * Added Messaging conformance to data switch. Also formatted code. * Move data collection flag internal until all SDKs conform to it. * Formatting in response to code review.
NOTE: This shouldn't be public until all SDKs conform to the setting.
This allows developers to enable/disable all collection at compile time and override it at runtime.