Skip to content

Conversation

sbarrio
Copy link
Contributor

@sbarrio sbarrio commented Aug 22, 2025

What does this PR do?

This PR aims to fix several issues with FileBasedConfiguration initialization of the SDK.

1.- Fixes a reported issue that makes it so directly passing a configuration json file enforces users to duplicate and nest another configuration property for it to work, ignoring the structure defined on datadog-configuration.schema.json. Doing so makes the schema validator label the json configuration as invalid. I fixed it so it properly accepts the schema we enforce with just one configuration entry.

This means that creating a new FileBasedConfiguration can be done like so:

// 1.- File based configuration from .json
const configuration = new FileBasedConfiguration(require("../datadog-configuration.json"));

// 2.- File based configuration from .json and custom mapper setup
const configuration = new FileBasedConfiguration( {
   configuration: require("../datadog-configuration.json").configuration, 
   errorEventMapper: (event) => event, 
   resourceEventMapper: (event) => event, 
   actionEventMapper: (event) => event}
);

2.- Removes the automatic loading of a datadog-configuration.json file by not passing a config file to FileBasedConfiguration(). The way in which this was done was flimsy, as it relied on jumping out of node_modules up to the root app folder. This worked most of the time but it caused an issue generating a require cycle that made 2 of our internal enums to be undefined at runtime (TrackingConsent and SdkVerbosity).

3.- Updates the FileBasedConfiguration tests to be more thorough and cover edge cases properly.

4.- Expands the example app showcasing different ways to provide a configuration object to the DatadogProvider, including FileBasedConfiguration schemes.

Motivation

FileBasedConfiguration should consistently work across the board.

Additional notes

This is a breaking change, as the option of automatically looking for a config.json file without having the user provide a specific path when creating a FileBasedConfiguration object will cease to work.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

@sbarrio sbarrio requested a review from a team as a code owner August 22, 2025 13:51
@sbarrio sbarrio marked this pull request as draft August 22, 2025 13:52
@sbarrio sbarrio changed the title Fix FileBasedConfiguration related issues [RUM-11388] Fix FileBasedConfiguration related issues Aug 22, 2025
@sbarrio sbarrio self-assigned this Sep 2, 2025
@sbarrio sbarrio marked this pull request as ready for review September 2, 2025 15:27
@sbarrio sbarrio changed the base branch from develop to feature/v3 September 3, 2025 15:13
@sbarrio sbarrio requested a review from a team as a code owner September 3, 2025 15:13
Copy link
Contributor

@buraizu buraizu left a comment

Choose a reason for hiding this comment

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

Just flagging some typos and suggesting a few other updates for consistency

@sbarrio
Copy link
Contributor Author

sbarrio commented Sep 4, 2025

Just flagging some typos and suggesting a few other updates for consistency

@buraizu Hi, thanks for raising all those typos 🙇

If you don't mind, I'll open a separate PR with your changes, as this specific PR is aimed toward a feature branch, and I think it's better to apply these corrections directly on develop.

EDIT: I've opened a PR with these fixes here.

@sbarrio sbarrio mentioned this pull request Sep 4, 2025
4 tasks
@sbarrio sbarrio changed the base branch from feature/v3 to develop September 4, 2025 10:15
@sbarrio sbarrio force-pushed the sbarrio/fix/file-based-configuration-issues branch from 1a1da93 to b1ae8ee Compare September 4, 2025 10:17
@sbarrio sbarrio changed the base branch from develop to feature/v3 September 4, 2025 10:17
@sbarrio sbarrio force-pushed the sbarrio/fix/file-based-configuration-issues branch from b1ae8ee to 6b944a9 Compare October 3, 2025 13:10
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.

2 participants