@fingerprintjs/fingerprintjs-pro-gtm
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -0,1 +1,28 @@ | ||
## 0.3.0 (2022-03-29) | ||
##### Chores | ||
* remove iife format ([090daddc](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/090daddcd007881577ce4bbaf7c26aa8388f7c91)) | ||
* add typecheck to build action ([c703b234](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/c703b234df81725369de5ee72514bea84a864c79)) | ||
* allow rollup to remove unused code from deps ([ca071f39](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/ca071f3949c9908b231b7b9785b82dde69c7e8ed)) | ||
* generate only esm module ([94981e1c](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/94981e1cb922a0ff2ea9308e75c1c74112276415)) | ||
* move rollup resolve to devDependencies section ([7458c77a](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/7458c77a9218b41d7da4539d130ba793d964919a)) | ||
##### Documentation Changes | ||
* update README.md ([a6931ecf](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/a6931ecfb753c4a48e3ceee9d99526397065a048)) | ||
* add ci badge, add beta notice ([b5f0aceb](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/b5f0acebab7739b45b8f166734971a94022d8c56)) | ||
##### New Features | ||
* add integrationInfo to loadOptions ([aff41286](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/aff412863fa4f6d947e4ccc6fedc588ca64733f9)) | ||
* use separate options for load and get ([7c8eaa0c](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/7c8eaa0c2fb3119e552022f0347e15f7dccf6000)) | ||
* use new fpjs-pro agent v3.6.0 ([3bb739ef](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/3bb739efce45fdececaac7f4d002296c25673a99)) | ||
* support endpoint, tag and linkedIt options ([b264b849](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/b264b849dc972b41a727b1ed5f6ebb5d05254e8a)) | ||
##### Bug Fixes | ||
* pick function, tests ([0b22e61a](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/0b22e61a9d75c91edd40c19aaa35fb4fbeb72f9b)) | ||
* remove unnecessary esm build ([1723ace3](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/commit/1723ace303290f4dabc1218f0e3ded1172d53826)) | ||
### 0.2.0 (2022-03-22) | ||
@@ -2,0 +29,0 @@ |
/** | ||
* FingerprintJS Pro React v0.2.0 - Copyright (c) FingerprintJS, Inc, 2022 (https://fingerprintjs.com) | ||
* FingerprintJS Pro React v0.3.0 - Copyright (c) FingerprintJS, Inc, 2022 (https://fingerprintjs.com) | ||
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. | ||
*/ | ||
const pick = (originalObject, fields) => { | ||
return Object.fromEntries(Object.entries(originalObject).filter(([key]) => fields.includes(key))); | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
const load = (loadOptions, callback) => { | ||
const cdnUrl = `https://fpcdn.io/v3/${loadOptions.apiKey}/esm.min.js`; | ||
const fpPromise = new Promise((resolve, reject) => { | ||
const script = document.createElement('script'); | ||
script.onload = resolve; | ||
script.onerror = reject; | ||
script.async = true; | ||
script.src = cdnUrl; | ||
document.head.appendChild(script); | ||
}).then(() => window.FingerprintJS.load(pick(loadOptions, ['region']))); | ||
fpPromise.then((fp) => fp.get()).then((result) => callback(result)); | ||
function __rest(s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
} | ||
/** | ||
* FingerprintJS Pro v3.6.0 - Copyright (c) FingerprintJS, Inc, 2022 (https://fingerprintjs.com) | ||
* | ||
* This software contains code from open-source projects: | ||
* MurmurHash3 by Karan Lyons (https://github.com/karanlyons/murmurHash3.js) | ||
*/ | ||
function r(e){for(var t="",r=0;r<e.length;++r)if(r>0){var n=e[r].toLowerCase();n!==e[r]?t+=" "+n:t+=e[r];}else t+=e[r].toUpperCase();return t}r("WrongRegion");r("SubscriptionNotActive");r("UnsupportedVersion");r("InstallationMethodRestricted");function y(e,t,r){return void 0===r&&(r=0),t(r).catch((function(n){if(r>=e.maxRetries)throw n;var o,i,R,a,d=(o=e.baseDelay,i=e.maxDelay,R=e.baseDelay*Math.pow(2,r),Math.max(o,Math.min(i,R)));return (a=d,new Promise((function(e){return setTimeout(e,a)}))).then((function(){return y(e,t,r+1)}))}))}var P="Failed to load the JS script of the agent",h="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";function m(r){var n=r.scriptUrlPattern,o=r.token,i=r.apiKey,R=void 0===i?o:i,a=__rest(r,["scriptUrlPattern","token","apiKey"]),d=[];return Promise.resolve().then((function(){if(!R||"string"!=typeof R)throw new Error("API key required");return y({maxRetries:5,baseDelay:100,maxDelay:3e3},(function(){var e,t=new Date,r=function(){return d.push({startedAt:t,finishedAt:new Date})},o=(e=function(e,t){void 0===t&&(t=h);var r=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return "<version>"===t?"3":"<apiKey>"===t?r(e):"<loaderVersion>"===t?r("3.6.0"):t}))}(R,n),new Promise((function(t,r){var n=document.createElement("script"),o=function(){var e;return null===(e=n.parentNode)||void 0===e?void 0:e.removeChild(n)},i=document.head||document.getElementsByTagName("head")[0];n.onload=function(){o(),t();},n.onerror=function(){o(),r(new Error(P));},n.async=!0,n.src=e,i.appendChild(n);})));return o.then(r,r),o}))})).then((function(){var e=window,r="__fpjs_p_l_b",n=e[r];if(function(e,t){var r,n=null===(r=Object.getOwnPropertyDescriptor)||void 0===r?void 0:r.call(Object,e,t);(null==n?void 0:n.configurable)?delete e[t]:n&&!n.writable||(e[t]=void 0);}(e,r),"function"!=typeof(null==n?void 0:n.load))throw new Error(P);return n.load(__assign(__assign({},a),{ldi:{attempts:d}}))}))} | ||
var version = "0.3.0"; | ||
function addIntegrationInfo(loadOptions) { | ||
const { integrationInfo = [] } = loadOptions; | ||
loadOptions.integrationInfo = [`fingerprintjs-pro-gtm/${version}`].concat(integrationInfo); | ||
return loadOptions; | ||
} | ||
const load = (loadOptions, getOptions, callback) => { | ||
const fpPromise = m(addIntegrationInfo(loadOptions)); | ||
fpPromise.then((fp) => fp.get(getOptions)).then((result) => callback(result)); | ||
}; | ||
export { load }; |
{ | ||
"name": "@fingerprintjs/fingerprintjs-pro-gtm", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "FingerprintJS pro version adapter for Google Tag Manager", | ||
@@ -12,5 +12,6 @@ "author": "FingerprintJS, Inc (https://fingerprintjs.com)", | ||
"scripts": { | ||
"build": "rimraf dist && rollup -c rollup.config.js", | ||
"build": "rimraf dist && rollup -c", | ||
"lint": "eslint --ext .js,.ts --ignore-path .gitignore --max-warnings 0 .", | ||
"lint:fix": "yarn lint --fix", | ||
"typecheck": "tsc --noEmit", | ||
"test": "jest", | ||
@@ -21,3 +22,2 @@ "release:major": "changelog -M && git add CHANGELOG.md && yarn version --major", | ||
}, | ||
"main": "dist/fpjs-pro-gtm.cjs.js", | ||
"module": "dist/fpjs-pro-gtm.esm.js", | ||
@@ -28,4 +28,5 @@ "files": [ | ||
"devDependencies": { | ||
"@fingerprintjs/fingerprintjs-pro": "^3.5.7", | ||
"@fingerprintjs/fingerprintjs-pro": "^3.6.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^13.1.3", | ||
"@rollup/plugin-typescript": "^8.3.1", | ||
@@ -44,3 +45,2 @@ "@types/jest": "^27.4.0", | ||
"rollup-plugin-peer-deps-external": "^2.2.4", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"ts-jest": "^27.1.3", | ||
@@ -47,0 +47,0 @@ "typescript": "^4.5.5" |
@@ -7,7 +7,11 @@ <p align="center"> | ||
<p align="center"> | ||
<Place for badges> | ||
<a href="https://github.com/fingerprintjs/fingerprintjs-pro-gtm/actions/workflows/build.yml"> | ||
<img src="https://github.com/fingerprintjs/fingerprintjs-pro-gtm/actions/workflows/build.yml/badge.svg" alt="Build status"> | ||
</a> | ||
</p> | ||
Adapter for [FingerprintJS Pro JS agent](https://dev.fingerprintjs.com/docs) to use in [Google Tag Manager (GTM)](https://tagmanager.google.com/) template. GTM uses javascript subset that doesn't support Pomises and this is the reason for this library. | ||
Since GTM ([Google Tag Manager](https://tagmanager.google.com/)) uses a subset of JavaScript API that doesn't support Promises, we created this adapter for the [FingerprintJS Pro JS agent](https://dev.fingerprintjs.com/docs) that can be used in a GTM template. | ||
> :warning: **Work in progress**: This is a beta version of the library | ||
## Example of usage | ||
@@ -14,0 +18,0 @@ |
10750
47
5
62