Skip to content

[WIP][INTER-2190] Migrate to API V4 - #267

Draft
TheUnderScorer wants to merge 8 commits into
feature/INTER-970-new-archfrom
feature/INTER-2190-v4-support
Draft

[WIP][INTER-2190] Migrate to API V4#267
TheUnderScorer wants to merge 8 commits into
feature/INTER-970-new-archfrom
feature/INTER-2190-v4-support

Conversation

@TheUnderScorer

Copy link
Copy Markdown
Contributor

No description provided.

@TheUnderScorer TheUnderScorer self-assigned this Aug 11, 2026
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
91.46% (+39.79% 🔼)
150/164
🟢 Branches
92.14% (+30.19% 🔼)
129/140
🟡 Functions
79.41% (+32.04% 🔼)
27/34
🟢 Lines
91.08% (+41.08% 🔼)
143/157
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢 FingerprintClient.ts 100% 92.86% 100% 100%
🟡 FingerprintContext.ts 66.67% 100% 0% 66.67%
🟢 FingerprintProvider.tsx 100% 100% 100% 100%
🔴 useFingerprint.ts 0% 0% 0% 0%
🔴 FingerprintClient.web.ts 0% 0% 0% 0%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢 useVisitorData.ts 100% 100%
75% (-25% 🔻)
100%

Test suite run success

74 tests passing in 5 suites.

Report generated by 🧪jest coverage report action from 5865d64

Show full coverage report
St File % Stmts % Branch % Funcs % Lines Uncovered Line #s
🟢 All files 91.46 92.14 79.41 91.08
🟢  src 91.46 92.14 79.41 91.08
🟢   FingerprintClient.ts 100 92.85 100 100 22,54
🔴   FingerprintClient.web.ts 0 0 0 0 5-58
🟡   FingerprintContext.ts 66.66 100 0 66.66 6
🟢   FingerprintProvider.tsx 100 100 100 100
🟢   errors.ts 85.71 100 66.66 85.71 3
🔴   index.ts 0 0 0 0
🔴   types.ts 0 0 0 0
🟢   unwrapError.ts 90 70 100 90 25
🟢   unwrapError.web.ts 100 100 100 100
🔴   useFingerprint.ts 0 0 0 0 24-28
🟢   useVisitorData.ts 100 100 75 100
🟢   utils.ts 100 100 100 100
🔴  src/specs 0 0 0 0
🔴   NativeRNFingerprintjsPro.ts 0 0 0 0

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Following releases will be created using changesets from this PR:

@fingerprintjs/fingerprintjs-pro-react-native@4.0.0-rc.0

Major Changes

  • Dropped React Native Old Architecture support. The native module is now a TurboModule (New Architecture only) exposed via a Codegen spec.

    This is a breaking change: the SDK now requires React Native >= 0.79 (Expo SDK >= 53) with the New Architecture enabled. (e83c165)

  • Migrated the SDK to Fingerprint API v4 and realigned the public API with @fingerprint/react. This is a breaking change on every platform (web, iOS, Android).

    Renamed API

    • FingerprintJsProProviderFingerprintProvider.
    • FingerprintJsProAgent (constructed with new) → start(options), returning a client with a single get(options) method (getVisitorId/getVisitorData are removed).
    • Added useFingerprint() to read the client from context.

    Single options object

    • getData(tags, linkedId, options)getData({ tag, linkedId, timeout }). tags is renamed to tag.
    • useVisitorData now returns a discriminated union (data/isLoading/isFetched/error) and getData always throws on error — the throwOnError option is removed. immediate defaults to false.

    Grouped provider/start options

    • Platform-only options are nested: android (allowUseOfLocationData, locationTimeoutMillis), ios (allowUseOfLocationData), web (storageKeyPrefix, urlHashing, remoteControlDetection, cache). locationTimeoutMillisAndroid moves to android.locationTimeoutMillis.
    • endpointUrl + fallbackEndpointUrls are replaced by a single endpoints (string or string[]).

    snake_case response

    • The response is now the flat, snake_case FingerprintResponse (visitor_id, event_id, suspect_score?, sealed_result), matching the Server API v4 and JS agent. requestIdevent_id, confidencesuspect_score, sealedResultsealed_result. The nested extended fields (ipLocation, firstSeenAt, etc.) and the extendedResponseFormat option are removed (v4 always returns the flat format).

    Single error type

    • The ~28 error classes are replaced by a single FingerprintError ({ name, code, event_id }) plus an isFingerprintError type guard. Discriminate on error.code (e.g. too_many_requests).

    Web

    • The web implementation now uses @fingerprint/agent (v4) instead of @fingerprintjs/fingerprintjs-pro-spa. Install @fingerprint/agent as the web peer dependency.

    Migration

    Provider

    - import { FingerprintJsProProvider } from '@fingerprintjs/fingerprintjs-pro-react-native'
    + import { FingerprintProvider } from '@fingerprintjs/fingerprintjs-pro-react-native'
    
    - <FingerprintJsProProvider apiKey="PUBLIC_API_KEY" region="eu">
    + <FingerprintProvider apiKey="PUBLIC_API_KEY" region="eu">
        <App />
    - </FingerprintJsProProvider>
    + </FingerprintProvider>

    Hook (useVisitorData)

    - const { isLoading, error, data, getData } = useVisitorData()
    + const { isLoading, isFetched, error, data, getData } = useVisitorData()
    
      // positional args + opt-in throwing → single options object, always throws
    - await getData({ userAction: 'login' }, 'user_1234', { timeout: 5000, throwOnError: true })
    + await getData({ tag: { userAction: 'login' }, linkedId: 'user_1234', timeout: 5000 })
    
    - data?.visitorId
    - data?.confidence.score
    + data?.visitor_id
    + data?.suspect_score

    Imperative client

    - import { FingerprintJsProAgent } from '@fingerprintjs/fingerprintjs-pro-react-native'
    + import { start } from '@fingerprintjs/fingerprintjs-pro-react-native'
    
    - const client = new FingerprintJsProAgent({ apiKey: 'PUBLIC_API_KEY', region: 'eu' })
    - const visitorId = await client.getVisitorId()
    - const data = await client.getVisitorData()
    + const fp = start({ apiKey: 'PUBLIC_API_KEY', region: 'eu' })
    + const result = await fp.get()
    + result.visitor_id

    Provider / start options

      {
        apiKey: 'PUBLIC_API_KEY',
        region: 'eu',
    -   endpointUrl: 'https://metrics.example.com',
    -   fallbackEndpointUrls: ['https://metrics2.example.com'],
    +   endpoints: ['https://metrics.example.com', 'https://metrics2.example.com'],
    -   extendedResponseFormat: true,
    -   allowUseOfLocationData: true,
    -   locationTimeoutMillisAndroid: 5000,
    +   android: { allowUseOfLocationData: true, locationTimeoutMillis: 5000 },
    +   ios: { allowUseOfLocationData: true },
      }

    Errors

    - import { TooManyRequestError } from '@fingerprintjs/fingerprintjs-pro-react-native'
    + import { isFingerprintError } from '@fingerprintjs/fingerprintjs-pro-react-native'
    
      try {
        await fp.get()
      } catch (error) {
    -   if (error instanceof TooManyRequestError) {
    +   if (isFingerprintError(error) && error.code === 'too_many_requests') {
          // handle rate limiting
        }
      }

    Web peer dependency

    - npm install @fingerprintjs/fingerprintjs-pro-spa
    + npm install @fingerprint/agent
    ``` ([687dff3](https://github.com/fingerprintjs/fingerprintjs-pro-react-native/commit/687dff3b0780ebf776c2af645fdb48c72ff9a24e))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant