-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
override fun getContext(): UnleashContext { | ||
return unleashContext | ||
return unleashContext.copy( | ||
appName = unleashContext.appName ?: unleashConfig.appName, | ||
environment = unleashContext.environment ?: unleashConfig.environment | ||
) | ||
} |
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.
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.
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.
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.
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.
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.
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.
Yeah, true. Then I think I'm fine with this. Let's merge.
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.
Thanks for this 👍
About the changes
Use config appName and environment as a fallback when context values are missing.
Fixes: #67
Important files
Discussion points