-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
752237c
commit 070db1e
Showing
26 changed files
with
356 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+17 Bytes
test/posthog-react-native-session-replay/android/.gradle/8.9/checksums/checksums.lock
Binary file not shown.
Empty file.
Binary file added
BIN
+17 Bytes
...og-react-native-session-replay/android/.gradle/8.9/executionHistory/executionHistory.lock
Binary file not shown.
Binary file added
BIN
+1 Byte
test/posthog-react-native-session-replay/android/.gradle/8.9/fileChanges/last-build.bin
Binary file not shown.
Binary file added
BIN
+17 Bytes
test/posthog-react-native-session-replay/android/.gradle/8.9/fileHashes/fileHashes.lock
Binary file not shown.
Empty file.
Binary file added
BIN
+17 Bytes
...og-react-native-session-replay/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
test/posthog-react-native-session-replay/android/.gradle/buildOutputCleanup/cache.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,2 @@ | ||
#Mon Sep 16 11:59:46 BST 2024 | ||
gradle.version=8.9 |
Empty file.
99 changes: 99 additions & 0 deletions
99
test/posthog-react-native-session-replay/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,99 @@ | ||
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["PosthogReactNativeSessionReplay_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["PosthogReactNativeSessionReplay_" + name] | ||
} | ||
|
||
def getExtOrIntegerDefault(name) { | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["PosthogReactNativeSessionReplay_" + 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.posthogreactnativesessionreplay" | ||
|
||
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 { | ||
// 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
test/posthog-react-native-session-replay/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 @@ | ||
PosthogReactNativeSessionReplay_kotlinVersion=1.7.0 | ||
PosthogReactNativeSessionReplay_minSdkVersion=21 | ||
PosthogReactNativeSessionReplay_targetSdkVersion=31 | ||
PosthogReactNativeSessionReplay_compileSdkVersion=31 | ||
PosthogReactNativeSessionReplay_ndkversion=21.4.7075529 |
3 changes: 3 additions & 0 deletions
3
test/posthog-react-native-session-replay/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.posthogreactnativesessionreplay"> | ||
</manifest> |
2 changes: 2 additions & 0 deletions
2
test/posthog-react-native-session-replay/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> |
25 changes: 25 additions & 0 deletions
25
...rc/main/java/com/posthogreactnativesessionreplay/PosthogReactNativeSessionReplayModule.kt
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,25 @@ | ||
package com.posthogreactnativesessionreplay | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule | ||
import com.facebook.react.bridge.ReactMethod | ||
import com.facebook.react.bridge.Promise | ||
|
||
class PosthogReactNativeSessionReplayModule(reactContext: ReactApplicationContext) : | ||
ReactContextBaseJavaModule(reactContext) { | ||
|
||
override fun getName(): String { | ||
return NAME | ||
} | ||
|
||
// Example method | ||
// See https://reactnative.dev/docs/native-modules-android | ||
@ReactMethod | ||
fun multiply(a: Double, b: Double, promise: Promise) { | ||
promise.resolve(a * b) | ||
} | ||
|
||
companion object { | ||
const val NAME = "PosthogReactNativeSessionReplay" | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...c/main/java/com/posthogreactnativesessionreplay/PosthogReactNativeSessionReplayPackage.kt
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,17 @@ | ||
package com.posthogreactnativesessionreplay | ||
|
||
import com.facebook.react.ReactPackage | ||
import com.facebook.react.bridge.NativeModule | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.uimanager.ViewManager | ||
|
||
|
||
class PosthogReactNativeSessionReplayPackage : ReactPackage { | ||
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> { | ||
return listOf(PosthogReactNativeSessionReplayModule(reactContext)) | ||
} | ||
|
||
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> { | ||
return emptyList() | ||
} | ||
} |
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 @@ | ||
module.exports = { | ||
presets: ['module:metro-react-native-babel-preset', '@babel/env', '@babel/preset-typescript'], | ||
} |
2 changes: 2 additions & 0 deletions
2
...posthog-react-native-session-replay/ios/PosthogReactNativeSessionReplay-Bridging-Header.h
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 @@ | ||
#import <React/RCTBridgeModule.h> | ||
#import <React/RCTViewManager.h> |
14 changes: 14 additions & 0 deletions
14
test/posthog-react-native-session-replay/ios/PosthogReactNativeSessionReplay.mm
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,14 @@ | ||
#import <React/RCTBridgeModule.h> | ||
|
||
@interface RCT_EXTERN_MODULE(PosthogReactNativeSessionReplay, NSObject) | ||
|
||
RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b | ||
withResolver:(RCTPromiseResolveBlock)resolve | ||
withRejecter:(RCTPromiseRejectBlock)reject) | ||
|
||
+ (BOOL)requiresMainQueueSetup | ||
{ | ||
return NO; | ||
} | ||
|
||
@end |
8 changes: 8 additions & 0 deletions
8
test/posthog-react-native-session-replay/ios/PosthogReactNativeSessionReplay.swift
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,8 @@ | ||
@objc(PosthogReactNativeSessionReplay) | ||
class PosthogReactNativeSessionReplay: NSObject { | ||
|
||
@objc(multiply:withB:withResolver:withRejecter:) | ||
func multiply(a: Float, b: Float, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void { | ||
resolve(a*b) | ||
} | ||
} |
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,16 @@ | ||
module.exports = { | ||
preset: 'jest-expo', | ||
roots: ['<rootDir>'], | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'json', 'node', 'tsx'], | ||
collectCoverage: true, | ||
clearMocks: true, | ||
coverageDirectory: 'coverage', | ||
testPathIgnorePatterns: ['<rootDir>/lib/', 'node_modules', 'examples'], | ||
fakeTimers: { enableGlobally: true }, | ||
transformIgnorePatterns: [], | ||
} | ||
|
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,51 @@ | ||
{ | ||
"name": "posthog-react-native-session-replay", | ||
"version": "0.1.0", | ||
"main": "lib/posthog-react-native-session-replay/index.js", | ||
"files": [ | ||
"src", | ||
"lib", | ||
"android", | ||
"ios", | ||
"cpp", | ||
"*.podspec", | ||
"!ios/build", | ||
"!android/build", | ||
"!android/gradle", | ||
"!android/gradlew", | ||
"!android/gradlew.bat", | ||
"!android/local.properties", | ||
"!**/__tests__", | ||
"!**/__fixtures__", | ||
"!**/__mocks__", | ||
"!**/.*" | ||
], | ||
"scripts": { | ||
"pretest": "npm run prebuild", | ||
"test": "jest -c jest.config.js", | ||
"prepublishOnly": "cd .. && yarn build", | ||
"prebuild": "node -p \"'export const version = ' + JSON.stringify(require('./package.json').version)\" > src/version.ts", | ||
"build": "rm -rf lib && tsc --outDir ./lib && babel ./lib --out-dir lib --extensions '.js'" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/PostHog/posthog-js-lite.git", | ||
"directory": "react-native-session-replay" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^28.1.5", | ||
"@types/react": "^18.2.44", | ||
"eslint": "^8.19.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"jest": "^29.0.0", | ||
"prettier": "^2.7.1", | ||
"react": "^18.2.0", | ||
"react-native": "^0.69.1", | ||
"turbo": "^1.10.7", | ||
"typescript": "^4.7.4" | ||
}, | ||
"peerDependencies": { | ||
"react-native": "*" | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
test/posthog-react-native-session-replay/posthog-react-native-session-replay.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,41 @@ | ||
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 = "posthog-react-native-session-replay" | ||
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/marandaneto/posthog-react-native-session-replay.git", :tag => "#{s.version}" } | ||
|
||
s.source_files = "ios/**/*.{h,m,mm,swift}" | ||
|
||
# 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 |
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,22 @@ | ||
import { NativeModules, Platform } from 'react-native'; | ||
|
||
const LINKING_ERROR = | ||
`The package 'posthog-react-native-session-replay' doesn't seem to be linked. Make sure: \n\n` + | ||
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + | ||
'- You rebuilt the app after installing the package\n' + | ||
'- You are not using Expo Go\n'; | ||
|
||
const PosthogReactNativeSessionReplay = NativeModules.PosthogReactNativeSessionReplay | ||
? NativeModules.PosthogReactNativeSessionReplay | ||
: new Proxy( | ||
{}, | ||
{ | ||
get() { | ||
throw new Error(LINKING_ERROR); | ||
}, | ||
} | ||
); | ||
|
||
export function multiply(a: number, b: number): Promise<number> { | ||
return PosthogReactNativeSessionReplay.multiply(a, b); | ||
} |
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 @@ | ||
export const version = "0.1.0" |
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,18 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"declaration": true, | ||
"esModuleInterop": true, | ||
"jsx": "react-native", | ||
"lib": ["ESNext"], | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"noEmitOnError": true, | ||
"outDir": "./lib", | ||
"skipLibCheck": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"target": "ES2018" | ||
}, | ||
"include": ["index.ts", "src/**/*.ts", "src/**/*.tsx"] | ||
} |
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,27 @@ | ||
{ | ||
"$schema": "https://turbo.build/schema.json", | ||
"pipeline": { | ||
"build:android": { | ||
"env": ["ORG_GRADLE_PROJECT_newArchEnabled"], | ||
"inputs": [ | ||
"package.json", | ||
"android", | ||
"!android/build", | ||
"src/*.ts", | ||
"src/*.tsx" | ||
], | ||
"outputs": [] | ||
}, | ||
"build:ios": { | ||
"env": ["RCT_NEW_ARCH_ENABLED"], | ||
"inputs": [ | ||
"package.json", | ||
"*.podspec", | ||
"ios", | ||
"src/*.ts", | ||
"src/*.tsx" | ||
], | ||
"outputs": [] | ||
} | ||
} | ||
} |