@picked/fingerprintjs 0.0.1-dev.1764710808992 → 0.0.1-dev.1764952778408

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,23 +1,18 @@
1
- # Fingerprintjs SDK
1
+ # FingerprintJS
2
2
 
3
3
  ## 🚀 Quick Start
4
4
 
5
- Here's a basic example of how to use `Fingerprintjs` SDK.
5
+ `@picked/fingerprintjs` is a plugin that automatically adds the FingerprintJS visitor ID to the analytics session, if it exists.
6
6
 
7
- ## API
8
-
9
- **`fingerprintjsPlugin`**: A plugin factory that returns a `Plugin` which, when added to the `createClient` `plugins` array, will attempt to read `window.FingerprintJS` and store the resolved visitor id in the session store under an internal key. The plugin automatically polls for `window.FingerprintJS` for up to 10 seconds and saves the `visitorId` when available. Check below how to import and use it.
10
-
11
- **`getFingerprintVisitorId`**: Retrieves the stored FingerprintJS visitor id from the session store.
12
- - **Returns**: `string | undefined` — returns the visitor id value (or `undefined` if `window` is not supported).
7
+ When added to the `createClient` `plugins` array, it will attempt to read `window.FingerprintJS` and store the resolved visitor ID in the session store under an internal key. The plugin automatically polls for `window.FingerprintJS` for up to 10 seconds and saves the `visitorId` when available. See below for how to import and use it.
13
8
 
14
9
  ## Snowplow integration
15
10
 
16
- After the plugin is initialized via `createClient` (i.e. the plugin is included in the `plugins` array and the client is started), the FingerprintJS visitor id will be automatically added to the Snowplow session event. The visitor id is attached with the key `fingerprintjs_visitor_id` on the session event.
11
+ After the plugin is initialized via `createClient` (i.e. the plugin is included in the `plugins` array and the client is started), the FingerprintJS visitor ID will be automatically added to the Snowplow session event as the `fingerprintjs_visitor_id` field.
17
12
 
18
13
  ## Using the `fingerprintjsPlugin`
19
14
 
20
- You should import the `fingerprintjsPlugin` from package `@picked/fingerprintjs` and add it to the `plugins` array passed to `createClient`.
15
+ You should import the `fingerprintjsPlugin` from the package `@picked/fingerprintjs` and add it to the `plugins` array passed to `createClient`.
21
16
 
22
17
  Example usage:
23
18
 
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@picked/client"),o=n.createStorageKey("fingerprintjs","global"),g=()=>({name:"fingerprintjs-plugin",setup:()=>{n.supportsWindow()&&p(1e4).then(i=>{if(!i){n.sessionStore.set(o,void 0);return}i.load().then(({get:r})=>{r().then(({visitorId:e})=>{n.sessionStore.set(o,e)})})})}});function d(){var t;return n.supportsWindow()?((t=n.sessionStore.get(o))==null?void 0:t.text())??void 0:void 0}function p(i){return new Promise(t=>{if(!n.supportsWindow())return t(void 0);const r=100,e=Date.now(),s=()=>{const u=globalThis.window.FingerprintJS;if(u)return t(u);if(Date.now()-e>=i)return t(void 0);setTimeout(s,r)};s()})}exports.fingerprintjsPlugin=g;exports.getFingerprintVisitorId=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@picked/client");o.createStorageKey("fingerprintjs","global");const g=()=>({name:"fingerprintjs-plugin",setup:n=>{if(!o.supportsWindow())return;(async()=>{var i,a;const r=await p(1e4);if(!r){(i=n.session)==null||i.removeIdentifier("fingerprintjs_visitor_id");return}const s=await r.load(),{visitorId:e}=await s.get();(a=n.session)==null||a.setIdentifier("fingerprintjs_visitor_id",e)})()}});function p(n){return new Promise(t=>{if(!o.supportsWindow()){t(void 0);return}const r=100,s=Date.now(),e=()=>{const i=globalThis.window.FingerprintJS;if(i)return t(i);if(Date.now()-s>=n)return t(void 0);setTimeout(e,r)};e()})}exports.fingerprintjsPlugin=g;
package/dist/esm/index.js CHANGED
@@ -1,40 +1,39 @@
1
- import { createStorageKey as d, supportsWindow as s, sessionStore as e } from "@picked/client";
2
- const o = d("fingerprintjs", "global"), p = () => ({
1
+ import { createStorageKey as p, supportsWindow as a } from "@picked/client";
2
+ p("fingerprintjs", "global");
3
+ const d = () => ({
3
4
  name: "fingerprintjs-plugin",
4
- setup: () => {
5
- s() && g(1e4).then((n) => {
6
- if (!n) {
7
- e.set(o, void 0);
5
+ setup: (n) => {
6
+ if (!a())
7
+ return;
8
+ (async () => {
9
+ var i, s;
10
+ const r = await f(1e4);
11
+ if (!r) {
12
+ (i = n.session) == null || i.removeIdentifier("fingerprintjs_visitor_id");
8
13
  return;
9
14
  }
10
- n.load().then(({ get: i }) => {
11
- i().then(({ visitorId: r }) => {
12
- e.set(o, r);
13
- });
14
- });
15
- });
15
+ const o = await r.load(), { visitorId: e } = await o.get();
16
+ (s = n.session) == null || s.setIdentifier("fingerprintjs_visitor_id", e);
17
+ })();
16
18
  }
17
19
  });
18
- function c() {
19
- var t;
20
- return s() ? ((t = e.get(o)) == null ? void 0 : t.text()) ?? void 0 : void 0;
21
- }
22
- function g(n) {
20
+ function f(n) {
23
21
  return new Promise((t) => {
24
- if (!s())
25
- return t(void 0);
26
- const i = 100, r = Date.now(), u = () => {
27
- const a = globalThis.window.FingerprintJS;
28
- if (a)
29
- return t(a);
30
- if (Date.now() - r >= n)
22
+ if (!a()) {
23
+ t(void 0);
24
+ return;
25
+ }
26
+ const r = 100, o = Date.now(), e = () => {
27
+ const i = globalThis.window.FingerprintJS;
28
+ if (i)
29
+ return t(i);
30
+ if (Date.now() - o >= n)
31
31
  return t(void 0);
32
- setTimeout(u, i);
32
+ setTimeout(e, r);
33
33
  };
34
- u();
34
+ e();
35
35
  });
36
36
  }
37
37
  export {
38
- p as fingerprintjsPlugin,
39
- c as getFingerprintVisitorId
38
+ d as fingerprintjsPlugin
40
39
  };
@@ -19,11 +19,5 @@ interface FingerprintJS {
19
19
  * @returns FingerprintJS plugin.
20
20
  */
21
21
  export declare const fingerprintjsPlugin: () => Plugin;
22
- /**
23
- * Retrieves the FingerprintJS visitorId from the session store.
24
- *
25
- * @returns StorageItem<string | undefined> The stored visitorId or undefined if not present.
26
- */
27
- export declare function getFingerprintVisitorId(): string | undefined;
28
22
  export {};
29
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,MAAM,EACZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,aAAa,CAAC,EAAE,aAAa,CAAA;KAC9B;CACF;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,OAAO,CAAC;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAA;CACnE;AAID;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,QAAO,MAwBtC,CAAA;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,SAAS,CAQ5D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5F,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,aAAa,CAAC,EAAE,aAAa,CAAA;KAC9B;CACF;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,OAAO,CAAC;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAA;CACnE;AAID;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,QAAO,MAyBtC,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@picked/fingerprintjs",
3
3
  "description": "Fingerprintjs plugin",
4
- "version": "0.0.1-dev.1764710808992",
4
+ "version": "0.0.1-dev.1764952778408",
5
5
  "dependencies": {},
6
6
  "devDependencies": {
7
7
  "@picked/client": "workspace:*",
@@ -31,7 +31,7 @@
31
31
  "main": "./dist/cjs/index.js",
32
32
  "module": "./dist/esm/index.js",
33
33
  "peerDependencies": {
34
- "@picked/client": "0.0.1-dev.1764710808992"
34
+ "@picked/client": "0.0.1-dev.1764952778408"
35
35
  },
36
36
  "private": false,
37
37
  "scripts": {