Skip to content

Pass InternalLogger through the SR mappers#3518

Merged
jonathanmos merged 1 commit into
developfrom
jmoskovich/pass-logger-through-mappers
Jun 15, 2026
Merged

Pass InternalLogger through the SR mappers#3518
jonathanmos merged 1 commit into
developfrom
jmoskovich/pass-logger-through-mappers

Conversation

@jonathanmos

@jonathanmos jonathanmos commented Jun 8, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Pass internalLogger through the mappers. While this looks like a lot of changes it's mainly changing 2-3 lines in every class.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • 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)

@codecov-commenter

codecov-commenter commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.56522% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.24%. Comparing base (e4099f5) to head (d8e09d6).
⚠️ Report is 41 commits behind head on develop.

Files with missing lines Patch % Lines
...l/mappers/semantics/CheckboxSemanticsNodeMapper.kt 73.33% 2 Missing and 2 partials ⚠️
...appers/semantics/RadioButtonSemanticsNodeMapper.kt 40.00% 2 Missing and 1 partial ⚠️
...ionreplay/compose/internal/utils/SemanticsUtils.kt 81.25% 3 Missing ⚠️
...ernal/mappers/semantics/RootSemanticsNodeMapper.kt 83.33% 2 Missing ⚠️
...sessionreplay/compose/internal/utils/ColorUtils.kt 33.33% 1 Missing and 1 partial ⚠️
...nal/mappers/semantics/ButtonSemanticsNodeMapper.kt 0.00% 1 Missing ⚠️
.../mappers/semantics/ContainerSemanticsNodeMapper.kt 0.00% 1 Missing ⚠️
...nal/mappers/semantics/SliderSemanticsNodeMapper.kt 0.00% 1 Missing ⚠️
...nal/mappers/semantics/SwitchSemanticsNodeMapper.kt 0.00% 0 Missing and 1 partial ⚠️
.../mappers/semantics/TextFieldSemanticsNodeMapper.kt 66.67% 1 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3518      +/-   ##
===========================================
- Coverage    72.34%   72.24%   -0.11%     
===========================================
  Files          965      965              
  Lines        35609    35618       +9     
  Branches      5933     5930       -3     
===========================================
- Hits         25760    25729      -31     
- Misses        8255     8277      +22     
- Partials      1594     1612      +18     
Files with missing lines Coverage Δ
...l/mappers/semantics/AbstractSemanticsNodeMapper.kt 77.36% <100.00%> (ø)
...rnal/mappers/semantics/AndroidComposeViewMapper.kt 92.86% <100.00%> (+0.55%) ⬆️
.../internal/mappers/semantics/ComposeHiddenMapper.kt 93.33% <ø> (ø)
...se/internal/mappers/semantics/ComposeViewMapper.kt 83.33% <100.00%> (+0.98%) ⬆️
...rnal/mappers/semantics/ImageSemanticsNodeMapper.kt 90.91% <100.00%> (-0.07%) ⬇️
...ternal/mappers/semantics/TabSemanticsNodeMapper.kt 93.33% <ø> (ø)
...nal/mappers/semantics/ButtonSemanticsNodeMapper.kt 80.00% <0.00%> (-20.00%) ⬇️
.../mappers/semantics/ContainerSemanticsNodeMapper.kt 86.67% <0.00%> (-6.67%) ⬇️
...nal/mappers/semantics/SliderSemanticsNodeMapper.kt 13.33% <0.00%> (-2.22%) ⬇️
...nal/mappers/semantics/SwitchSemanticsNodeMapper.kt 94.74% <0.00%> (ø)
... and 8 more

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jonathanmos
jonathanmos force-pushed the jmoskovich/pass-logger-through-mappers branch from 3800e92 to 053d46e Compare June 9, 2026 07:45
@jonathanmos
jonathanmos marked this pull request as ready for review June 9, 2026 09:15
@jonathanmos
jonathanmos requested review from a team as code owners June 9, 2026 09:15
@datadog-official

This comment has been minimized.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 053d46e354

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +41 to +43
private val internalLogger by lazy {
(Datadog.getInstance() as FeatureSdkCore).internalLogger
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use the mapper-provided logger instead of the default SDK

When Session Replay is enabled with an explicit/non-default sdkCore (or the configuration is built before the default SDK is initialized), this lazy property resolves Datadog.getInstance() independently of the internalLogger later passed into ComposeViewMapper.map(). Because the shared SemanticsUtils and RootSemanticsNodeMapper are constructed from this captured default/no-op logger, Compose telemetry/errors continue to be logged against the wrong core even though the mapper receives the correct feature logger at mapping time.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

While possible, it requires restructuring how SessionReplayConfiguration and SessionReplay.enable() interact, moving logic between classes, and touching the public ExtensionSupport interface — which is out of scope for this PR. Can be a potential follow-up

private val rootSemanticsNodeMapper = RootSemanticsNodeMapper(colorStringFormatter)

private val internalLogger by lazy {
(Datadog.getInstance() as FeatureSdkCore).internalLogger

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you sure it is ok to use the default unnamed SDKCore here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it's not ideal but the alternative is to get the correct core through the constructor, which modifies the public api and means the customer can forget and it will silently break, or to make changes that are outside the scope of this pr

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That is all because different Utils classes require logger in the constructor and/or are initialized at the caller class creation.

If we move logger to the method or resolve Utils instances lazily when they are needed, that would allow to avoid this.

Would it be a big lift?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right - I've now hooked the compose mappers up to the existing logger chain. It's more files touched in the pr but it's a better solution

@jonathanmos
jonathanmos force-pushed the jmoskovich/pass-logger-through-mappers branch 2 times, most recently from 8e7d906 to 564da32 Compare June 9, 2026 14:38
@jonathanmos
jonathanmos force-pushed the jmoskovich/pass-logger-through-mappers branch from 564da32 to c8b3549 Compare June 11, 2026 09:22
@jonathanmos
jonathanmos requested a review from 0xnm June 11, 2026 10:34
kikoveiga
kikoveiga previously approved these changes Jun 11, 2026
0xnm
0xnm previously approved these changes Jun 12, 2026
@jonathanmos
jonathanmos dismissed stale reviews from 0xnm, kikoveiga, and aleksandr-gringauz via d8e09d6 June 14, 2026 07:59
@jonathanmos
jonathanmos force-pushed the jmoskovich/pass-logger-through-mappers branch from c8b3549 to d8e09d6 Compare June 14, 2026 07:59
@jonathanmos
jonathanmos merged commit 7fe6a67 into develop Jun 15, 2026
27 checks passed
@jonathanmos
jonathanmos deleted the jmoskovich/pass-logger-through-mappers branch June 15, 2026 07:26
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.

5 participants