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

[Rollouts] Notify RolloutsState change to Interop subscriber #12334

Merged
merged 19 commits into from
Feb 12, 2024

Conversation

ddnan
Copy link
Contributor

@ddnan ddnan commented Jan 30, 2024

Notify RolloutsState change to Interop subscriber

  • Update lastFetchedTemplateVersion after successful fetch
  • When Crashlytics register with RC instance, if there is no such instance create one
  • Send persistent active rollout metadata (if exists) to Interop right after register subscriber
  • Send active rollout metadata to interop after successful RC activation

Note: this change will merge to our feature branch not master
#no-changelog

@ddnan
Copy link
Contributor Author

ddnan commented Feb 6, 2024

Add some screenshots from app manual testing
Before first RC fetch and activate, no rollout metadata in Crashlytics persistence
Before first RC fetch and activate
After RC activate, rollout metadata stored in Crashlytics persistence
After RC activate
A Crash
A crash
Re-launch app, pervious session uploaded, new session with rollout metadata from RC persistence
Re-launch
Rollout metadata in RC sqlite
rollout metadata in RC persistence
Rollout metadata in Crashlytics persistence
rollout metadata in Crashlytics persistence

@ddnan ddnan changed the title [Rollouts/Draft] Notify RolloutsState change to Interop subscriber [Rollouts] Notify RolloutsState change to Interop subscriber Feb 6, 2024
@ddnan ddnan marked this pull request as ready for review February 6, 2024 19:48
@ddnan ddnan self-assigned this Feb 7, 2024
FirebaseRemoteConfig/Interop/RemoteConfigConstants3P.swift Outdated Show resolved Hide resolved
FirebaseRemoteConfig/Sources/FIRRemoteConfig.m Outdated Show resolved Hide resolved
FirebaseRemoteConfig/Sources/FIRRemoteConfig.m Outdated Show resolved Hide resolved
// Send active rollout metadata stored in persistence while app launched if there is activeConfig
NSString *FQNamespace = [self fullyQualifiedNamespace:_FIRNamespace];
NSDictionary<NSString *, NSDictionary *> *activeConfig = self->_configContent.activeConfig;
if (activeConfig[FQNamespace].count > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible activeConfig[FQNamespace] == nil? Would we throw an exception getting count in that case?

Copy link
Contributor Author

@ddnan ddnan Feb 9, 2024

Choose a reason for hiding this comment

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

When the db is loading, we initialized all the content with namespace. It should be at least an empty dictionary. But I still add a nil check before check count.

FirebaseRemoteConfig/Sources/FIRRemoteConfig.m Outdated Show resolved Hide resolved
if (rolloutId && variantID && affectedParameterKeys) {
for (NSString *key in affectedParameterKeys) {
FIRRemoteConfigValue *value = self->_configContent.activeConfig[FQNamespace][key];
if (value) {
Copy link
Contributor

@danasilver danasilver Feb 8, 2024

Choose a reason for hiding this comment

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

Does this allow an empty string value? (we want to allow that since it's a valid value from the backend)

Other note here is that we want to fall back to the in-app default value or the static default if there isn't a value present in the active config (i.e. following the SDK's get(param) logic)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, empty string will return true when do if check on it and nil will return false.
Add in-app default value logic if value is nil.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm missing it - can you point me to where the in-app default fallback logic is?

Copy link
Contributor

@themiswang themiswang left a comment

Choose a reason for hiding this comment

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

Just a minor comment and LGTM! Thank you for the changing!

@@ -45,6 +45,8 @@
/// Notification when config is successfully activated
const NSNotificationName FIRRemoteConfigActivateNotification =
@"FIRRemoteConfigActivateNotification";
static NSNotificationName RolloutsStateDidChangeNotificationName =
@"RolloutsStateDidChangeNotification";
Copy link
Contributor

Choose a reason for hiding this comment

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

curious - should this be the same format as the other notification name? (prefixed with FIR)

Copy link
Contributor

@themiswang themiswang Feb 12, 2024

Choose a reason for hiding this comment

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

Ah yeah, since it's global(used by notification center) let's perfix with FIR. Also this is in objc (objc does not have namespace so the best practise is uppercase prefixes for every object).

if (rolloutId && variantID && affectedParameterKeys) {
for (NSString *key in affectedParameterKeys) {
FIRRemoteConfigValue *value = self->_configContent.activeConfig[FQNamespace][key];
if (value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm missing it - can you point me to where the in-app default fallback logic is?

for (NSString *key in affectedParameterKeys) {
FIRRemoteConfigValue *value = self->_configContent.activeConfig[FQNamespace][key];
if (!value) {
value = [self defaultValueForFullyQualifiedNamespace:FQNamespace key:key];
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, i like how you factored this out 👍

@ddnan ddnan merged commit 4dd6070 into featureRollouts Feb 12, 2024
89 of 91 checks passed
@ddnan ddnan deleted the ddn-rollouts-notify branch February 12, 2024 23:48
@firebase firebase locked and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants