Skip to content

Commit

Permalink
feat: add scriptUrlPatternFallbacks configuration param
Browse files Browse the repository at this point in the history
  • Loading branch information
ilfa committed Aug 19, 2024
1 parent aeae143 commit ae44e86
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class _MyAppState extends State<MyApp> {
}
```

You can also configure `region`, `endpoint` and `endpointFallbacks` in the `initFpjs` method, like below. For the web platform, you can use an additional `scriptUrlPattern` property to specify a custom URL for loading the JavaScript agent. This is required for proxy integrations.
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.
```dart
void doInit() async {
await FpjsProPlugin.initFpjs(
Expand All @@ -98,7 +98,8 @@ void doInit() async {
endpointFallbacks: ['https://subdomain2.domain.com', 'https://subdomain3.domain.com'],
region: Region.eu, // or Region.ap, Region.us
// Only necessary for the web platform
scriptUrlPattern: 'https://your.domain/fp_js/script_path?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>'
scriptUrlPattern: 'https://your.domain/fp_js/script_path?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>',
scriptUrlPatternFallbacks: ['https://your.second-domain/fp_js/script_path?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>']
);
}
```
Expand Down
2 changes: 2 additions & 0 deletions lib/fpjs_pro_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ class FpjsProPlugin {
{String? endpoint,
List<String>? endpointFallbacks,
String? scriptUrlPattern,
List<String>? scriptUrlPatternFallbacks,
Region? region,
bool extendedResponseFormat = false}) async {
await _channel.invokeMethod('init', {
'apiToken': apiKey,
'endpoint': endpoint,
'endpointFallbacks': endpointFallbacks,
'scriptUrlPattern': scriptUrlPattern,
'scriptUrlPatternFallbacks': scriptUrlPatternFallbacks,
'region': region?.stringValue,
'extendedResponseFormat': extendedResponseFormat,
'pluginVersion': pluginVersion,
Expand Down
5 changes: 4 additions & 1 deletion lib/fpjs_pro_plugin_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ class FpjsProPluginWeb {
];
}
if (call.arguments['scriptUrlPattern'] != null) {
options.scriptUrlPattern = call.arguments['scriptUrlPattern'];
options.scriptUrlPattern = [
call.arguments['scriptUrlPattern'],
...(call.arguments['scriptUrlPatternFallbacks'] ?? [])
];
}
try {
_fpPromise = promiseToFuture(FingerprintJS.load(options));
Expand Down
4 changes: 2 additions & 2 deletions lib/js_agent_interop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ class FingerprintJSOptions {
/// - <version> — the major version of JS agent;
/// - <apiKey> — the public key set via the `apiKey` option;
/// - <loaderVersion> — the version of this package;
external String? get scriptUrlPattern;
external set scriptUrlPattern(String? scriptUrlPattern);
external List<String>? get scriptUrlPattern;
external set scriptUrlPattern(List<String>? scriptUrlPattern);

external factory FingerprintJSOptions(
{String apiKey, List<String> integrationInfo});
Expand Down

0 comments on commit ae44e86

Please sign in to comment.