Skip to content

[FIX] [RUM-13466] iOS: fix AnyEncodable attribute decoding#1216

Merged
marco-saia-datadog merged 1 commit intodevelopfrom
marcosaia/RUM-13466/ios-shared-any-encodable
Mar 20, 2026
Merged

[FIX] [RUM-13466] iOS: fix AnyEncodable attribute decoding#1216
marco-saia-datadog merged 1 commit intodevelopfrom
marcosaia/RUM-13466/ios-shared-any-encodable

Conversation

@marco-saia-datadog
Copy link
Member

@marco-saia-datadog marco-saia-datadog commented Mar 19, 2026

What does this PR do?

On iOS, it replaces usages of the existing AnyEncodable internal definition with the imported AnyEncodable from DatadogInternal.

Motivation

When the IOS SDK decodes attributes before attaching them to the events, it expects dictionary-like objects to be of AnyEncodable (DatadogInternal), while currently they are of type DdSdkReactNative.AnyEncodable. This results in the final object to be nil.

In this specific case, it is blocking us from propagating the request and response headers from the JS layer down to the native event.

TODO: Regression Testing

  • Call setUser with an extraInfo containing nested objects and verify the data arrives correctly on the native event
  • Call setAccount with an extraInfo containing nested objects and verify the data arrives correctly on the native event
  • Call addAttribute / addAttributes with a nested object value and verify it appears correctly on RUM events
  • Call addAttribute / addAttributes with an array value and verify it appears correctly on RUM events
  • Set a global attribute with a nested object and verify it persists correctly across views
  • Send a log with a nested object attribute and verify the attribute arrives correctly
  • Start a trace span with a nested object tag and verify it arrives correctly
  • Verify nested structures are preserved (e.g., { a: { b: 1 } } is not flattened)
  • Verify arrays of objects remain intact
  • Verify primitive values inside nested objects keep their types (e.g., integers remain integers, not stringified)

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

@marco-saia-datadog marco-saia-datadog marked this pull request as ready for review March 19, 2026 16:31
@marco-saia-datadog marco-saia-datadog requested a review from a team as a code owner March 19, 2026 16:31
Copilot AI review requested due to automatic review settings March 19, 2026 16:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes iOS attribute decoding by removing the module-local AnyEncodable implementation and standardizing on DatadogInternal.AnyEncodable, matching what the iOS SDK expects when decoding nested/dictionary-like attributes.

Changes:

  • Import DatadogInternal in the attribute-casting utilities and rely on its AnyEncodable instead of a local wrapper.
  • Update unit tests to cast nested attributes using AnyEncodable (from DatadogInternal).
  • Add DatadogInternal import in AnyEncodableTests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/core/ios/Sources/AnyEncodable.swift Switches to DatadogInternal.AnyEncodable and removes the local AnyEncodable type implementation.
packages/core/ios/Tests/DdSdkTests.swift Updates nested extraInfo assertions to cast using AnyEncodable (expected SDK type).
packages/core/ios/Tests/AnyEncodableTests.swift Imports DatadogInternal so tests compile against the SDK’s AnyEncodable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/RUM-13466/ios-shared-any-encodable branch from 9d02758 to 50f4c7b Compare March 19, 2026 16:41
@marco-saia-datadog marco-saia-datadog merged commit 9a18fa9 into develop Mar 20, 2026
11 checks passed
@marco-saia-datadog marco-saia-datadog deleted the marcosaia/RUM-13466/ios-shared-any-encodable branch March 20, 2026 10:25
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