Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUMM-1213 Allow additional configuration when initializing the SDK #456

Merged
merged 2 commits into from
Apr 1, 2021

Conversation

xgouchet
Copy link
Member

What and why?

Let customer set additional configuration as a Dictionary. This will be used to configure internal settings of the SDK

@xgouchet xgouchet self-assigned this Mar 31, 2021
@xgouchet xgouchet requested a review from a team as a code owner March 31, 2021 08:47
Copy link
Member

@ncreated ncreated left a comment

Choose a reason for hiding this comment

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

Nice 👌. I left one important change request.

Additionally, we could pass this value to the FeaturesConfiguration.Common so it will become visible to all features. Or we can do it later, when implementing the first additional attribute.

@@ -277,6 +277,11 @@ public class DDConfigurationBuilder: NSObject {
_ = sdkBuilder.set(uploadFrequency: uploadFrequency.swiftType)
}

@objc
public func set(additionalConfiguration: [String: Any]) {
_ = sdkBuilder.set(additionalConfiguration: castAttributesToSwift(additionalConfiguration))
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't and we can't use castAttributesToSwift() in this case. The castAttributesToSwift() wraps Any value into AnyEncodable wrapper - so it changes its identity. That said, if we pass "_dd.foo": "bar" from Obj-c, the downstream assumption in Swift SDK will fail:

// This will fail, as `additionalConfigurations["_dd.foo"]` is `AnyEncodable`, not `String`:
let bar = additionalConfigurations["_dd.foo"] as? String

Instead, we should just pass the additionalConfiguration as it is:

_ = sdkBuilder.set(additionalConfiguration: additionalConfiguration)

so the above assumption can pass.

The castAttributesToSwift() is only used for capturing serializable values (log / span / rum attributes). In their case, we don't make the as? assumption on their identity - we just encode them using encoding implementation from AnyEncodable.

@xgouchet xgouchet requested a review from ncreated March 31, 2021 15:12
Copy link
Member

@ncreated ncreated left a comment

Choose a reason for hiding this comment

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

👌

@xgouchet xgouchet merged commit 8eb7385 into master Apr 1, 2021
@xgouchet xgouchet deleted the xgouchet/RUMM-1213/additional_configuration branch April 1, 2021 05:42
buranmert added a commit that referenced this pull request Apr 12, 2021
…nfiguration

RUMM-1213 Allow additional configuration when initializing the SDK
buranmert added a commit that referenced this pull request Apr 12, 2021
…nfiguration

RUMM-1213 Allow additional configuration when initializing the SDK
ncreated pushed a commit that referenced this pull request Apr 13, 2021
…nfiguration

RUMM-1213 Allow additional configuration when initializing the SDK

(cherry picked from commit 8eb7385)
ncreated pushed a commit that referenced this pull request Apr 13, 2021
…nfiguration

RUMM-1213 Allow additional configuration when initializing the SDK

(cherry picked from commit 8eb7385)
@ncreated ncreated mentioned this pull request Apr 13, 2021
2 tasks
@ncreated ncreated mentioned this pull request Jun 28, 2023
6 tasks
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