@datadog/mobile-react-native-session-replay 2.9.0 → 2.10.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/DatadogSDKReactNativeSessionReplay.podspec +1 -1
- package/android/build.gradle +5 -3
- package/android/src/rn80/kotlin/com/datadog/reactnative/sessionreplay/extensions/ComputedBorderRadiusExt.kt +27 -0
- package/android/src/rn80/kotlin/com/datadog/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +157 -0
- package/package.json +2 -2
|
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
20
|
|
|
21
21
|
# /!\ Remember to keep the version in sync with DatadogSDKReactNative.podspec
|
|
22
|
-
s.dependency 'DatadogSessionReplay', '
|
|
22
|
+
s.dependency 'DatadogSessionReplay', '2.29.0'
|
|
23
23
|
s.dependency 'DatadogSDKReactNative'
|
|
24
24
|
|
|
25
25
|
s.test_spec 'Tests' do |test_spec|
|
package/android/build.gradle
CHANGED
|
@@ -135,7 +135,9 @@ android {
|
|
|
135
135
|
java.srcDirs += ['src/oldarch/kotlin']
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
if (reactNativeMinorVersion >=
|
|
138
|
+
if (reactNativeMinorVersion >= 80) {
|
|
139
|
+
java.srcDirs += ['src/rn80/kotlin']
|
|
140
|
+
} else if (reactNativeMinorVersion >= 79) {
|
|
139
141
|
java.srcDirs += ['src/rn79/kotlin']
|
|
140
142
|
} else if (reactNativeMinorVersion >= 76) {
|
|
141
143
|
java.srcDirs += ['src/rn76/kotlin']
|
|
@@ -209,8 +211,8 @@ dependencies {
|
|
|
209
211
|
api "com.facebook.react:react-android:$reactNativeVersion"
|
|
210
212
|
}
|
|
211
213
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
212
|
-
implementation "com.datadoghq:dd-sdk-android-session-replay:2.
|
|
213
|
-
implementation "com.datadoghq:dd-sdk-android-internal:2.
|
|
214
|
+
implementation "com.datadoghq:dd-sdk-android-session-replay:2.23.0"
|
|
215
|
+
implementation "com.datadoghq:dd-sdk-android-internal:2.23.0"
|
|
214
216
|
implementation project(path: ':datadog_mobile-react-native')
|
|
215
217
|
|
|
216
218
|
testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
package com.datadog.reactnative.sessionreplay.extensions
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.uimanager.style.ComputedBorderRadius
|
|
9
|
+
import com.facebook.react.uimanager.style.ComputedBorderRadiusProp
|
|
10
|
+
|
|
11
|
+
internal fun ComputedBorderRadius?.getAverage(): Float {
|
|
12
|
+
val topRightRadius = this
|
|
13
|
+
?.getAverageForProp(ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS) ?: 0f
|
|
14
|
+
val topLeftRadius = this
|
|
15
|
+
?.getAverageForProp(ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS) ?: 0f
|
|
16
|
+
val bottomRightRadius = this
|
|
17
|
+
?.getAverageForProp(ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS) ?: 0f
|
|
18
|
+
val bottomLeftRadius = this
|
|
19
|
+
?.getAverageForProp(ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS) ?: 0f
|
|
20
|
+
return (topRightRadius + topLeftRadius + bottomRightRadius + bottomLeftRadius) / 4f
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
internal fun ComputedBorderRadius?.getAverageForProp(prop: ComputedBorderRadiusProp): Float {
|
|
24
|
+
val vertical = this?.get(prop)?.vertical ?: 0f
|
|
25
|
+
val horizontal = this?.get(prop)?.vertical ?: 0f
|
|
26
|
+
return (vertical + horizontal) / 2f
|
|
27
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
import android.graphics.Canvas
|
|
7
|
+
import android.graphics.Color
|
|
8
|
+
import android.graphics.ColorFilter
|
|
9
|
+
import android.graphics.PixelFormat
|
|
10
|
+
import android.graphics.drawable.Drawable
|
|
11
|
+
import android.graphics.drawable.InsetDrawable
|
|
12
|
+
import android.graphics.drawable.LayerDrawable
|
|
13
|
+
import com.datadog.android.sessionreplay.model.MobileSegment
|
|
14
|
+
import com.datadog.reactnative.sessionreplay.extensions.getAverage
|
|
15
|
+
import com.datadog.reactnative.sessionreplay.utils.DrawableUtils
|
|
16
|
+
import com.datadog.reactnative.sessionreplay.utils.formatAsRgba
|
|
17
|
+
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
|
18
|
+
import com.facebook.react.uimanager.Spacing
|
|
19
|
+
import com.facebook.react.uimanager.drawable.CSSBackgroundDrawable
|
|
20
|
+
import com.facebook.react.uimanager.style.ComputedBorderRadius
|
|
21
|
+
|
|
22
|
+
internal class ReactViewBackgroundDrawableUtils : DrawableUtils() {
|
|
23
|
+
/**
|
|
24
|
+
* Used to wrap instances of internal class:
|
|
25
|
+
* com.facebook.react.uimanager.drawable.BackgroundDrawable
|
|
26
|
+
*/
|
|
27
|
+
class BackgroundDrawableWrapper(
|
|
28
|
+
val backgroundColor: String,
|
|
29
|
+
val cornerRadius: Float
|
|
30
|
+
) : Drawable() {
|
|
31
|
+
override fun draw(p0: Canvas) {}
|
|
32
|
+
override fun setAlpha(p0: Int) {}
|
|
33
|
+
override fun setColorFilter(p0: ColorFilter?) {}
|
|
34
|
+
@Suppress("OVERRIDE_DEPRECATION")
|
|
35
|
+
override fun getOpacity(): Int { return PixelFormat.OPAQUE }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
39
|
+
override fun resolveShapeAndBorder(
|
|
40
|
+
drawable: Drawable,
|
|
41
|
+
opacity: Float,
|
|
42
|
+
pixelDensity: Float
|
|
43
|
+
): Pair<MobileSegment.ShapeStyle?, MobileSegment.ShapeBorder?> {
|
|
44
|
+
if (drawable is BackgroundDrawableWrapper) {
|
|
45
|
+
return MobileSegment.ShapeStyle(
|
|
46
|
+
drawable.backgroundColor,
|
|
47
|
+
opacity,
|
|
48
|
+
drawable.cornerRadius
|
|
49
|
+
) to null
|
|
50
|
+
} else if (drawable is CSSBackgroundDrawable) {
|
|
51
|
+
val borderProps = resolveBorder(drawable, pixelDensity)
|
|
52
|
+
val backgroundColor = getCSSBackgroundColor(drawable)
|
|
53
|
+
val colorHexString = if (backgroundColor != null) {
|
|
54
|
+
formatAsRgba(backgroundColor)
|
|
55
|
+
} else {
|
|
56
|
+
return null to borderProps
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return MobileSegment.ShapeStyle(
|
|
60
|
+
colorHexString,
|
|
61
|
+
opacity,
|
|
62
|
+
getCSSComputedBorderRadius(drawable)?.getAverage() ?: 0f
|
|
63
|
+
) to borderProps
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return null to null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
70
|
+
override fun getReactBackgroundFromDrawable(drawable: Drawable?): Drawable? {
|
|
71
|
+
return when(drawable) {
|
|
72
|
+
is CSSBackgroundDrawable -> drawable
|
|
73
|
+
is InsetDrawable -> getReactBackgroundFromDrawable(drawable.drawable)
|
|
74
|
+
is LayerDrawable -> getDrawableFromLayerDrawable(drawable)
|
|
75
|
+
else -> null
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
80
|
+
private fun getDrawableFromLayerDrawable(layerDrawable: LayerDrawable): Drawable? {
|
|
81
|
+
for (layerNumber in 0 until layerDrawable.numberOfLayers) {
|
|
82
|
+
val layer = layerDrawable.getDrawable(layerNumber)
|
|
83
|
+
if (layer is CSSBackgroundDrawable) {
|
|
84
|
+
return layer
|
|
85
|
+
} else if (layer != null) {
|
|
86
|
+
if (layer.javaClass.name == "com.facebook.react.uimanager.drawable.BackgroundDrawable") {
|
|
87
|
+
val backgroundColor = getBackgroundColor(layer) ?: Color.TRANSPARENT
|
|
88
|
+
val cornerRadius = getComputedBorderRadius(layer)?.getAverage() ?: 0f
|
|
89
|
+
return BackgroundDrawableWrapper(
|
|
90
|
+
backgroundColor = formatAsRgba(backgroundColor),
|
|
91
|
+
cornerRadius = cornerRadius,
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return null
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
100
|
+
private fun getCSSComputedBorderRadius(
|
|
101
|
+
drawable: CSSBackgroundDrawable
|
|
102
|
+
): ComputedBorderRadius? {
|
|
103
|
+
return reflectionUtils.getDeclaredField(
|
|
104
|
+
drawable,
|
|
105
|
+
CSS_COMPUTED_BORDER_RADIUS_FIELD_NAME
|
|
106
|
+
) as? ComputedBorderRadius
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private fun getComputedBorderRadius(
|
|
110
|
+
drawable: Any
|
|
111
|
+
): ComputedBorderRadius? {
|
|
112
|
+
return reflectionUtils.getDeclaredField(
|
|
113
|
+
drawable,
|
|
114
|
+
COMPUTED_BORDER_RADIUS_FIELD_NAME
|
|
115
|
+
) as? ComputedBorderRadius
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
119
|
+
private fun getCSSBackgroundColor(
|
|
120
|
+
backgroundDrawable: CSSBackgroundDrawable
|
|
121
|
+
): Int? {
|
|
122
|
+
return reflectionUtils.getDeclaredField(
|
|
123
|
+
backgroundDrawable,
|
|
124
|
+
CSS_BACKGROUND_COLOR_FIELD_NAME
|
|
125
|
+
) as? Int
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private fun getBackgroundColor(
|
|
129
|
+
backgroundDrawable: Any
|
|
130
|
+
): Int? {
|
|
131
|
+
return reflectionUtils.getDeclaredField(
|
|
132
|
+
backgroundDrawable,
|
|
133
|
+
BACKGROUND_COLOR_FIELD_NAME
|
|
134
|
+
) as? Int
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
138
|
+
private fun resolveBorder(
|
|
139
|
+
backgroundDrawable: CSSBackgroundDrawable,
|
|
140
|
+
pixelDensity: Float
|
|
141
|
+
): MobileSegment.ShapeBorder {
|
|
142
|
+
val borderWidth = (backgroundDrawable.fullBorderWidth / pixelDensity).toLong()
|
|
143
|
+
val borderColor = formatAsRgba(backgroundDrawable.getBorderColor(Spacing.ALL))
|
|
144
|
+
|
|
145
|
+
return MobileSegment.ShapeBorder(
|
|
146
|
+
color = borderColor,
|
|
147
|
+
width = borderWidth
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private companion object {
|
|
152
|
+
private const val CSS_BACKGROUND_COLOR_FIELD_NAME = "mColor"
|
|
153
|
+
private const val CSS_COMPUTED_BORDER_RADIUS_FIELD_NAME = "mComputedBorderRadius"
|
|
154
|
+
private const val COMPUTED_BORDER_RADIUS_FIELD_NAME = "computedBorderRadius"
|
|
155
|
+
private const val BACKGROUND_COLOR_FIELD_NAME = "backgroundColor"
|
|
156
|
+
}
|
|
157
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native-session-replay",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "A client-side React Native module to enable session replay with Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"javaPackageName": "com.datadog.reactnative.sessionreplay"
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "dc5004b9971ffa1152916bea19a17d3202e004f0"
|
|
94
94
|
}
|