Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 9 additions & 3 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
"@fingerprintjs/changesets-native-dependency-format",
{
"repo": "fingerprintjs/react-native",
"androidPath": "sdk/android",
"iosPodspecPath": "sdk/RNFingerprint.podspec",
"packageName": "@fingerprint/react-native"
"packageName": "@fingerprint/react-native",
"ios": {
"podspecPath": "sdk/RNFingerprint.podspec",
"dependencyName": "Fingerprint-iOS"
},
"android": {
"path": "sdk/android",
"gradleTaskName": "printFingerprintNativeSDKVersion"
}
}
],
"commit": false,
Expand Down
2 changes: 1 addition & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mode": "pre",
"mode": "exit",
"tag": "rc",
"initialVersions": {
"@fingerprint/react-native": "3.17.0"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docs-and-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
generate-docs-and-coverage:
name: Generate docs and coverage report
uses: fingerprintjs/dx-team-toolkit/.github/workflows/docs-and-coverage.yml@v1
with:
prepare-gh-pages-commands: |
mv docs/* ./gh-pages
mv coverage/lcov-report ./gh-pages/coverage
permissions:
contents: read
pages: write
id-token: write
6 changes: 3 additions & 3 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
REACT_NATIVE_VERSION: ${{ matrix.react-native }}

- name: Install ${{github.event.release.tag_name}} version of the package
run: pnpm add @fingerprint/react-native@${{github.event.release.tag_name}}
run: pnpm add ${{github.event.release.tag_name}}
if: github.event_name == 'release'
working-directory: e2e-app

Expand Down Expand Up @@ -259,7 +259,7 @@ jobs:
REACT_NATIVE_VERSION: ${{ matrix.react-native }}

- name: Install ${{github.event.release.tag_name}} version of the package
run: pnpm add @fingerprint/react-native@${{github.event.release.tag_name}}
run: pnpm add ${{github.event.release.tag_name}}
if: github.event_name == 'release'
working-directory: e2e-app

Expand Down Expand Up @@ -410,7 +410,7 @@ jobs:
working-directory: e2e-app

- name: Install ${{github.event.release.tag_name}} version of the package
run: pnpm add @fingerprint/react-native@${{github.event.release.tag_name}}
run: pnpm add ${{github.event.release.tag_name}}
if: github.event_name == 'release'
working-directory: e2e-app

Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,26 @@ return (
)
```

### Custom endpoints

To avoid ad blockers, proxy identification through a [proxy integration](https://docs.fingerprint.com/docs/protecting-the-javascript-agent-from-adblockers). Pass identification URLs as `endpoints`, first to last.

We recommend including the default API URL for your [region](https://docs.fingerprint.com/docs/regions) as a fallback: `https://api.fpjs.io` (US), `https://eu.api.fpjs.io` (EU), `https://ap.api.fpjs.io` (Asia). There are no fallbacks by default.


```javascript
return (
<FingerprintProvider
apiKey={PUBLIC_API_KEY}
endpoints={[
'https://metrics.yourwebsite.com',
'https://api.fpjs.io'
]}>
<App />
</FingerprintProvider>
)
```

## API Reference

See the full [generated API Reference](https://fingerprintjs.github.io/react-native/).
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@changesets/types": "^6.1.0",
"@commitlint/cli": "^21.2.1",
"@eslint-react/eslint-plugin": "^5.16.1",
"@fingerprintjs/changesets-native-dependency-format": "^0.1.0",
"@fingerprintjs/changesets-native-dependency-format": "^0.2.0",
"@fingerprintjs/commit-lint-dx-team": "^0.1.0",
"@fingerprintjs/eslint-config-dx-team": "^3.0.0",
"@fingerprintjs/prettier-config-dx-team": "^0.3.0",
Expand Down
12 changes: 7 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ let package = Package(
.package(name: "React-GeneratedCode", path: "../../../ios"),
.package(
url: "https://github.com/fingerprintjs/fingerprint-ios",
from: "4.0.0"
.upToNextMinor(from: "4.1.0")
),
],
targets: [
Expand Down
20 changes: 20 additions & 0 deletions sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,26 @@ return (
)
```

### Custom endpoints

To avoid ad blockers, proxy identification through a [proxy integration](https://docs.fingerprint.com/docs/protecting-the-javascript-agent-from-adblockers). Pass identification URLs as `endpoints`, first to last.

We recommend including the default API URL for your [region](https://docs.fingerprint.com/docs/regions) as a fallback: `https://api.fpjs.io` (US), `https://eu.api.fpjs.io` (EU), `https://ap.api.fpjs.io` (Asia). There are no fallbacks by default.


```javascript
return (
<FingerprintProvider
apiKey={PUBLIC_API_KEY}
endpoints={[
'https://metrics.yourwebsite.com',
'https://api.fpjs.io'
]}>
<App />
</FingerprintProvider>
)
```

## API Reference

See the full [generated API Reference](https://fingerprintjs.github.io/react-native/).
Expand Down
2 changes: 1 addition & 1 deletion sdk/RNFingerprint.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Pod::Spec.new do |s|
# s.requires_arc = true

s.dependency "React-Core"
s.dependency "Fingerprint-iOS", "~> 4.0"
s.dependency "Fingerprint-iOS", "~> 4.1.0"

# Wires up the TurboModule/Codegen dependencies (ReactCommon, generated specs, ...) and defines
# `RCT_NEW_ARCH_ENABLED` for the pod when the app is built with the New Architecture.
Expand Down
6 changes: 5 additions & 1 deletion sdk/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ plugins {

// The SDK supports the New Architecture only. Applying the React Gradle plugin runs library Codegen
// (generates the `NativeRNFingerprintSpec` base class).
apply plugin: 'com.facebook.react'
// Only apply when evaluated as a subproject of a host RN app; when run standalone (e.g. CLI tasks like
// printFingerprintNativeSDKVersion), project == rootProject and the React plugin is not on the classpath.
if (project != rootProject) {
apply plugin: 'com.facebook.react'
}

apply from: 'fingerprint.gradle'

Expand Down
2 changes: 1 addition & 1 deletion sdk/android/fingerprint.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ext.fingerprint_native_sdk_version = "[4.1.0, 5.0.0)"
ext.fingerprint_native_sdk_version = "[4.1.0, 4.2.0)"

task printFingerprintNativeSDKVersion {
doLast {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.fingerprint.android.RequestTimeout
import com.fingerprint.android.TooManyRequest
import com.fingerprint.android.WrongRegion
import com.fingerprint.android.SubscriptionNotActive
import com.fingerprint.android.SubscriptionNotFound
import com.fingerprint.android.SubscriptionRestricted
import com.fingerprint.android.InstallationMethodRestricted
import com.fingerprint.android.EnvironmentRestricted
Expand Down Expand Up @@ -132,7 +131,6 @@ class RNFingerprintModule(reactContext: ReactApplicationContext) : NativeRNFinge
is TooManyRequest -> "too_many_requests"
is WrongRegion -> "wrong_region"
is SubscriptionNotActive -> "subscription_not_active"
is SubscriptionNotFound -> "subscription_not_found"
is SubscriptionRestricted -> "subscription_restricted"
is InstallationMethodRestricted -> "installation_method_restricted"
is EnvironmentRestricted -> "environment_restricted"
Expand Down
6 changes: 2 additions & 4 deletions sdk/ios/FPError+React.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ extension FPError {
var reactMessage: String {
switch self {
case .apiError(let apiError):
return apiError.message ?? self.localizedDescription
return apiError.message ?? self.description
case .networkError(let networkError):
return networkError.localizedDescription
case .jsonParsingError(let jsonParsingError):
return jsonParsingError.localizedDescription
default:
return self.localizedDescription
return self.description
}
}

Expand Down Expand Up @@ -88,7 +88,6 @@ extension APIError {
case .visitorNotFound: return "visitor_not_found"
case .tooManyRequests: return "too_many_requests"
case .failed: return "failed"
case .eventNotFound: return "event_not_found"
case .missingModule: return "missing_module"
case .payloadTooLarge: return "payload_too_large"
case .serviceUnavailable: return "service_unavailable"
Expand All @@ -97,7 +96,6 @@ extension APIError {
case .invalidProxyIntegrationHeaders: return "invalid_proxy_integration_headers"
case .subscriptionRestricted: return "subscription_restricted"
case .environmentRestricted: return "environment_restricted"
case .subscriptionNotFound: return "subscription_not_found"
case .installationMethodRestricted: return "installation_method_restricted"
// A future SDK may add codes; fall back to the raw value rather than losing the information.
@unknown default: return code.rawValue
Expand Down
8 changes: 7 additions & 1 deletion sdk/src/FingerprintClient.web.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Fingerprint from '@fingerprint/agent'
import type { FingerprintClient, FingerprintResponse, GetOptions, StartOptions } from './types'
import { unwrapError } from './unwrapError'
import { isEmptyArray, isTruthy } from './utils'

const packageVersion = '__VERSION__'

Expand All @@ -13,7 +14,12 @@
class WebFingerprintClient implements FingerprintClient {
private readonly agent: Fingerprint.Agent

constructor({ apiKey, region, endpoints, web }: StartOptions) {
constructor({ apiKey, region, endpoints: endpointsParam, web }: StartOptions) {
const endpoints =
isTruthy(endpointsParam) && !isEmptyArray(endpointsParam)

Check warning on line 19 in sdk/src/FingerprintClient.web.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 19 in sdk/src/FingerprintClient.web.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
? Fingerprint.withoutDefault(endpointsParam)

Check warning on line 20 in sdk/src/FingerprintClient.web.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
: endpointsParam

Check warning on line 21 in sdk/src/FingerprintClient.web.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 21 in sdk/src/FingerprintClient.web.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

this.agent = Fingerprint.start({
apiKey,
region,
Expand Down
1 change: 0 additions & 1 deletion sdk/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export type ErrorCode =
| 'wrong_region'
| 'feature_not_enabled'
| 'visitor_not_found'
| 'event_not_found'
| 'missing_module'
| 'payload_too_large'
| 'service_unavailable'
Expand Down
4 changes: 4 additions & 0 deletions sdk/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
return Boolean(value)
}

export function isEmptyArray(value: unknown): value is [] {

Check warning on line 9 in sdk/src/utils.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return Array.isArray(value) && value.length === 0

Check warning on line 10 in sdk/src/utils.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 10 in sdk/src/utils.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 10 in sdk/src/utils.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
}

function isObject(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null
}
Expand Down
Loading