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

Create SR module without native implementation #541

Conversation

louiszawadzki
Copy link
Contributor

What does this PR do?

This creates a module for SR with no actual logic on the native side.
The configuration on the JS side is done, no more thing should be needed here after.

The package cannot be published to npm, even by accident.

Additional Notes

A coming PR will enable SR on both Android and iOS and add test + linting on native code in Bitrise.

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

@louiszawadzki louiszawadzki requested review from a team as code owners October 25, 2023 11:37
buildToolsVersion getExtOrDefault('buildToolsVersion')
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
namespace = "com.datadog.sessionreplay.reactnative"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if you think we can come up with a better package name (the core package name is com.datadog.reactnative

Copy link
Member

Choose a reason for hiding this comment

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

yes, let's flip the parts and call it com.datadog.reactnative.sessionreplay, this will align with the naming on the native side, which is com.datadog.android.sessionreplay

@louiszawadzki louiszawadzki force-pushed the louiszawadzki/rum-1815/create-sr-module-without-native-implementation branch from 728336e to 85ee611 Compare October 25, 2023 11:53
@louiszawadzki louiszawadzki force-pushed the louiszawadzki/rum-1815/create-sr-module-without-native-implementation branch 5 times, most recently from d4fc364 to 5f9f7eb Compare October 25, 2023 14:11
},
"license": "Apache-2.0",
"main": "lib/commonjs/index",
"private": true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the line that prevents the package from being published

buraizu
buraizu previously approved these changes Oct 25, 2023
Copy link
Contributor

@buraizu buraizu left a comment

Choose a reason for hiding this comment

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

Approving the packages/react-native-session-replay/README.md update, but just wanted to ask whether it's necessary to add a page for something that's not supported yet. Is this something that's expected later?

I might be misunderstanding something or not have all the relevant context, but flagging just in case.

@louiszawadzki louiszawadzki dismissed buraizu’s stale review October 25, 2023 21:35

The merge-base changed after approval.

Comment on lines 4 to 8
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.0))
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
Copy link
Member

Choose a reason for hiding this comment

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

is this file needed? it contains very old references to Gradle 6.0, which is not used for sure, and Java 11 is needed at least instead of the Java 1.8 referenced here.

buildToolsVersion getExtOrDefault('buildToolsVersion')
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
namespace = "com.datadog.sessionreplay.reactnative"
Copy link
Member

Choose a reason for hiding this comment

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

yes, let's flip the parts and call it com.datadog.reactnative.sessionreplay, this will align with the naming on the native side, which is com.datadog.android.sessionreplay

}
}

// This is needed to make unmock work. Choreographer class was loaded from android.jar of Android SDK
Copy link
Member

Choose a reason for hiding this comment

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

There is no more Choreographer class usage in Android SDK, is this configuration lambda needed?

Comment on lines 2 to 4
DatadogSDKReactNativeSessionReplay_compileSdkVersion=31
DatadogSDKReactNativeSessionReplay_buildToolsVersion=31.0.0
DatadogSDKReactNativeSessionReplay_targetSdkVersion=31
Copy link
Member

Choose a reason for hiding this comment

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

minor question: given that the current Android API is 34, should we target it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to keep this in sync with the value used in the version of the RN dev dependency (currently 0.71).
So I agree it should be at least 33 which is the default version for RN 0.71 and 0.72.

Is it ok if I bump it to 34 once we migrate the RN dev dependency to 0.73?

Copy link
Member

Choose a reason for hiding this comment

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

My question is just theoretical, let's keep it in sync with the value used by the latest RN version we are using.

@louiszawadzki louiszawadzki force-pushed the louiszawadzki/rum-1815/create-sr-module-without-native-implementation branch 2 times, most recently from 1697817 to 5c54e0d Compare October 26, 2023 08:50
@louiszawadzki louiszawadzki requested a review from 0xnm October 26, 2023 09:05
@louiszawadzki louiszawadzki force-pushed the louiszawadzki/rum-1815/create-sr-module-without-native-implementation branch from 5c54e0d to 0f14db3 Compare October 26, 2023 09:07
api "com.facebook.react:react-android:$reactNativeVersion"
}
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compileOnly "com.squareup.okhttp3:okhttp:3.12.13"
Copy link
Member

Choose a reason for hiding this comment

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

FYI: SDK v2 is on OkHttp 4.11 https://github.com/DataDog/dd-sdk-android/blob/4744e9d7f85449708c96580ba5f7bd9695dbebc0/gradle/libs.versions.toml#L6, so you probably would like to change the version here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed it's not needed here.
We only use it for the ProxyAuthenticator and it's compileOnly, so the migration should be fairly easy for core.
I will create a technical task for the migration.

Copy link
Member

Choose a reason for hiding this comment

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

all files should be moved to conform the new namespace, they shouldn't be under com/datadog/sessionreplay/reactnative, but under com/datadog/reactnative/sessionreplay

@louiszawadzki louiszawadzki force-pushed the louiszawadzki/rum-1815/create-sr-module-without-native-implementation branch 2 times, most recently from 1765a47 to a65de6b Compare October 26, 2023 13:43
@louiszawadzki louiszawadzki requested a review from 0xnm October 26, 2023 13:45
0xnm
0xnm previously approved these changes Oct 26, 2023
Comment on lines 133 to 134
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Copy link
Member

Choose a reason for hiding this comment

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

SDK v2 is producing Java 11 bytecode, so maybe you would like to align

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the risk with changing this value?
I would prefer to make the change in a dedicated PR to avoid breaking support for some client apps.

Copy link
Member

@0xnm 0xnm Oct 27, 2023

Choose a reason for hiding this comment

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

I guess there is no risk, because SDK v2 artifacts are already with Java 11 bytecode anyway. Out of curiosity, what bytecode level is emitted by RN itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's VERSION_11 for the latest versions.

Comment on lines 186 to 192
unMock {
keep("android.os.Looper")
keep("android.os.MessageQueue")
keep("android.os.SystemProperties")
keep("android.view.Choreographer")
keep("android.view.DisplayEventReceiver")
}
Copy link
Member

Choose a reason for hiding this comment

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

not sure if all this is still needed with SDK v2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed for RNSR but still needed for core tests. I will remove in the next PR so you don't have to approve this one again for it to be merged :)

@louiszawadzki
Copy link
Contributor Author

louiszawadzki commented Oct 26, 2023

@buraizu I wanted to add an indication in case someone noticed it browsing github and would attempt to use it right away.

@louiszawadzki louiszawadzki force-pushed the louiszawadzki/rum-1815/create-sr-module-without-native-implementation branch from a65de6b to 5c58db4 Compare October 27, 2023 12:05
testImplementation "com.github.xgouchet.Elmyr:jvm:1.3.1"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
unmock 'org.robolectric:android-all:4.4_r1-robolectric-r2'
Copy link
Member

Choose a reason for hiding this comment

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

probably you don't need this either and no need to apply unmock plugin as well, but this is very minor, can be addressed later

@louiszawadzki louiszawadzki merged commit 62c2833 into develop Oct 27, 2023
3 checks passed
@louiszawadzki louiszawadzki deleted the louiszawadzki/rum-1815/create-sr-module-without-native-implementation branch October 27, 2023 12:17
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