-
Notifications
You must be signed in to change notification settings - Fork 9
INTER-1488: Migrate SDK to APIv4 #217
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
base: main
Are you sure you want to change the base?
Changes from 8 commits
f543622
42cd278
a928611
558c352
c6a02cd
696acb3
3840e16
ce2854d
41876b5
29e8497
8e2343e
174b14d
385b01b
ef98a92
ba36af2
4f21b23
db81f58
ba552dc
60156de
297d679
577660b
6ff4e05
a9d0af3
bfce2df
0e4ff4e
bbf565b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| '@fingerprint/fingerprint-server-sdk': major | ||
| --- | ||
|
|
||
| **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. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v2.12.0 | ||
| v3.0.1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| API_KEY=<API_KEY> | ||
| VISITOR_ID=<VISITOR_ID> | ||
| REQUEST_ID=<REQUEST_ID> | ||
| EVENT_ID=<REQUEST_ID> | ||
| # "eu" or "ap", "us" is the default | ||
| REGION=<REGION> | ||
| WEBHOOK_SIGNATURE_SECRET=<WEBHOOK_SIGNATURE_SECRET> | ||
| BASE64_KEY=<BASE64_KEY> | ||
| BASE64_SEALED_RESULT=<BASE64_SEALED_RESULT> | ||
| BASE64_SEALED_RESULT=<BASE64_SEALED_RESULT> | ||
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,7 +15,7 @@ | |||||
| <a href="https://discord.gg/39EpE2neBg"><img src="https://img.shields.io/discord/852099967190433792?style=logo&label=Discord&logo=Discord&logoColor=white" alt="Discord server"></a> | ||||||
| </p> | ||||||
|
|
||||||
| # Fingerprint Server API Node.js SDK | ||||||
| # Fingerprint Server Node.js SDK | ||||||
|
|
||||||
| [Fingerprint](https://fingerprint.com) is a device intelligence platform offering industry-leading accuracy. | ||||||
|
|
||||||
|
|
@@ -55,16 +55,16 @@ Install the package using your favorite package manager: | |||||
| - NPM: | ||||||
|
|
||||||
| ```sh | ||||||
| npm i @fingerprintjs/fingerprintjs-pro-server-api | ||||||
| npm i @fingerprint/fingerprintjs-server-sdk | ||||||
necipallef marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| ``` | ||||||
|
|
||||||
| - Yarn: | ||||||
| ```sh | ||||||
| yarn add @fingerprintjs/fingerprintjs-pro-server-api | ||||||
| yarn add @fingerprint/fingerprintjs-server-sdk | ||||||
| ``` | ||||||
| - pnpm: | ||||||
| ```sh | ||||||
| pnpm i @fingerprintjs/fingerprintjs-pro-server-api | ||||||
| pnpm i @fingerprint/fingerprintjs-server-sdk | ||||||
| ``` | ||||||
|
|
||||||
| ## Getting started | ||||||
|
|
@@ -75,20 +75,20 @@ Initialize the client instance and use it to make API requests. You need to spec | |||||
| import { | ||||||
| FingerprintJsServerApiClient, | ||||||
| Region, | ||||||
| } from '@fingerprintjs/fingerprintjs-pro-server-api' | ||||||
| } from '@fingerprint/fingerprint-server-sdk' | ||||||
|
|
||||||
| const client = new FingerprintJsServerApiClient({ | ||||||
| apiKey: '<SECRET_API_KEY>', | ||||||
| region: Region.Global, | ||||||
| }) | ||||||
|
|
||||||
| // Get visit history of a specific visitor | ||||||
| client.getVisits('<visitorId>').then((visitorHistory) => { | ||||||
| client.searchEvents({ visitor_id: '<visitorId>' }).then((visitorHistory) => { | ||||||
| console.log(visitorHistory) | ||||||
| }) | ||||||
|
|
||||||
| // Get a specific identification event | ||||||
| client.getEvent('<requestId>').then((event) => { | ||||||
| client.getEvent('<eventId>').then((event) => { | ||||||
| console.log(event) | ||||||
| }) | ||||||
|
|
||||||
|
|
@@ -116,7 +116,7 @@ import { | |||||
| RequestError, | ||||||
| FingerprintJsServerApiClient, | ||||||
| TooManyRequestsError, | ||||||
| } from '@fingerprintjs/fingerprintjs-pro-server-api' | ||||||
| } from '@fingerprint/fingerprint-server-sdk' | ||||||
|
|
||||||
| const client = new FingerprintJsServerApiClient({ | ||||||
| apiKey: '<SECRET_API_KEY>', | ||||||
|
|
@@ -125,7 +125,7 @@ const client = new FingerprintJsServerApiClient({ | |||||
|
|
||||||
| // Handling getEvent errors | ||||||
| try { | ||||||
| const event = await client.getEvent(requestId) | ||||||
| const event = await client.getEvent(eventId) | ||||||
| console.log(JSON.stringify(event, null, 2)) | ||||||
| } catch (error) { | ||||||
| if (error instanceof RequestError) { | ||||||
|
|
@@ -136,28 +136,6 @@ try { | |||||
| console.log('unknown error: ', error) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Handling getVisits errors | ||||||
| try { | ||||||
| const visitorHistory = await client.getVisits(visitorId, { | ||||||
| limit: 10, | ||||||
| }) | ||||||
| console.log(JSON.stringify(visitorHistory, null, 2)) | ||||||
| } catch (error) { | ||||||
| if (error instanceof RequestError) { | ||||||
| console.log(error.status, error.error) | ||||||
| if (error instanceof TooManyRequestsError) { | ||||||
| retryLater(error.retryAfter) // Needs to be implemented on your side | ||||||
| } | ||||||
| } else { | ||||||
| console.error('unknown error: ', error) | ||||||
| } | ||||||
|
|
||||||
| // You can also check for specific error instance | ||||||
| // if(error instanceof VisitorsError403) { | ||||||
| // Handle 403 error... | ||||||
| // } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ### Webhooks | ||||||
|
|
@@ -167,9 +145,9 @@ try { | |||||
| When handling [Webhooks](https://dev.fingerprint.com/docs/webhooks) coming from Fingerprint, you can cast the payload as the built-in `VisitWebhook` type: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Not sure about the link, but it should be more relevant. |
||||||
|
|
||||||
| ```ts | ||||||
| import { VisitWebhook } from '@fingerprintjs/fingerprintjs-pro-server-api' | ||||||
| import { Event } from '@fingerprint/fingerprint-server-sdk' | ||||||
|
|
||||||
| const visit = visitWebhookBody as unknown as VisitWebhook | ||||||
| const visit = visitWebhookBody as unknown as Event | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ``` | ||||||
|
|
||||||
| #### Webhook signature validation | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.