@amplitude/session-replay-react-native 0.1.0-beta.0 → 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.
Files changed (84) hide show
  1. package/AmplitudeSessionReplayReactNative.podspec +43 -2
  2. package/README.md +125 -0
  3. package/android/build.gradle +145 -5
  4. package/android/src/androidTest/java/com/amplitude/sessionreplayreactnative/SRMaskViewTest.kt +459 -0
  5. package/android/src/main/java/com/amplitude/sessionreplayreactnative/SRDefaultMaskingPrimitive.kt +36 -0
  6. package/android/src/main/java/com/amplitude/sessionreplayreactnative/SRMaskingPrimitive.kt +84 -0
  7. package/android/src/main/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeModule.kt +51 -16
  8. package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativePackage.kt +41 -0
  9. package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeSpec.kt +7 -0
  10. package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskView.kt +174 -0
  11. package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskViewManager.kt +44 -0
  12. package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskViewPointerEvents.java +36 -0
  13. package/android/src/{main → oldarch}/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativePackage.kt +2 -1
  14. package/android/src/oldarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeSpec.kt +20 -0
  15. package/cpp/SRMaskViewComponentDescriptor.h +20 -0
  16. package/cpp/SRMaskViewShadowNode.cpp +54 -0
  17. package/cpp/SRMaskViewShadowNode.h +56 -0
  18. package/ios/AMPNativeSessionReplay.mm +20 -0
  19. package/ios/NativeSessionReplay.swift +29 -8
  20. package/ios/SRDefaultMaskingPrimitive.swift +34 -0
  21. package/ios/SRMaskingPrimitive.h +26 -0
  22. package/ios/SRMaskingRegistry.m +105 -0
  23. package/ios/fabric/SRMaskView.h +10 -0
  24. package/ios/fabric/SRMaskView.mm +178 -0
  25. package/lib/commonjs/Mask.types.js +29 -0
  26. package/lib/commonjs/Mask.types.js.map +1 -0
  27. package/lib/commonjs/fabric/MaskFabric.js +92 -0
  28. package/lib/commonjs/fabric/MaskFabric.js.map +1 -0
  29. package/lib/commonjs/index.js +19 -0
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/mask-fallback.js +53 -0
  32. package/lib/commonjs/mask-fallback.js.map +1 -0
  33. package/lib/commonjs/native-module.js +10 -1
  34. package/lib/commonjs/native-module.js.map +1 -1
  35. package/lib/commonjs/paper/MaskPaper.js +27 -0
  36. package/lib/commonjs/paper/MaskPaper.js.map +1 -0
  37. package/lib/commonjs/specs/NativeAmpSessionReplay.js +22 -0
  38. package/lib/commonjs/specs/NativeAmpSessionReplay.js.map +1 -0
  39. package/lib/commonjs/specs/SRMaskViewNativeComponent.js +11 -0
  40. package/lib/commonjs/specs/SRMaskViewNativeComponent.js.map +1 -0
  41. package/lib/commonjs/version.js +1 -1
  42. package/lib/module/Mask.types.js +23 -0
  43. package/lib/module/Mask.types.js.map +1 -0
  44. package/lib/module/fabric/MaskFabric.js +85 -0
  45. package/lib/module/fabric/MaskFabric.js.map +1 -0
  46. package/lib/module/index.js +15 -0
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/mask-fallback.js +45 -0
  49. package/lib/module/mask-fallback.js.map +1 -0
  50. package/lib/module/native-module.js +10 -2
  51. package/lib/module/native-module.js.map +1 -1
  52. package/lib/module/paper/MaskPaper.js +21 -0
  53. package/lib/module/paper/MaskPaper.js.map +1 -0
  54. package/lib/module/specs/NativeAmpSessionReplay.js +18 -0
  55. package/lib/module/specs/NativeAmpSessionReplay.js.map +1 -0
  56. package/lib/module/specs/SRMaskViewNativeComponent.js +5 -0
  57. package/lib/module/specs/SRMaskViewNativeComponent.js.map +1 -0
  58. package/lib/module/version.js +1 -1
  59. package/lib/typescript/Mask.types.d.ts +38 -0
  60. package/lib/typescript/Mask.types.d.ts.map +1 -0
  61. package/lib/typescript/fabric/MaskFabric.d.ts +8 -0
  62. package/lib/typescript/fabric/MaskFabric.d.ts.map +1 -0
  63. package/lib/typescript/index.d.ts +11 -0
  64. package/lib/typescript/index.d.ts.map +1 -1
  65. package/lib/typescript/mask-fallback.d.ts +27 -0
  66. package/lib/typescript/mask-fallback.d.ts.map +1 -0
  67. package/lib/typescript/native-module.d.ts.map +1 -1
  68. package/lib/typescript/paper/MaskPaper.d.ts +10 -0
  69. package/lib/typescript/paper/MaskPaper.d.ts.map +1 -0
  70. package/lib/typescript/specs/NativeAmpSessionReplay.d.ts +15 -0
  71. package/lib/typescript/specs/NativeAmpSessionReplay.d.ts.map +1 -0
  72. package/lib/typescript/specs/SRMaskViewNativeComponent.d.ts +11 -0
  73. package/lib/typescript/specs/SRMaskViewNativeComponent.d.ts.map +1 -0
  74. package/lib/typescript/version.d.ts +1 -1
  75. package/package.json +19 -6
  76. package/src/Mask.types.ts +45 -0
  77. package/src/fabric/MaskFabric.tsx +73 -0
  78. package/src/index.tsx +18 -0
  79. package/src/mask-fallback.tsx +60 -0
  80. package/src/native-module.ts +16 -10
  81. package/src/paper/MaskPaper.tsx +24 -0
  82. package/src/specs/NativeAmpSessionReplay.ts +29 -0
  83. package/src/specs/SRMaskViewNativeComponent.ts +12 -0
  84. 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
- s.source_files = "ios/**/*.{h,m,mm,swift}"
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
@@ -8,6 +8,32 @@ Amplitude Session Replay for React Native
8
8
  npm install @amplitude/session-replay-react-native
9
9
  ```
10
10
 
11
+ ## React Native New Architecture
12
+
13
+ This SDK supports both the New Architecture (Bridgeless / TurboModules) and the
14
+ legacy architecture. On the New Architecture the native module is exposed as a
15
+ TurboModule; on the legacy architecture it continues to work as a standard bridge
16
+ module. No configuration is required — the correct implementation is selected
17
+ automatically based on how your app is built.
18
+
19
+ `peerDependencies` are intentionally left unconstrained (`react-native: "*"`) so
20
+ the SDK keeps working on older React Native versions on the legacy architecture.
21
+ The TurboModule code path is compiled only when the New Architecture is enabled,
22
+ which itself requires React Native 0.74 or newer.
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
+
11
37
  ## Usage
12
38
 
13
39
  ### Session Replay React Native Standalone SDK
@@ -89,6 +115,105 @@ import { AmpMaskView } from '@amplitude/session-replay-react-native';
89
115
  </AmpMaskView>;
90
116
  ```
91
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
+
92
217
  ## Tracking Web Views (Beta)
93
218
 
94
219
  Web views are blocked by default and will not be tracked. If you'd like webviews to be tracked, you can manually unmask
@@ -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,12 +138,29 @@ android {
42
138
  }
43
139
  }
44
140
 
141
+ // New Arch compiles src/newarch (codegen spec + BaseReactPackage + Fabric SRMaskView);
142
+ // Old Arch compiles src/oldarch (hand-written spec + plain ReactPackage).
143
+ sourceSets {
144
+ main {
145
+ if (isNewArchitectureEnabled()) {
146
+ java.srcDirs += ['src/newarch/java']
147
+ } else {
148
+ java.srcDirs += ['src/oldarch/java']
149
+ }
150
+ }
151
+ }
152
+
45
153
  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
46
154
 
47
155
  defaultConfig {
48
156
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
49
157
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
158
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
159
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
160
+ }
50
161
 
162
+ buildFeatures {
163
+ buildConfig true
51
164
  }
52
165
 
53
166
  buildTypes {
@@ -56,6 +169,10 @@ android {
56
169
  }
57
170
  }
58
171
 
172
+ packagingOptions {
173
+ pickFirst "lib/**/*.so"
174
+ }
175
+
59
176
  lintOptions {
60
177
  disable "GradleCompatible"
61
178
  }
@@ -76,10 +193,33 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
76
193
  dependencies {
77
194
  implementation("com.amplitude:session-replay-android:[0.24.0,0.25.0)")
78
195
  implementation("com.amplitude:analytics-android:[1.25.0,1.26.0)")
79
-
80
- // For < 0.71, this will be from the local maven repo
81
- // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
82
196
  //noinspection GradleDynamicVersion
83
197
  implementation "com.facebook.react:react-native:+"
84
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"
202
+ }
203
+
204
+ if (isNewArchitectureEnabled()) {
205
+ react {
206
+ jsRootDir = file("../src/specs/")
207
+ libraryName = "AmpSessionReplaySpec"
208
+ codegenJavaPackageName = "com.amplitude.sessionreplayreactnative"
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
+ }
85
225
  }