refactor: CMA improvements [MAPS-198]#10442
Merged
Joaquin (joaquincasal) merged 2 commits intomasterfrom Jan 28, 2026
Merged
Conversation
JuliRossi
approved these changes
Jan 13, 2026
| fieldsRef.current, | ||
| sdk.ids.space, | ||
| sdk.ids.environment, | ||
| sdk.ids.environmentAlias ?? sdk.ids.environment, |
Collaborator
There was a problem hiding this comment.
💭 Perhaps we can create a function like the one I added for dashboard:
import { BaseAppSDK } from '@contentful/app-sdk';
// We want to support environment aliases
export function getEnvironmentId(sdk: BaseAppSDK): string {
return sdk.ids.environmentAlias ?? sdk.ids.environment;
}
Franco Banfi (FBanfi)
approved these changes
Jan 22, 2026
Collaborator
Franco Banfi (FBanfi)
left a comment
There was a problem hiding this comment.
Amazing refactor!! Lgtm 🚀
ryunsong-contentful
approved these changes
Jan 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
It was noticed that the Braze app was using an environment id even when the app was used through an environment alias. This can be unexpected for customers and can also lead to issues if the used API keys do not have the same permissions for the environemnt and the alias.
Approach
In most cases, explicitly setting the environment ID is unnecessary, as the CMA client already provides a good default. We removed those cases and use the default instead.
When an explicit value is required, we now use
sdk.ids.environmentAlias ?? sdk.ids.environment, so the app uses the environment alias when available.We also took the opportunity to remove any
createClientusage and replaced it withsdk.cma.Testing steps
Some automated tests needed adjustment, all tests pass now.
Breaking Changes
No.
Affected apps