Skip to content

refactor: CMA improvements [MAPS-198]#10442

Merged
Joaquin (joaquincasal) merged 2 commits intomasterfrom
cma-improvements
Jan 28, 2026
Merged

refactor: CMA improvements [MAPS-198]#10442
Joaquin (joaquincasal) merged 2 commits intomasterfrom
cma-improvements

Conversation

@joaquincasal
Copy link
Copy Markdown
Collaborator

@joaquincasal Joaquin (joaquincasal) commented Jan 13, 2026

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 createClient usage and replaced it with sdk.cma.

Testing steps

Some automated tests needed adjustment, all tests pass now.

Breaking Changes

No.

Affected apps

  • Braze
  • Bulk Edit
  • Closest Preview
  • Deep Clone
  • Homebase
  • Hubspot
  • Iterable
  • Rich Text Versioning

@joaquincasal Joaquin (joaquincasal) requested a review from a team as a code owner January 13, 2026 13:54
Copy link
Copy Markdown
Collaborator

@JuliRossi JuliRossi left a comment

Choose a reason for hiding this comment

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

LGTM

fieldsRef.current,
sdk.ids.space,
sdk.ids.environment,
sdk.ids.environmentAlias ?? sdk.ids.environment,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

💭 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;
}

Copy link
Copy Markdown
Collaborator

@FBanfi Franco Banfi (FBanfi) left a comment

Choose a reason for hiding this comment

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

Amazing refactor!! Lgtm 🚀

@joaquincasal Joaquin (joaquincasal) merged commit 19587e6 into master Jan 28, 2026
15 checks passed
@joaquincasal Joaquin (joaquincasal) deleted the cma-improvements branch January 28, 2026 17:04
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.

4 participants