Skip to content

Commit b88a2a9

Browse files
committed
Merge branch 'main' into chore/externalize-fingerprint-sdk-version
2 parents 2c2dd76 + b6fb789 commit b88a2a9

File tree

20 files changed

+465
-320
lines changed

20 files changed

+465
-320
lines changed

CODEOWNERS

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# Users referenced in this file will automatically be requested as reviewers for PRs that modify the given paths.
22
# See https://help.github.com/articles/about-code-owners/
33

4-
ios/ @mgutski
5-
android/ @Alexey-Verkhovsky
6-
7-
* @ilfa @TheUnderScorer
4+
* @ilfa @TheUnderScorer @JuroUhlar

README.md

Lines changed: 89 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,43 @@
1515
</p>
1616

1717
# Fingerprint Pro Flutter
18-
[Fingerprint](https://fingerprint.com/) is a device intelligence platform offering 99.5% accurate visitor
19-
identification. Fingerprint Pro Flutter SDK is an easy way to integrate Fingerprint Pro into your Flutter
20-
application to call the native Fingerprint Pro libraries (Android, iOS and Web) and identify devices.
18+
19+
[Fingerprint](https://fingerprint.com/) is a device intelligence platform offering visitor
20+
identification and device intelligence with industry-leading accuracy. Fingerprint Flutter SDK is an easy way to integrate Fingerprint into your Flutter
21+
application. The plugin allows you to call the underlying native Fingerprint agents (Android, iOS, and Web) and identify devices.
2122

2223
## Table of contents
23-
* [Requirements](#requirements)
24-
* [Dependencies](#dependencies)
25-
* [How to install](#how-to-install)
26-
* [Usage](#usage)
27-
* [Additional Resources](#additional-resources)
28-
* [Support and feedback](#support-and-feedback)
29-
* [License](#license)
24+
- [Fingerprint Pro Flutter](#fingerprint-pro-flutter)
25+
- [Table of contents](#table-of-contents)
26+
- [Requirements](#requirements)
27+
- [Dependencies](#dependencies)
28+
- [How to install](#how-to-install)
29+
- [Web platform (Optional)](#web-platform-optional)
30+
- [Usage](#usage)
31+
- [1. Configure and initialize the plugin](#1-configure-and-initialize-the-plugin)
32+
- [2. Identify visitors](#2-identify-visitors)
33+
- [Linking and tagging information](#linking-and-tagging-information)
34+
- [Specifying a custom timeout](#specifying-a-custom-timeout)
35+
- [Additional Resources](#additional-resources)
36+
- [Support and feedback](#support-and-feedback)
37+
- [License](#license)
3038

3139
## Requirements
32-
- Flutter 3.10 or higher
40+
- Flutter 3.13 or higher
41+
- Dart 3.3 or higher
3342
- Android 5.0 (API level 21+) or higher
3443
- iOS 13+/tvOS 15+, Swift 5.7 or higher (stable releases)
3544

3645
We aim to keep the [Flutter compatibility policy](https://docs.flutter.dev/release/compatibility-policy).
3746

3847
## Dependencies
39-
- [Fingerprint Pro iOS](https://github.com/fingerprintjs/fingerprintjs-pro-ios)
40-
- [Fingerprint Pro Android](https://github.com/fingerprintjs/fingerprintjs-pro-android)
48+
- [Fingerprint JavaScript agent](https://www.npmjs.com/package/@fingerprintjs/fingerprintjs-pro)
49+
- [Fingerprint iOS](https://github.com/fingerprintjs/fingerprintjs-pro-ios)
50+
- [Fingerprint Android](https://github.com/fingerprintjs/fingerprintjs-pro-android)
4151

4252
## How to install
43-
Add `fpjs_pro_plugin` to the pubspec.yaml in your Flutter app:
53+
54+
Add `fpjs_pro_plugin` to the `pubspec.yaml` file in your Flutter app:
4455

4556
```yaml
4657
dependencies:
@@ -50,27 +61,44 @@ dependencies:
5061
fpjs_pro_plugin: ^3.3.2
5162
```
5263
53-
Run `pub get` to download and install the package.
64+
Run `flutter pub get` to download and install the package.
5465

55-
### Web platform
66+
### Web platform (Optional)
5667

57-
Add a `<script>` tag with the JS agent loader inside the `<head>` tag in your HTML template to use `fpjs_pro_plugin`:
68+
To use this plugin on the web, add the JavaScript agent loader `<script>` tag to the `<head>` of your HTML template inside the `web/index.html` file:
5869

5970
```html
60-
<script src="assets/packages/fpjs_pro_plugin/web/index.js" defer></script>
71+
<head>
72+
<!-- ... -->
73+
<script src="assets/packages/fpjs_pro_plugin/web/index.js" defer></script>
74+
</head>
6175
```
6276

6377
## Usage
64-
To identify visitors, you need a Fingerprint Pro account (you can [sign up for free](https://dashboard.fingerprintjs.com/signup/)).
78+
79+
To identify visitors, you need to [sign up for a Fingerprint account](https://dashboard.fingerprintjs.com/signup/) (there is a free trial available).
6580

6681
- Go to [the Fingerprint Pro dashboard](https://dashboard.fingerprint.com/).
6782
- Navigate to **App Settings** > **API Keys** to find your _Public_ API Key.
6883

69-
### 1. Configure the plugin
84+
### 1. Configure and initialize the plugin
85+
86+
Initialize the Fingerprint Flutter plugin inside a [StatefulWidget](https://api.flutter.dev/flutter/widgets/StatefulWidget-class.html), for example, in the `initState` method.
87+
88+
Use the [Public API key](https://dev.fingerprint.com/docs/quick-start-guide#2-get-your-api-key) and [region](https://dev.fingerprint.com/docs/regions) of your Fingerprint workspace (US region is used by default).
7089

7190
```dart
7291
import 'package:fpjs_pro_plugin/fpjs_pro_plugin.dart';
73-
// ...
92+
import 'package:fpjs_pro_plugin/region.dart';
93+
94+
void main() {
95+
runApp(MyApp());
96+
}
97+
98+
class MyApp extends StatefulWidget {
99+
@override
100+
State<MyApp> createState() => _MyAppState();
101+
}
74102
75103
// Initialization
76104
class _MyAppState extends State<MyApp> {
@@ -82,80 +110,70 @@ class _MyAppState extends State<MyApp> {
82110
83111
void doInit() async {
84112
await FpjsProPlugin.initFpjs(
85-
'<apiKey>' // insert your actual API key here
113+
'<PUBLIC_API_KEY>', // insert your API key here
114+
region: Region.us // or Region.eu, Region.ap
86115
);
87116
}
88117
// ...
89118
}
90119
```
91120

92-
You can also configure `region`, `endpoint` and `endpointFallbacks` in the `initFpjs` method, like below. For the web platform, you can use an additional `scriptUrlPattern` and `scriptUrlPatternFallbacks` properties to specify a custom URL for loading the JavaScript agent. This is required for proxy integrations.
93-
```dart
94-
void doInit() async {
95-
await FpjsProPlugin.initFpjs(
96-
'<apiKey>',
97-
endpoint: 'https://subdomain.domain.com',
98-
endpointFallbacks: ['https://subdomain2.domain.com', 'https://subdomain3.domain.com'],
99-
region: Region.eu, // or Region.ap, Region.us
100-
// Only necessary for the web platform
101-
scriptUrlPattern: 'https://your.domain/fp_js/script_path?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>',
102-
scriptUrlPatternFallbacks: ['https://your.second-domain/fp_js/script_path?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>']
103-
);
104-
}
105-
```
106-
107-
### 2. Use the plugin in your application code to identify a visitor
121+
To avoid ad blockers, we recommend proxying requests from your application to Fingerprint servers through one of our proxy integrations. See [Evading ad blockers with proxy integrations](https://dev.fingerprint.com/docs/protecting-the-javascript-agent-from-adblockers) for more information.
108122

109-
#### 2.1 Use the `getVisitorId` method if you only need a `visitorId`:
123+
To use a proxy integration, you can configure `endpoint`, `scriptUrlPattern`, and their fallbacks.
110124

111125
```dart
112-
import 'package:fpjs_pro_plugin/fpjs_pro_plugin.dart';
113-
// ...
114-
115-
// Initialization
116-
class _MyAppState extends State<MyApp> {
117-
// ...
118-
// Usage
119-
void identify() async {
120-
try {
121-
visitorId = await FpjsProPlugin.getVisitorId() ?? 'Unknown';
122-
// use the visitor id
123-
} on FingerprintProError catch (e) {
124-
// process an error somehow
125-
// check lib/error.dart to get more info about error types
126-
}
126+
void doInit() async {
127+
await FpjsProPlugin.initFpjs(
128+
'<PUBLIC_API_KEY>',
129+
region: Region.us,
130+
// Your proxy integration identification endpoint
131+
endpoint: 'https://metrics.yourwebsite.com',
132+
endpointFallbacks: ['https://api.fpjs.io'], // region-specific fallback
133+
// Your proxy integration script URL pattern
134+
// Only necessary for the web platform
135+
scriptUrlPattern: 'https://metrics.yourwebsite.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js',
136+
scriptUrlPatternFallbacks: [
137+
'https://fpjscdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js',
138+
],
139+
);
127140
}
128-
}
129141
```
130142

131-
#### 2.2 Use `getVisitorData` to get extended result
143+
### 2. Identify visitors
144+
145+
Use `getVisitorId` to get just the visitor ID, or `getVisitorData` to get the identification response object.
132146

133147
```dart
134148
import 'package:fpjs_pro_plugin/fpjs_pro_plugin.dart';
149+
import 'package:fpjs_pro_plugin/region.dart';
150+
import 'package:fpjs_pro_plugin/error.dart';
135151
// ...
136152
137-
// Initialization
138153
class _MyAppState extends State<MyApp> {
139-
// ...
140-
// Usage
141154
void identify() async {
142155
try {
143-
deviceData = await FpjsProPlugin.getVisitorData();
144-
// use the visitor id
156+
var visitorId = await FpjsProPlugin.getVisitorId();
157+
var visitorData = await FpjsProPlugin.getVisitorData();
158+
159+
print('Visitor ID: $visitorId');
160+
print('Visitor data: $visitorData');
145161
} on FingerprintProError catch (e) {
146-
// process an error somehow
147-
// check lib/error.dart to get more info about error types
162+
// Process the error
163+
print('Error identifying visitor: $e');
164+
// See lib/error.dart to get more information about error types
148165
}
149166
}
150167
}
151168
```
152169

153-
By default `getVisitorData()` will return a short response with the `FingerprintJSProResponse` type.
154-
Provide `extendedResponseFormat=true` to the `initFpjs` function to get extended result of `FingerprintJSProExtendedResponse` type.
170+
171+
By default, `getVisitorData()` will return a short response (`FingerprintJSProResponse`).
172+
Pass `extendedResponseFormat: true` to the `initFpjs` function to get an extended response (`FingerprintJSProExtendedResponse`).
155173

156174
```dart
157175
void doInit() async {
158-
await FpjsProPlugin.initFpjs('<apiKey>', extendedResponseFormat: true);
176+
await FpjsProPlugin.initFpjs('<PUBLIC_API_KEY>', extendedResponseFormat: true);
159177
}
160178
```
161179

@@ -166,8 +184,8 @@ The `visitorId` provided by Fingerprint Identification is especially useful when
166184
```dart
167185
void identify() async {
168186
const tags = {
169-
userAction: 'login',
170-
analyticsId: 'UA-5555-1111-1'
187+
'userAction': 'login',
188+
'analyticsId': 'UA-5555-1111-1'
171189
};
172190
const linkedId = 'user_1234';
173191
@@ -193,14 +211,15 @@ void identify() async {
193211
```
194212

195213
## Additional Resources
196-
- [Server-to-Server API](https://dev.fingerprint.com/docs/server-api)
197214
- [Fingerprint Pro documentation](https://dev.fingerprint.com/docs)
215+
- [Server API](https://dev.fingerprint.com/reference/server-api)
198216

199217
## Support and feedback
200218

201-
To report problems, ask questions or provide feedback, please
219+
To report problems, ask questions, or provide feedback, please
202220
use [Issues](https://github.com/fingerprintjs/fingerprintjs-pro-flutter/issues). If you need private support, please
203221
email us at `[email protected]`.
204222

205223
## License
224+
206225
This project is licensed under the [MIT license](https://github.com/fingerprintjs/fingerprintjs-pro-flutter/blob/main/LICENSE).

android/build.gradle

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
apply from: 'fingerprint.gradle'
22

3+
plugins {
4+
id 'com.android.library'
5+
id 'kotlin-android'
6+
}
7+
38
group 'com.fingerprintjs.flutter.fpjs_pro.fpjs_pro_plugin'
49
version '3.3.2'
510

6-
buildscript {
7-
ext.kotlin_version = '1.8.10'
8-
repositories {
9-
google()
10-
mavenCentral()
11-
}
12-
13-
dependencies {
14-
classpath 'com.android.tools.build:gradle:7.4.2'
15-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
16-
}
17-
}
18-
1911
rootProject.allprojects {
2012
repositories {
2113
google()
@@ -25,9 +17,6 @@ rootProject.allprojects {
2517
}
2618
}
2719

28-
apply plugin: 'com.android.library'
29-
apply plugin: 'kotlin-android'
30-
3120
android {
3221
compileSdkVersion 34
3322

@@ -54,6 +43,5 @@ android {
5443
}
5544

5645
dependencies {
57-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
5846
implementation "com.fingerprint.android:pro:$fingerprint_native_sdk_version"
5947
}

android/settings.gradle

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
9+
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
11+
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
18+
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "7.4.2" apply false
22+
id "org.jetbrains.kotlin.android" version "1.8.10" apply false
23+
}
24+
25+
// Docs say to include the app, but it doesn't seem needed for a library
26+
// include ":app"
27+
128
rootProject.name = 'fpjs_pro_plugin'

example/.env

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
API_KEY=<your-api-key>
2-
REGION=<your-region>
3-
PROXY_INTEGRATION_PATH=<your-proxy-path># example: `https://your.domain/behaviour_path`
4-
PROXY_INTEGRATION_SCRIPT_PATH=<your-script-path># example `script_path?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`
5-
PROXY_INTEGRATION_REQUEST_PATH=<your-request-path># example `request_path`
1+
# https://dev.fingerprint.com/docs/quick-start-guide#2-get-your-api-key
2+
# API_KEY=
3+
4+
# https://dev.fingerprint.com/docs/regions
5+
# REGION=
6+
7+
# https://dev.fingerprint.com/docs/install-the-javascript-agent#configuring-the-agent
8+
# SCRIPT_URL_PATTERN=
9+
10+
# https://dev.fingerprint.com/docs/install-the-javascript-agent#configuring-the-agent
11+
# ENDPOINT=

0 commit comments

Comments
 (0)