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

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
@@ -2,10 +2,42 @@
2
2
 
3
3
  ## 🚀 Quick Start
4
4
 
5
- Here's a basic example of how to use `Fingerprintjs` SDK:
5
+ Here's a basic example of how to use `Fingerprintjs` SDK.
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).
13
+
14
+ ## Snowplow integration
15
+
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.
17
+
18
+ ## Using the `fingerprintjsPlugin`
19
+
20
+ You should import the `fingerprintjsPlugin` from package `@picked/fingerprintjs` and add it to the `plugins` array passed to `createClient`.
21
+
22
+ Example usage:
6
23
 
7
24
  ```typescript
8
- import { doSomething } from '@picked/fingerprintjs'
25
+ import { createClient, fingerprintjsPlugin } from '@picked/fingerprintjs'
26
+
27
+ function app() {
28
+ try {
29
+ const plugins: CreateClientOptions['plugins'] = [fingerprintjsPlugin()]
30
+
31
+ const client = createClient({
32
+ organizationId: 'organization-id',
33
+ projectId: 'project-id',
34
+ predicates: {},
35
+ plugins,
36
+ })
9
37
 
10
- doSomething()
38
+ client.start()
39
+ } catch (error) {
40
+ throw error
41
+ }
42
+ }
11
43
  ```
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@picked/client"),i=n.createStorageKey("fingerprintjs","global"),p=()=>({name:"fingerprintjs-plugin",setup:()=>{if(console.log("====> [fingerprintjsPlugin] Setting up FingerprintJS plugin"),!n.supportsWindow()){console.log("====> [fingerprintjsPlugin] Window is not supported");return}d(1e4).then(t=>{if(!t){console.log("====> [fingerprintjsPlugin] FingerprintJS not found on window after retry"),n.sessionStore.set(i,void 0);return}t.load().then(({get:o})=>{o().then(({visitorId:e})=>{n.sessionStore.set(i,e),console.log("====> [fingerprintjsPlugin] FingerprintJS visitorId stored:",i,e)})})})}});function u(){if(!n.supportsWindow()){console.log("====> [getFingerprintVisitorId] Window is not supported");return}return console.log("====> [getFingerprintVisitorId] Retrieving FingerprintJS visitorId from session store:",i,n.sessionStore.get(i).text()),n.sessionStore.get(i)}function d(t){return new Promise(r=>{if(!n.supportsWindow())return r(void 0);const o=100,e=Date.now(),s=()=>{const g=globalThis.window.FingerprintJS;if(g)return r(g);if(Date.now()-e>=t)return r(void 0);setTimeout(s,o)};s()})}exports.fingerprintjsPlugin=p;exports.getFingerprintVisitorId=u;
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;
package/dist/esm/index.js CHANGED
@@ -1,55 +1,40 @@
1
- import { createStorageKey as u, supportsWindow as s, sessionStore as o } from "@picked/client";
2
- const n = u("fingerprintjs", "global"), f = () => ({
1
+ import { createStorageKey as d, supportsWindow as s, sessionStore as e } from "@picked/client";
2
+ const o = d("fingerprintjs", "global"), p = () => ({
3
3
  name: "fingerprintjs-plugin",
4
4
  setup: () => {
5
- if (console.log("====> [fingerprintjsPlugin] Setting up FingerprintJS plugin"), !s()) {
6
- console.log("====> [fingerprintjsPlugin] Window is not supported");
7
- return;
8
- }
9
- d(1e4).then((i) => {
10
- if (!i) {
11
- console.log("====> [fingerprintjsPlugin] FingerprintJS not found on window after retry"), o.set(n, void 0);
5
+ s() && g(1e4).then((n) => {
6
+ if (!n) {
7
+ e.set(o, void 0);
12
8
  return;
13
9
  }
14
- i.load().then(({ get: e }) => {
15
- e().then(({ visitorId: r }) => {
16
- o.set(n, r), console.log(
17
- "====> [fingerprintjsPlugin] FingerprintJS visitorId stored:",
18
- n,
19
- r
20
- );
10
+ n.load().then(({ get: i }) => {
11
+ i().then(({ visitorId: r }) => {
12
+ e.set(o, r);
21
13
  });
22
14
  });
23
15
  });
24
16
  }
25
17
  });
26
18
  function c() {
27
- if (!s()) {
28
- console.log("====> [getFingerprintVisitorId] Window is not supported");
29
- return;
30
- }
31
- return console.log(
32
- "====> [getFingerprintVisitorId] Retrieving FingerprintJS visitorId from session store:",
33
- n,
34
- o.get(n).text()
35
- ), o.get(n);
19
+ var t;
20
+ return s() ? ((t = e.get(o)) == null ? void 0 : t.text()) ?? void 0 : void 0;
36
21
  }
37
- function d(i) {
22
+ function g(n) {
38
23
  return new Promise((t) => {
39
24
  if (!s())
40
25
  return t(void 0);
41
- const e = 100, r = Date.now(), g = () => {
42
- const p = globalThis.window.FingerprintJS;
43
- if (p)
44
- return t(p);
45
- if (Date.now() - r >= i)
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)
46
31
  return t(void 0);
47
- setTimeout(g, e);
32
+ setTimeout(u, i);
48
33
  };
49
- g();
34
+ u();
50
35
  });
51
36
  }
52
37
  export {
53
- f as fingerprintjsPlugin,
38
+ p as fingerprintjsPlugin,
54
39
  c as getFingerprintVisitorId
55
40
  };
@@ -1,4 +1,4 @@
1
- import { StorageItem, Plugin } from '@picked/client';
1
+ import { Plugin } from '@picked/client';
2
2
  declare global {
3
3
  interface Window {
4
4
  FingerprintJS?: FingerprintJS;
@@ -24,6 +24,6 @@ export declare const fingerprintjsPlugin: () => Plugin;
24
24
  *
25
25
  * @returns StorageItem<string | undefined> The stored visitorId or undefined if not present.
26
26
  */
27
- export declare function getFingerprintVisitorId(): StorageItem<string | undefined> | undefined;
27
+ export declare function getFingerprintVisitorId(): string | undefined;
28
28
  export {};
29
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EAEhB,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,MAiCtC,CAAA;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAYrF"}
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"}
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.1764699646503",
4
+ "version": "0.0.1-dev.1764710808992",
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.1764699646503"
34
+ "@picked/client": "0.0.1-dev.1764710808992"
35
35
  },
36
36
  "private": false,
37
37
  "scripts": {