-
Notifications
You must be signed in to change notification settings - Fork 44
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
Migrate native SDKs to v2 #523
Conversation
c4a3dbf
to
375636d
Compare
6fd80c4
to
2766f66
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not gonna lie, I skimmed the changes to the main unit test files
I may come back and do a second pass on those files specifically.
@@ -53,22 +77,38 @@ internal class DatadogSDKWrapper : DatadogWrapper { | |||
} | |||
|
|||
override fun telemetryDebug(message: String) { | |||
Datadog._internal._telemetry.debug(message) | |||
// Do not initialize the telemetry proxy before SDK is initialized | |||
if (isInitialized()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you simplify this a bit and have telemetryProxy
return an optional, then move the check into that accessor? Same with webViewProxy
.
@@ -274,7 +240,7 @@ class DdSdkImplementation( | |||
} | |||
) | |||
|
|||
_InternalProxy.setTelemetryConfigurationEventMapper( | |||
_RumInternalProxy.setTelemetryConfigurationEventMapper( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird that Android kept this and iOS didn't...
@@ -7,13 +7,14 @@ | |||
package com.datadog.reactnative | |||
|
|||
import android.content.Context | |||
import com.datadog.android.api.SdkCore | |||
import com.datadog.android.rum.tracking.ViewTrackingStrategy | |||
|
|||
/** | |||
* No-op implementation of the [ViewTrackingStrategy]. | |||
*/ | |||
object NoOpViewTrackingStrategy : ViewTrackingStrategy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't NoOpViewTrackingStrategy available in the SDK now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it's internal
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could make it public 🤔
self.mainDispatchQueue = mainDispatchQueue | ||
self.jsDispatchQueue = jsDispatchQueue | ||
self.jsRefreshRateMonitor = jsRefreshRateMonitor | ||
self.RUMMonitorProvider = RUMMonitorProvider | ||
self.RUMMonitorInternalProvider = RUMMonitorInternalProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth looking into this double injections now that ._internal
isn't overly specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because _internal
is an extension I cannot override it from a Monitor
mock, so I need to inject it as well.
Let me know if you see a good way for doing this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had MockRUMMonitor
extend both RUMMonitorProtocol
and RUMCommandSubscriber
. It's a little white-boxy, but all of the _internal
methods send commands to the subscriber, so I check the correct commands get sent to the Subscriber.
Relevant code from the Flutter repo: https://github.com/DataDog/dd-sdk-flutter/blob/79b2c00d4b2fcc81a55093cdbea63f9e3c9d735c/packages/datadog_flutter_plugin/example/ios/Tests/DatadogRumPluginTests.swift#L498
That said, in order for ._internal
to be able to return your mock, it requires a change I made in iOS which I don't think is in a released version yet, so... this may be moot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's not a huge change to make the change in the tests once your change makes it in a released version, I can make it in a separate PR if that's ok with you?
affc501
to
2766f66
Compare
d16840a
to
d77f4bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Probably worth upgrading to 2.2.1
Other than that left some minor comments
s.dependency 'DatadogCore', '~> 2.2.0' | ||
s.dependency 'DatadogLogs', '~> 2.2.0' | ||
s.dependency 'DatadogTrace', '~> 2.2.0' | ||
s.dependency 'DatadogRUM', '~> 2.2.0' | ||
s.dependency 'DatadogCrashReporting', '~> 2.2.0' | ||
s.dependency 'DatadogWebViewTracking', '~> 2.2.0' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's 2.2.1 now :)
if (field == null) { | ||
if (isInitialized()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to use && to join nested if statements in cases like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this leads to a huge improvement to performance, but I think this way conveys more meaning into the order in which we want to make the checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normally logical checks are performed left to right and if something on the left of && fails it doesn't even compute the right statement.
It's more of a pyramind of doom concern.
configBuilder.setAdditionalConfiguration( | ||
additionalConfig?.filterValues { it != null }?.mapValues { | ||
it.value!! | ||
} | ||
?: emptyMap() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be rusty on kotlin, but I think you can avoid force unwrap this way:
configBuilder.setAdditionalConfiguration(
additionalConfig?.mapValues {
it?.value
}.filterNotNull() ?: emptyMap()
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather make that change in a separate PR to avoid adding more chances to break in this one which is already pretty big if that's ok with you
@@ -7,13 +7,14 @@ | |||
package com.datadog.reactnative | |||
|
|||
import android.content.Context | |||
import com.datadog.android.api.SdkCore | |||
import com.datadog.android.rum.tracking.ViewTrackingStrategy | |||
|
|||
/** | |||
* No-op implementation of the [ViewTrackingStrategy]. | |||
*/ | |||
object NoOpViewTrackingStrategy : ViewTrackingStrategy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could make it public 🤔
public var uploadFrequency: Datadog.Configuration.UploadFrequency | ||
public var batchSize: Datadog.Configuration.BatchSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably should keep defaults for these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these defaults dont make any sense since we always set these values in the init
function.
Actually we should probably remove all of them, as they could be misleading and this would allow us to detect if any value is not set by accident in the init
function.
Do you agree or do you see a good reason to keep them?
@testable import DatadogInternal | ||
@testable import DatadogSDKReactNative | ||
|
||
internal class MockRUMMonitor: RUMMonitorProtocol { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you generating these using stencil or something?
I leverage Sourcery for these kind of tasks. Saves some minutes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing it by hand, but I'll improve the toolchain on iOS in a follow-up PR before releasing v2!
92f5b5e
to
eee8f69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does this PR do?
Migrate native SDKs to v2.
Review checklist (to be filled by reviewers)