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

fix: use config fallback for appName and environment #70

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Feb 5, 2024

About the changes

Use config appName and environment as a fallback when context values are missing.

Fixes: #67

Important files

Discussion points

@kwasniew kwasniew requested a review from chriswk February 5, 2024 15:52
Comment on lines 106 to 111
override fun getContext(): UnleashContext {
return unleashContext
return unleashContext.copy(
appName = unleashContext.appName ?: unleashConfig.appName,
environment = unleashContext.environment ?: unleashConfig.environment
)
}
Copy link
Member

@chriswk chriswk Feb 6, 2024

Choose a reason for hiding this comment

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

This will create a brand new class every time we call it, instead of using the existing field on the class. I'm wondering if we should rather do the fallback to config values on constructing the client.

Copy link
Contributor Author

@kwasniew kwasniew Feb 6, 2024

Choose a reason for hiding this comment

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

I was trying to cater for a use case when people overwrite config appName with updateContext appName in the first call and then another updateContext removes appName and then we should fall back to the config appName. So it gives you a fallback no matter how you used updateContext in the past.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In other frontend SDKs updateContext can't update appName so we can save appName from config during construction. Since this SDK allows for appName overwrites from context it complicates the solution space a bit.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, true. Then I think I'm fine with this. Let's merge.

Copy link
Member

@chriswk chriswk left a comment

Choose a reason for hiding this comment

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

Thanks for this 👍

@kwasniew kwasniew merged commit 182f752 into main Feb 7, 2024
2 checks passed
@kwasniew kwasniew deleted the use-config-fallback-for-context branch February 7, 2024 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The app name passed into UnleashConfig.Builder is not used at all from the SDK when adding the appName header.
2 participants