Skip to content

Commit

Permalink
Merge pull request #149 from fingerprintjs/docs/readme-formatting-and…
Browse files Browse the repository at this point in the history
…-get-data-on-demand

docs(README): mention immediate: false explicitly, improve formatting
  • Loading branch information
JuroUhlar committed May 31, 2024
2 parents da53105 + a24d9fd commit 2d5cbb2
Show file tree
Hide file tree
Showing 4 changed files with 11,239 additions and 8,183 deletions.
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ To get your API key and get started, see the [Fingerprint Pro Quick Start Guide]
// src/index.js
import React from 'react'
import ReactDOM from 'react-dom/client'
import { FpjsProvider /*, FingerprintJSPro */ } from '@fingerprintjs/fingerprintjs-pro-react'
import {
FpjsProvider /*, FingerprintJSPro */,
} from '@fingerprintjs/fingerprintjs-pro-react'
import App from './App'

const root = ReactDOM.createRoot(document.getElementById('app'))
Expand Down Expand Up @@ -131,13 +133,19 @@ export default App

The `useVisitorData` hook also returns a `getData` method you can use to make an API call on command.

- You can pass `{ ignoreCache: true }` to `useVisitorData` to force a fresh identification request.
- You can pass `{ immediate: false }` to `useVisitorData` to disable automatic visitor identification on render.

```jsx
// src/App.js
import React, { useState } from 'react'
import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'

function App() {
const { isLoading, error, getData } = useVisitorData({ tag: 'subscription-form' }, { immediate: false })
const { isLoading, error, getData } = useVisitorData(
{ ignoreCache: true },
{ immediate: false }
)
const [email, setEmail] = useState('')

if (isLoading) {
Expand All @@ -164,7 +172,11 @@ function App() {
}}
>
<label htmlFor='email'>Email:</label>
<input type='email' value={email} onChange={(e) => setEmail(e.currentTarget.value)} />
<input
type='email'
value={email}
onChange={(e) => setEmail(e.currentTarget.value)}
/>
<button type='submit'>Subscribe</button>
</form>
</div>
Expand All @@ -185,20 +197,15 @@ Associate the visitor ID with your data using the `linkedId` or `tag` parameter

```jsx
// ...

function App() {
const {
isLoading,
error,
getData
} = useVisitorData({
linkedId: "user_1234",
const { isLoading, error, getData } = useVisitorData({
linkedId: 'user_1234',
tag: {
userAction: "login",
analyticsId: "UA-5555-1111-1"
}
});

userAction: 'login',
analyticsId: 'UA-5555-1111-1',
},
})
}
// ...
```

Expand Down
19 changes: 14 additions & 5 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The main branch is locked for the push action. For proposing changes, use the st
### Development playground

There are 4 demo pages for this integration:

1. In `/examples/create-react-app` folder. It is a rich demo with scenarios of using different caching strategies. You can find more info about configuration and starting demo in the [readme](examples/create-react-app/README.md).
2. In `/examples/next` folder. It is a demo built with NextJS that allows testing SSR scenarios. You can find more info about configuration and starting demo in the [readme](examples/next/README.md).
3. In `/examples/next-appDir` folder. It is the same demo built with NextJS, but with new `app` directory approach. You can find more info about configuration and starting demo in the [readme](examples/next-appDir/README.md).
Expand All @@ -20,43 +21,51 @@ If you want to test integration with [fingerprintjs-pro-spa](https://github.com/
❗ Build projects before testing integration. First build `fingerprintjs-pro-spa`, then `fingerprintjs-pro-react`, and then start spa example app.

### How to build

Just run:

```shell
pnpm build
```

### Code style

The code style is controlled by [ESLint](https://eslint.org/) and [Prettier](https://prettier.io/). Run to check that the code style is ok:

```shell
pnpm lint
```

You aren't required to run the check manually, the CI will do it. Run the following command to fix style issues (not all issues can be fixed automatically):

```shell
pnpm lint:fix
```

### How to test

Tests are located in `__tests__` folder and run by [jest](https://jestjs.io/) in [jsdom](https://github.com/jsdom/jsdom) environment.

To run tests you can use IDE instruments or just run:

```shell
pnpm test
```

To check the distributive TypeScript declarations, build the project and run:

```shell
pnpm test:dts
```

### How to publish

The library is automatically released and published to NPM on every push to the main branch if there are relevant changes using [semantic-release](https://github.com/semantic-release/semantic-release) with following plugins:
* [@semantic-release/commit-analyzer](https://github.com/semantic-release/commit-analyzer)
* [@semantic-release/release-notes-generator](https://github.com/semantic-release/release-notes-generator)
* [@semantic-release/changelog](https://github.com/semantic-release/changelog)
* [@semantic-release/npm](https://github.com/semantic-release/npm)
* [@semantic-release/github](https://github.com/semantic-release/github)

- [@semantic-release/commit-analyzer](https://github.com/semantic-release/commit-analyzer)
- [@semantic-release/release-notes-generator](https://github.com/semantic-release/release-notes-generator)
- [@semantic-release/changelog](https://github.com/semantic-release/changelog)
- [@semantic-release/npm](https://github.com/semantic-release/npm)
- [@semantic-release/github](https://github.com/semantic-release/github)

The workflow must be approved by one of the maintainers, first.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@fingerprintjs/commit-lint-dx-team": "^0.0.2",
"@fingerprintjs/conventional-changelog-dx-team": "^0.1.0",
"@fingerprintjs/eslint-config-dx-team": "^0.1.0",
"@fingerprintjs/prettier-config-dx-team": "^0.1.0",
"@fingerprintjs/prettier-config-dx-team": "^0.2.0",
"@fingerprintjs/tsconfig-dx-team": "^0.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-typescript": "^11.1.6",
Expand All @@ -74,6 +74,7 @@
"@types/react-dom": "^18.2.22",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "8.57.0",
"eslint-config-next": "14.1.3",
"eslint-config-preact": "^1.3.0",
"eslint-plugin-react": "7.34.0",
Expand Down
Loading

0 comments on commit 2d5cbb2

Please sign in to comment.