-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: publish react native session replay plugin (#910)
- Loading branch information
Showing
90 changed files
with
9,370 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.pbxproj -text | ||
# specific for windows script files | ||
*.bat text eol=crlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# XDE | ||
.expo/ | ||
|
||
# VSCode | ||
.vscode/ | ||
jsconfig.json | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
|
||
# Android/IJ | ||
# | ||
.classpath | ||
.cxx | ||
.gradle | ||
.idea | ||
.project | ||
.settings | ||
local.properties | ||
android.iml | ||
|
||
# Cocoapods | ||
# | ||
example/ios/Pods | ||
|
||
# Ruby | ||
example/vendor/ | ||
|
||
# node.js | ||
# | ||
node_modules/ | ||
npm-debug.log | ||
yarn-debug.log | ||
yarn-error.log | ||
|
||
# BUCK | ||
buck-out/ | ||
\.buckd/ | ||
android/app/libs | ||
android/keystores/debug.keystore | ||
|
||
# Yarn | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
# Expo | ||
.expo/ | ||
|
||
# Turborepo | ||
.turbo/ | ||
|
||
# generated by bob | ||
lib/ | ||
|
||
# React Native Codegen | ||
ios/generated | ||
android/generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Amplitude, Inc. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# @amplitude/plugin-session-replay-react-native | ||
|
||
Amplitude Session Replay plugin for React Native | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install @amplitude/plugin-session-replay-react-native | ||
``` | ||
|
||
## Usage | ||
Add the session replay plugin to your Amplitude instance as follows | ||
|
||
```js | ||
import { SessionReplayPlugin } from '@amplitude/plugin-session-replay-react-native'; | ||
|
||
// ... | ||
|
||
await init('YOUR_API_KEY').promise; | ||
await add(new SessionReplayPlugin()).promise; | ||
|
||
``` | ||
|
||
## Masking views | ||
To maks certain views, add the `AmpMaskView` tag with the mask property `amp-mask` around the section to be masked | ||
|
||
```js | ||
import { AmpMaskView } from '@amplitude/plugin-session-replay-react-native'; | ||
|
||
// ... | ||
|
||
<AmpMaskView mask="amp-mask"> | ||
<Text | ||
style={[ | ||
styles.sectionTitle, | ||
{ | ||
color: isDarkMode ? Colors.white : Colors.black, | ||
}, | ||
]} | ||
> | ||
{title} | ||
</Text> | ||
</AmpMaskView> | ||
``` | ||
|
||
## Unmasking views | ||
To unmask views, add the `AmpMaskView` tag with the mask property `amp-unmask` around the section to be unmasked | ||
|
||
```js | ||
import { AmpMaskView } from '@amplitude/plugin-session-replay-react-native'; | ||
|
||
// ... | ||
|
||
<AmpMaskView mask="amp-unmask"> | ||
<Text | ||
style={[ | ||
styles.sectionTitle, | ||
{ | ||
color: isDarkMode ? Colors.white : Colors.black, | ||
}, | ||
]} | ||
> | ||
{title} | ||
</Text> | ||
</AmpMaskView> | ||
``` |
43 changes: 43 additions & 0 deletions
43
...s/plugin-session-replay-react-native/amplitude-plugin-session-replay-react-native.podspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require "json" | ||
|
||
package = JSON.parse(File.read(File.join(__dir__, "package.json"))) | ||
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' | ||
|
||
Pod::Spec.new do |s| | ||
s.name = "amplitude-plugin-session-replay-react-native" | ||
s.version = package["version"] | ||
s.summary = package["description"] | ||
s.homepage = package["homepage"] | ||
s.license = package["license"] | ||
s.authors = package["author"] | ||
|
||
s.platforms = { :ios => min_ios_version_supported } | ||
s.source = { :git => "https://github.com/amplitude/Amplitude-TypeScript.git", :tag => "#{s.version}" } | ||
|
||
s.source_files = "ios/**/*.{h,m,mm,swift}" | ||
|
||
s.dependency 'AmplitudeSessionReplay' | ||
|
||
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0. | ||
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79. | ||
if respond_to?(:install_modules_dependencies, true) | ||
install_modules_dependencies(s) | ||
else | ||
s.dependency "React-Core" | ||
|
||
# Don't install the dependencies when we run `pod install` in the old architecture. | ||
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then | ||
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1" | ||
s.pod_target_xcconfig = { | ||
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"", | ||
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1", | ||
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17" | ||
} | ||
s.dependency "React-Codegen" | ||
s.dependency "RCT-Folly" | ||
s.dependency "RCTRequired" | ||
s.dependency "RCTTypeSafety" | ||
s.dependency "ReactCommon/turbomodule/core" | ||
end | ||
end | ||
end |
101 changes: 101 additions & 0 deletions
101
packages/plugin-session-replay-react-native/android/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
buildscript { | ||
// Buildscript is evaluated before everything else so we can't use getExtOrDefault | ||
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["PluginSessionReplayReactNative_kotlinVersion"] | ||
|
||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath "com.android.tools.build:gradle:7.2.1" | ||
// noinspection DifferentKotlinGradleVersion | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
def reactNativeArchitectures() { | ||
def value = rootProject.getProperties().get("reactNativeArchitectures") | ||
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] | ||
} | ||
|
||
def isNewArchitectureEnabled() { | ||
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" | ||
} | ||
|
||
apply plugin: "com.android.library" | ||
apply plugin: "kotlin-android" | ||
|
||
if (isNewArchitectureEnabled()) { | ||
apply plugin: "com.facebook.react" | ||
} | ||
|
||
def getExtOrDefault(name) { | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["PluginSessionReplayReactNative_" + name] | ||
} | ||
|
||
def getExtOrIntegerDefault(name) { | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["PluginSessionReplayReactNative_" + name]).toInteger() | ||
} | ||
|
||
def supportsNamespace() { | ||
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.') | ||
def major = parsed[0].toInteger() | ||
def minor = parsed[1].toInteger() | ||
|
||
// Namespace support was added in 7.3.0 | ||
return (major == 7 && minor >= 3) || major >= 8 | ||
} | ||
|
||
android { | ||
if (supportsNamespace()) { | ||
namespace "com.amplitude.pluginsessionreplayreactnative" | ||
|
||
sourceSets { | ||
main { | ||
manifest.srcFile "src/main/AndroidManifestNew.xml" | ||
} | ||
} | ||
} | ||
|
||
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion") | ||
|
||
defaultConfig { | ||
minSdkVersion getExtOrIntegerDefault("minSdkVersion") | ||
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion") | ||
|
||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
|
||
lintOptions { | ||
disable "GradleCompatible" | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
google() | ||
} | ||
|
||
def kotlin_version = getExtOrDefault("kotlinVersion") | ||
|
||
dependencies { | ||
implementation("com.amplitude:session-replay-android:[0.15.2, 1.0.0]") | ||
|
||
// For < 0.71, this will be from the local maven repo | ||
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin | ||
//noinspection GradleDynamicVersion | ||
implementation "com.facebook.react:react-native:+" | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
packages/plugin-session-replay-react-native/android/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
PluginSessionReplayReactNative_kotlinVersion=1.7.0 | ||
PluginSessionReplayReactNative_minSdkVersion=21 | ||
PluginSessionReplayReactNative_targetSdkVersion=31 | ||
PluginSessionReplayReactNative_compileSdkVersion=31 | ||
PluginSessionReplayReactNative_ndkversion=21.4.7075529 |
3 changes: 3 additions & 0 deletions
3
packages/plugin-session-replay-react-native/android/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.amplitude.pluginsessionreplayreactnative"> | ||
</manifest> |
2 changes: 2 additions & 0 deletions
2
packages/plugin-session-replay-react-native/android/src/main/AndroidManifestNew.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
</manifest> |
Oops, something went wrong.