@tekibo/feedpulse-sdk 2.1.4 → 2.3.0

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
@@ -20,6 +20,7 @@ The SDK automatically tracks:
20
20
  - `hover`: when users hover an element for more than 500ms
21
21
  - `scroll_into_view`: when tagged elements enter viewport
22
22
  - `feedback`: explicit rating/message submissions from widget or manual API
23
+
23
24
  ## Quick start (Nuxt)
24
25
 
25
26
  Import from `@tekibo/feedpulse-sdk/nuxt` and wrap your app:
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class c{constructor(e){this.queue=[],this.flushInterval=null,this.observer=null,this.intersectionObserver=null,this.scrollFallbackListener=null,this.resizeFallbackListener=null,this.seenInView=new Set;const i="https://feed-pulse.vercel.app/api/ingest";this.config={apiKey:e.apiKey,endpoint:e.endpoint??i,batchInterval:e.batchInterval??5e3},this.visitorId="",this.sessionId=""}init(){this.isBrowser()&&(this.visitorId=this.getOrCreateVisitorId(),this.sessionId=this.generateSessionId(),this.startFlushInterval(),this.attachGlobalListeners(),this.observeDOM())}attachGlobalListeners(){document.addEventListener("click",t=>{const r=t.target.closest("[data-fp-id]");r&&this.track("click",r.getAttribute("data-fp-id"),{x:t.clientX,y:t.clientY})},{passive:!0});let e=0,i=null;document.addEventListener("mouseover",t=>{const r=t.target.closest("[data-fp-id]");r&&(e=Date.now(),i=r.getAttribute("data-fp-id"))},{passive:!0}),document.addEventListener("mouseout",t=>{if(!t.target.closest("[data-fp-id]")||!i)return;const s=Date.now()-e;s>500&&this.track("hover",i,{hoverDuration:s}),i=null},{passive:!0})}observeDOM(){const e=r=>{this.seenInView.has(r)||(this.seenInView.add(r),this.track("scroll_into_view",r,{scrollDepth:Math.round(window.scrollY/Math.max(1,document.body.scrollHeight)*100)}))};this.intersectionObserver=new IntersectionObserver(r=>{for(const s of r){const n=s.target.dataset.fpId;!n||!s.isIntersecting||e(n)}},{threshold:.1});const i=()=>{document.querySelectorAll("[data-fp-id]").forEach(r=>{this.intersectionObserver?.observe(r)})},t=()=>{const r=window.innerHeight*.1,s=window.innerHeight*.9;document.querySelectorAll("[data-fp-id]").forEach(n=>{const o=n.dataset.fpId;if(!o||this.seenInView.has(o))return;const a=n.getBoundingClientRect();a.bottom>=r&&a.top<=s&&e(o)})};i(),t(),this.scrollFallbackListener=()=>t(),this.resizeFallbackListener=()=>t(),window.addEventListener("scroll",this.scrollFallbackListener,{passive:!0}),window.addEventListener("resize",this.resizeFallbackListener,{passive:!0}),this.observer=new MutationObserver(()=>i()),this.observer.observe(document.body,{childList:!0,subtree:!0})}track(e,i,t){this.isBrowser()&&this.queue.push({projectApiKey:this.config.apiKey,elementId:i,eventType:e,sessionId:this.sessionId,visitorId:this.visitorId,page:window.location.pathname,referrer:document.referrer,device:this.getDeviceType(),browser:this.getBrowser(),os:this.getOS(),metadata:t,timestamp:new Date().toISOString()})}trackFeedback(e,i,t){this.isBrowser()&&(!i&&!t||this.sendImmediate([{projectApiKey:this.config.apiKey,elementId:e??"__page__",eventType:"feedback",sessionId:this.sessionId,visitorId:this.visitorId,page:window.location.pathname,device:this.getDeviceType(),metadata:{rating:i,message:t},timestamp:new Date().toISOString()}]))}async flush(){if(this.queue.length===0)return;const e=[...this.queue];this.queue=[],await this.sendImmediate(e)}async sendImmediate(e){try{await fetch(this.config.endpoint,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:e}),keepalive:!0})}catch{}}startFlushInterval(){this.flushInterval=setInterval(()=>this.flush(),this.config.batchInterval),window.addEventListener("beforeunload",()=>this.flush()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flush()})}getOrCreateVisitorId(){const e="__fp_vid",i=this.generateId();try{let t=localStorage.getItem(e);return t||(t=i,localStorage.setItem(e,t)),t}catch{return i}}generateId(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}isBrowser(){return typeof window<"u"&&typeof document<"u"}generateSessionId(){return`${Date.now()}-${Math.random().toString(36).slice(2)}`}getDeviceType(){const e=navigator.userAgent;return/Mobi|Android/i.test(e)?"mobile":/Tablet|iPad/i.test(e)?"tablet":"desktop"}getBrowser(){const e=navigator.userAgent;return e.includes("Edg")?"Edge":e.includes("Chrome")?"Chrome":e.includes("Firefox")?"Firefox":e.includes("Safari")?"Safari":"Other"}getOS(){const e=navigator.userAgent;return e.includes("Windows")?"Windows":e.includes("Mac")?"macOS":e.includes("Linux")?"Linux":e.includes("Android")?"Android":/iPhone|iOS/.test(e)?"iOS":"Other"}destroy(){this.flushInterval&&clearInterval(this.flushInterval),this.scrollFallbackListener&&window.removeEventListener("scroll",this.scrollFallbackListener),this.resizeFallbackListener&&window.removeEventListener("resize",this.resizeFallbackListener),this.observer?.disconnect(),this.intersectionObserver?.disconnect(),this.flush()}}exports.FeedPulseTracker=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class c{constructor(e){this.queue=[],this.flushInterval=null,this.observer=null,this.intersectionObserver=null,this.scrollFallbackListener=null,this.resizeFallbackListener=null,this.seenInView=new Set;const i="https://feed-pulse.vercel.app/api/ingest";this.config={apiKey:e.apiKey,endpoint:e.endpoint??i,batchInterval:e.batchInterval??5e3,debug:e.debug??!1},this.visitorId="",this.sessionId=""}init(){this.isBrowser()&&(this.visitorId=this.getOrCreateVisitorId(),this.sessionId=this.generateSessionId(),this.startFlushInterval(),this.attachGlobalListeners(),this.observeDOM())}attachGlobalListeners(){document.addEventListener("click",t=>{const s=t.target.closest("[data-fp-id]");s&&this.track("click",s.getAttribute("data-fp-id"),{x:t.clientX,y:t.clientY})},{passive:!0});let e=0,i=null;document.addEventListener("mouseover",t=>{const s=t.target.closest("[data-fp-id]");s&&(e=Date.now(),i=s.getAttribute("data-fp-id"))},{passive:!0}),document.addEventListener("mouseout",t=>{if(!t.target.closest("[data-fp-id]")||!i)return;const r=Date.now()-e;r>500&&this.track("hover",i,{hoverDuration:r}),i=null},{passive:!0})}observeDOM(){const e=s=>{this.seenInView.has(s)||(this.seenInView.add(s),this.track("scroll_into_view",s,{scrollDepth:Math.round(window.scrollY/Math.max(1,document.body.scrollHeight)*100)}))};this.intersectionObserver=new IntersectionObserver(s=>{for(const r of s){const n=r.target.dataset.fpId;!n||!r.isIntersecting||e(n)}},{threshold:.1});const i=()=>{document.querySelectorAll("[data-fp-id]").forEach(s=>{this.intersectionObserver?.observe(s)})},t=()=>{const s=window.innerHeight*.1,r=window.innerHeight*.9;document.querySelectorAll("[data-fp-id]").forEach(n=>{const o=n.dataset.fpId;if(!o||this.seenInView.has(o))return;const a=n.getBoundingClientRect();a.bottom>=s&&a.top<=r&&e(o)})};i(),t(),this.scrollFallbackListener=()=>t(),this.resizeFallbackListener=()=>t(),window.addEventListener("scroll",this.scrollFallbackListener,{passive:!0}),window.addEventListener("resize",this.resizeFallbackListener,{passive:!0}),this.observer=new MutationObserver(()=>i()),this.observer.observe(document.body,{childList:!0,subtree:!0})}track(e,i,t){this.isBrowser()&&this.queue.push({projectApiKey:this.config.apiKey,elementId:i,eventType:e,sessionId:this.sessionId,visitorId:this.visitorId,page:window.location.pathname,referrer:document.referrer,device:this.getDeviceType(),browser:this.getBrowser(),os:this.getOS(),metadata:t,timestamp:new Date().toISOString()})}trackFeedback(e,i,t){this.isBrowser()&&(!i&&!t||this.sendImmediate([{projectApiKey:this.config.apiKey,elementId:e??"__page__",eventType:"feedback",sessionId:this.sessionId,visitorId:this.visitorId,page:window.location.pathname,device:this.getDeviceType(),metadata:{rating:i,message:t},timestamp:new Date().toISOString()}]))}async flush(){if(this.queue.length===0)return;const e=[...this.queue];this.queue=[],await this.sendImmediate(e)}async sendImmediate(e){try{const i=await fetch(this.config.endpoint,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:e}),keepalive:!0});if(this.config.debug&&i.ok){const t=await i.json().catch(()=>null);t?.ingested!==void 0&&t?.pipeline&&globalThis.console.debug(`[FeedPulse] ${t.ingested} events via ${t.pipeline} pipeline`)}}catch{}}startFlushInterval(){this.flushInterval=setInterval(()=>this.flush(),this.config.batchInterval),window.addEventListener("beforeunload",()=>this.flush()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flush()})}getOrCreateVisitorId(){const e="__fp_vid",i=this.generateId();try{let t=localStorage.getItem(e);return t||(t=i,localStorage.setItem(e,t)),t}catch{return i}}generateId(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}isBrowser(){return typeof window<"u"&&typeof document<"u"}generateSessionId(){return`${Date.now()}-${Math.random().toString(36).slice(2)}`}getDeviceType(){const e=navigator.userAgent;return/Mobi|Android/i.test(e)?"mobile":/Tablet|iPad/i.test(e)?"tablet":"desktop"}getBrowser(){const e=navigator.userAgent;return e.includes("Edg")?"Edge":e.includes("Chrome")?"Chrome":e.includes("Firefox")?"Firefox":e.includes("Safari")?"Safari":"Other"}getOS(){const e=navigator.userAgent;return e.includes("Windows")?"Windows":e.includes("Mac")?"macOS":e.includes("Linux")?"Linux":e.includes("Android")?"Android":/iPhone|iOS/.test(e)?"iOS":"Other"}destroy(){this.flushInterval&&clearInterval(this.flushInterval),this.scrollFallbackListener&&window.removeEventListener("scroll",this.scrollFallbackListener),this.resizeFallbackListener&&window.removeEventListener("resize",this.resizeFallbackListener),this.observer?.disconnect(),this.intersectionObserver?.disconnect(),this.flush()}}exports.FeedPulseTracker=c;
package/dist/index.mjs CHANGED
@@ -5,7 +5,8 @@ class l {
5
5
  this.config = {
6
6
  apiKey: e.apiKey,
7
7
  endpoint: e.endpoint ?? i,
8
- batchInterval: e.batchInterval ?? 5e3
8
+ batchInterval: e.batchInterval ?? 5e3,
9
+ debug: e.debug ?? !1
9
10
  }, this.visitorId = "", this.sessionId = "";
10
11
  }
11
12
  init() {
@@ -13,47 +14,47 @@ class l {
13
14
  }
14
15
  attachGlobalListeners() {
15
16
  document.addEventListener("click", (t) => {
16
- const r = t.target.closest("[data-fp-id]");
17
- r && this.track("click", r.getAttribute("data-fp-id"), {
17
+ const s = t.target.closest("[data-fp-id]");
18
+ s && this.track("click", s.getAttribute("data-fp-id"), {
18
19
  x: t.clientX,
19
20
  y: t.clientY
20
21
  });
21
22
  }, { passive: !0 });
22
23
  let e = 0, i = null;
23
24
  document.addEventListener("mouseover", (t) => {
24
- const r = t.target.closest("[data-fp-id]");
25
- r && (e = Date.now(), i = r.getAttribute("data-fp-id"));
25
+ const s = t.target.closest("[data-fp-id]");
26
+ s && (e = Date.now(), i = s.getAttribute("data-fp-id"));
26
27
  }, { passive: !0 }), document.addEventListener("mouseout", (t) => {
27
28
  if (!t.target.closest("[data-fp-id]") || !i)
28
29
  return;
29
- const s = Date.now() - e;
30
- s > 500 && this.track("hover", i, { hoverDuration: s }), i = null;
30
+ const r = Date.now() - e;
31
+ r > 500 && this.track("hover", i, { hoverDuration: r }), i = null;
31
32
  }, { passive: !0 });
32
33
  }
33
34
  observeDOM() {
34
- const e = (r) => {
35
- this.seenInView.has(r) || (this.seenInView.add(r), this.track("scroll_into_view", r, {
35
+ const e = (s) => {
36
+ this.seenInView.has(s) || (this.seenInView.add(s), this.track("scroll_into_view", s, {
36
37
  scrollDepth: Math.round(window.scrollY / Math.max(1, document.body.scrollHeight) * 100)
37
38
  }));
38
39
  };
39
- this.intersectionObserver = new IntersectionObserver((r) => {
40
- for (const s of r) {
41
- const n = s.target.dataset.fpId;
42
- !n || !s.isIntersecting || e(n);
40
+ this.intersectionObserver = new IntersectionObserver((s) => {
41
+ for (const r of s) {
42
+ const n = r.target.dataset.fpId;
43
+ !n || !r.isIntersecting || e(n);
43
44
  }
44
45
  }, { threshold: 0.1 });
45
46
  const i = () => {
46
- document.querySelectorAll("[data-fp-id]").forEach((r) => {
47
- this.intersectionObserver?.observe(r);
47
+ document.querySelectorAll("[data-fp-id]").forEach((s) => {
48
+ this.intersectionObserver?.observe(s);
48
49
  });
49
50
  }, t = () => {
50
- const r = window.innerHeight * 0.1, s = window.innerHeight * 0.9;
51
+ const s = window.innerHeight * 0.1, r = window.innerHeight * 0.9;
51
52
  document.querySelectorAll("[data-fp-id]").forEach((n) => {
52
53
  const o = n.dataset.fpId;
53
54
  if (!o || this.seenInView.has(o))
54
55
  return;
55
56
  const a = n.getBoundingClientRect();
56
- a.bottom >= r && a.top <= s && e(o);
57
+ a.bottom >= s && a.top <= r && e(o);
57
58
  });
58
59
  };
59
60
  i(), t(), this.scrollFallbackListener = () => t(), this.resizeFallbackListener = () => t(), window.addEventListener("scroll", this.scrollFallbackListener, { passive: !0 }), window.addEventListener("resize", this.resizeFallbackListener, { passive: !0 }), this.observer = new MutationObserver(() => i()), this.observer.observe(document.body, { childList: !0, subtree: !0 });
@@ -95,12 +96,16 @@ class l {
95
96
  }
96
97
  async sendImmediate(e) {
97
98
  try {
98
- await fetch(this.config.endpoint, {
99
+ const i = await fetch(this.config.endpoint, {
99
100
  method: "POST",
100
101
  headers: { "content-type": "application/json" },
101
102
  body: JSON.stringify({ events: e }),
102
103
  keepalive: !0
103
104
  });
105
+ if (this.config.debug && i.ok) {
106
+ const t = await i.json().catch(() => null);
107
+ t?.ingested !== void 0 && t?.pipeline && globalThis.console.debug(`[FeedPulse] ${t.ingested} events via ${t.pipeline} pipeline`);
108
+ }
104
109
  } catch {
105
110
  }
106
111
  }
package/dist/nuxt.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),x=require("./index.js"),c=Symbol("feedpulse");function p(){return e.inject(c,null)}const g=e.defineComponent({__name:"FeedPulseProvider",props:{apiKey:{},endpoint:{}},setup(t){const n=t,d=new x.FeedPulseTracker({apiKey:n.apiKey,endpoint:n.endpoint});return e.provide(c,d),e.onMounted(()=>d.init()),e.onBeforeUnmount(()=>d.destroy()),(r,o)=>e.renderSlot(r.$slots,"default")}}),b={key:1,style:{background:"#fff",border:"1px solid #e5e7eb","border-radius":"12px",padding:"16px",width:"280px","box-shadow":"0 10px 25px rgba(0,0,0,0.15)"}},k={style:{margin:"0 0 12px","font-weight":"600",color:"#111"}},v={style:{display:"flex",gap:"6px","margin-bottom":"12px"}},y=["onClick"],h={key:1,style:{"text-align":"center",padding:"16px",color:"#111"}},E=e.defineComponent({__name:"FeedPulseWidget",props:{id:{},placeholder:{},position:{default:"bottom-right"}},setup(t){const n=t,d=p(),r=e.ref(n.position==="inline"),o=e.ref(null),s=e.ref(""),a=e.ref(!1);function m(u){o.value=u}function f(){!o.value&&!s.value.trim()||(d?.trackFeedback(n.id??null,o.value,s.value||null),a.value=!0,setTimeout(()=>{r.value=n.position==="inline",a.value=!1,o.value=null,s.value=""},2e3))}return(u,l)=>(e.openBlock(),e.createElementBlock("div",{class:"feedpulse-widget",style:e.normalizeStyle(t.position!=="inline"?`position:fixed; ${t.position==="bottom-right"?"right:24px":"left:24px"}; bottom:24px; z-index:9999;`:"")},[t.position!=="inline"?(e.openBlock(),e.createElementBlock("button",{key:0,style:{background:"#6366f1",color:"#fff",border:"none","border-radius":"50%",width:"48px",height:"48px","font-size":"20px",cursor:"pointer"},onClick:l[0]||(l[0]=i=>r.value=!r.value)}," 💬 ")):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createElementBlock("div",b,[a.value?(e.openBlock(),e.createElementBlock("div",h,[...l[2]||(l[2]=[e.createElementVNode("p",{style:{"font-size":"28px",margin:"0"}}," 🎉 ",-1),e.createElementVNode("p",{style:{margin:"8px 0 0","font-weight":"600"}}," Thanks for your feedback! ",-1)])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("p",k,e.toDisplayString(t.placeholder??"How was your experience?"),1),e.createElementVNode("div",v,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(5,i=>e.createElementVNode("button",{key:i,style:e.normalizeStyle({background:"none",border:"none",cursor:"pointer",fontSize:"24px",opacity:o.value!==null&&i<=o.value?1:.3}),onClick:w=>m(i)}," ⭐ ",12,y)),64))]),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":l[1]||(l[1]=i=>s.value=i),placeholder:"Tell us more (optional)...",rows:"3",style:{width:"100%",padding:"8px",border:"1px solid #d1d5db","border-radius":"8px",resize:"none","font-size":"14px"}},null,512),[[e.vModelText,s.value]]),e.createElementVNode("button",{style:{"margin-top":"10px",width:"100%",background:"#6366f1",color:"#fff",border:"none","border-radius":"8px",padding:"10px","font-weight":"600",cursor:"pointer"},onClick:f}," Submit Feedback ")],64))])):e.createCommentVNode("",!0)],4))}});exports.FeedPulseProvider=g;exports.FeedPulseWidget=E;exports.useFeedPulse=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),g=require("./index.js"),c=Symbol("feedpulse");function p(){return e.inject(c,null)}const b=e.defineComponent({__name:"FeedPulseProvider",props:{apiKey:{},endpoint:{},debug:{type:Boolean}},setup(t){const o=t,d=new g.FeedPulseTracker({apiKey:o.apiKey,endpoint:o.endpoint,debug:o.debug});return e.provide(c,d),e.onMounted(()=>d.init()),e.onBeforeUnmount(()=>d.destroy()),(r,n)=>e.renderSlot(r.$slots,"default")}}),x={key:1,style:{background:"#fff",border:"1px solid #e5e7eb","border-radius":"12px",padding:"16px",width:"280px","box-shadow":"0 10px 25px rgba(0,0,0,0.15)"}},k={style:{margin:"0 0 12px","font-weight":"600",color:"#111"}},v={style:{display:"flex",gap:"6px","margin-bottom":"12px"}},y=["onClick"],h={key:1,style:{"text-align":"center",padding:"16px",color:"#111"}},E=e.defineComponent({__name:"FeedPulseWidget",props:{id:{},placeholder:{},position:{default:"bottom-right"}},setup(t){const o=t,d=p(),r=e.ref(o.position==="inline"),n=e.ref(null),s=e.ref(""),a=e.ref(!1);function m(u){n.value=u}function f(){!n.value&&!s.value.trim()||(d?.trackFeedback(o.id??null,n.value,s.value||null),a.value=!0,setTimeout(()=>{r.value=o.position==="inline",a.value=!1,n.value=null,s.value=""},2e3))}return(u,l)=>(e.openBlock(),e.createElementBlock("div",{class:"feedpulse-widget",style:e.normalizeStyle(t.position!=="inline"?`position:fixed; ${t.position==="bottom-right"?"right:24px":"left:24px"}; bottom:24px; z-index:9999;`:"")},[t.position!=="inline"?(e.openBlock(),e.createElementBlock("button",{key:0,style:{background:"#6366f1",color:"#fff",border:"none","border-radius":"50%",width:"48px",height:"48px","font-size":"20px",cursor:"pointer"},onClick:l[0]||(l[0]=i=>r.value=!r.value)}," 💬 ")):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createElementBlock("div",x,[a.value?(e.openBlock(),e.createElementBlock("div",h,[...l[2]||(l[2]=[e.createElementVNode("p",{style:{"font-size":"28px",margin:"0"}}," 🎉 ",-1),e.createElementVNode("p",{style:{margin:"8px 0 0","font-weight":"600"}}," Thanks for your feedback! ",-1)])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("p",k,e.toDisplayString(t.placeholder??"How was your experience?"),1),e.createElementVNode("div",v,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(5,i=>e.createElementVNode("button",{key:i,style:e.normalizeStyle({background:"none",border:"none",cursor:"pointer",fontSize:"24px",opacity:n.value!==null&&i<=n.value?1:.3}),onClick:w=>m(i)}," ⭐ ",12,y)),64))]),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":l[1]||(l[1]=i=>s.value=i),placeholder:"Tell us more (optional)...",rows:"3",style:{width:"100%",padding:"8px",border:"1px solid #d1d5db","border-radius":"8px",resize:"none","font-size":"14px"}},null,512),[[e.vModelText,s.value]]),e.createElementVNode("button",{style:{"margin-top":"10px",width:"100%",background:"#6366f1",color:"#fff",border:"none","border-radius":"8px",padding:"10px","font-weight":"600",cursor:"pointer"},onClick:f}," Submit Feedback ")],64))])):e.createCommentVNode("",!0)],4))}});exports.FeedPulseProvider=b;exports.FeedPulseWidget=E;exports.useFeedPulse=p;
package/dist/nuxt.mjs CHANGED
@@ -1,29 +1,31 @@
1
- import { inject as h, defineComponent as g, provide as w, onMounted as F, onBeforeUnmount as P, renderSlot as _, ref as p, createElementBlock as s, openBlock as d, normalizeStyle as x, createCommentVNode as m, Fragment as b, createElementVNode as o, withDirectives as z, toDisplayString as S, renderList as C, vModelText as E } from "vue";
1
+ import { inject as h, defineComponent as m, provide as w, onMounted as F, onBeforeUnmount as P, renderSlot as _, ref as p, createElementBlock as s, openBlock as d, normalizeStyle as x, createCommentVNode as b, Fragment as g, createElementVNode as n, withDirectives as z, toDisplayString as S, renderList as C, vModelText as E } from "vue";
2
2
  import { FeedPulseTracker as T } from "./index.mjs";
3
3
  const v = /* @__PURE__ */ Symbol("feedpulse");
4
4
  function $() {
5
5
  return h(v, null);
6
6
  }
7
- const W = /* @__PURE__ */ g({
7
+ const W = /* @__PURE__ */ m({
8
8
  __name: "FeedPulseProvider",
9
9
  props: {
10
10
  apiKey: {},
11
- endpoint: {}
11
+ endpoint: {},
12
+ debug: { type: Boolean }
12
13
  },
13
14
  setup(e) {
14
- const n = e, a = new T({
15
- apiKey: n.apiKey,
16
- endpoint: n.endpoint
15
+ const t = e, u = new T({
16
+ apiKey: t.apiKey,
17
+ endpoint: t.endpoint,
18
+ debug: t.debug
17
19
  });
18
- return w(v, a), F(() => a.init()), P(() => a.destroy()), (i, t) => _(i.$slots, "default");
20
+ return w(v, u), F(() => u.init()), P(() => u.destroy()), (i, o) => _(i.$slots, "default");
19
21
  }
20
- }), K = {
22
+ }), B = {
21
23
  key: 1,
22
24
  style: { background: "#fff", border: "1px solid #e5e7eb", "border-radius": "12px", padding: "16px", width: "280px", "box-shadow": "0 10px 25px rgba(0,0,0,0.15)" }
23
- }, B = { style: { margin: "0 0 12px", "font-weight": "600", color: "#111" } }, D = { style: { display: "flex", gap: "6px", "margin-bottom": "12px" } }, U = ["onClick"], V = {
25
+ }, K = { style: { margin: "0 0 12px", "font-weight": "600", color: "#111" } }, D = { style: { display: "flex", gap: "6px", "margin-bottom": "12px" } }, U = ["onClick"], V = {
24
26
  key: 1,
25
27
  style: { "text-align": "center", padding: "16px", color: "#111" }
26
- }, j = /* @__PURE__ */ g({
28
+ }, j = /* @__PURE__ */ m({
27
29
  __name: "FeedPulseWidget",
28
30
  props: {
29
31
  id: {},
@@ -31,13 +33,13 @@ const W = /* @__PURE__ */ g({
31
33
  position: { default: "bottom-right" }
32
34
  },
33
35
  setup(e) {
34
- const n = e, a = $(), i = p(n.position === "inline"), t = p(null), u = p(""), c = p(!1);
36
+ const t = e, u = $(), i = p(t.position === "inline"), o = p(null), a = p(""), c = p(!1);
35
37
  function y(f) {
36
- t.value = f;
38
+ o.value = f;
37
39
  }
38
40
  function k() {
39
- !t.value && !u.value.trim() || (a?.trackFeedback(n.id ?? null, t.value, u.value || null), c.value = !0, setTimeout(() => {
40
- i.value = n.position === "inline", c.value = !1, t.value = null, u.value = "";
41
+ !o.value && !a.value.trim() || (u?.trackFeedback(t.id ?? null, o.value, a.value || null), c.value = !0, setTimeout(() => {
42
+ i.value = t.position === "inline", c.value = !1, o.value = null, a.value = "";
41
43
  }, 2e3));
42
44
  }
43
45
  return (f, r) => (d(), s("div", {
@@ -48,34 +50,34 @@ const W = /* @__PURE__ */ g({
48
50
  key: 0,
49
51
  style: { background: "#6366f1", color: "#fff", border: "none", "border-radius": "50%", width: "48px", height: "48px", "font-size": "20px", cursor: "pointer" },
50
52
  onClick: r[0] || (r[0] = (l) => i.value = !i.value)
51
- }, " 💬 ")) : m("", !0),
52
- i.value ? (d(), s("div", K, [
53
+ }, " 💬 ")) : b("", !0),
54
+ i.value ? (d(), s("div", B, [
53
55
  c.value ? (d(), s("div", V, [...r[2] || (r[2] = [
54
- o("p", { style: { "font-size": "28px", margin: "0" } }, " 🎉 ", -1),
55
- o("p", { style: { margin: "8px 0 0", "font-weight": "600" } }, " Thanks for your feedback! ", -1)
56
- ])])) : (d(), s(b, { key: 0 }, [
57
- o("p", B, S(e.placeholder ?? "How was your experience?"), 1),
58
- o("div", D, [
59
- (d(), s(b, null, C(5, (l) => o("button", {
56
+ n("p", { style: { "font-size": "28px", margin: "0" } }, " 🎉 ", -1),
57
+ n("p", { style: { margin: "8px 0 0", "font-weight": "600" } }, " Thanks for your feedback! ", -1)
58
+ ])])) : (d(), s(g, { key: 0 }, [
59
+ n("p", K, S(e.placeholder ?? "How was your experience?"), 1),
60
+ n("div", D, [
61
+ (d(), s(g, null, C(5, (l) => n("button", {
60
62
  key: l,
61
- style: x({ background: "none", border: "none", cursor: "pointer", fontSize: "24px", opacity: t.value !== null && l <= t.value ? 1 : 0.3 }),
63
+ style: x({ background: "none", border: "none", cursor: "pointer", fontSize: "24px", opacity: o.value !== null && l <= o.value ? 1 : 0.3 }),
62
64
  onClick: (L) => y(l)
63
65
  }, " ⭐ ", 12, U)), 64))
64
66
  ]),
65
- z(o("textarea", {
66
- "onUpdate:modelValue": r[1] || (r[1] = (l) => u.value = l),
67
+ z(n("textarea", {
68
+ "onUpdate:modelValue": r[1] || (r[1] = (l) => a.value = l),
67
69
  placeholder: "Tell us more (optional)...",
68
70
  rows: "3",
69
71
  style: { width: "100%", padding: "8px", border: "1px solid #d1d5db", "border-radius": "8px", resize: "none", "font-size": "14px" }
70
72
  }, null, 512), [
71
- [E, u.value]
73
+ [E, a.value]
72
74
  ]),
73
- o("button", {
75
+ n("button", {
74
76
  style: { "margin-top": "10px", width: "100%", background: "#6366f1", color: "#fff", border: "none", "border-radius": "8px", padding: "10px", "font-weight": "600", cursor: "pointer" },
75
77
  onClick: k
76
78
  }, " Submit Feedback ")
77
79
  ], 64))
78
- ])) : m("", !0)
80
+ ])) : b("", !0)
79
81
  ], 4));
80
82
  }
81
83
  });
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),ne=require("./index.js");var S={exports:{}},g={};var z;function oe(){if(z)return g;z=1;var i=Symbol.for("react.transitional.element"),d=Symbol.for("react.fragment");function l(c,a,u){var f=null;if(u!==void 0&&(f=""+u),a.key!==void 0&&(f=""+a.key),"key"in a){u={};for(var b in a)b!=="key"&&(u[b]=a[b])}else u=a;return a=u.ref,{$$typeof:i,type:c,key:f,ref:a!==void 0?a:null,props:u}}return g.Fragment=d,g.jsx=l,g.jsxs=l,g}var x={};var D;function ae(){return D||(D=1,process.env.NODE_ENV!=="production"&&(function(){function i(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ee?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case P:return"Fragment";case V:return"Profiler";case J:return"StrictMode";case H:return"Suspense";case Z:return"SuspenseList";case K:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case U:return"Portal";case X:return e.displayName||"Context";case G:return(e._context.displayName||"Context")+".Consumer";case B:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Q:return r=e.displayName||null,r!==null?r:i(e.type)||"Memo";case j:r=e._payload,e=e._init;try{return i(e(r))}catch{}}return null}function d(e){return""+e}function l(e){try{d(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),d(e)}}function c(e){if(e===P)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===j)return"<...>";try{var r=i(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function a(){var e=w.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function f(e){if(N.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function b(e,r){function t(){F||(F=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function R(){var e=i(this.type);return Y[e]||(Y[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function T(e,r,t,n,y,A){var o=t.ref;return e={$$typeof:p,type:e,key:r,props:t,_owner:n},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:R}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:y}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function k(e,r,t,n,y,A){var o=r.children;if(o!==void 0)if(n)if(re(o)){for(n=0;n<o.length;n++)v(o[n]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else v(o);if(N.call(r,"key")){o=i(e);var _=Object.keys(r).filter(function(te){return te!=="key"});n=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",W[o+n]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),ne=require("./index.js");var S={exports:{}},g={};var z;function oe(){if(z)return g;z=1;var i=Symbol.for("react.transitional.element"),f=Symbol.for("react.fragment");function s(d,n,u){var c=null;if(u!==void 0&&(c=""+u),n.key!==void 0&&(c=""+n.key),"key"in n){u={};for(var b in n)b!=="key"&&(u[b]=n[b])}else u=n;return n=u.ref,{$$typeof:i,type:d,key:c,ref:n!==void 0?n:null,props:u}}return g.Fragment=f,g.jsx=s,g.jsxs=s,g}var x={};var D;function ae(){return D||(D=1,process.env.NODE_ENV!=="production"&&(function(){function i(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ee?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case P:return"Fragment";case V:return"Profiler";case J:return"StrictMode";case H:return"Suspense";case Z:return"SuspenseList";case K:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case U:return"Portal";case X:return e.displayName||"Context";case G:return(e._context.displayName||"Context")+".Consumer";case B:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Q:return r=e.displayName||null,r!==null?r:i(e.type)||"Memo";case j:r=e._payload,e=e._init;try{return i(e(r))}catch{}}return null}function f(e){return""+e}function s(e){try{f(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,o=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),f(e)}}function d(e){if(e===P)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===j)return"<...>";try{var r=i(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function n(){var e=w.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function c(e){if(N.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function b(e,r){function t(){F||(F=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function R(){var e=i(this.type);return Y[e]||(Y[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function T(e,r,t,o,y,A){var a=t.ref;return e={$$typeof:p,type:e,key:r,props:t,_owner:o},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:R}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:y}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function k(e,r,t,o,y,A){var a=r.children;if(a!==void 0)if(o)if(re(a)){for(o=0;o<a.length;o++)v(a[o]);Object.freeze&&Object.freeze(a)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else v(a);if(N.call(r,"key")){a=i(e);var _=Object.keys(r).filter(function(te){return te!=="key"});o=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",W[a+o]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,n,o,_,o),W[o+n]=!0)}if(o=null,t!==void 0&&(l(t),o=""+t),f(r)&&(l(r.key),o=""+r.key),"key"in r){t={};for(var C in r)C!=="key"&&(t[C]=r[C])}else t=r;return o&&b(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),T(e,o,t,a(),y,A)}function v(e){h(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===j&&(e._payload.status==="fulfilled"?h(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function h(e){return typeof e=="object"&&e!==null&&e.$$typeof===p}var E=m,p=Symbol.for("react.transitional.element"),U=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),J=Symbol.for("react.strict_mode"),V=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),X=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),Z=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),ee=Symbol.for("react.client.reference"),w=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=Object.prototype.hasOwnProperty,re=Array.isArray,O=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(e){return e()}};var F,Y={},I=E.react_stack_bottom_frame.bind(E,u)(),$=O(c(u)),W={};x.Fragment=P,x.jsx=function(e,r,t){var n=1e4>w.recentlyCreatedOwnerStacks++;return k(e,r,t,!1,n?Error("react-stack-top-frame"):I,n?O(c(e)):$)},x.jsxs=function(e,r,t){var n=1e4>w.recentlyCreatedOwnerStacks++;return k(e,r,t,!0,n?Error("react-stack-top-frame"):I,n?O(c(e)):$)}})()),x}var M;function se(){return M||(M=1,process.env.NODE_ENV==="production"?S.exports=oe():S.exports=ae()),S.exports}var s=se();const L=m.createContext({tracker:null});function le({apiKey:i,endpoint:d,children:l}){const c=m.useRef(null);return m.useEffect(()=>(c.current=new ne.FeedPulseTracker({apiKey:i,endpoint:d}),c.current.init(),()=>c.current?.destroy()),[i,d]),s.jsx(L.Provider,{value:{tracker:c.current},children:l})}function q(){return m.useContext(L)}function ue({id:i,placeholder:d,position:l="bottom-right"}){const{tracker:c}=q(),[a,u]=m.useState(l==="inline"),[f,b]=m.useState(null),[R,T]=m.useState(""),[k,v]=m.useState(!1),h=()=>{!f&&!R.trim()||(c?.trackFeedback(i??null,f,R||null),v(!0),setTimeout(()=>{u(l==="inline"),v(!1),b(null),T("")},2e3))},E=l!=="inline"?{position:"fixed",bottom:24,[l==="bottom-right"?"right":"left"]:24,zIndex:9999}:{};return s.jsxs("div",{style:E,children:[l!=="inline"&&s.jsx("button",{onClick:()=>u(!a),style:{background:"#6366f1",color:"#fff",border:"none",borderRadius:"50%",width:48,height:48,fontSize:20,cursor:"pointer"},children:"💬"}),a&&s.jsx("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,padding:16,width:280,boxShadow:"0 10px 25px rgba(0,0,0,0.15)"},children:k?s.jsxs("div",{style:{textAlign:"center",padding:16},children:[s.jsx("p",{style:{fontSize:28,margin:0},children:"🎉"}),s.jsx("p",{style:{margin:"8px 0 0",fontWeight:600},children:"Thanks for your feedback!"})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{style:{margin:"0 0 12px",fontWeight:600},children:d??"How was your experience?"}),s.jsx("div",{style:{display:"flex",gap:6,marginBottom:12},children:[1,2,3,4,5].map(p=>s.jsx("button",{onClick:()=>b(p),style:{background:"none",border:"none",cursor:"pointer",fontSize:24,opacity:f!==null&&p<=f?1:.3},children:"⭐"},p))}),s.jsx("textarea",{value:R,onChange:p=>T(p.target.value),placeholder:"Tell us more (optional)...",rows:3,style:{width:"100%",padding:8,border:"1px solid #d1d5db",borderRadius:8,resize:"none",fontSize:14}}),s.jsx("button",{onClick:h,style:{marginTop:10,width:"100%",background:"#6366f1",color:"#fff",border:"none",borderRadius:8,padding:10,fontWeight:600,cursor:"pointer"},children:"Submit Feedback"})]})})]})}exports.FeedPulseProvider=le;exports.FeedPulseWidget=ue;exports.useFeedPulse=q;
6
+ <%s key={someKey} {...props} />`,o,a,_,a),W[a+o]=!0)}if(a=null,t!==void 0&&(s(t),a=""+t),c(r)&&(s(r.key),a=""+r.key),"key"in r){t={};for(var C in r)C!=="key"&&(t[C]=r[C])}else t=r;return a&&b(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),T(e,a,t,n(),y,A)}function v(e){h(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===j&&(e._payload.status==="fulfilled"?h(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function h(e){return typeof e=="object"&&e!==null&&e.$$typeof===p}var E=m,p=Symbol.for("react.transitional.element"),U=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),J=Symbol.for("react.strict_mode"),V=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),X=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),Z=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),ee=Symbol.for("react.client.reference"),w=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=Object.prototype.hasOwnProperty,re=Array.isArray,O=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(e){return e()}};var F,Y={},I=E.react_stack_bottom_frame.bind(E,u)(),$=O(d(u)),W={};x.Fragment=P,x.jsx=function(e,r,t){var o=1e4>w.recentlyCreatedOwnerStacks++;return k(e,r,t,!1,o?Error("react-stack-top-frame"):I,o?O(d(e)):$)},x.jsxs=function(e,r,t){var o=1e4>w.recentlyCreatedOwnerStacks++;return k(e,r,t,!0,o?Error("react-stack-top-frame"):I,o?O(d(e)):$)}})()),x}var M;function se(){return M||(M=1,process.env.NODE_ENV==="production"?S.exports=oe():S.exports=ae()),S.exports}var l=se();const L=m.createContext({tracker:null});function le({apiKey:i,endpoint:f,debug:s,children:d}){const n=m.useRef(null);return m.useEffect(()=>(n.current=new ne.FeedPulseTracker({apiKey:i,endpoint:f,debug:s}),n.current.init(),()=>n.current?.destroy()),[i,f,s]),l.jsx(L.Provider,{value:{tracker:n.current},children:d})}function q(){return m.useContext(L)}function ue({id:i,placeholder:f,position:s="bottom-right"}){const{tracker:d}=q(),[n,u]=m.useState(s==="inline"),[c,b]=m.useState(null),[R,T]=m.useState(""),[k,v]=m.useState(!1),h=()=>{!c&&!R.trim()||(d?.trackFeedback(i??null,c,R||null),v(!0),setTimeout(()=>{u(s==="inline"),v(!1),b(null),T("")},2e3))},E=s!=="inline"?{position:"fixed",bottom:24,[s==="bottom-right"?"right":"left"]:24,zIndex:9999}:{};return l.jsxs("div",{style:E,children:[s!=="inline"&&l.jsx("button",{onClick:()=>u(!n),style:{background:"#6366f1",color:"#fff",border:"none",borderRadius:"50%",width:48,height:48,fontSize:20,cursor:"pointer"},children:"💬"}),n&&l.jsx("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,padding:16,width:280,boxShadow:"0 10px 25px rgba(0,0,0,0.15)"},children:k?l.jsxs("div",{style:{textAlign:"center",padding:16},children:[l.jsx("p",{style:{fontSize:28,margin:0},children:"🎉"}),l.jsx("p",{style:{margin:"8px 0 0",fontWeight:600},children:"Thanks for your feedback!"})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{style:{margin:"0 0 12px",fontWeight:600},children:f??"How was your experience?"}),l.jsx("div",{style:{display:"flex",gap:6,marginBottom:12},children:[1,2,3,4,5].map(p=>l.jsx("button",{onClick:()=>b(p),style:{background:"none",border:"none",cursor:"pointer",fontSize:24,opacity:c!==null&&p<=c?1:.3},children:"⭐"},p))}),l.jsx("textarea",{value:R,onChange:p=>T(p.target.value),placeholder:"Tell us more (optional)...",rows:3,style:{width:"100%",padding:8,border:"1px solid #d1d5db",borderRadius:8,resize:"none",fontSize:14}}),l.jsx("button",{onClick:h,style:{marginTop:10,width:"100%",background:"#6366f1",color:"#fff",border:"none",borderRadius:8,padding:10,fontWeight:600,cursor:"pointer"},children:"Submit Feedback"})]})})]})}exports.FeedPulseProvider=le;exports.FeedPulseWidget=ue;exports.useFeedPulse=q;
package/dist/react.mjs CHANGED
@@ -2,32 +2,32 @@ import te, { createContext as ne, useRef as oe, useEffect as ae, useContext as s
2
2
  import { FeedPulseTracker as le } from "./index.mjs";
3
3
  var S = { exports: {} }, v = {};
4
4
  var z;
5
- function ue() {
5
+ function ie() {
6
6
  if (z) return v;
7
7
  z = 1;
8
- var i = /* @__PURE__ */ Symbol.for("react.transitional.element"), d = /* @__PURE__ */ Symbol.for("react.fragment");
9
- function l(c, a, u) {
10
- var f = null;
11
- if (u !== void 0 && (f = "" + u), a.key !== void 0 && (f = "" + a.key), "key" in a) {
12
- u = {};
13
- for (var m in a)
14
- m !== "key" && (u[m] = a[m]);
15
- } else u = a;
16
- return a = u.ref, {
17
- $$typeof: i,
18
- type: c,
19
- key: f,
20
- ref: a !== void 0 ? a : null,
21
- props: u
8
+ var u = /* @__PURE__ */ Symbol.for("react.transitional.element"), f = /* @__PURE__ */ Symbol.for("react.fragment");
9
+ function s(d, n, i) {
10
+ var c = null;
11
+ if (i !== void 0 && (c = "" + i), n.key !== void 0 && (c = "" + n.key), "key" in n) {
12
+ i = {};
13
+ for (var m in n)
14
+ m !== "key" && (i[m] = n[m]);
15
+ } else i = n;
16
+ return n = i.ref, {
17
+ $$typeof: u,
18
+ type: d,
19
+ key: c,
20
+ ref: n !== void 0 ? n : null,
21
+ props: i
22
22
  };
23
23
  }
24
- return v.Fragment = d, v.jsx = l, v.jsxs = l, v;
24
+ return v.Fragment = f, v.jsx = s, v.jsxs = s, v;
25
25
  }
26
- var g = {};
26
+ var x = {};
27
27
  var D;
28
- function ie() {
28
+ function ue() {
29
29
  return D || (D = 1, process.env.NODE_ENV !== "production" && (function() {
30
- function i(e) {
30
+ function u(e) {
31
31
  if (e == null) return null;
32
32
  if (typeof e == "function")
33
33
  return e.$$typeof === K ? null : e.displayName || e.name || null;
@@ -60,55 +60,55 @@ function ie() {
60
60
  var r = e.render;
61
61
  return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
62
  case Z:
63
- return r = e.displayName || null, r !== null ? r : i(e.type) || "Memo";
63
+ return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
64
64
  case w:
65
65
  r = e._payload, e = e._init;
66
66
  try {
67
- return i(e(r));
67
+ return u(e(r));
68
68
  } catch {
69
69
  }
70
70
  }
71
71
  return null;
72
72
  }
73
- function d(e) {
73
+ function f(e) {
74
74
  return "" + e;
75
75
  }
76
- function l(e) {
76
+ function s(e) {
77
77
  try {
78
- d(e);
78
+ f(e);
79
79
  var r = !1;
80
80
  } catch {
81
81
  r = !0;
82
82
  }
83
83
  if (r) {
84
84
  r = console;
85
- var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
85
+ var t = r.error, o = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
86
  return t.call(
87
87
  r,
88
88
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
- n
90
- ), d(e);
89
+ o
90
+ ), f(e);
91
91
  }
92
92
  }
93
- function c(e) {
93
+ function d(e) {
94
94
  if (e === j) return "<>";
95
95
  if (typeof e == "object" && e !== null && e.$$typeof === w)
96
96
  return "<...>";
97
97
  try {
98
- var r = i(e);
98
+ var r = u(e);
99
99
  return r ? "<" + r + ">" : "<...>";
100
100
  } catch {
101
101
  return "<...>";
102
102
  }
103
103
  }
104
- function a() {
104
+ function n() {
105
105
  var e = P.A;
106
106
  return e === null ? null : e.getOwner();
107
107
  }
108
- function u() {
108
+ function i() {
109
109
  return Error("react-stack-top-frame");
110
110
  }
111
- function f(e) {
111
+ function c(e) {
112
112
  if (N.call(e, "key")) {
113
113
  var r = Object.getOwnPropertyDescriptor(e, "key").get;
114
114
  if (r && r.isReactWarning) return !1;
@@ -128,20 +128,20 @@ function ie() {
128
128
  });
129
129
  }
130
130
  function _() {
131
- var e = i(this.type);
131
+ var e = u(this.type);
132
132
  return Y[e] || (Y[e] = !0, console.error(
133
133
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
134
134
  )), e = this.props.ref, e !== void 0 ? e : null;
135
135
  }
136
- function x(e, r, t, n, h, A) {
137
- var o = t.ref;
136
+ function g(e, r, t, o, h, A) {
137
+ var a = t.ref;
138
138
  return e = {
139
139
  $$typeof: b,
140
140
  type: e,
141
141
  key: r,
142
142
  props: t,
143
- _owner: n
144
- }, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
143
+ _owner: o
144
+ }, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
145
145
  enumerable: !1,
146
146
  get: _
147
147
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
@@ -166,50 +166,50 @@ function ie() {
166
166
  value: A
167
167
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
168
168
  }
169
- function k(e, r, t, n, h, A) {
170
- var o = r.children;
171
- if (o !== void 0)
172
- if (n)
173
- if (ee(o)) {
174
- for (n = 0; n < o.length; n++)
175
- R(o[n]);
176
- Object.freeze && Object.freeze(o);
169
+ function k(e, r, t, o, h, A) {
170
+ var a = r.children;
171
+ if (a !== void 0)
172
+ if (o)
173
+ if (ee(a)) {
174
+ for (o = 0; o < a.length; o++)
175
+ R(a[o]);
176
+ Object.freeze && Object.freeze(a);
177
177
  } else
178
178
  console.error(
179
179
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
180
180
  );
181
- else R(o);
181
+ else R(a);
182
182
  if (N.call(r, "key")) {
183
- o = i(e);
183
+ a = u(e);
184
184
  var E = Object.keys(r).filter(function(re) {
185
185
  return re !== "key";
186
186
  });
187
- n = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", W[o + n] || (E = 0 < E.length ? "{" + E.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ o = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", W[a + o] || (E = 0 < E.length ? "{" + E.join(": ..., ") + ": ...}" : "{}", console.error(
188
188
  `A props object containing a "key" prop is being spread into JSX:
189
189
  let props = %s;
190
190
  <%s {...props} />
191
191
  React keys must be passed directly to JSX without using spread:
192
192
  let props = %s;
193
193
  <%s key={someKey} {...props} />`,
194
- n,
195
194
  o,
195
+ a,
196
196
  E,
197
- o
198
- ), W[o + n] = !0);
197
+ a
198
+ ), W[a + o] = !0);
199
199
  }
200
- if (o = null, t !== void 0 && (l(t), o = "" + t), f(r) && (l(r.key), o = "" + r.key), "key" in r) {
200
+ if (a = null, t !== void 0 && (s(t), a = "" + t), c(r) && (s(r.key), a = "" + r.key), "key" in r) {
201
201
  t = {};
202
202
  for (var C in r)
203
203
  C !== "key" && (t[C] = r[C]);
204
204
  } else t = r;
205
- return o && m(
205
+ return a && m(
206
206
  t,
207
207
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
208
- ), x(
208
+ ), g(
209
209
  e,
210
- o,
210
+ a,
211
211
  t,
212
- a(),
212
+ n(),
213
213
  h,
214
214
  A
215
215
  );
@@ -230,88 +230,89 @@ React keys must be passed directly to JSX without using spread:
230
230
  };
231
231
  var F, Y = {}, I = p.react_stack_bottom_frame.bind(
232
232
  p,
233
- u
234
- )(), $ = O(c(u)), W = {};
235
- g.Fragment = j, g.jsx = function(e, r, t) {
236
- var n = 1e4 > P.recentlyCreatedOwnerStacks++;
233
+ i
234
+ )(), $ = O(d(i)), W = {};
235
+ x.Fragment = j, x.jsx = function(e, r, t) {
236
+ var o = 1e4 > P.recentlyCreatedOwnerStacks++;
237
237
  return k(
238
238
  e,
239
239
  r,
240
240
  t,
241
241
  !1,
242
- n ? Error("react-stack-top-frame") : I,
243
- n ? O(c(e)) : $
242
+ o ? Error("react-stack-top-frame") : I,
243
+ o ? O(d(e)) : $
244
244
  );
245
- }, g.jsxs = function(e, r, t) {
246
- var n = 1e4 > P.recentlyCreatedOwnerStacks++;
245
+ }, x.jsxs = function(e, r, t) {
246
+ var o = 1e4 > P.recentlyCreatedOwnerStacks++;
247
247
  return k(
248
248
  e,
249
249
  r,
250
250
  t,
251
251
  !0,
252
- n ? Error("react-stack-top-frame") : I,
253
- n ? O(c(e)) : $
252
+ o ? Error("react-stack-top-frame") : I,
253
+ o ? O(d(e)) : $
254
254
  );
255
255
  };
256
- })()), g;
256
+ })()), x;
257
257
  }
258
258
  var M;
259
259
  function ce() {
260
- return M || (M = 1, process.env.NODE_ENV === "production" ? S.exports = ue() : S.exports = ie()), S.exports;
260
+ return M || (M = 1, process.env.NODE_ENV === "production" ? S.exports = ie() : S.exports = ue()), S.exports;
261
261
  }
262
- var s = ce();
262
+ var l = ce();
263
263
  const L = ne({ tracker: null });
264
264
  function be({
265
- apiKey: i,
266
- endpoint: d,
267
- children: l
265
+ apiKey: u,
266
+ endpoint: f,
267
+ debug: s,
268
+ children: d
268
269
  }) {
269
- const c = oe(null);
270
- return ae(() => (c.current = new le({ apiKey: i, endpoint: d }), c.current.init(), () => c.current?.destroy()), [i, d]), /* @__PURE__ */ s.jsx(L.Provider, { value: { tracker: c.current }, children: l });
270
+ const n = oe(null);
271
+ return ae(() => (n.current = new le({ apiKey: u, endpoint: f, debug: s }), n.current.init(), () => n.current?.destroy()), [u, f, s]), /* @__PURE__ */ l.jsx(L.Provider, { value: { tracker: n.current }, children: d });
271
272
  }
272
273
  function fe() {
273
274
  return se(L);
274
275
  }
275
- function pe({ id: i, placeholder: d, position: l = "bottom-right" }) {
276
- const { tracker: c } = fe(), [a, u] = y(l === "inline"), [f, m] = y(null), [_, x] = y(""), [k, R] = y(!1), T = () => {
277
- !f && !_.trim() || (c?.trackFeedback(i ?? null, f, _ || null), R(!0), setTimeout(() => {
278
- u(l === "inline"), R(!1), m(null), x("");
276
+ function pe({ id: u, placeholder: f, position: s = "bottom-right" }) {
277
+ const { tracker: d } = fe(), [n, i] = y(s === "inline"), [c, m] = y(null), [_, g] = y(""), [k, R] = y(!1), T = () => {
278
+ !c && !_.trim() || (d?.trackFeedback(u ?? null, c, _ || null), R(!0), setTimeout(() => {
279
+ i(s === "inline"), R(!1), m(null), g("");
279
280
  }, 2e3));
280
- }, p = l !== "inline" ? { position: "fixed", bottom: 24, [l === "bottom-right" ? "right" : "left"]: 24, zIndex: 9999 } : {};
281
- return /* @__PURE__ */ s.jsxs("div", { style: p, children: [
282
- l !== "inline" && /* @__PURE__ */ s.jsx(
281
+ }, p = s !== "inline" ? { position: "fixed", bottom: 24, [s === "bottom-right" ? "right" : "left"]: 24, zIndex: 9999 } : {};
282
+ return /* @__PURE__ */ l.jsxs("div", { style: p, children: [
283
+ s !== "inline" && /* @__PURE__ */ l.jsx(
283
284
  "button",
284
285
  {
285
- onClick: () => u(!a),
286
+ onClick: () => i(!n),
286
287
  style: { background: "#6366f1", color: "#fff", border: "none", borderRadius: "50%", width: 48, height: 48, fontSize: 20, cursor: "pointer" },
287
288
  children: "💬"
288
289
  }
289
290
  ),
290
- a && /* @__PURE__ */ s.jsx("div", { style: { background: "#fff", border: "1px solid #e5e7eb", borderRadius: 12, padding: 16, width: 280, boxShadow: "0 10px 25px rgba(0,0,0,0.15)" }, children: k ? /* @__PURE__ */ s.jsxs("div", { style: { textAlign: "center", padding: 16 }, children: [
291
- /* @__PURE__ */ s.jsx("p", { style: { fontSize: 28, margin: 0 }, children: "🎉" }),
292
- /* @__PURE__ */ s.jsx("p", { style: { margin: "8px 0 0", fontWeight: 600 }, children: "Thanks for your feedback!" })
293
- ] }) : /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
294
- /* @__PURE__ */ s.jsx("p", { style: { margin: "0 0 12px", fontWeight: 600 }, children: d ?? "How was your experience?" }),
295
- /* @__PURE__ */ s.jsx("div", { style: { display: "flex", gap: 6, marginBottom: 12 }, children: [1, 2, 3, 4, 5].map((b) => /* @__PURE__ */ s.jsx(
291
+ n && /* @__PURE__ */ l.jsx("div", { style: { background: "#fff", border: "1px solid #e5e7eb", borderRadius: 12, padding: 16, width: 280, boxShadow: "0 10px 25px rgba(0,0,0,0.15)" }, children: k ? /* @__PURE__ */ l.jsxs("div", { style: { textAlign: "center", padding: 16 }, children: [
292
+ /* @__PURE__ */ l.jsx("p", { style: { fontSize: 28, margin: 0 }, children: "🎉" }),
293
+ /* @__PURE__ */ l.jsx("p", { style: { margin: "8px 0 0", fontWeight: 600 }, children: "Thanks for your feedback!" })
294
+ ] }) : /* @__PURE__ */ l.jsxs(l.Fragment, { children: [
295
+ /* @__PURE__ */ l.jsx("p", { style: { margin: "0 0 12px", fontWeight: 600 }, children: f ?? "How was your experience?" }),
296
+ /* @__PURE__ */ l.jsx("div", { style: { display: "flex", gap: 6, marginBottom: 12 }, children: [1, 2, 3, 4, 5].map((b) => /* @__PURE__ */ l.jsx(
296
297
  "button",
297
298
  {
298
299
  onClick: () => m(b),
299
- style: { background: "none", border: "none", cursor: "pointer", fontSize: 24, opacity: f !== null && b <= f ? 1 : 0.3 },
300
+ style: { background: "none", border: "none", cursor: "pointer", fontSize: 24, opacity: c !== null && b <= c ? 1 : 0.3 },
300
301
  children: "⭐"
301
302
  },
302
303
  b
303
304
  )) }),
304
- /* @__PURE__ */ s.jsx(
305
+ /* @__PURE__ */ l.jsx(
305
306
  "textarea",
306
307
  {
307
308
  value: _,
308
- onChange: (b) => x(b.target.value),
309
+ onChange: (b) => g(b.target.value),
309
310
  placeholder: "Tell us more (optional)...",
310
311
  rows: 3,
311
312
  style: { width: "100%", padding: 8, border: "1px solid #d1d5db", borderRadius: 8, resize: "none", fontSize: 14 }
312
313
  }
313
314
  ),
314
- /* @__PURE__ */ s.jsx(
315
+ /* @__PURE__ */ l.jsx(
315
316
  "button",
316
317
  {
317
318
  onClick: T,
package/package.json CHANGED
@@ -1,13 +1,7 @@
1
1
  {
2
2
  "name": "@tekibo/feedpulse-sdk",
3
- "version": "2.1.4",
3
+ "version": "2.3.0",
4
4
  "description": "Embeddable analytics and feedback SDK for FeedPulse",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
- "files": [
9
- "dist"
10
- ],
11
5
  "exports": {
12
6
  ".": {
13
7
  "import": "./dist/index.mjs",
@@ -22,6 +16,16 @@
22
16
  "require": "./dist/react.js"
23
17
  }
24
18
  },
19
+ "main": "./dist/index.js",
20
+ "module": "./dist/index.mjs",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "scripts": {
26
+ "build": "vite build",
27
+ "dev": "vite build --watch"
28
+ },
25
29
  "peerDependencies": {
26
30
  "react": ">=18.0.0",
27
31
  "vue": ">=3.0.0"
@@ -34,10 +38,6 @@
34
38
  "optional": true
35
39
  }
36
40
  },
37
- "scripts": {
38
- "build": "vite build",
39
- "dev": "vite build --watch"
40
- },
41
41
  "devDependencies": {
42
42
  "@vitejs/plugin-react": "^4.7.0",
43
43
  "@vitejs/plugin-vue": "^6.0.1",