Skip to content

Conversation

@erayaydin
Copy link
Contributor

This PR upgrades the Server SDK to the Server API v4. It removes Server APIv3 specific behavior and aligns the SDK with the new events format shared by Server API and Webhooks.

❓ Why?

  • Server API v3 is deprecated on Oct 31, 2025 and will be sunset on Oct 31, 2026.
  • v4 standardizes responses (no data/products/result nesting), switches to Bearer auth, unifies Webhooks & Server API event formats, and deprecates /visitors in favor of /v4/events.

⚙️ What Changed?

  • Endpoints & paths
    • GET /events/search -> GET /v4/events
    • GET /visitors -> removed, migrate to GET /v4/events
    • Request builder now constructs /v4/* URLs.
  • Authentication
    • Replace Auth-Api-Key custom header and apiKey query param with Authorization: Bearer <secret_api_key>.
    • Remove AuthenticationMode option.
  • Names
    • request_id -> event_id
    • Use snake_case in request and response models (e.g., linked_id, pagination_key)
  • Responses
    • Remove legacy top-level nesting
    • Align types with unified events schema
  • Search and Examples
    • Implement GET /v4/events with filters.
    • Update examples and mocked responses
  • Update Event
    • PUT /events -> PATCH /v4/event/:event_id
    • Body fields now snake_case
  • Docs
    • README updated for v4

⚠️ Breaking Changes

  • Auth: only Bearer is supported. Query and custom header API key modes and AuthenticationMode option are removed.
  • Endpoints/Signatures:
    • getEvent(requestId) -> getEvent(eventId)
    • updateEvent(body, eventId) now use snake_case fields
  • Models: v3 style top-level nesting removed. Consumers must map to the v4 unified event format.

📦 Migration Guide (SDK Consumers)

  • Remove authenticationMode option when initializing FingerprintJsServerApiClient.
const client = new FingerprintJsServerApiClient({
  apiKey: '<SECRET_API_KEY>',
  region: Region.Global,
-  authenticationMode: AuthenticationMode.AuthHeader
})
  • When triggering getEvent() function, use eventId parameter name instead of requestId.
- client.getEvent(requestId: "<request-id>")
+ client.getEvent(eventId: "<request-id>")
  • Use snake_case fields when updating an event.
client.updateEvent({
- linkedId: "linkedId"
+ linked_id: "linkedId"
}, "<event-id>")
  • Use tags instead of tag for updating an event.
client.updateEvent({
- tag: {
+ tags: {
    key: 'value',
  }, 
}, "<event-id>")
  • When triggering updateEvent() function, use eventId parameter name instead of requestId.
client.updateEvent(
  {},
- requestId: "<request-id>"
+ eventId: "<event-id>"
)
  • Removed deprecated getVisitorHistory() function.
  • Removed getVisits() function. Use searchEvents() function.
- client.getVisits('<visitorId>')
+ client.searchEvents({ visitor_id: "<visitorId>" })
  • Removed getRelatedVisitors() function.
  • Removed VisitorHistoryFilter, ErrorPlainResponse, VisitorsResponse, RelatedVisitorsResponse, RelatedVisitorsFilter, Webhook, EventsUpdateRequest types.

- Switch base URLs to APIv4 (`https://{region}.api.fpjs.io/v4`) and add
  `apiVersion` handling in URL builder.
- Use `Authorization: Bearer <secret-api-key>` only. Remove custom
  header and query api authorization.
- Event API renamed and updated. Use `event_id` instead of `request_id`.
  Also use `PATCH` for event update instead of `PUT` method.
- Add new examples, mocked responses, and update `sync.sh` script.
- README reworked for v4
- Package renamed to `@fingerprint/fingerprint-server-sdk`. Updated
  description and subpackages (example).
- Regenerated types and OpenAPI schema.
- Updated unit and mock tests for v4 URLs.

BREAKING CHANGES:
- Only **Bearer auth** is supported; query and custom-header API-key
  modes are removed. `AuthenticationMode` option is deleted.
- Event endpoint and signatures changes:
  - Use `client.getEvent(eventId)` instead of `requestId`

Related-Task: INTER-1488
Remove `Accept: application/json` testing header for `updateEvent`
function.

Related-Task: INTER-1488
Fix updateEventTests test expected method to `PATCH`.

Related-Task: INTER-1488
Removed unnecessary commented line.

Related-Task: INTER-1488
Expands `searchEvents` JSDoc with new filters. Also its align parameter
names.
Removes `example/getVisitorHistory.mjs` file because it's not a
different endpoint anymore.

Related-Task: INTER-1488
Add `fingerprint-server-sdk-smoke-tests` to changeset ignore list.

Related-Task: INTER-1488
Explicitly mention about package name change in changeset file.

Related-Task: INTER-1488
Use correct `patch` method instead of `put` for updating an event.

Related-Task: INTER-1488
Replace strict `response.status === 200` checks with `response.ok` in
fetch handlers.

Related-Task: INTER-1488
Added a new `callApi()` function to handle request building and `fetch`
usage in one place. Replaced all direct `fetch` calls with `callApi`.
Introduced `defaultHeaders` options to the client, it's include
`Authorization` header and allow extra headers and override of
`Authorization` header. Made `region` optional in `GetRequestPathOptions`
and it's default to `Region.Global` in `getRequestPath` function.

Related-Task: INTER-1488
Remove `isEmptyValue` helper function and use direct `== null` checks to
skip `undefined` or `null` values.

Related-Task: INTER-1488
Use correct `EVENT_ID` placeholder for the example `.env.example` dotenv
file.

Related-Task: INTER-1488
Add `IsNever` and `NonNeverKeys` utility types to filter out `never`
type keys. Introduce and export `AllowedMethod` that excludes specific
`parameters` and any `never` type methods. Use this `AllowedMethod` type
for `GetRequestPathOptions` type and `getRequestPath` functions. Update
related signatures.

Related-Task: INTER-1488
Use `options.method.toUpperCase()` when calling `fetch` to ensure
standard HTTP method casing and avoid test fails. Change `AllowedMethod`
to make a string literal union.

Related-Task: INTER-1488
Extend `callApi` to accept an optional `body?: BodyInit` and forward it
to `fetch`. Fix `updateEvent` to send `body`.

Related-Task: INTER-1488
Removed unnecessary visitor detail tests.

Related-Task: INTER-1488
Fix missing quote for `linked_id` in `searchEvents.mjs` example file.

Related-Task: INTER-1488
Removed redundant `await` keyword in `callApi` function.

Related-Task: INTER-1488
Centralize response parsing and error handling in `callApi` function.
Throw consistent `SdkError`, `RequestError`, or `TooManyRequestsError`
depends on the case. Added `SuccessJsonOrVoid<Path, Method>` to
automatically resolve the potential/correct return type for success
responses. Simplify all public methods.

Related-Task: INTER-1488
Removed `handleErrorResponse` and moved all error logic into `callApi`.
Exported `isErrorResponse` to detect valid error payloads. Added
`createResponse` helper for creating mock Response object with headers.

Related-Task: INTER-1488
Fixes webhook example and description in the `readme.md` file.

Related-Task: INTER-1488
Use `Event` type instead of duplicated `EventsGetResponse` type. Update
sealedResults snapshot and example base64 sealed result value. Fix
reference links.

Related-Task: INTER-1488
Removes unnecessary `ErrorJson` type from the project.

Related-Task: INTER-1488
@erayaydin erayaydin self-assigned this Oct 29, 2025
@erayaydin erayaydin added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 29, 2025
@changeset-bot
Copy link

changeset-bot bot commented Oct 29, 2025

🦋 Changeset detected

Latest commit: 2eb7507

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 29, 2025

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
100% (+4.27% 🔼)
184/184
🟢 Branches
100% (+10.26% 🔼)
62/62
🟢 Functions
100% (+2.22% 🔼)
34/34
🟢 Lines
100% (+4.31% 🔼)
182/182

Test suite run success

74 tests passing in 10 suites.

Report generated by 🧪jest coverage report action from 2eb7507

Show full coverage report
St File % Stmts % Branch % Funcs % Lines Uncovered Line #s
🟢 All files 100 100 100 100
🟢  src 100 100 100 100
🟢   index.ts 100 100 100 100
🟢   sealedResults.ts 100 100 100 100
🟢   serverApiClient.ts 100 100 100 100
🟢   types.ts 100 100 100 100
🟢   urlUtils.ts 100 100 100 100
🟢   webhook.ts 100 100 100 100
🟢  src/errors 100 100 100 100
🟢   apiErrors.ts 100 100 100 100
🟢   getRetryAfter.ts 100 100 100 100
🟢   handleErrorResponse.ts 100 100 100 100
🟢   unsealError.ts 100 100 100 100

Revert `package.json` version field to old value for fixing changeset
issue.

Related-Task: INTER-1488
Removes unused `responseUtils.ts` file from the project.

Related-Task: INTER-1488
Increases test coverage for `serverApiClient`.

Related-Task: INTER-1488
Removes `utils.ts` file and move it to `serverApiClient` file.

Related-Task: INTER-1488
Make changes for `throws SdkError` tests in `serverApiClientTests` file
to test `toError` functionality.

Related-Task: INTER-1488
Remove unnecessary length guard in `serializeQueryStringParams`
function. Because always `ii` param exists when using this function.
Also it's okay to construct `URLSearchParams` with empty array.

Related-Task: INTER-1488
Adds `errorTests.spec.ts` to test `TooManyRequestsError` and
`getRetryAfter` function. Add extra tests for covering `getRequestPath`
method.

Related-Task: INTER-1488
@github-actions
Copy link
Contributor

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

@fingerprint/fingerprint-server-sdk@7.0.0

Major Changes

  • Server APIv3 -> Server APIv4 migration

    • Switch all endpoints to /v4/*.
    • Remove authenticationMode option when initializing FingerprintJsServerApiClient.
    • Rename request_id to event_id.
    • Use snake_case fields when updating an event.
    • Use PATCH method when updating an event.
    • Examples, tests, and docs updated.

    BREAKING CHANGES

    • authenticationMode option removed.
    • Endpoints and method signatures changed.
      • Use eventId instead of requestId when triggering updateEvent() function.
      • Use eventId instead of requestId when triggering getEvent() function.
    • Removed getVisits() function.
    • Removed getRelatedVisitors() function.
    • Removed VisitorHistoryFilter, ErrorPlainResponse, VisitorsResponse, RelatedVisitorsResponse,
      RelatedVisitorsFilter, Webhook, EventsUpdateRequest types.
    • Use tags instead of tag for updating an event.
    • Response models changed. (ce2854d)
  • change package name to @fingerprint/fingerprint-server-sdk (385b01b)

@erayaydin erayaydin marked this pull request as ready for review October 29, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants