@amplitude/session-replay-react-native 0.1.0-beta.1 → 0.1.0-beta.2
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/AmplitudeSessionReplayReactNative.podspec +43 -2
- package/README.md +112 -0
- package/android/build.gradle +127 -9
- package/android/src/androidTest/java/com/amplitude/sessionreplayreactnative/SRMaskViewTest.kt +459 -0
- package/android/src/main/java/com/amplitude/sessionreplayreactnative/SRDefaultMaskingPrimitive.kt +36 -0
- package/android/src/main/java/com/amplitude/sessionreplayreactnative/SRMaskingPrimitive.kt +84 -0
- package/android/src/main/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeModule.kt +35 -5
- package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativePackage.kt +2 -1
- package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskView.kt +174 -0
- package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskViewManager.kt +44 -0
- package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskViewPointerEvents.java +36 -0
- package/cpp/SRMaskViewComponentDescriptor.h +20 -0
- package/cpp/SRMaskViewShadowNode.cpp +54 -0
- package/cpp/SRMaskViewShadowNode.h +56 -0
- package/ios/NativeSessionReplay.swift +29 -8
- package/ios/SRDefaultMaskingPrimitive.swift +34 -0
- package/ios/SRMaskingPrimitive.h +26 -0
- package/ios/SRMaskingRegistry.m +105 -0
- package/ios/fabric/SRMaskView.h +10 -0
- package/ios/fabric/SRMaskView.mm +178 -0
- package/lib/commonjs/Mask.types.js +29 -0
- package/lib/commonjs/Mask.types.js.map +1 -0
- package/lib/commonjs/fabric/MaskFabric.js +92 -0
- package/lib/commonjs/fabric/MaskFabric.js.map +1 -0
- package/lib/commonjs/index.js +19 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mask-fallback.js +53 -0
- package/lib/commonjs/mask-fallback.js.map +1 -0
- package/lib/commonjs/paper/MaskPaper.js +27 -0
- package/lib/commonjs/paper/MaskPaper.js.map +1 -0
- package/lib/commonjs/specs/SRMaskViewNativeComponent.js +11 -0
- package/lib/commonjs/specs/SRMaskViewNativeComponent.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/module/Mask.types.js +23 -0
- package/lib/module/Mask.types.js.map +1 -0
- package/lib/module/fabric/MaskFabric.js +85 -0
- package/lib/module/fabric/MaskFabric.js.map +1 -0
- package/lib/module/index.js +15 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mask-fallback.js +45 -0
- package/lib/module/mask-fallback.js.map +1 -0
- package/lib/module/paper/MaskPaper.js +21 -0
- package/lib/module/paper/MaskPaper.js.map +1 -0
- package/lib/module/specs/SRMaskViewNativeComponent.js +5 -0
- package/lib/module/specs/SRMaskViewNativeComponent.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/Mask.types.d.ts +38 -0
- package/lib/typescript/Mask.types.d.ts.map +1 -0
- package/lib/typescript/fabric/MaskFabric.d.ts +8 -0
- package/lib/typescript/fabric/MaskFabric.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +11 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/mask-fallback.d.ts +27 -0
- package/lib/typescript/mask-fallback.d.ts.map +1 -0
- package/lib/typescript/paper/MaskPaper.d.ts +10 -0
- package/lib/typescript/paper/MaskPaper.d.ts.map +1 -0
- package/lib/typescript/specs/SRMaskViewNativeComponent.d.ts +11 -0
- package/lib/typescript/specs/SRMaskViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +11 -6
- package/src/Mask.types.ts +45 -0
- package/src/fabric/MaskFabric.tsx +73 -0
- package/src/index.tsx +18 -0
- package/src/mask-fallback.tsx +60 -0
- package/src/paper/MaskPaper.tsx +24 -0
- package/src/specs/SRMaskViewNativeComponent.ts +12 -0
- package/src/version.ts +1 -1
|
@@ -3,6 +3,31 @@ require "json"
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
4
|
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
5
|
|
|
6
|
+
# --- RN-floor gate: Fabric SRMaskView (cpp + ios/fabric) needs new-arch + RN >= 0.77 ---
|
|
7
|
+
new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
8
|
+
rn_version = nil
|
|
9
|
+
begin
|
|
10
|
+
rn_pkg_path = `node -e "console.log(require.resolve('react-native/package.json'))"`.strip
|
|
11
|
+
rn_version = JSON.parse(File.read(rn_pkg_path))["version"] unless rn_pkg_path.empty?
|
|
12
|
+
rescue StandardError
|
|
13
|
+
rn_version = nil
|
|
14
|
+
end
|
|
15
|
+
srmaskview_version_ge_077 = lambda do |v|
|
|
16
|
+
next false if v.nil?
|
|
17
|
+
parts = v.split('.')
|
|
18
|
+
major = parts[0].to_i
|
|
19
|
+
minor = parts[1].to_i
|
|
20
|
+
major > 0 || (major == 0 && minor >= 77)
|
|
21
|
+
end
|
|
22
|
+
# Only a KNOWN RN below 0.77 disqualifies Fabric. When the version is unresolvable,
|
|
23
|
+
# the Fabric sources must still build: codegen (type:"all") references SRMaskViewCls
|
|
24
|
+
# unconditionally, so omitting them would break linking. (Android gates the same way.)
|
|
25
|
+
rn_known_below_077 = !rn_version.nil? && !srmaskview_version_ge_077.call(rn_version)
|
|
26
|
+
if new_arch_enabled && rn_known_below_077
|
|
27
|
+
raise "[AmplitudeSessionReplayReactNative] The Fabric SRMaskView component requires React Native >= 0.77 with the New Architecture (found #{rn_version})."
|
|
28
|
+
end
|
|
29
|
+
fabric_enabled = new_arch_enabled && !rn_known_below_077
|
|
30
|
+
|
|
6
31
|
Pod::Spec.new do |s|
|
|
7
32
|
s.name = "AmplitudeSessionReplayReactNative"
|
|
8
33
|
s.version = package["version"].split(/[-+]/).first
|
|
@@ -14,7 +39,15 @@ Pod::Spec.new do |s|
|
|
|
14
39
|
s.platforms = { :ios => min_ios_version_supported }
|
|
15
40
|
s.source = { :git => "https://github.com/amplitude/Amplitude-TypeScript.git", :tag => "#{s.version}" }
|
|
16
41
|
|
|
17
|
-
|
|
42
|
+
if fabric_enabled
|
|
43
|
+
# Fabric build: include the C++ ShadowNode + the ios/fabric host view.
|
|
44
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}", "cpp/**/*.{h,cpp}"
|
|
45
|
+
s.public_header_files = "ios/SRMaskingPrimitive.h", "ios/NativeSessionReplay-Bridging-Header.h"
|
|
46
|
+
s.private_header_files = "ios/fabric/**/*.h", "cpp/**/*.h"
|
|
47
|
+
else
|
|
48
|
+
# No Fabric: exclude cpp/** and ios/fabric/** (they pull in renderer headers).
|
|
49
|
+
s.source_files = "ios/*.{h,m,mm,swift}"
|
|
50
|
+
end
|
|
18
51
|
|
|
19
52
|
s.dependency 'AmplitudeSessionReplay', '>=0.11.1'
|
|
20
53
|
s.dependency 'AmplitudeCore', '>=1.4.2'
|
|
@@ -24,6 +57,14 @@ Pod::Spec.new do |s|
|
|
|
24
57
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
25
58
|
if respond_to?(:install_modules_dependencies, true)
|
|
26
59
|
install_modules_dependencies(s)
|
|
60
|
+
if fabric_enabled
|
|
61
|
+
# Fabric shadow-node C++ headers break Clang module dependency scanning.
|
|
62
|
+
existing_xcconfig = s.attributes_hash["pod_target_xcconfig"] || {}
|
|
63
|
+
s.pod_target_xcconfig = existing_xcconfig.merge({
|
|
64
|
+
"DEFINES_MODULE" => "NO",
|
|
65
|
+
"CLANG_ENABLE_EXPLICIT_MODULES" => "NO",
|
|
66
|
+
})
|
|
67
|
+
end
|
|
27
68
|
else
|
|
28
69
|
s.dependency "React-Core"
|
|
29
70
|
|
|
@@ -42,4 +83,4 @@ Pod::Spec.new do |s|
|
|
|
42
83
|
s.dependency "ReactCommon/turbomodule/core"
|
|
43
84
|
end
|
|
44
85
|
end
|
|
45
|
-
end
|
|
86
|
+
end
|
package/README.md
CHANGED
|
@@ -21,6 +21,19 @@ the SDK keeps working on older React Native versions on the legacy architecture.
|
|
|
21
21
|
The TurboModule code path is compiled only when the New Architecture is enabled,
|
|
22
22
|
which itself requires React Native 0.74 or newer.
|
|
23
23
|
|
|
24
|
+
### Fabric-based masking
|
|
25
|
+
|
|
26
|
+
The layout-transparent masking components (`AmpMask` / `AmpUnmask`, see
|
|
27
|
+
[Layout-transparent masking](#layout-transparent-masking-with-ampmask--ampunmask-experimental))
|
|
28
|
+
are built on Fabric.
|
|
29
|
+
|
|
30
|
+
The Fabric/C++ sources compile only on the New Architecture with React Native
|
|
31
|
+
0.77 or newer (they rely on capabilities that exist only in those versions).
|
|
32
|
+
On the legacy architecture, or on the New Architecture with React Native older
|
|
33
|
+
than 0.77, the Fabric sources are excluded. Enabling the New Architecture on
|
|
34
|
+
React Native older than 0.77 fails the build fast with a clear error (an
|
|
35
|
+
"RN-floor gate" enforced in both `android/build.gradle` and the iOS podspec).
|
|
36
|
+
|
|
24
37
|
## Usage
|
|
25
38
|
|
|
26
39
|
### Session Replay React Native Standalone SDK
|
|
@@ -102,6 +115,105 @@ import { AmpMaskView } from '@amplitude/session-replay-react-native';
|
|
|
102
115
|
</AmpMaskView>;
|
|
103
116
|
```
|
|
104
117
|
|
|
118
|
+
## Layout-transparent masking with `AmpMask` / `AmpUnmask` (Experimental)
|
|
119
|
+
|
|
120
|
+
> **@experimental** — this API is new and may change in a future release.
|
|
121
|
+
|
|
122
|
+
`AmpMaskView` wraps its children in an extra native view, which introduces a
|
|
123
|
+
layout boundary: children that depend on their parent for sizing (`flex: 1`,
|
|
124
|
+
percentage heights, `position: 'absolute'`) can shift or collapse to zero.
|
|
125
|
+
`AmpMask` and `AmpUnmask` are layout-transparent replacements: they mark their
|
|
126
|
+
children as masked/unmasked in the replay without affecting layout at all —
|
|
127
|
+
wrapping content in `<AmpMask>` renders pixel-identical to not wrapping it.
|
|
128
|
+
|
|
129
|
+
### Requirements
|
|
130
|
+
|
|
131
|
+
`AmpMask`/`AmpUnmask` require React Native **0.77 or newer** with the
|
|
132
|
+
**New Architecture** enabled (Fabric) **with bridgeless enabled** (the RN
|
|
133
|
+
0.77 default). On Fabric without bridgeless (bridge mode) — as well as on
|
|
134
|
+
the Old Architecture — they are not supported as a layout-transparent path:
|
|
135
|
+
|
|
136
|
+
- On the Old Architecture, in development they throw with a clear error;
|
|
137
|
+
in production they fall back to `AmpMaskView` and log a one-time
|
|
138
|
+
`console.error`.
|
|
139
|
+
- On Fabric without bridgeless (bridge mode), they never throw — they
|
|
140
|
+
always fall back to `AmpMaskView` and log a one-time `console.error`,
|
|
141
|
+
in both development and production (bridge-mode Fabric cannot detect
|
|
142
|
+
`SRMaskView` on iOS).
|
|
143
|
+
- Both fallbacks **ignore `enabled`** — wrapped content stays masked
|
|
144
|
+
regardless (it fails toward privacy). Neither is layout-transparent —
|
|
145
|
+
the `AmpMaskView` layout caveats above apply. Use `AmpMaskView`
|
|
146
|
+
directly outside the bridgeless-Fabric path.
|
|
147
|
+
|
|
148
|
+
### Caveats
|
|
149
|
+
|
|
150
|
+
- `style` is not supported on `<AmpMask>`/`<AmpUnmask>` — they never occupy
|
|
151
|
+
layout, so there is no box to style. Style your children directly instead.
|
|
152
|
+
- `enabled` is only honored on the layout-transparent Fabric path — all
|
|
153
|
+
fallback paths (Old Architecture, Fabric bridge-mode, and the
|
|
154
|
+
build-misconfiguration cases below) ignore it and keep content masked
|
|
155
|
+
regardless (they fail toward privacy).
|
|
156
|
+
- If the New Architecture is active but the native `SRMaskView` component is
|
|
157
|
+
missing — including on Fabric without bridgeless, which cannot detect
|
|
158
|
+
`SRMaskView` on iOS and always falls back — `<AmpMask>`/`<AmpUnmask>` log a
|
|
159
|
+
one-time `console.error` and fall back to `<AmpMaskView>` — content stays
|
|
160
|
+
**masked**, but layout-transparency is lost. Treat that log as a build
|
|
161
|
+
error to fix, not a warning to ignore.
|
|
162
|
+
- On the **New Architecture**, if the package's native code is absent
|
|
163
|
+
entirely (so Session Replay cannot record at all), `<AmpMask>`/`<AmpUnmask>`
|
|
164
|
+
log a one-time `console.error` and render children directly. If instead the
|
|
165
|
+
native module is present but neither masking component is registered (an
|
|
166
|
+
unexpected build error), they throw in development and log a distinct
|
|
167
|
+
one-time `console.error` in production instead of silently passing content
|
|
168
|
+
through. On the **Old Architecture** with the native code absent, rendering
|
|
169
|
+
fails at `requireNativeComponent` like any other native component — there
|
|
170
|
+
is no silent passthrough.
|
|
171
|
+
|
|
172
|
+
### Usage
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import { AmpMask, AmpUnmask } from '@amplitude/session-replay-react-native';
|
|
176
|
+
|
|
177
|
+
// Mask: children are masked in the replay, layout is unchanged.
|
|
178
|
+
<AmpMask>
|
|
179
|
+
<View style={{ flex: 1 }}>
|
|
180
|
+
<Text>{accountNumber}</Text>
|
|
181
|
+
</View>
|
|
182
|
+
</AmpMask>
|
|
183
|
+
|
|
184
|
+
// Block: fully block the subtree from the replay.
|
|
185
|
+
<AmpMask maskLevel="block">
|
|
186
|
+
<CreditCardForm />
|
|
187
|
+
</AmpMask>
|
|
188
|
+
|
|
189
|
+
// Unmask: opt content back in to the replay.
|
|
190
|
+
<AmpUnmask>
|
|
191
|
+
<Text>Public banner</Text>
|
|
192
|
+
</AmpUnmask>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
`AmpMask` props:
|
|
196
|
+
|
|
197
|
+
| Prop | Type | Default | Description |
|
|
198
|
+
| --- | --- | --- | --- |
|
|
199
|
+
| `enabled` | `boolean` | `true` | When `false`, children render without masking. |
|
|
200
|
+
| `maskLevel` | `'mask' \| 'block'` | `'mask'` | Masking level applied to the children. On iOS, `mask` and `block` currently behave identically (both fully block). |
|
|
201
|
+
|
|
202
|
+
`AmpUnmask` takes no masking props — it always unmasks its children.
|
|
203
|
+
|
|
204
|
+
### Migrating from `AmpMaskView`
|
|
205
|
+
|
|
206
|
+
| Before | After |
|
|
207
|
+
| --- | --- |
|
|
208
|
+
| `<AmpMaskView mask="amp-mask">` | `<AmpMask>` |
|
|
209
|
+
| `<AmpMaskView mask="amp-block">` | `<AmpMask maskLevel="block">` |
|
|
210
|
+
| `<AmpMaskView mask="amp-unmask">` | `<AmpUnmask>` |
|
|
211
|
+
|
|
212
|
+
`AmpMaskView` remains supported on both architectures. Prefer
|
|
213
|
+
`AmpMask`/`AmpUnmask` on the New Architecture, especially around children that
|
|
214
|
+
are sized by their parent (`flex: 1`, percentage heights, absolute
|
|
215
|
+
positioning).
|
|
216
|
+
|
|
105
217
|
## Tracking Web Views (Beta)
|
|
106
218
|
|
|
107
219
|
Web views are blocked by default and will not be tracked. If you'd like webviews to be tracked, you can manually unmask
|
package/android/build.gradle
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import groovy.json.JsonSlurper
|
|
2
|
+
|
|
1
3
|
def reactNativeArchitectures() {
|
|
2
4
|
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
3
5
|
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
@@ -26,11 +28,105 @@ def supportsNamespace() {
|
|
|
26
28
|
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
27
29
|
def major = parsed[0].toInteger()
|
|
28
30
|
def minor = parsed[1].toInteger()
|
|
29
|
-
|
|
30
|
-
// Namespace support was added in 7.3.0
|
|
31
31
|
return (major == 7 && minor >= 3) || major >= 8
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// --- RN-floor gate: the Fabric SRMaskView codegen/C++ needs RN >= 0.77 under new-arch.
|
|
35
|
+
// Defensive: if RN can't be resolved, do NOT fail (don't break the happy path). ---
|
|
36
|
+
def resolveReactNativeVersion() {
|
|
37
|
+
def candidates = [
|
|
38
|
+
file("${rootProject.projectDir}/../node_modules/react-native/package.json"),
|
|
39
|
+
file("${rootProject.projectDir}/node_modules/react-native/package.json"),
|
|
40
|
+
file("${projectDir}/../../../react-native/package.json"),
|
|
41
|
+
]
|
|
42
|
+
for (c in candidates) {
|
|
43
|
+
if (c.exists()) {
|
|
44
|
+
try { return new JsonSlurper().parse(c).version } catch (ignored) {}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (isNewArchitectureEnabled()) {
|
|
51
|
+
def rnVersion = resolveReactNativeVersion()
|
|
52
|
+
if (rnVersion != null) {
|
|
53
|
+
def p = rnVersion.tokenize('.')
|
|
54
|
+
def major = p[0].toInteger()
|
|
55
|
+
def minor = p[1].toInteger()
|
|
56
|
+
def ge077 = major > 0 || (major == 0 && minor >= 77)
|
|
57
|
+
if (!ge077) {
|
|
58
|
+
throw new GradleException(
|
|
59
|
+
"[SessionReplayReactNative] The Fabric SRMaskView component requires React Native >= 0.77 " +
|
|
60
|
+
"with the New Architecture (found ${rnVersion})."
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
def patchComponentDescriptorsHeader() {
|
|
67
|
+
def componentsDir = file("$buildDir/generated/source/codegen/jni/react/renderer/components/AmpSessionReplaySpec")
|
|
68
|
+
def header = new File(componentsDir, "ComponentDescriptors.h")
|
|
69
|
+
|
|
70
|
+
if (!header.exists()) {
|
|
71
|
+
throw new GradleException(
|
|
72
|
+
"[SessionReplayReactNative] Expected codegen ComponentDescriptors.h at ${header.absolutePath}. " +
|
|
73
|
+
"Ensure newArchEnabled=true and generateCodegenArtifactsFromSchema ran successfully."
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
def original = header.getText("UTF-8")
|
|
78
|
+
if (original.contains("#include <SRMaskViewComponentDescriptor.h>")) {
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
def typedefPattern = /using SRMaskViewComponentDescriptor = ConcreteComponentDescriptor<SRMaskViewShadowNode>;/
|
|
83
|
+
if (!(original =~ typedefPattern)) {
|
|
84
|
+
throw new GradleException(
|
|
85
|
+
"[SessionReplayReactNative] patchComponentDescriptorsHeader regex did not match ComponentDescriptors.h. " +
|
|
86
|
+
"React Native codegen output may have changed; update the patch task before shipping."
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
def patched = original.replace(
|
|
91
|
+
"#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>",
|
|
92
|
+
"""#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
93
|
+
#include <SRMaskViewComponentDescriptor.h>"""
|
|
94
|
+
).replaceFirst(typedefPattern, "")
|
|
95
|
+
header.write(patched, "UTF-8")
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
def patchCodegenCMakeLists() {
|
|
99
|
+
def cmakeFile = file("$buildDir/generated/source/codegen/jni/CMakeLists.txt")
|
|
100
|
+
|
|
101
|
+
if (!cmakeFile.exists()) {
|
|
102
|
+
throw new GradleException(
|
|
103
|
+
"[SessionReplayReactNative] Expected codegen CMakeLists.txt at ${cmakeFile.absolutePath}. " +
|
|
104
|
+
"Ensure newArchEnabled=true and generateCodegenArtifactsFromSchema ran successfully."
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
def original = cmakeFile.getText("UTF-8")
|
|
109
|
+
if (original.contains("SRMaskViewShadowNode.cpp")) {
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
def cppDir = file("../cpp").absolutePath.replace("\\", "/")
|
|
114
|
+
def insertion = """target_sources(react_codegen_AmpSessionReplaySpec PRIVATE
|
|
115
|
+
"${cppDir}/SRMaskViewShadowNode.cpp"
|
|
116
|
+
)
|
|
117
|
+
target_include_directories(react_codegen_AmpSessionReplaySpec PUBLIC "${cppDir}")
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
if (!original.contains("target_link_libraries(")) {
|
|
121
|
+
throw new GradleException(
|
|
122
|
+
"[SessionReplayReactNative] patchCodegenCMakeLists could not find target_link_libraries in CMakeLists.txt."
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
def patched = original.replace("target_link_libraries(", insertion + "target_link_libraries(")
|
|
127
|
+
cmakeFile.write(patched, "UTF-8")
|
|
128
|
+
}
|
|
129
|
+
|
|
34
130
|
android {
|
|
35
131
|
if (supportsNamespace()) {
|
|
36
132
|
namespace "com.amplitude.sessionreplayreactnative"
|
|
@@ -42,8 +138,8 @@ android {
|
|
|
42
138
|
}
|
|
43
139
|
}
|
|
44
140
|
|
|
45
|
-
// New Arch compiles src/newarch (codegen spec + BaseReactPackage);
|
|
46
|
-
// compiles src/oldarch (hand-written spec + plain ReactPackage).
|
|
141
|
+
// New Arch compiles src/newarch (codegen spec + BaseReactPackage + Fabric SRMaskView);
|
|
142
|
+
// Old Arch compiles src/oldarch (hand-written spec + plain ReactPackage).
|
|
47
143
|
sourceSets {
|
|
48
144
|
main {
|
|
49
145
|
if (isNewArchitectureEnabled()) {
|
|
@@ -59,7 +155,12 @@ android {
|
|
|
59
155
|
defaultConfig {
|
|
60
156
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
61
157
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
158
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
159
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
160
|
+
}
|
|
62
161
|
|
|
162
|
+
buildFeatures {
|
|
163
|
+
buildConfig true
|
|
63
164
|
}
|
|
64
165
|
|
|
65
166
|
buildTypes {
|
|
@@ -68,6 +169,10 @@ android {
|
|
|
68
169
|
}
|
|
69
170
|
}
|
|
70
171
|
|
|
172
|
+
packagingOptions {
|
|
173
|
+
pickFirst "lib/**/*.so"
|
|
174
|
+
}
|
|
175
|
+
|
|
71
176
|
lintOptions {
|
|
72
177
|
disable "GradleCompatible"
|
|
73
178
|
}
|
|
@@ -88,20 +193,33 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
|
88
193
|
dependencies {
|
|
89
194
|
implementation("com.amplitude:session-replay-android:[0.24.0,0.25.0)")
|
|
90
195
|
implementation("com.amplitude:analytics-android:[1.25.0,1.26.0)")
|
|
91
|
-
|
|
92
|
-
// For < 0.71, this will be from the local maven repo
|
|
93
|
-
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
94
196
|
//noinspection GradleDynamicVersion
|
|
95
197
|
implementation "com.facebook.react:react-native:+"
|
|
96
198
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
199
|
+
|
|
200
|
+
androidTestImplementation "androidx.test.ext:junit:1.2.1"
|
|
201
|
+
androidTestImplementation "androidx.test:runner:1.6.2"
|
|
97
202
|
}
|
|
98
203
|
|
|
99
|
-
// Codegen for the TurboModule spec (New Architecture only). Generates
|
|
100
|
-
// NativeAmpSessionReplaySpec from src/specs/NativeAmpSessionReplay.ts.
|
|
101
204
|
if (isNewArchitectureEnabled()) {
|
|
102
205
|
react {
|
|
103
206
|
jsRootDir = file("../src/specs/")
|
|
104
207
|
libraryName = "AmpSessionReplaySpec"
|
|
105
208
|
codegenJavaPackageName = "com.amplitude.sessionreplayreactnative"
|
|
106
209
|
}
|
|
210
|
+
|
|
211
|
+
afterEvaluate {
|
|
212
|
+
tasks.named("generateCodegenArtifactsFromSchema").configure {
|
|
213
|
+
doLast {
|
|
214
|
+
patchComponentDescriptorsHeader()
|
|
215
|
+
patchCodegenCMakeLists()
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
tasks.configureEach { task ->
|
|
220
|
+
if (task.name.contains("configureCMake")) {
|
|
221
|
+
task.dependsOn("generateCodegenArtifactsFromSchema")
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
107
225
|
}
|