@datadog/mobile-react-native-webview 2.4.4 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNativeWebView.podspec +46 -0
- package/android/build.gradle +249 -0
- package/android/detekt.yml +572 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +11 -0
- package/android/src/newarch/com/datadog/reactnative/webview/DdSdkReactNativeWebViewPackage.kt +35 -0
- package/android/src/oldarch/com/datadog/reactnative/webview/DdSdkReactNativeWebViewManager.kt +112 -0
- package/android/src/oldarch/com/datadog/reactnative/webview/DdSdkReactNativeWebViewPackage.kt +36 -0
- package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/GenericAssert.kt +18 -0
- package/android/src/test/kotlin/com/datadog/reactnative/webview/DatadogWebViewTest.kt +126 -0
- package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
- package/ios/DatadogSDKReactNativeWebView.xcodeproj/project.pbxproj +272 -0
- package/ios/DatadogSDKReactNativeWebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/Sources/DatadogSDKReactNativeWebView.h +12 -0
- package/ios/Sources/RCTDatadogWebView.h +21 -0
- package/ios/Sources/RCTDatadogWebView.mm +53 -0
- package/ios/Sources/RCTDatadogWebViewManager.h +10 -0
- package/ios/Sources/RCTDatadogWebViewManager.mm +84 -0
- package/ios/Sources/RCTDatadogWebViewTracking.swift +67 -0
- package/lib/commonjs/ext-specs/NativeDdLogs.js +19 -0
- package/lib/commonjs/ext-specs/NativeDdLogs.js.map +1 -0
- package/lib/commonjs/ext-specs/NativeDdSdk.js.map +1 -0
- package/lib/commonjs/index.js +40 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeDdWebView.js +16 -0
- package/lib/commonjs/specs/NativeDdWebView.js.map +1 -0
- package/lib/commonjs/utils/env-utils.js +17 -0
- package/lib/commonjs/utils/env-utils.js.map +1 -0
- package/lib/commonjs/utils/webview-js-utils.js +124 -0
- package/lib/commonjs/utils/webview-js-utils.js.map +1 -0
- package/lib/module/ext-specs/NativeDdLogs.js +17 -0
- package/lib/module/ext-specs/NativeDdLogs.js.map +1 -0
- package/lib/module/ext-specs/NativeDdSdk.js.map +1 -0
- package/lib/module/index.js +39 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeDdWebView.js +11 -0
- package/lib/module/specs/NativeDdWebView.js.map +1 -0
- package/lib/module/utils/env-utils.js +10 -0
- package/lib/module/utils/env-utils.js.map +1 -0
- package/lib/module/utils/webview-js-utils.js +115 -0
- package/lib/module/utils/webview-js-utils.js.map +1 -0
- package/lib/typescript/ext-specs/NativeDdLogs.d.ts +16 -0
- package/lib/typescript/ext-specs/NativeDdLogs.d.ts.map +1 -0
- package/lib/typescript/ext-specs/NativeDdSdk.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +20 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdWebView.d.ts +4 -0
- package/lib/typescript/specs/NativeDdWebView.d.ts.map +1 -0
- package/lib/typescript/utils/env-utils.d.ts +2 -0
- package/lib/typescript/utils/env-utils.d.ts.map +1 -0
- package/lib/typescript/utils/webview-js-utils.d.ts +34 -0
- package/lib/typescript/utils/webview-js-utils.d.ts.map +1 -0
- package/package.json +22 -4
- package/src/__tests__/WebviewDatadog.test.tsx +39 -43
- package/src/__tests__/WebviewDatadogInjectedJS.test.tsx +200 -1
- package/src/__tests__/WebviewDatadogPerformance.test.tsx +12 -0
- package/src/__tests__/__utils__/string-utils.ts +13 -0
- package/src/__tests__/webview-js-utils.test.ts +51 -0
- package/src/ext-specs/NativeDdLogs.ts +25 -0
- package/src/{NativeDdSdk.ts → ext-specs/NativeDdSdk.ts} +1 -0
- package/src/index.tsx +70 -13
- package/src/specs/NativeDdWebView.ts +16 -0
- package/src/utils/env-utils.ts +9 -0
- package/src/utils/webview-js-utils.ts +150 -0
- package/lib/commonjs/NativeDdSdk.js.map +0 -1
- package/lib/commonjs/__utils__/formatAllowedHosts.js +0 -65
- package/lib/commonjs/__utils__/formatAllowedHosts.js.map +0 -1
- package/lib/commonjs/__utils__/getInjectedJavaScriptBeforeContentLoaded.js +0 -32
- package/lib/commonjs/__utils__/getInjectedJavaScriptBeforeContentLoaded.js.map +0 -1
- package/lib/module/NativeDdSdk.js.map +0 -1
- package/lib/module/__utils__/formatAllowedHosts.js +0 -58
- package/lib/module/__utils__/formatAllowedHosts.js.map +0 -1
- package/lib/module/__utils__/getInjectedJavaScriptBeforeContentLoaded.js +0 -24
- package/lib/module/__utils__/getInjectedJavaScriptBeforeContentLoaded.js.map +0 -1
- package/lib/typescript/NativeDdSdk.d.ts.map +0 -1
- package/lib/typescript/__utils__/formatAllowedHosts.d.ts +0 -2
- package/lib/typescript/__utils__/formatAllowedHosts.d.ts.map +0 -1
- package/lib/typescript/__utils__/getInjectedJavaScriptBeforeContentLoaded.d.ts +0 -3
- package/lib/typescript/__utils__/getInjectedJavaScriptBeforeContentLoaded.d.ts.map +0 -1
- package/src/__tests__/formatAllowedHosts.test.ts +0 -40
- package/src/__tests__/getInjectedJavaScriptBeforeContentLoaded.test.ts +0 -86
- package/src/__utils__/formatAllowedHosts.ts +0 -70
- package/src/__utils__/getInjectedJavaScriptBeforeContentLoaded.ts +0 -29
- /package/lib/commonjs/{NativeDdSdk.js → ext-specs/NativeDdSdk.js} +0 -0
- /package/lib/module/{NativeDdSdk.js → ext-specs/NativeDdSdk.js} +0 -0
- /package/lib/typescript/{NativeDdSdk.d.ts → ext-specs/NativeDdSdk.d.ts} +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "DatadogSDKReactNativeWebView"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => "12.0", :tvos => "12.0" }
|
|
14
|
+
s.source = { :git => "https://github.com/DataDog/dd-sdk-reactnative.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/Sources/*.{h,m,mm,swift}"
|
|
18
|
+
|
|
19
|
+
s.dependency "React-Core"
|
|
20
|
+
|
|
21
|
+
# /!\ Remember to keep the version in sync with DatadogSDKReactNative.podspec
|
|
22
|
+
s.dependency 'DatadogWebViewTracking', '~> 2.18.0'
|
|
23
|
+
s.dependency 'DatadogInternal', '~> 2.18.0'
|
|
24
|
+
s.dependency 'DatadogSDKReactNative'
|
|
25
|
+
|
|
26
|
+
s.test_spec 'Tests' do |test_spec|
|
|
27
|
+
test_spec.dependency "react-native-webview"
|
|
28
|
+
test_spec.dependency "React-RCTText"
|
|
29
|
+
|
|
30
|
+
test_spec.source_files = 'ios/Tests/*.swift'
|
|
31
|
+
test_spec.platforms = { :ios => "13.4", :tvos => "13.4" }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# This guard prevents installing the dependencies when we run `pod install` in the old architecture.
|
|
36
|
+
# The `install_modules_dependencies` function is only available from RN 0.71, the new architecture is not
|
|
37
|
+
# supported on earlier RN versions.
|
|
38
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
39
|
+
s.pod_target_xcconfig = {
|
|
40
|
+
"DEFINES_MODULE" => "YES",
|
|
41
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DRCT_NEW_ARCH_ENABLED=1"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
install_modules_dependencies(s)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import java.nio.file.Paths
|
|
2
|
+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
3
|
+
|
|
4
|
+
buildscript {
|
|
5
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
6
|
+
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['DatadogSDKReactNativeWebView_kotlinVersion']
|
|
7
|
+
|
|
8
|
+
repositories {
|
|
9
|
+
mavenCentral()
|
|
10
|
+
google()
|
|
11
|
+
gradlePluginPortal()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
dependencies {
|
|
15
|
+
classpath 'com.android.tools.build:gradle:7.2.2'
|
|
16
|
+
// noinspection DifferentKotlinGradleVersion
|
|
17
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
18
|
+
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1"
|
|
19
|
+
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.0"
|
|
20
|
+
classpath 'com.github.bjoernq:unmockplugin:0.7.9'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
apply plugin: 'de.mobilej.unmock'
|
|
26
|
+
|
|
27
|
+
def isNewArchitectureEnabled() {
|
|
28
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
apply plugin: 'com.android.library'
|
|
32
|
+
if (isNewArchitectureEnabled()) {
|
|
33
|
+
apply plugin: 'com.facebook.react'
|
|
34
|
+
}
|
|
35
|
+
apply plugin: 'kotlin-android'
|
|
36
|
+
apply plugin: 'org.jlleitschuh.gradle.ktlint'
|
|
37
|
+
apply plugin: "io.gitlab.arturbosch.detekt"
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Finds the path of the installed npm package with the given name using Node's
|
|
41
|
+
* module resolution algorithm, which searches "node_modules" directories up to
|
|
42
|
+
* the file system root.
|
|
43
|
+
* This enables us to handle monorepos without requiring the node executable.
|
|
44
|
+
*
|
|
45
|
+
* The search begins at the given base directory (a File object). The returned
|
|
46
|
+
* path is a string.
|
|
47
|
+
*/
|
|
48
|
+
static def findNodeModulePath(baseDir, packageName) {
|
|
49
|
+
def basePath = baseDir.toPath().normalize()
|
|
50
|
+
// Node's module resolution algorithm searches up to the root directory,
|
|
51
|
+
// after which the base path will be null
|
|
52
|
+
while (basePath) {
|
|
53
|
+
def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
|
|
54
|
+
if (candidatePath.toFile().exists()) {
|
|
55
|
+
return candidatePath.toString()
|
|
56
|
+
}
|
|
57
|
+
basePath = basePath.getParent()
|
|
58
|
+
}
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
def resolveReactNativeDirectory() {
|
|
63
|
+
def reactNativeLocation = rootProject.hasProperty("reactNativeDir") ? rootProject.getProperty("reactNativeDir") : null
|
|
64
|
+
|
|
65
|
+
if (reactNativeLocation != null) {
|
|
66
|
+
return file(reactNativeLocation)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
def reactNativePath = findNodeModulePath(projectDir, "react-native")
|
|
70
|
+
|
|
71
|
+
if (reactNativePath != null) {
|
|
72
|
+
return file(reactNativePath)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
throw new Exception(
|
|
76
|
+
"${project.name}: Failed to resolve 'react-native' in the project. " +
|
|
77
|
+
"Altenatively, you can specify 'reactNativeDir' with the path to 'react-native' in your 'gradle.properties' file."
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
def reactNativeRootDir = resolveReactNativeDirectory()
|
|
82
|
+
def reactProperties = new Properties()
|
|
83
|
+
file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
|
|
84
|
+
|
|
85
|
+
def reactNativeVersion = reactProperties.getProperty("VERSION_NAME")
|
|
86
|
+
def (reactNativeMajorVersion, reactNativeMinorVersion) = reactNativeVersion.split("\\.").collect { it.isInteger() ? it.toInteger() : it }
|
|
87
|
+
|
|
88
|
+
def getExtOrDefault(name) {
|
|
89
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['DatadogSDKReactNativeWebView_' + name]
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
def getExtOrIntegerDefault(name) {
|
|
93
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['DatadogSDKReactNativeWebView_' + name]).toInteger()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
android {
|
|
97
|
+
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
98
|
+
buildToolsVersion getExtOrDefault('buildToolsVersion')
|
|
99
|
+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
|
100
|
+
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
|
|
101
|
+
namespace = "com.datadog.reactnative.webview"
|
|
102
|
+
}
|
|
103
|
+
if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
|
|
104
|
+
buildFeatures {
|
|
105
|
+
buildConfig = true
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
|
|
109
|
+
compileOptions {
|
|
110
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
111
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
112
|
+
}
|
|
113
|
+
kotlinOptions {
|
|
114
|
+
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
defaultConfig {
|
|
119
|
+
minSdkVersion 21
|
|
120
|
+
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
121
|
+
versionCode 1
|
|
122
|
+
versionName "1.0"
|
|
123
|
+
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
sourceSets {
|
|
127
|
+
main {
|
|
128
|
+
if (isNewArchitectureEnabled()) {
|
|
129
|
+
java.srcDirs += ['src/newarch']
|
|
130
|
+
} else {
|
|
131
|
+
java.srcDirs += ['src/oldarch']
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
test {
|
|
136
|
+
java.srcDir("src/test/kotlin")
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
testOptions {
|
|
141
|
+
unitTests {
|
|
142
|
+
returnDefaultValues = true
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
buildTypes {
|
|
147
|
+
release {
|
|
148
|
+
minifyEnabled false
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
lintOptions {
|
|
152
|
+
disable 'GradleCompatible'
|
|
153
|
+
}
|
|
154
|
+
compileOptions {
|
|
155
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
156
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
repositories {
|
|
161
|
+
mavenCentral()
|
|
162
|
+
google()
|
|
163
|
+
maven { url "https://jitpack.io" }
|
|
164
|
+
mavenLocal()
|
|
165
|
+
|
|
166
|
+
if (reactNativeMajorVersion == 0 && reactNativeMinorVersion < 71) {
|
|
167
|
+
def androidSourcesDir = file("$reactNativeRootDir/android")
|
|
168
|
+
def androidSourcesName = "React Native sources"
|
|
169
|
+
|
|
170
|
+
if (androidSourcesDir.exists()) {
|
|
171
|
+
maven {
|
|
172
|
+
url androidSourcesDir.toString()
|
|
173
|
+
name androidSourcesName
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
180
|
+
|
|
181
|
+
dependencies {
|
|
182
|
+
if (reactNativeMajorVersion == 0 && reactNativeMinorVersion < 71) {
|
|
183
|
+
// noinspection GradleDynamicVersion
|
|
184
|
+
api 'com.facebook.react:react-native:+'
|
|
185
|
+
} else {
|
|
186
|
+
// We specify the $reactNativeVersion, like it's done on the react-native-gradle-plugin, as the plugin is not applied in tests.
|
|
187
|
+
// There is no impact for apps as we apply the same logic:
|
|
188
|
+
// https://github.com/facebook/react-native/blob/e1a1e6aa8030bf11d691c3dcf7abd13b25175027/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt
|
|
189
|
+
implementation "com.facebook.react:react-android:$reactNativeVersion"
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
implementation "com.datadoghq:dd-sdk-android-webview:2.14.0"
|
|
193
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
194
|
+
|
|
195
|
+
implementation project(path: ':datadog_mobile-react-native')
|
|
196
|
+
implementation project(path: ':react-native-webview')
|
|
197
|
+
|
|
198
|
+
testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
|
|
199
|
+
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
|
|
200
|
+
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.6.2"
|
|
201
|
+
testImplementation "org.junit.jupiter:junit-jupiter-params:5.6.2"
|
|
202
|
+
testImplementation "org.mockito:mockito-junit-jupiter:3.4.6"
|
|
203
|
+
testImplementation "org.assertj:assertj-core:3.18.1"
|
|
204
|
+
testImplementation "com.github.xgouchet.Elmyr:core:1.3.1"
|
|
205
|
+
testImplementation "com.github.xgouchet.Elmyr:inject:1.3.1"
|
|
206
|
+
testImplementation "com.github.xgouchet.Elmyr:junit5:1.3.1"
|
|
207
|
+
testImplementation "com.github.xgouchet.Elmyr:jvm:1.3.1"
|
|
208
|
+
testImplementation "org.mockito.kotlin:mockito-kotlin:5.1.0"
|
|
209
|
+
testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
|
210
|
+
unmock 'org.robolectric:android-all:4.4_r1-robolectric-r2'
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
tasks.withType(Test) {
|
|
214
|
+
useJUnitPlatform {
|
|
215
|
+
includeEngines("spek", "junit-jupiter", "junit-vintage")
|
|
216
|
+
}
|
|
217
|
+
reports {
|
|
218
|
+
junitXml.required.set(true)
|
|
219
|
+
html.required.set(true)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
tasks.named("check") {
|
|
224
|
+
dependsOn("ktlintCheck")
|
|
225
|
+
dependsOn("detekt")
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
ktlint {
|
|
229
|
+
debug.set(false)
|
|
230
|
+
android.set(true)
|
|
231
|
+
outputToConsole.set(true)
|
|
232
|
+
ignoreFailures.set(false)
|
|
233
|
+
enableExperimentalRules.set(false)
|
|
234
|
+
filter {
|
|
235
|
+
exclude("**/generated/**")
|
|
236
|
+
include("**/kotlin/**")
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
detekt {
|
|
241
|
+
input = files("$projectDir/src/main/kotlin")
|
|
242
|
+
config = files("$projectDir/detekt.yml")
|
|
243
|
+
reports {
|
|
244
|
+
xml {
|
|
245
|
+
enabled = true
|
|
246
|
+
destination = file("build/reports/detekt.xml")
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|