Skip to content

Commit f28ba9d

Browse files
feat: deprecate getVisitorHistory method
1 parent ef75bb4 commit f28ba9d

File tree

2 files changed

+44
-31
lines changed

2 files changed

+44
-31
lines changed

.changeset/ten-taxis-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@fingerprintjs/fingerprintjs-pro-server-api': minor
3+
---
4+
5+
Deprecate `getVisitorHistory` method. Use `getVisits` instead.

src/serverApiClient.ts

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
AuthenticationMode,
44
EventResponse,
55
EventUpdateRequest,
6+
FingerprintApi,
67
Options,
78
Region,
89
VisitorHistoryFilter,
@@ -25,7 +26,7 @@ import {
2526
VisitorsError429,
2627
} from './errors/apiErrors'
2728

28-
export class FingerprintJsServerApiClient {
29+
export class FingerprintJsServerApiClient implements FingerprintApi {
2930
public readonly region: Region
3031

3132
public readonly apiKey: string
@@ -254,36 +255,8 @@ export class FingerprintJsServerApiClient {
254255
}
255256

256257
/**
257-
* Retrieves event history for the specific visitor using the given filter, returns a promise with visitor history response.
258-
*
259-
* @param {string} visitorId - Identifier of the visitor
260-
* @param {VisitorHistoryFilter} filter - Visitor history filter
261-
* @param {string} filter.limit - limit scanned results
262-
* @param {string} filter.request_id - filter visits by `requestId`.
263-
* @param {string} filter.linked_id - filter visits by your custom identifier.
264-
* @param {string} filter.paginationKey - use `paginationKey` to get the next page of results. When more results are available (e.g., you requested 200 results using `limit` parameter, but a total of 600 results are available), the `paginationKey` top-level attribute is added to the response. The key corresponds to the `requestId` of the last returned event. In the following request, use that value in the `paginationKey` parameter to get the next page of results:
265-
*
266-
* 1. First request, returning most recent 200 events: `GET api-base-url/visitors/:visitorId?limit=200`
267-
* 2. Use `response.paginationKey` to get the next page of results: `GET api-base-url/visitors/:visitorId?limit=200&paginationKey=1683900801733.Ogvu1j`
268-
*
269-
* Pagination happens during scanning and before filtering, so you can get less visits than the `limit` you specified with more available on the next page. When there are no more results available for scanning, the `paginationKey` attribute is not returned.
270-
* @example
271-
* ```javascript
272-
* client
273-
* .getVisitorHistory('<visitorId>', { limit: 1 })
274-
* .then((visitorHistory) => {
275-
* console.log(visitorHistory)
276-
* })
277-
* .catch((error) => {
278-
* if (isVisitorsError(error)) {
279-
* console.log(error.statusCode, error.message)
280-
* if (error.status === 429) {
281-
* retryLater(error.retryAfter) // Needs to be implemented on your side
282-
* }
283-
* }
284-
* })
285-
* ```
286-
*/
258+
* @deprecated Please use {@link FingerprintJsServerApiClient.getVisits} instead
259+
* */
287260
public async getVisitorHistory(visitorId: string, filter?: VisitorHistoryFilter): Promise<VisitorsResponse> {
288261
if (!visitorId) {
289262
throw TypeError('VisitorId is not set')
@@ -318,6 +291,41 @@ export class FingerprintJsServerApiClient {
318291
}
319292
}
320293

294+
/**
295+
* Retrieves event history for the specific visitor using the given filter, returns a promise with visitor history response.
296+
*
297+
* @param {string} visitorId - Identifier of the visitor
298+
* @param {VisitorHistoryFilter} filter - Visitor history filter
299+
* @param {string} filter.limit - limit scanned results
300+
* @param {string} filter.request_id - filter visits by `requestId`.
301+
* @param {string} filter.linked_id - filter visits by your custom identifier.
302+
* @param {string} filter.paginationKey - use `paginationKey` to get the next page of results. When more results are available (e.g., you requested 200 results using `limit` parameter, but a total of 600 results are available), the `paginationKey` top-level attribute is added to the response. The key corresponds to the `requestId` of the last returned event. In the following request, use that value in the `paginationKey` parameter to get the next page of results:
303+
*
304+
* 1. First request, returning most recent 200 events: `GET api-base-url/visitors/:visitorId?limit=200`
305+
* 2. Use `response.paginationKey` to get the next page of results: `GET api-base-url/visitors/:visitorId?limit=200&paginationKey=1683900801733.Ogvu1j`
306+
*
307+
* Pagination happens during scanning and before filtering, so you can get less visits than the `limit` you specified with more available on the next page. When there are no more results available for scanning, the `paginationKey` attribute is not returned.
308+
* @example
309+
* ```javascript
310+
* client
311+
* .getVisits('<visitorId>', { limit: 1 })
312+
* .then((visitorHistory) => {
313+
* console.log(visitorHistory)
314+
* })
315+
* .catch((error) => {
316+
* if (isVisitorsError(error)) {
317+
* console.log(error.statusCode, error.message)
318+
* if (error.status === 429) {
319+
* retryLater(error.retryAfter) // Needs to be implemented on your side
320+
* }
321+
* }
322+
* })
323+
* ```
324+
*/
325+
public async getVisits(visitorId: string, filter?: VisitorHistoryFilter): Promise<VisitorsResponse> {
326+
return this.getVisitorHistory(visitorId, filter)
327+
}
328+
321329
private getHeaders() {
322330
return this.authenticationMode === AuthenticationMode.AuthHeader ? { 'Auth-API-Key': this.apiKey } : undefined
323331
}

0 commit comments

Comments
 (0)