Skip to content

Commit 64c0c9c

Browse files
refactor: replace Fp with Fingerprint in components, context, and exports
1 parent a0ee321 commit 64c0c9c

18 files changed

Lines changed: 64 additions & 64 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Fingerprint is a device intelligence platform offering industry-leading accuracy
2929
- [Requirements](#requirements)
3030
- [Installation](#installation)
3131
- [Getting started](#getting-started)
32-
- [1. Wrap your application (or component) in `<FpProvider>`.](#1-wrap-your-application-or-component-in-fpprovider)
32+
- [1. Wrap your application (or component) in `<FingerprintProvider>`.](#1-wrap-your-application-or-component-in-FingerprintProvider)
3333
- [2. Use the `useVisitorData()` hook in your components to identify visitors](#2-use-the-usevisitordata-hook-in-your-components-to-identify-visitors)
3434
- [Linking and tagging information](#linking-and-tagging-information)
3535
- [Caching strategy](#caching-strategy)
@@ -73,7 +73,7 @@ pnpm add @fingerprint/react
7373
In order to identify visitors, you'll need a Fingerprint Pro account (you can [sign up for free](https://dashboard.fingerprint.com/signup/)).
7474
To get your API key and get started, see the [Fingerprint Pro Quick Start Guide](https://docs.fingerprint.com/docs/quick-start-guide).
7575

76-
### 1. Wrap your application (or component) in `<FpProvider>`.
76+
### 1. Wrap your application (or component) in `<FingerprintProvider>`.
7777

7878
- Set `apiKey` to your Fingerprint [Public API Key](https://dashboard.fingerprint.com/api-keys).
7979
- Set `region` if you have chosen a non-global [region](https://docs.fingerprint.com/docs/regions) during registration.
@@ -85,20 +85,20 @@ To get your API key and get started, see the [Fingerprint Pro Quick Start Guide]
8585
import React from 'react'
8686
import ReactDOM from 'react-dom/client'
8787
import {
88-
FpProvider,
88+
FingerprintProvider,
8989
FingerprintJSPro,
9090
} from '@fingerprint/react'
9191
import App from './App'
9292

9393
const root = ReactDOM.createRoot(document.getElementById('app'))
9494

95-
// <FpProvider /> supports the same options as `start()` function.
95+
// <FingerprintProvider /> supports the same options as `start()` function.
9696
root.render(
97-
<FpProvider
97+
<FingerprintProvider
9898
apiKey='your-public-api-key'
9999
>
100100
<App />
101-
</FpProvider>
101+
</FingerprintProvider>
102102
)
103103
```
104104

__tests__/fpjs-provider.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useContext } from 'react'
22
import { renderHook } from '@testing-library/react'
3-
import { FpContext } from '../src'
3+
import { FingerprintContext } from '../src'
44
import { createWrapper, getDefaultLoadOptions } from './helpers'
55
import { version } from '../package.json'
66
import { describe, it, expect, vi } from 'vitest'
@@ -10,7 +10,7 @@ vi.mock('@fingerprint/agent', { spy: true })
1010

1111
const mockStart = vi.mocked(agent.start)
1212

13-
describe('FpProvider', () => {
13+
describe('FingerprintProvider', () => {
1414
it('should configure an instance of the Fp Agent', async () => {
1515
const loadOptions = getDefaultLoadOptions()
1616
const wrapper = createWrapper({
@@ -20,7 +20,7 @@ describe('FpProvider', () => {
2020
duration: 100,
2121
},
2222
})
23-
renderHook(() => useContext(FpContext), {
23+
renderHook(() => useContext(FingerprintContext), {
2424
wrapper,
2525
})
2626
expect(mockStart).toHaveBeenCalledWith({

__tests__/helpers.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { PropsWithChildren } from 'react'
2-
import { FpProvider, FpProviderOptions } from '../src'
2+
import { FingerprintProvider, FingerprintProviderOptions } from '../src'
33
import { act } from '@testing-library/react'
44

55
export const getDefaultLoadOptions = () => ({
66
apiKey: 'test_api_key',
77
})
88

99
export const createWrapper =
10-
(providerProps: Partial<FpProviderOptions> = {}) =>
10+
(providerProps: Partial<FingerprintProviderOptions> = {}) =>
1111
({ children }: PropsWithChildren<{}>) => (
12-
<FpProvider {...getDefaultLoadOptions()} {...providerProps}>
12+
<FingerprintProvider {...getDefaultLoadOptions()} {...providerProps}>
1313
{children}
14-
</FpProvider>
14+
</FingerprintProvider>
1515
)
1616

1717
export const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))

examples/create-react-app/src/in_memory_cache/InMemoryCache.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { FpProvider } from '@fingerprint/react'
1+
import { FingerprintProvider } from '@fingerprint/react'
22
import { Outlet } from 'react-router-dom'
33
import { FPJS_API_KEY } from '../shared/utils/env'
44
import { Nav } from '../shared/components/Nav'
55

66
function InMemoryCache() {
77
return (
8-
<FpProvider apiKey={FPJS_API_KEY} cache={{ storage: 'agent', duration: 'optimize-cost' }}>
8+
<FingerprintProvider apiKey={FPJS_API_KEY} cache={{ storage: 'agent', duration: 'optimize-cost' }}>
99
<div className='App'>
1010
<header className='header'>
1111
<h2>Solution with an in-memory cache</h2>
@@ -16,7 +16,7 @@ function InMemoryCache() {
1616
<Nav />
1717
<Outlet />
1818
</div>
19-
</FpProvider>
19+
</FingerprintProvider>
2020
)
2121
}
2222

examples/create-react-app/src/local_storage_cache/LocalStorageCache.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Outlet } from 'react-router-dom'
22
import { Nav } from '../shared/components/Nav'
33
import { FPJS_API_KEY } from '../shared/utils/env'
4-
import { FpProvider } from '@fingerprint/react'
4+
import { FingerprintProvider } from '@fingerprint/react'
55

66
function LocalStorageCache() {
77
return (
8-
<FpProvider
8+
<FingerprintProvider
99
apiKey={FPJS_API_KEY}
1010
cache={{
1111
storage: 'localStorage',
@@ -21,7 +21,7 @@ function LocalStorageCache() {
2121
<Nav />
2222
<Outlet />
2323
</div>
24-
</FpProvider>
24+
</FingerprintProvider>
2525
)
2626
}
2727

examples/create-react-app/src/no_cache/WithoutCache.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { FpProvider } from '@fingerprint/react'
1+
import { FingerprintProvider } from '@fingerprint/react'
22
import { Outlet } from 'react-router-dom'
33
import { Nav } from '../shared/components/Nav'
44
import { FPJS_API_KEY } from '../shared/utils/env'
55

66
function WithoutCache() {
77
return (
8-
<FpProvider apiKey={FPJS_API_KEY}>
8+
<FingerprintProvider apiKey={FPJS_API_KEY}>
99
<div className='App'>
1010
<header className='header'>
1111
<h2>Solution without cache</h2>
@@ -14,7 +14,7 @@ function WithoutCache() {
1414
<Nav />
1515
<Outlet />
1616
</div>
17-
</FpProvider>
17+
</FingerprintProvider>
1818
)
1919
}
2020

examples/create-react-app/src/session_storage_cache/SessionStorageCache.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { FpProvider } from '@fingerprint/react'
1+
import { FingerprintProvider } from '@fingerprint/react'
22
import { Outlet } from 'react-router-dom'
33
import { Nav } from '../shared/components/Nav'
44
import { FPJS_API_KEY } from '../shared/utils/env'
55

66
function SessionStorageCache() {
77
return (
8-
<FpProvider apiKey={FPJS_API_KEY} cache={{ storage: 'sessionStorage', duration: 60 * 5 }}>
8+
<FingerprintProvider apiKey={FPJS_API_KEY} cache={{ storage: 'sessionStorage', duration: 60 * 5 }}>
99
<div className='App'>
1010
<header className='header'>
1111
<h2>Solution with a custom implementation of a session storage cache</h2>
@@ -14,7 +14,7 @@ function SessionStorageCache() {
1414
<Nav />
1515
<Outlet />
1616
</div>
17-
</FpProvider>
17+
</FingerprintProvider>
1818
)
1919
}
2020

examples/next-appDir/app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import '../styles/globals.css'
2-
import { FpProvider } from '@fingerprint/react'
2+
import { FingerprintProvider } from '@fingerprint/react'
33
import { PropsWithChildren } from 'react'
44

55
const fpjsPublicApiKey = process.env.NEXT_PUBLIC_FPJS_PUBLIC_API_KEY as string
@@ -8,7 +8,7 @@ function RootLayout({ children }: PropsWithChildren) {
88
return (
99
<html>
1010
<body>
11-
<FpProvider apiKey={fpjsPublicApiKey}>{children}</FpProvider>
11+
<FingerprintProvider apiKey={fpjsPublicApiKey}>{children}</FingerprintProvider>
1212
</body>
1313
</html>
1414
)

examples/next/pages/_app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import '../styles/globals.css'
22
import type { AppProps } from 'next/app'
3-
import { FpProvider } from '@fingerprint/react'
3+
import { FingerprintProvider } from '@fingerprint/react'
44

55
const fpjsPublicApiKey = process.env.NEXT_PUBLIC_FPJS_PUBLIC_API_KEY as string
66

77
function MyApp({ Component, pageProps }: AppProps) {
88
return (
9-
<FpProvider apiKey={fpjsPublicApiKey}>
9+
<FingerprintProvider apiKey={fpjsPublicApiKey}>
1010
<Component {...pageProps} />
11-
</FpProvider>
11+
</FingerprintProvider>
1212
)
1313
}
1414

examples/preact/src/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { FunctionalComponent } from 'preact'
22
import './style/index.css'
33
import App from './components/app'
4-
import { FpProvider } from '@fingerprint/react'
4+
import { FingerprintProvider } from '@fingerprint/react'
55

66
const WrappedApp: FunctionalComponent = () => {
77
const apiKey = process.env.PREACT_APP_FPJS_PUBLIC_API_KEY as string
88
return (
9-
<FpProvider apiKey={apiKey}>
9+
<FingerprintProvider apiKey={apiKey}>
1010
<App />
11-
</FpProvider>
11+
</FingerprintProvider>
1212
)
1313
}
1414

0 commit comments

Comments
 (0)