Skip to content

Conversation

@sbarrio
Copy link
Contributor

@sbarrio sbarrio commented Dec 15, 2025

What does this PR do?

Same as we did with #1065, this PR changes the internal-testing-tool package logic to adapt to the changes done on v3 related to the SDK core instance and how to retrieve and wrap it to be able to capture the SDK events and successfully do E2E test runs on the nightly tests app.

Approach

The main problem relies on how v3 of the SDK works with the native SDK core. Before v3, the core was obtained during initialization and a reference to it was stored inside DatadogSDKWrapper. Then, every component of the React Native SDK would go through that reference to perform native SDK tasks. That has changed on v3, as that intermediate reference is now removed, and all modules rely directly on accessing Datadog.getInstance() to directly obtain the SDK core.

This works fine for the SDK on all fronts and it's a mandatory requirement to achieve SDK modularization. However, it causes a problem for the internal-testing-module, which relied on that core sdk reference to wrap the core around a StubSDKCore that would allow it to listen to SDK events and then assess if the SDK did what was asked of it properly.

The solution taken for the iOS SDK was simple, once the SDK is initialized we use the onSdkInitializationlistener to obtain the core, then wrap it with the testing and event listening code and then reassign it as the active core instance by using theregister and unregister methods exposed by the Datadog class.

This was not that simple on Android, as those methods are internal, so the first hurdle to go over was to use reflection to access them. We encapsulated this core swap into a separate function, that also makes sure that the access to the core registry is synchronized, as otherwise it could cause concurrency problems when swapping the cores.

Next we did a few more changes to make sure that features are properly intercepted even if they are enabled before the internal testing module, as well as making sure that SDK calls are only performed once but it's calls are registered and written by the interceptors properly.

Motivation

We need to be able to use the Nightly Tests app to assess if new releases of the SDK are working properly or not.

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 force-pushed the sbarrio/v3/fix-dd-internal-testing-on-android branch from d3beca1 to ddbbbf4 Compare December 15, 2025 11:14
@sbarrio sbarrio marked this pull request as ready for review December 15, 2025 11:15
@sbarrio sbarrio requested a review from a team as a code owner December 15, 2025 11:15
Copy link
Member

@marco-saia-datadog marco-saia-datadog left a comment

Choose a reason for hiding this comment

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

💯

@sbarrio sbarrio merged commit b723843 into feature/v3 Dec 15, 2025
9 checks passed
@sbarrio sbarrio deleted the sbarrio/v3/fix-dd-internal-testing-on-android branch December 15, 2025 15: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.

3 participants