@picked/hotjar 0.0.1-dev.1764287278696

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../plugin-gtyELynT.cjs");exports.hotjarPlugin=e.hotjarPlugin;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../plugin-gtyELynT.cjs");exports.hotjarPlugin=e.hotjarPlugin;
@@ -0,0 +1,4 @@
1
+ import { h as a } from "../plugin-Dyy--wRc.js";
2
+ export {
3
+ a as hotjarPlugin
4
+ };
@@ -0,0 +1,4 @@
1
+ import { h as a } from "../../../plugin-Dyy--wRc.js";
2
+ export {
3
+ a as hotjarPlugin
4
+ };
@@ -0,0 +1,106 @@
1
+ import i from "@hotjar/browser";
2
+ import { supportsWindow as x } from "@picked/client";
3
+ import { createEffect as l, sample as f } from "effector";
4
+ const I = [
5
+ "step_enter",
6
+ "step_complete",
7
+ "step_submit",
8
+ "field_validation_error",
9
+ "experience_complete",
10
+ "experience_initialized",
11
+ "session"
12
+ ], w = ({
13
+ siteId: u,
14
+ snippetVersion: d = 6,
15
+ trackedEvents: m = I,
16
+ getUserAttributes: n,
17
+ autoStartRecording: y = !0,
18
+ recordingStartEvent: g = "hotjar_start"
19
+ }) => {
20
+ let o = !1, a = !1;
21
+ const c = {
22
+ events: [],
23
+ isProcessing: !1,
24
+ isWaiting: !1,
25
+ push(t) {
26
+ c.events.push(t), Promise.resolve().then(() => this.processQueue());
27
+ },
28
+ processQueue() {
29
+ if (!this.isProcessing) {
30
+ if (!i.isReady()) {
31
+ this.wait();
32
+ return;
33
+ }
34
+ this.isProcessing = !0;
35
+ try {
36
+ for (; this.events.length > 0; ) {
37
+ const t = this.events.shift();
38
+ if (!t) break;
39
+ t();
40
+ }
41
+ } finally {
42
+ this.isProcessing = !1, this.events.length > 0 && i.isReady() && Promise.resolve().then(() => this.processQueue());
43
+ }
44
+ }
45
+ },
46
+ wait() {
47
+ if (this.isWaiting)
48
+ return;
49
+ this.isWaiting = !0;
50
+ const t = setInterval(() => {
51
+ i.isReady() && (clearInterval(t), this.isWaiting = !1, this.processQueue());
52
+ }, 100);
53
+ }
54
+ }, p = (t) => {
55
+ c.push(t);
56
+ };
57
+ return {
58
+ name: "hotjar",
59
+ setup: (t) => {
60
+ if (!x())
61
+ return;
62
+ const v = new Set(m), _ = l((e) => {
63
+ if (!o) {
64
+ o = !0;
65
+ try {
66
+ i.init(u, d);
67
+ } catch {
68
+ }
69
+ }
70
+ p(() => {
71
+ var s;
72
+ try {
73
+ y && e.type === "experience_initialized" && !a && (i.event(g), a = !0);
74
+ const r = [e.type], h = "experience" in e && e.experience.configStore.getState().name;
75
+ h && (r.push(h), "step" in e && ((s = e.step) != null && s.label) && r.push(e.step.label)), i.event(r.join(" > "));
76
+ } catch {
77
+ }
78
+ });
79
+ }), j = l((e) => {
80
+ e.type === "session" && "id" in e && p(() => {
81
+ try {
82
+ const s = (n == null ? void 0 : n()) ?? {};
83
+ i.identify(e.id, {
84
+ organisationId: t.organizationId,
85
+ projectId: t.projectId,
86
+ ...s
87
+ });
88
+ } catch {
89
+ }
90
+ });
91
+ });
92
+ f({
93
+ clock: t.eventBus,
94
+ filter: ({ type: e }) => e === "session",
95
+ target: j
96
+ }), f({
97
+ clock: t.eventBus,
98
+ filter: (e) => v.has(e.type),
99
+ target: _
100
+ });
101
+ }
102
+ };
103
+ };
104
+ export {
105
+ w as h
106
+ };
@@ -0,0 +1 @@
1
+ "use strict";const i=require("@hotjar/browser"),m=require("@picked/client"),n=require("effector"),E=["step_enter","step_complete","step_submit","field_validation_error","experience_complete","experience_initialized","session"],I=({siteId:h,snippetVersion:f=6,trackedEvents:d=E,getUserAttributes:r,autoStartRecording:g=!0,recordingStartEvent:y="hotjar_start"})=>{let a=!1,c=!1;const l={events:[],isProcessing:!1,isWaiting:!1,push(t){l.events.push(t),Promise.resolve().then(()=>this.processQueue())},processQueue(){if(!this.isProcessing){if(!i.isReady()){this.wait();return}this.isProcessing=!0;try{for(;this.events.length>0;){const t=this.events.shift();if(!t)break;t()}}finally{this.isProcessing=!1,this.events.length>0&&i.isReady()&&Promise.resolve().then(()=>this.processQueue())}}},wait(){if(this.isWaiting)return;this.isWaiting=!0;const t=setInterval(()=>{i.isReady()&&(clearInterval(t),this.isWaiting=!1,this.processQueue())},100)}},p=t=>{l.push(t)};return{name:"hotjar",setup:t=>{if(!m.supportsWindow())return;const v=new Set(d),_=n.createEffect(e=>{if(!a){a=!0;try{i.init(h,f)}catch{}}p(()=>{var s;try{g&&e.type==="experience_initialized"&&!c&&(i.event(y),c=!0);const o=[e.type],u="experience"in e&&e.experience.configStore.getState().name;u&&(o.push(u),"step"in e&&((s=e.step)!=null&&s.label)&&o.push(e.step.label)),i.event(o.join(" > "))}catch{}})}),j=n.createEffect(e=>{e.type==="session"&&"id"in e&&p(()=>{try{const s=(r==null?void 0:r())??{};i.identify(e.id,{organisationId:t.organizationId,projectId:t.projectId,...s})}catch{}})});n.sample({clock:t.eventBus,filter:({type:e})=>e==="session",target:j}),n.sample({clock:t.eventBus,filter:e=>v.has(e.type),target:_})}}};exports.hotjarPlugin=I;
@@ -0,0 +1,3 @@
1
+ export { hotjarPlugin } from './plugins/hotjar';
2
+ export type { HotjarPluginOptions } from './plugins/hotjar';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { hotjarPlugin } from './plugin';
2
+ export type { HotjarPluginOptions } from './plugin';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/hotjar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { Plugin } from '@picked/client';
2
+ export interface HotjarPluginOptions {
3
+ siteId: number;
4
+ snippetVersion?: number;
5
+ trackedEvents?: readonly string[];
6
+ getUserAttributes?: () => Record<string, string | number | boolean>;
7
+ autoStartRecording?: boolean;
8
+ recordingStartEvent?: string;
9
+ }
10
+ export declare const hotjarPlugin: ({ siteId, snippetVersion, trackedEvents, getUserAttributes, autoStartRecording, recordingStartEvent, }: HotjarPluginOptions) => Plugin;
11
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/hotjar/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAI7D,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC,iBAAiB,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;IACnE,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAYD,eAAO,MAAM,YAAY,GAAI,wGAO1B,mBAAmB,KAAG,MAiJxB,CAAA"}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@picked/hotjar",
3
+ "description": "Picked Hotjar Plugin",
4
+ "version": "0.0.1-dev.1764287278696",
5
+ "dependencies": {
6
+ "@hotjar/browser": "^1.0.9"
7
+ },
8
+ "devDependencies": {
9
+ "@picked/client": "workspace:*",
10
+ "@repo/eslint-config": "workspace:*",
11
+ "@repo/types": "workspace:*",
12
+ "@repo/typescript-config": "workspace:*",
13
+ "@rollup/plugin-replace": "^6.0.2",
14
+ "@types/node": "^22",
15
+ "@vitest/coverage-v8": "^3.2.3",
16
+ "effector": "^23.3.0",
17
+ "jsdom": "^26.1.0",
18
+ "tsup": "^8.5.0",
19
+ "tsx": "^4.20.3",
20
+ "vite": "^6.4.1",
21
+ "vite-plugin-dts": "^4.5.4",
22
+ "vitest": "^3.2.4"
23
+ },
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/types/index.d.ts",
27
+ "import": "./dist/esm/index.js",
28
+ "require": "./dist/cjs/index.js",
29
+ "default": "./dist/esm/index.js"
30
+ },
31
+ "./plugins/hotjar": {
32
+ "types": "./dist/types/plugins/hotjar/index.d.ts",
33
+ "import": "./dist/esm/plugins/hotjar/index.js",
34
+ "require": "./dist/cjs/plugins/hotjar/index.js",
35
+ "default": "./dist/esm/plugins/hotjar/index.js"
36
+ }
37
+ },
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "main": "./dist/cjs/index.js",
42
+ "module": "./dist/esm/index.js",
43
+ "peerDependencies": {
44
+ "@picked/client": "0.0.1-dev.1764287278696",
45
+ "effector": "^23.3.0"
46
+ },
47
+ "private": false,
48
+ "scripts": {
49
+ "build": "vite build",
50
+ "dev": "vite build --watch",
51
+ "lint": "eslint .",
52
+ "lint-files": "eslint",
53
+ "lint:format": "eslint . --fix",
54
+ "lint:report": "eslint . -o './.reports/eslint.json' -f json || true",
55
+ "test": "vitest run",
56
+ "test:coverage": "vitest run --coverage",
57
+ "test:packaged-types": "attw --pack",
58
+ "test:watch": "vitest",
59
+ "type-check": "tsc -p . --noEmit"
60
+ },
61
+ "type": "module",
62
+ "types": "./dist/types/index.d.ts"
63
+ }