Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update ios and android agents to v2.7.0 INTER-1002 #135

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9a34f87
feat: update ios and android agents to v2.7.0
Orkuncakilkaya Nov 19, 2024
b126eaa
chore: update test project podfile lock
Orkuncakilkaya Nov 19, 2024
bb0e619
chore: update podspec minimum version operator
Orkuncakilkaya Nov 19, 2024
58d72b9
chore: wip update native modules for exporting required members
Orkuncakilkaya Nov 27, 2024
de48e5e
feat: add sealed result support to sdk
Orkuncakilkaya Nov 28, 2024
da1451b
feat: add sealed result support to sdk
Orkuncakilkaya Nov 28, 2024
4f7cca6
feat: add custom timeout feature
Orkuncakilkaya Dec 3, 2024
6693757
fix: ios timeout feature native bridge
necipallef Dec 10, 2024
4c3bcc1
docs: jsdoc for functions
necipallef Dec 12, 2024
a24f93a
fix: node22 assert keyword, fix sourcemaps
necipallef Dec 12, 2024
a02128d
fix: missing requestOptions in provider
necipallef Dec 12, 2024
d85c266
fix: attempt to fix android type problem
necipallef Dec 12, 2024
d19d747
fix: client timeout error
necipallef Dec 12, 2024
5015345
feat: ios bridge refactor, added new methods with timeout
necipallef Dec 12, 2024
dd917e4
feat: android bridge refactor, add methods for timeout
necipallef Dec 12, 2024
fcef4f7
feat: js side timeout param handling
necipallef Dec 12, 2024
67620cb
test: testproject support for node22
necipallef Dec 12, 2024
776d398
ci: add a workflow to test build
necipallef Dec 12, 2024
586c5dd
ci: test build separate jobs
necipallef Dec 12, 2024
5440ee4
fix: android timeout native bridge code
necipallef Dec 12, 2024
5ac2ec4
fix: android bridge type error
necipallef Dec 12, 2024
d8f201e
test: test project upgrade jest
necipallef Dec 12, 2024
7748bd8
test: disable running yarn test for now
necipallef Dec 12, 2024
53198f4
chore: remove namespace from android manifest
necipallef Dec 12, 2024
33374d6
chore: test project use gradle 8.2.1
necipallef Dec 12, 2024
bcac51e
test: remove namespace from test project android manifest
necipallef Dec 12, 2024
a0e50a2
chore: undo pre-commit hook deletion
necipallef Dec 12, 2024
b676d99
chore: undo pre-commit hook deletion
necipallef Dec 12, 2024
2e9a4cb
test: attempt to fix jest in TestProject
necipallef Dec 17, 2024
fe75847
test: attempt to fix jest in TestProject
necipallef Dec 17, 2024
605ab83
chore: fix getData type missing requestOptions
necipallef Dec 17, 2024
f7b84f4
test: add unit tests for timeout functions
necipallef Dec 17, 2024
72605fa
test: attempt to fix jest in TestProject
necipallef Dec 17, 2024
f2504ec
test: fix getVisitorDataWithTimeout test
necipallef Dec 17, 2024
2784934
test: temprorarily disable running jest for TestApp
necipallef Dec 17, 2024
df337db
chore: jsdoc for options param
necipallef Dec 17, 2024
8786062
fix: correct native function call when timeout is 0
necipallef Dec 18, 2024
4a8f4a1
test: add different test cases for the TestProject
necipallef Dec 18, 2024
ec18490
chore: fix markup in test project for small screens
ilfa Dec 19, 2024
b5d66c2
test: add 2 more testcases for timeout to be sure
ilfa Dec 19, 2024
44662c1
chore: test project lock file
necipallef Dec 24, 2024
7cb2d69
test: improve test description
necipallef Dec 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/test-react-native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Test React Native Library

on:
push:

jobs:
android-build:
name: Android - Build and Test React Native Library
runs-on: macos-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4

- name: Install dependencies
run: |
yarn install
yarn build
cd TestProject
yarn install

- name: Build Android
run: |
cd TestProject/android
./gradlew assembleDebug

- name: Start Metro Bundler # and Test App
run: |
cd TestProject
yarn start &
sleep 10 # Allow Metro Bundler to start
# yarn test

ios-build:
name: iOS - Build and Test React Native Library
runs-on: macos-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4

- name: Install dependencies
run: |
yarn install
yarn build
cd TestProject
yarn install

- name: Install Pods
run: |
cd TestProject/ios
pod install

- name: Build iOS
env:
CI: true
run: |
cd TestProject/ios
xcodebuild -workspace TestProject.xcworkspace -scheme TestProject -sdk iphonesimulator -configuration Debug build

- name: Start Metro Bundler # and Test App
run: |
cd TestProject
yarn start &
sleep 10 # Allow Metro Bundler to start
# yarn test
2 changes: 1 addition & 1 deletion RNFingerprintjsPro.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Pod::Spec.new do |s|
# s.requires_arc = true

s.dependency "React-Core"
s.dependency "FingerprintPro", '~> 2.6.0'
s.dependency "FingerprintPro", '>= 2.7.0', '< 3.0.0'
end
11 changes: 9 additions & 2 deletions TestProject/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { SafeAreaView, StatusBar, useColorScheme } from 'react-native'
import { Colors } from 'react-native/Libraries/NewAppScreen'
import { FingerprintJsProProvider } from '@fingerprintjs/fingerprintjs-pro-react-native'
import { Visitor } from './src/Visitor'
import { PUBLIC_API_KEY, REGION, ENDPOINT } from '@env'
import { PUBLIC_API_KEY, REGION, ENDPOINT, CUSTOM_TIMEOUT } from '@env'

const App = () => {
const isDarkMode = useColorScheme() === 'dark'
const apiKey = PUBLIC_API_KEY
const region = REGION
const endpoint = ENDPOINT
const customTimeout = Number(CUSTOM_TIMEOUT ?? '60000')

const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
Expand All @@ -19,7 +20,13 @@ const App = () => {
}

return (
<FingerprintJsProProvider apiKey={apiKey} extendedResponseFormat={true} region={region} endpointUrl={endpoint}>
<FingerprintJsProProvider
apiKey={apiKey}
extendedResponseFormat={true}
region={region}
endpointUrl={endpoint}
requestOptions={{ timeout: customTimeout }}
>
<SafeAreaView style={backgroundStyle}>
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<Visitor />
Expand Down
3 changes: 1 addition & 2 deletions TestProject/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.testproject">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
2 changes: 1 addition & 1 deletion TestProject/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
}

dependencies {
classpath("com.android.tools.build:gradle:8.1.1")
classpath("com.android.tools.build:gradle:8.2.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
// NOTE: Do not place your application dependencies here; they belong
Expand Down
16 changes: 8 additions & 8 deletions TestProject/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PODS:
- React-Core (= 0.73.2)
- React-jsi (= 0.73.2)
- ReactCommon/turbomodule/core (= 0.73.2)
- FingerprintPro (2.6.0)
- FingerprintPro (2.7.0)
- fmt (6.2.1)
- glog (0.3.5)
- hermes-engine (0.73.2):
Expand Down Expand Up @@ -1055,7 +1055,7 @@ PODS:
- React-logger (= 0.73.2)
- React-perflogger (= 0.73.2)
- RNFingerprintjsPro (1.0.4):
- FingerprintPro (~> 2.6.0)
- FingerprintPro (< 3.0.0, >= 2.7.0)
- React-Core
- SocketRocket (0.6.1)
- Yoga (1.14.0)
Expand Down Expand Up @@ -1224,12 +1224,12 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
FBLazyVector: fbc4957d9aa695250b55d879c1d86f79d7e69ab4
FBReactNativeSpec: 86de768f89901ef6ed3207cd686362189d64ac88
FingerprintPro: 3f06f491c77d871ab543b49fd25fddc52dc34f8c
FingerprintPro: 0c7dbd28fc83751ca64b06328e2fb22bbc7ed118
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
hermes-engine: b361c9ef5ef3cda53f66e195599b47e1f84ffa35
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0
Expand Down Expand Up @@ -1273,10 +1273,10 @@ SPEC CHECKSUMS:
React-runtimescheduler: df8945a656356ff10f58f65a70820478bfcf33ad
React-utils: f5bc61e7ea3325c0732ae2d755f4441940163b85
ReactCommon: 45b5d4f784e869c44a6f5a8fad5b114ca8f78c53
RNFingerprintjsPro: 5a6f377649bc343770e4c28dd2ba9476a918b9fc
RNFingerprintjsPro: 7437638503c6257e54b6d84406c1b6c65a50c499
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 13c8ef87792450193e117976337b8527b49e8c03
Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047

PODFILE CHECKSUM: ab81067ce8c7c4c73b9d3ab72ba8cc955f098393

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
4 changes: 4 additions & 0 deletions TestProject/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: 'react-native',
testEnvironment: 'jsdom',
}
10 changes: 5 additions & 5 deletions TestProject/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"@react-native/metro-config": "0.73.3",
"babel-jest": "^29.6.3",
"eslint": "^8.19.0",
"jest": "^27.4.7",
"jest": "^29.4.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to commit updated lock file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks!

"jest-circus": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"jest-react-native": "18.0.0",
"metro-react-native-babel-preset": "^0.77.0",
"react-test-renderer": "18.2.0"
},
"engines": {
"node": "^20"
},
"jest": {
"preset": "react-native"
"node": "^20 || ^22"
}
}
103 changes: 100 additions & 3 deletions TestProject/src/Visitor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React, { useState } from 'react'
import { StyleSheet, Text, Button, View, Modal, Platform } from 'react-native'
import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react-native'
import {
FingerprintJsProAgent,
useVisitorData,
ClientTimeoutError,
} from '@fingerprintjs/fingerprintjs-pro-react-native'
import { PUBLIC_API_KEY, REGION, ENDPOINT } from '@env'

const styles = StyleSheet.create({
centeredView: {
Expand All @@ -13,8 +18,8 @@ const styles = StyleSheet.create({
flex: 1,
justifyContent: 'space-evenly',
alignItems: 'center',
paddingTop: '75%',
paddingBottom: '75%',
paddingTop: '60%',
paddingBottom: '60%',
},
modalView: {
margin: 10,
Expand Down Expand Up @@ -50,12 +55,20 @@ const linkedId = 'React native'

export const Visitor = () => {
const { isLoading, data, getData, error } = useVisitorData()

const [modalVisible, setModalVisible] = useState(false)
const [sealedResultModalVisible, setSealedResultModalVisible] = useState(false)
const [testResults, setTestResults] = useState('tests not running')

const onLoadData = () => {
getData()
}

const onLoadSealedResult = () => {
getData()
setSealedResultModalVisible(true)
}

const onLoadDataWithTag = () => {
getData(tags, linkedId)
}
Expand All @@ -65,6 +78,69 @@ export const Visitor = () => {
setModalVisible(true)
}

const onRunTestsPressed = async () => {
setTestResults('Running tests')
try {
await runTests()
setTestResults('Success!')
} catch (error) {
setTestResults(`Failed: ${error}`)
}
}

const runTests = async () => {
const fingerprintClient = new FingerprintJsProAgent({
apiKey: PUBLIC_API_KEY,
region: REGION,
endpointUrl: ENDPOINT,
})

const tags = {
a: 'a',
b: 0,
c: {
foo: true,
bar: [1, 2, 3],
},
d: false,
}
const tests = [
() => fingerprintClient.getVisitorId(),
() => fingerprintClient.getVisitorData(),
() => fingerprintClient.getVisitorId(null, 'checkId'),
() => fingerprintClient.getVisitorData(null, 'checkData'),
() => fingerprintClient.getVisitorId(tags),
() => fingerprintClient.getVisitorData(tags),
() => fingerprintClient.getVisitorId(tags, 'checkIdWithTag'),
() => fingerprintClient.getVisitorData(tags, 'checkDataWithTag'),
() => fingerprintClient.getVisitorId(null, null, { timeout: 5_000 }),
() => fingerprintClient.getVisitorData(null, null, { timeout: 5_000 }),
]

const timeoutTests = [
() => fingerprintClient.getVisitorId(null, null, { timeout: 5 }),
() => fingerprintClient.getVisitorData(null, null, { timeout: 5 }),
]

for (const test of tests) {
await test()
setTestResults((testResult) => `${testResult}.`)
}

for (const test of timeoutTests) {
try {
await test()
throw new Error('Expected timeout for test')
} catch (e) {
if (e instanceof ClientTimeoutError) {
setTestResults((testResult) => `${testResult}!`)
} else {
throw e
}
}
}
}

let info = 'Loading...'
if (!isLoading) {
if (error) {
Expand All @@ -75,6 +151,7 @@ export const Visitor = () => {
}

const extendedResult = JSON.stringify(data, null, ' ')
const sealedResultInfo = JSON.stringify(data?.sealedResult ?? '', null, ' ')

return (
<View style={styles.centeredView}>
Expand All @@ -83,7 +160,27 @@ export const Visitor = () => {
<Button title='Load data' onPress={onLoadData} />
<Button title='Load with tag and linkedId' onPress={onLoadDataWithTag} />
<Button title='Load extendedResult' onPress={onLoadExtendedResult} />
<Button title='Load sealedResult' onPress={onLoadSealedResult} />
<Button title='Run tests!' onPress={onRunTestsPressed} />
<Text>{testResults}</Text>
</View>

<Modal
animationType='slide'
transparent={true}
visible={sealedResultModalVisible}
onRequestClose={() => {
setSealedResultModalVisible(!setSealedResultModalVisible)
}}
>
<View style={styles.centeredView}>
<View style={styles.modalView}>
<Text style={styles.monoText}>{sealedResultInfo}</Text>
<Button title='Close' onPress={() => setSealedResultModalVisible(!sealedResultModalVisible)} />
</View>
</View>
</Modal>

<Modal
animationType='slide'
transparent={true}
Expand Down
Loading
Loading