Skip to content

Commit 949d66a

Browse files
authored
Merge pull request #110 from fingerprintjs/feat-INTER-88/reexport-default-endpoints
INTER-88 reexport default endpoints
2 parents 52b22d4 + f07afa7 commit 949d66a

File tree

5 files changed

+54
-44
lines changed

5 files changed

+54
-44
lines changed

.github/workflows/coverage-diff.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,26 @@ jobs:
1212
pull-requests: write
1313
steps:
1414
- uses: actions/checkout@v3
15+
- name: Cache
16+
uses: actions/cache@v2
17+
with:
18+
path: node_modules
19+
key: nodemodules-${{ hashFiles('yarn.lock') }}
20+
restore-keys: nodemodules-
21+
- name: Install Node packages
22+
run: yarn install
23+
- name: Build
24+
run: yarn build
25+
- run: yarn test:coverage
26+
- name: Read coverage text report
27+
uses: fingerprintjs/action-coverage-report-md@v1
28+
id: coverage-md
1529
- name: Jest coverage comment
1630
id: coverage
1731
uses: ArtiomTr/jest-coverage-report-action@df2b025553c31d68f84be6337843e277e2576844
1832
with:
1933
package-manager: yarn
2034
output: report-markdown
21-
- run: yarn test:coverage
22-
- name: Read coverage text report
23-
uses: fingerprintjs/action-coverage-report-md@v1
24-
id: coverage-md
2535
- uses: marocchino/sticky-pull-request-comment@adca94abcaf73c10466a71cc83ae561fd66d1a56
2636
with:
2737
message: |

README.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
</a>
3131

3232

33-
# FingerprintJS Pro React
33+
# Fingerprint Pro React
3434

35-
FingerprintJS Pro React is an easy-to-use React library for **[FingerprintJS Pro](https://fingerprint.com/)**. It's also compatible with the Next.js framework. SPA and Next.js examples are located in the [examples](https://github.com/fingerprintjs/fingerprintjs-pro-react/tree/main/examples) folder. **This package works with FingerprintJS Pro, it is not compatible with [open-source FingerprintJS](https://github.com/fingerprintjs/fingerprintjs).** You can learn more about the difference between FingerprintJS Pro and open-source FingerprintJS in the [official documentation](https://dev.fingerprint.com/docs/pro-vs-open-source).
35+
Fingerprint Pro React SDK is an easy way to integrate **[Fingerprint Pro](https://fingerprint.com/)** into your React application. It's also compatible with Next.js and Preact. See application demos in the [examples](https://github.com/fingerprintjs/fingerprintjs-pro-react/tree/main/examples) folder. **This package works with Fingerprint Pro, it is not compatible with [open-source FingerprintJS](https://github.com/fingerprintjs/fingerprintjs).** You can learn more about the difference between Fingerprint Pro and open-source FingerprintJS in the [official documentation](https://dev.fingerprint.com/docs/pro-vs-open-source).
3636

3737
## Table of contents
3838

@@ -60,33 +60,35 @@ yarn add @fingerprintjs/fingerprintjs-pro-react
6060

6161
## Getting started
6262

63-
In order to identify visitors, you'll need a FingerprintJS Pro account (you can [sign up for free](https://dashboard.fingerprint.com/signup/)).
64-
You can learn more about API keys in the [official FingerprintJS Pro documentation](https://dev.fingerprint.com/docs/quick-start-guide).
63+
In order to identify visitors, you'll need a Fingerprint Pro account (you can [sign up for free](https://dashboard.fingerprint.com/signup/)).
64+
To get your API key and get started, see the [official Fingerprint Pro documentation](https://dev.fingerprint.com/docs/quick-start-guide).
6565

66-
1. Wrap your application (or component) in `FpjsProvider`. You can specify multiple configuration options. \
67-
Set a region if you have chosen a non-global region during registration. Please refer to the [Regions page](https://dev.fingerprint.com/docs/regions).
66+
1. Wrap your application (or component) in `FpjsProvider`. You can specify multiple configuration options. Set a region if you have chosen a non-global region during registration. See [Regions](https://dev.fingerprint.com/docs/regions) in our documentation. Set `endpoint` and `scriptUrlPattern` if you are using [one of our proxy integrations to increase accuracy](https://dev.fingerprint.com/docs/protecting-the-javascript-agent-from-adblockers) and effectiveness of visitor identification.
6867

6968
```jsx
7069
// src/index.js
7170
import React from 'react';
7271
import ReactDOM from 'react-dom/client';
73-
import { FpjsProvider } from '@fingerprintjs/fingerprintjs-pro-react';
72+
import { FpjsProvider, /* defaultEndpoint, defaultScriptUrlPattern */ } from '@fingerprintjs/fingerprintjs-pro-react';
7473
import App from './App';
7574

7675
const root = ReactDOM.createRoot(document.getElementById('app'))
7776

7877
root.render(
7978
<FpjsProvider
80-
loadOptions = {{
81-
apiKey: 'your-fpjs-public-api-key'
79+
loadOptions={{
80+
apiKey: 'your-fpjs-public-api-key',
81+
// region: 'eu',
82+
// endpoint: ['metrics.yourwebsite.com', defaultEndpoint],
83+
// scriptUrlPattern: ['metrics.yourwebsite.com/agent-path', defaultScriptUrlPattern],
8284
}}
8385
>
8486
<App />
8587
</FpjsProvider>
8688
);
8789
```
8890

89-
2. Use the `useVisitorData` hook in your components to perform visitor identification and get the data.
91+
2. Use the `useVisitorData` hook in your components to identify visitors and get the result data.
9092

9193
```jsx
9294
// src/App.js
@@ -111,7 +113,7 @@ function App() {
111113
// perform some logic based on the visitor data
112114
return (
113115
<div>
114-
Welcome {data.visitorFound ? 'back' : ''}!
116+
Welcome {data.visitorFound ? 'back' : ''}, {data.visitorId}!
115117
</div>
116118
);
117119
} else {
@@ -122,7 +124,7 @@ function App() {
122124
export default App;
123125
```
124126

125-
The `useVisitorData` hook also returns a `getData` method which can make an API call on your command.
127+
The `useVisitorData` hook also returns a `getData` method you can use to make an API call on command.
126128

127129
```jsx
128130
// src/App.js
@@ -179,26 +181,26 @@ function App() {
179181
export default App;
180182
```
181183

182-
See the full code example in the [examples folder](https://github.com/fingerprintjs/fingerprintjs-pro-react/tree/main/examples/spa).
184+
See the full code example in the [examples folder](https://github.com/fingerprintjs/fingerprintjs-pro-react/tree/main/examples/create-react-app).
183185

184186
## Caching strategy
185187

186-
When you use FingerprintJS Pro, you pay for each API call. Our [best practices](https://dev.fingerprint.com/docs/caching-visitor-information) recommend using cache to reduce the API call rate. The Library uses the SessionStorage cache strategy by default.
188+
Fingerprint Pro usage is billed per API call. To reduce API calls, it is a good practice to [cache identification results](https://dev.fingerprint.com/docs/caching-visitor-information). The SDK uses SessionStorage to cache results by default.
187189

188-
:warning: **WARNING** If you use data from `extendedResult`, please pay additional attention to caching strategy.
189-
190-
Some fields from the [extendedResult](https://dev.fingerprint.com/docs/js-agent#extendedresult) (e.g `ip` or `lastSeenAt`) might change for the same visitor. If you need to get the current data, it is recommended to pass `ignoreCache=true` inside [getData](#returned-object) function.
190+
> :warning: **WARNING** If you use data from `extendedResult`, pay additional attention to caching strategy.
191+
>
192+
> Some fields from the [extendedResult](https://dev.fingerprint.com/docs/js-agent#extendedresult) (e.g., `ip` or `lastSeenAt`) might change over time for the same visitor. If you need to get the latest results, pass `{ignoreCache: true}` to the `getData()` function.
191193
192194
## Error handling
193195

194-
`getData` throws errors directly from our Pro Agent without changing them. [Read more about error handling.](https://dev.fingerprint.com/docs/js-agent#error-handling)
196+
The `getData` function throws errors directly from the JS Agent without changing them. See [JS Agent error handling](https://dev.fingerprint.com/docs/js-agent#error-handling) for more details.
195197

196198
## API Reference
197199

198-
You can find API reference [here](https://fingerprintjs.github.io/fingerprintjs-pro-react/).
200+
See the full [generated API reference](https://fingerprintjs.github.io/fingerprintjs-pro-react/).
199201

200202
## Support and feedback
201-
For support or to provide feedback, please [raise an issue on our issue tracker](https://github.com/fingerprintjs/fingerprintjs-pro-react/issues). If you require private support, please email us at [email protected]. If you'd like to have a similar React wrapper for the [open-source FingerprintJS](https://github.com/fingerprintjs/fingerprintjs), consider [raising an issue in our issue tracker](https://github.com/fingerprintjs/fingerprintjs-pro-react/issues).
203+
To ask questions or provide feedback, use [Issues](https://github.com/fingerprintjs/fingerprintjs-pro-react/issues). If you need private support, please email us at `[email protected]`. If you'd like to have a similar React wrapper for the [open-source FingerprintJS](https://github.com/fingerprintjs/fingerprintjs), consider creating an issue in the main [FingerprintJS repository](https://github.com/fingerprintjs/fingerprintjs/issues).
202204

203205

204206
## License

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
"homepage": "https://github.com/fingerprintjs/fingerprintjs-pro-react#readme",
5656
"dependencies": {
57-
"@fingerprintjs/fingerprintjs-pro-spa": "^1.0.2",
57+
"@fingerprintjs/fingerprintjs-pro-spa": "^1.1.0",
5858
"fast-deep-equal": "3.1.3"
5959
},
6060
"devDependencies": {
@@ -101,7 +101,7 @@
101101
"rollup-plugin-peer-deps-external": "^2.2.4",
102102
"semantic-release": "19.0.3",
103103
"ts-jest": "^27.1.5",
104-
"tslib": "2.5.0",
104+
"tslib": "^2.5.0",
105105
"typedoc": "^0.24.8",
106106
"typescript": "^4.9.5"
107107
},

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export {
1616
InMemoryCache,
1717
LocalStorageCache,
1818
SessionStorageCache,
19+
defaultEndpoint,
20+
defaultScriptUrlPattern,
21+
defaultTlsEndpoint,
1922
} from '@fingerprintjs/fingerprintjs-pro-spa'
2023
export type {
2124
Agent,

yarn.lock

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -827,18 +827,18 @@
827827
minimatch "^3.1.2"
828828
strip-json-comments "^3.1.1"
829829

830-
"@fingerprintjs/fingerprintjs-pro-spa@^1.0.2":
831-
version "1.0.2"
832-
resolved "https://registry.yarnpkg.com/@fingerprintjs/fingerprintjs-pro-spa/-/fingerprintjs-pro-spa-1.0.2.tgz#6179ea58cd60a23d113d93ee363ac3ecfa46a15e"
833-
integrity sha512-Lo95+PDzezG6FYuILKWl77hB7CfCKOai+GNm/IRbDhhVaATIyYPEPbFArsdv9aRiJD6rZKBEr56thC6CXGZNiQ==
830+
"@fingerprintjs/fingerprintjs-pro-spa@^1.1.0":
831+
version "1.1.0"
832+
resolved "https://registry.yarnpkg.com/@fingerprintjs/fingerprintjs-pro-spa/-/fingerprintjs-pro-spa-1.1.0.tgz#3a1924c4bdc91599ecc41971d01b9e38ec1b18d5"
833+
integrity sha512-mj+8zl70lwtibQYdZUN5yUO6Bhw8/MxhbzNolBOp8asCdsXCEEx5DYzRADijQ73vJgimb+ys5zrQ9sZ8O7W0iw==
834834
dependencies:
835-
"@fingerprintjs/fingerprintjs-pro" "^3.8.2"
835+
"@fingerprintjs/fingerprintjs-pro" "^3.8.4"
836836
tslib "^2.5.0"
837837

838-
"@fingerprintjs/fingerprintjs-pro@^3.8.2":
839-
version "3.8.2"
840-
resolved "https://registry.yarnpkg.com/@fingerprintjs/fingerprintjs-pro/-/fingerprintjs-pro-3.8.2.tgz#91a642c7a8555157acdf7e30ed085e754d8879b2"
841-
integrity sha512-cccPaHhzt2AnXbUEdpMW4/19eous5/WJhNlawq5BJKmmGSHJzjjb0kkNXgC0QlFll1YsoqLAxmGLOYRVVfmTBA==
838+
"@fingerprintjs/fingerprintjs-pro@^3.8.4":
839+
version "3.8.4"
840+
resolved "https://registry.yarnpkg.com/@fingerprintjs/fingerprintjs-pro/-/fingerprintjs-pro-3.8.4.tgz#d73f7d4da986bf0c10226464e87092e3b50ac0b8"
841+
integrity sha512-6m2fTydRjuiM8y02AoUJcOXZuXblHCLmKH3Huu7sgmxDhogTAm1JO0QsF4rigM6hedlFRAejcozBEteqWRZWew==
842842
dependencies:
843843
tslib "^2.4.1"
844844

@@ -8550,20 +8550,15 @@ tsconfig-paths@^3.14.1:
85508550
minimist "^1.2.6"
85518551
strip-bom "^3.0.0"
85528552

8553-
[email protected], tslib@^2.4.0, tslib@^2.4.1, tslib@^2.5.0:
8554-
version "2.5.0"
8555-
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
8556-
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
8557-
85588553
tslib@^1.8.1, tslib@^1.9.0:
85598554
version "1.14.1"
85608555
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
85618556
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
85628557

8563-
tslib@^2.1.0:
8564-
version "2.4.0"
8565-
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"
8566-
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==
8558+
tslib@^2.1.0, tslib@^2.4.0, tslib@^2.4.1, tslib@^2.5.0:
8559+
version "2.6.0"
8560+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.0.tgz#b295854684dbda164e181d259a22cd779dcd7bc3"
8561+
integrity sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA==
85678562

85688563
tsutils@^3.21.0:
85698564
version "3.21.0"

0 commit comments

Comments
 (0)