@daybook/feedback 1.4.0 → 1.4.2
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/dist/context.js +4 -0
- package/dist/feedback.js +10 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +13 -3
- package/dist/types.d.ts +5 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.js +10 -0
- package/package.json +1 -1
package/dist/context.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { redactUrl } from './redact.js';
|
|
2
|
+
import { SDK_NAME, SDK_VERSION } from './version.js';
|
|
2
3
|
/**
|
|
3
4
|
* The metadata a triager needs and a reporter should never be asked for.
|
|
4
5
|
*
|
|
@@ -23,6 +24,9 @@ export function captureContext(options) {
|
|
|
23
24
|
dpr: window.devicePixelRatio ?? 1,
|
|
24
25
|
},
|
|
25
26
|
device: device(),
|
|
27
|
+
// The widget's own version, beside the host app's. A report can arrive without a handshake
|
|
28
|
+
// before it (a queued retry, an older session), and it should still say what filed it.
|
|
29
|
+
sdk: { name: SDK_NAME, version: SDK_VERSION },
|
|
26
30
|
};
|
|
27
31
|
if (document.referrer)
|
|
28
32
|
context.referrer = redactUrl(document.referrer);
|
package/dist/feedback.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";var DaybookFeedback=(()=>{var z=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Ue=Object.prototype.hasOwnProperty;var ze=(n,e)=>{for(var t in e)z(n,t,{get:e[t],enumerable:!0})},De=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ne(e))!Ue.call(n,r)&&r!==t&&z(n,r,{get:()=>e[r],enumerable:!(o=qe(e,r))||o.enumerable});return n};var Xe=n=>De(z({},"__esModule",{value:!0}),n);var _t={};ze(_t,{DEFAULT_API_URL:()=>je,DaybookFeedback:()=>j,captureAnchor:()=>P,init:()=>St,previewLauncher:()=>Ie,resolveAnchor:()=>Ee});function S(n){var e;try{let t=new URL(n,location.href);return t.origin===location.origin?t.pathname:`${t.origin}${t.pathname}`}catch{return(e=n.split("?")[0])!=null?e:n}}var Ke=/pass|secret|token|auth|cvv|card|ssn|pin|otp|key/i;function se(n,e){return n.length===0?"":e&&Ke.test(e)?"[redacted]":`[${n.length} chars]`}function D(n){var o,r,i,s,a,c;let e=n.tagName.toLowerCase();if(!n.getAttribute("aria-label")&&!n.getAttribute("data-testid")&&!((o=n.textContent)!=null?o:"").trim()){let l=n.closest("button, a, [role=button], [data-testid], label");if(l&&l!==n)return D(l)}if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement){let l=(i=(r=n.getAttribute("name"))!=null?r:n.id)!=null?i:"",p=n instanceof HTMLInputElement?n.type:e;return`${e}[${p}]${l?` name=${l}`:""}`}let t=(c=(s=n.getAttribute("aria-label"))!=null?s:n.getAttribute("data-testid"))!=null?c:((a=n.textContent)!=null?a:"").replace(/\s+/g," ").trim().slice(0,40);return t?`${e} "${t}"`:e}function ae(n){return n.replace(/[\w.+-]+@[\w-]+\.[\w.]+/g,"[email]").replace(/\b[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[jwt]").replace(/\bBearer\s+[\w.-]+/gi,"Bearer [redacted]").replace(/\b\d{12,19}\b/g,"[number]").slice(0,500)}var A="data-daybook-private";var M=class{constructor(e=40,t=!0){this.limit=e;this.redact=t;this.entries=[];this.detach=[]}list(){return[...this.entries]}add(e,t){for(this.entries.push({at:new Date().toISOString(),type:e,message:this.redact?ae(t):t.slice(0,500)});this.entries.length>this.limit;)this.entries.shift()}start(){let e=a=>{let c=a.target;c instanceof Element&&(c.closest("[data-daybook-feedback]")||this.add("click",D(c)))};document.addEventListener("click",e,{capture:!0,passive:!0}),this.detach.push(()=>document.removeEventListener("click",e,{capture:!0}));let t=history.pushState,o=history.replaceState,r=()=>this.add("nav",S(location.href));history.pushState=(...a)=>{t.apply(history,a),r()},history.replaceState=(...a)=>{o.apply(history,a),r()},window.addEventListener("popstate",r),this.detach.push(()=>{history.pushState=t,history.replaceState=o,window.removeEventListener("popstate",r)});for(let a of["error","warn"]){let c=console[a];console[a]=(...l)=>{this.add("console",`${a}: ${l.map(X).join(" ")}`),c.apply(console,l)},this.detach.push(()=>{console[a]=c})}let i=a=>this.add("console",`uncaught: ${a.message}`),s=a=>this.add("console",`unhandled rejection: ${X(a.reason)}`);window.addEventListener("error",i),window.addEventListener("unhandledrejection",s),this.detach.push(()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",s)}),this.watchFetch()}stop(){for(let e of this.detach.splice(0))e()}watchFetch(){if(typeof window.fetch!="function")return;let e=window.fetch;window.fetch=async(...t)=>{let o=performance.now();try{let r=await e.apply(window,t),i=Math.round(performance.now()-o);return(!r.ok||i>3e3)&&this.add("network",`${r.status} ${S(ce(t[0]))} ${i}ms`),r}catch(r){throw this.add("network",`failed ${S(ce(t[0]))}: ${X(r)}`),r}},this.detach.push(()=>{window.fetch=e})}};function ce(n){return typeof n=="string"?n:n instanceof URL?n.href:n.url}function X(n){var e,t;if(typeof n=="string")return n;if(n instanceof Error)return`${n.name}: ${n.message}`;try{return(t=(e=JSON.stringify(n))==null?void 0:e.slice(0,200))!=null?t:String(n)}catch{return String(n)}}var W="pm.feedback.queue";var R=class{constructor(e,t){this.apiUrl=e;this.ingestKey=t;this.session=null;this.identityToken=null}setSession(e){this.session=e}async send(e,t=[],o){var c,l,p;let r={idempotencyKey:(c=e.idempotencyKey)!=null?c:le(),...e,attachments:[...(l=e.attachments)!=null?l:[],...t.map(h=>({filename:h.filename,contentType:h.contentType,size:h.blob.size}))]},i=await this.post("/ingest/v1",r);if(!i.ok)throw await C(i);let s=await i.json(),a=((p=e.attachments)!=null?p:[]).length;return await Promise.all(t.map(async(h,d)=>{let f=We(s,a+d);if(!f){o==null||o(h,new Error("The server would not accept that file."));return}try{await this.upload(f,h)}catch(w){o==null||o(h,w)}})),s}async flush(){let e=pe();if(e.length!==0){he([]);for(let t of e)try{let o=await this.post("/ingest/v1",t);!o.ok&&(o.status===429||o.status>=500)&&K(t)}catch{K(t)}}}queue(e){var t;K({...e,idempotencyKey:(t=e.idempotencyKey)!=null?t:le(),attachments:void 0})}async signIn(){let e=de(64),t=await Ve(e),o=de(16),r=`${this.base()}/ingest/v1/authorize?key=${encodeURIComponent(this.ingestKey)}&origin=${encodeURIComponent(location.origin)}&code_challenge=${encodeURIComponent(t)}&state=${encodeURIComponent(o)}`,i=window.open(r,"daybook-feedback","width=460,height=640");if(!i)throw Object.assign(new Error("Popup blocked"),{code:"popup_blocked"});let s=await new Promise((l,p)=>{let h=setInterval(()=>{i.closed&&(f(),p(Object.assign(new Error("Sign-in cancelled"),{code:"cancelled"})))},400),d=w=>{if(w.origin!==new URL(this.base()).origin)return;let y=w.data;if((y==null?void 0:y.source)==="daybook-feedback"&&y.state===o){if(f(),y.error||!y.code){p(Object.assign(new Error("Sign-in was refused"),{code:y.error||"refused"}));return}l(y.code)}},f=()=>{clearInterval(h),window.removeEventListener("message",d)};window.addEventListener("message",d)}),a=await this.post("/ingest/v1/token",{code:s,codeVerifier:e});if(!a.ok)throw await C(a);let{identityToken:c}=await a.json();return this.identityToken=c,c}base(){return this.apiUrl.replace(/\/$/,"")}resolve(e){try{let t=new URL(this.base()),o=new URL(e,t);return o.hostname===t.hostname?new URL(o.pathname+o.search,t).toString():o.toString()}catch{return e}}async handshake(e){var r,i;let t=await this.post("/ingest/v1/session",{...e,identityToken:(r=this.identityToken)!=null?r:void 0});if(!t.ok)throw await C(t);let o=await t.json();return this.session=(i=o.sessionToken)!=null?i:null,o}post(e,t){let o={"Content-Type":"application/json","X-Ingest-Key":this.ingestKey};return this.session&&(o["X-Feedback-Session"]=this.session),fetch(`${this.base()}${e}`,{method:"POST",headers:o,body:JSON.stringify(t),credentials:"omit"})}async upload(e,t){let o=await fetch(this.resolve(e.uploadUrl),{method:e.method,headers:{"Content-Type":e.contentType,"X-Ingest-Key":this.ingestKey},body:t.blob,credentials:"omit"});if(!o.ok)throw await C(o);await this.post(`/ingest/v1/attachments/${e.id}/confirm`,{})}};function We(n,e){let t=n.attachments.find(o=>o.index===e);return t!=null?t:n.attachments.some(o=>typeof o.index=="number")?void 0:n.attachments[e]}function K(n){let e=pe();e.push(n),he(e.slice(-20))}function pe(){try{let n=localStorage.getItem(W);return n?JSON.parse(n):[]}catch{return[]}}function he(n){try{n.length===0?localStorage.removeItem(W):localStorage.setItem(W,JSON.stringify(n))}catch{}}async function C(n){let e=`http_${n.status}`;try{let t=await n.json();if(t.code&&(e=t.code),t.message)return Object.assign(new Error(t.message),{code:e})}catch{}return Object.assign(new Error(`Ingest failed (${n.status})`),{code:e})}function le(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function de(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=new Uint8Array(n);return crypto.getRandomValues(t),Array.from(t,o=>e[o%e.length]).join("")}async function Ve(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function V(n){var o,r;let e={platform:"web",route:location.pathname,title:document.title.slice(0,200),locale:navigator.language,timezone:Je(),viewport:{width:window.innerWidth,height:window.innerHeight,dpr:(o=window.devicePixelRatio)!=null?o:1},device:Ye()};document.referrer&&(e.referrer=S(document.referrer)),n.app&&(e.app=n.app);let t=(r=n.anchors)!=null?r:[];return t[0]&&(e.anchor=t[0]),t.length>1&&(e.anchors=t),n.breadcrumbs&&n.breadcrumbs.length>0&&(e.breadcrumbs=n.breadcrumbs),e}function Ye(){var r;let n=navigator.userAgent,e=/Edg\//.test(n)?"Edge":/OPR\//.test(n)?"Opera":/Firefox\//.test(n)?"Firefox":/Chrome\//.test(n)?"Chrome":/Safari\//.test(n)?"Safari":"Unknown",t=/Windows NT/.test(n)?"Windows":/iPhone|iPad|iPod/.test(n)?"iOS":/Mac OS X/.test(n)?"macOS":/Android/.test(n)?"Android":/Linux/.test(n)?"Linux":"Unknown",o=(r=n.match(/(?:Edg|OPR|Firefox|Chrome|Version)\/(\d+)/))==null?void 0:r[1];return{browser:o?`${e} ${o}`:e,os:t,touch:navigator.maxTouchPoints>0,userAgent:n.slice(0,300)}}function Je(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return`UTC${-new Date().getTimezoneOffset()/60}`}}async function fe(n,e=()=>()=>{}){var i;if(typeof((i=navigator.mediaDevices)==null?void 0:i.getDisplayMedia)!="function")return null;let t=n?et():()=>{},o=e(),r=null;try{return r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude",monitorTypeSurfaces:"exclude"}),r.getVideoTracks()[0]?(await new Promise(a=>setTimeout(a,250)),await Ge(r)):null}catch{return null}finally{r==null||r.getTracks().forEach(s=>s.stop()),o(),t()}}var ue=1920,Qe=.82;async function Ge(n){let e=document.createElement("video");e.srcObject=n,e.muted=!0,await e.play().catch(()=>{});let t=e.videoWidth||window.innerWidth,o=e.videoHeight||window.innerHeight,r=t>ue?ue/t:1,i=document.createElement("canvas");i.width=Math.round(t*r),i.height=Math.round(o*r);let s=i.getContext("2d");if(!s)return null;s.imageSmoothingQuality="high",s.drawImage(e,0,0,i.width,i.height),e.pause(),e.srcObject=null;let a=await Ze(i);if(!a)return null;let c=a.type||"image/png";return{blob:a,filename:`screenshot.${c==="image/webp"?"webp":c==="image/jpeg"?"jpg":"png"}`,contentType:c}}async function Ze(n){for(let e of["image/webp","image/jpeg"]){let t=await me(n,e,Qe);if((t==null?void 0:t.type)===e)return t}return me(n,"image/png")}function me(n,e,t){return new Promise(o=>n.toBlob(r=>o(r),e,t))}function et(){let n=[...document.querySelectorAll(`[${A}]`),...document.querySelectorAll('input[type="password"]')],e=n.map(t=>t.style.filter);return n.forEach(t=>{t.style.filter="blur(12px)"}),()=>{n.forEach((t,o)=>{var r;t.style.filter=(r=e[o])!=null?r:""})}}var J=4e5,ge=300,be=600,ye=8e3,tt=new Set(["SCRIPT","NOSCRIPT","TEMPLATE"]),nt=["display","position","z-index","opacity","visibility","overflow","width","height","margin","padding","box-sizing","color","background-color","border","border-radius","box-shadow","font-family","font-size","font-weight","line-height","text-align","white-space","flex-direction","justify-content","align-items","gap","grid-template-columns","transform","transition","pointer-events","cursor"],ot="The page at the moment this was reported. Field values are described rather than reproduced when redacted is true, and data-daybook-private subtrees are withheld. html is last because only the head of this file is inlined beside the report \u2014 download the attachment for the rest of it.";function Q(n){let e=[],t=n;for(let o=0;t&&o<4&&t.nodeType===1;o+=1){let r=t.localName;if(t.id){e.unshift(`${r}#${t.id}`);break}let i=Array.from(t.classList).slice(0,3).join(".");i&&(r+=`.${i}`),e.unshift(r),t=t.parentElement}return e.join(" > ")}var rt=(n,e)=>e.length>ge?`${e.slice(0,ge)}\u2026[${e.length}]`:e,Y=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function it(n,e){let t=n;if(n.localName==="input"&&(t.type==="checkbox"||t.type==="radio"))return t.checked?"checked":"unchecked";let o=t.value;return typeof o!="string"||o===""?null:e?se(o,t.name||t.id||t.type):o}function ve(n,e,t,o){var p,h;if(t.used>J)return!1;if(n.nodeType===3){let d=((p=n.textContent)!=null?p:"").replace(/\s+/g," ");if(!d.trim())return!0;let f=d.length>be?`${d.slice(0,be)}\u2026`:d;return e.push(Y(f)),t.used+=f.length,!0}if(n.nodeType!==1)return!0;let r=n,i=r.tagName;if(r.hasAttribute("data-daybook-feedback")||tt.has(i))return!0;let s=r.localName;if(o&&r.hasAttribute(A))return e.push(`<${s} ${A}>[withheld]</${s}>`),t.used+=32,!0;let a=[];for(let d of Array.from(r.attributes))d.name!=="value"&&a.push(`${d.name}="${Y(rt(d.name,d.value))}"`);let c=it(r,o);c!==null&&a.push(`value="${Y(c)}"`);let l=a.length>0?`<${s} ${a.join(" ")}>`:`<${s}>`;if(e.push(l),t.used+=l.length,s==="style"){let d=(h=r.textContent)!=null?h:"",f=d.length>ye?`${d.slice(0,ye)}
|
|
2
|
-
/* \u2026${d.length} chars */`:d;e.push(f),t.used+=f.length}else for(let d of Array.from(r.childNodes))if(!
|
|
1
|
+
"use strict";var DaybookFeedback=(()=>{var D=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Ke=(n,e)=>{for(var t in e)D(n,t,{get:e[t],enumerable:!0})},Xe=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ze(e))!De.call(n,r)&&r!==t&&D(n,r,{get:()=>e[r],enumerable:!(o=Ue(e,r))||o.enumerable});return n};var Ve=n=>Xe(D({},"__esModule",{value:!0}),n);var $t={};Ke($t,{DEFAULT_API_URL:()=>qe,DaybookFeedback:()=>j,SDK_VERSION:()=>S,captureAnchor:()=>I,init:()=>_t,previewLauncher:()=>Be,resolveAnchor:()=>Se});var S="1.4.2";function L(n){var e;try{let t=new URL(n,location.href);return t.origin===location.origin?t.pathname:`${t.origin}${t.pathname}`}catch{return(e=n.split("?")[0])!=null?e:n}}var We=/pass|secret|token|auth|cvv|card|ssn|pin|otp|key/i;function ce(n,e){return n.length===0?"":e&&We.test(e)?"[redacted]":`[${n.length} chars]`}function K(n){var o,r,i,s,a,c;let e=n.tagName.toLowerCase();if(!n.getAttribute("aria-label")&&!n.getAttribute("data-testid")&&!((o=n.textContent)!=null?o:"").trim()){let l=n.closest("button, a, [role=button], [data-testid], label");if(l&&l!==n)return K(l)}if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement){let l=(i=(r=n.getAttribute("name"))!=null?r:n.id)!=null?i:"",p=n instanceof HTMLInputElement?n.type:e;return`${e}[${p}]${l?` name=${l}`:""}`}let t=(c=(s=n.getAttribute("aria-label"))!=null?s:n.getAttribute("data-testid"))!=null?c:((a=n.textContent)!=null?a:"").replace(/\s+/g," ").trim().slice(0,40);return t?`${e} "${t}"`:e}function le(n){return n.replace(/[\w.+-]+@[\w-]+\.[\w.]+/g,"[email]").replace(/\b[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[jwt]").replace(/\bBearer\s+[\w.-]+/gi,"Bearer [redacted]").replace(/\b\d{12,19}\b/g,"[number]").slice(0,500)}var $="data-daybook-private";var C=class{constructor(e=40,t=!0){this.limit=e;this.redact=t;this.entries=[];this.detach=[]}list(){return[...this.entries]}add(e,t){for(this.entries.push({at:new Date().toISOString(),type:e,message:this.redact?le(t):t.slice(0,500)});this.entries.length>this.limit;)this.entries.shift()}start(){let e=a=>{let c=a.target;c instanceof Element&&(c.closest("[data-daybook-feedback]")||this.add("click",K(c)))};document.addEventListener("click",e,{capture:!0,passive:!0}),this.detach.push(()=>document.removeEventListener("click",e,{capture:!0}));let t=history.pushState,o=history.replaceState,r=()=>this.add("nav",L(location.href));history.pushState=(...a)=>{t.apply(history,a),r()},history.replaceState=(...a)=>{o.apply(history,a),r()},window.addEventListener("popstate",r),this.detach.push(()=>{history.pushState=t,history.replaceState=o,window.removeEventListener("popstate",r)});for(let a of["error","warn"]){let c=console[a];console[a]=(...l)=>{this.add("console",`${a}: ${l.map(X).join(" ")}`),c.apply(console,l)},this.detach.push(()=>{console[a]=c})}let i=a=>this.add("console",`uncaught: ${a.message}`),s=a=>this.add("console",`unhandled rejection: ${X(a.reason)}`);window.addEventListener("error",i),window.addEventListener("unhandledrejection",s),this.detach.push(()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",s)}),this.watchFetch()}stop(){for(let e of this.detach.splice(0))e()}watchFetch(){if(typeof window.fetch!="function")return;let e=window.fetch;window.fetch=async(...t)=>{let o=performance.now();try{let r=await e.apply(window,t),i=Math.round(performance.now()-o);return(!r.ok||i>3e3)&&this.add("network",`${r.status} ${L(de(t[0]))} ${i}ms`),r}catch(r){throw this.add("network",`failed ${L(de(t[0]))}: ${X(r)}`),r}},this.detach.push(()=>{window.fetch=e})}};function de(n){return typeof n=="string"?n:n instanceof URL?n.href:n.url}function X(n){var e,t;if(typeof n=="string")return n;if(n instanceof Error)return`${n.name}: ${n.message}`;try{return(t=(e=JSON.stringify(n))==null?void 0:e.slice(0,200))!=null?t:String(n)}catch{return String(n)}}var W="pm.feedback.queue";var H=class{constructor(e,t){this.apiUrl=e;this.ingestKey=t;this.session=null;this.identityToken=null}setSession(e){this.session=e}async send(e,t=[],o){var c,l,p;let r={idempotencyKey:(c=e.idempotencyKey)!=null?c:pe(),...e,attachments:[...(l=e.attachments)!=null?l:[],...t.map(h=>({filename:h.filename,contentType:h.contentType,size:h.blob.size}))]},i=await this.post("/ingest/v1",r);if(!i.ok)throw await R(i);let s=await i.json(),a=((p=e.attachments)!=null?p:[]).length;return await Promise.all(t.map(async(h,d)=>{let f=Ye(s,a+d);if(!f){o==null||o(h,new Error("The server would not accept that file."));return}try{await this.upload(f,h)}catch(w){o==null||o(h,w)}})),s}async flush(){let e=ue();if(e.length!==0){me([]);for(let t of e)try{let o=await this.post("/ingest/v1",t);!o.ok&&(o.status===429||o.status>=500)&&V(t)}catch{V(t)}}}queue(e){var t;V({...e,idempotencyKey:(t=e.idempotencyKey)!=null?t:pe(),attachments:void 0})}async signIn(){let e=he(64),t=await Je(e),o=he(16),r=`${this.base()}/ingest/v1/authorize?key=${encodeURIComponent(this.ingestKey)}&origin=${encodeURIComponent(location.origin)}&code_challenge=${encodeURIComponent(t)}&state=${encodeURIComponent(o)}`,i=window.open(r,"daybook-feedback","width=460,height=640");if(!i)throw Object.assign(new Error("Popup blocked"),{code:"popup_blocked"});let s=await new Promise((l,p)=>{let h=setInterval(()=>{i.closed&&(f(),p(Object.assign(new Error("Sign-in cancelled"),{code:"cancelled"})))},400),d=w=>{if(w.origin!==new URL(this.base()).origin)return;let y=w.data;if((y==null?void 0:y.source)==="daybook-feedback"&&y.state===o){if(f(),y.error||!y.code){p(Object.assign(new Error("Sign-in was refused"),{code:y.error||"refused"}));return}l(y.code)}},f=()=>{clearInterval(h),window.removeEventListener("message",d)};window.addEventListener("message",d)}),a=await this.post("/ingest/v1/token",{code:s,codeVerifier:e});if(!a.ok)throw await R(a);let{identityToken:c}=await a.json();return this.identityToken=c,c}base(){return this.apiUrl.replace(/\/$/,"")}resolve(e){try{let t=new URL(this.base()),o=new URL(e,t);return o.hostname===t.hostname?new URL(o.pathname+o.search,t).toString():o.toString()}catch{return e}}async handshake(e){var r,i;let t=await this.post("/ingest/v1/session",{...e,identityToken:(r=this.identityToken)!=null?r:void 0});if(!t.ok)throw await R(t);let o=await t.json();return this.session=(i=o.sessionToken)!=null?i:null,o}post(e,t){let o={"Content-Type":"application/json","X-Ingest-Key":this.ingestKey};return this.session&&(o["X-Feedback-Session"]=this.session),fetch(`${this.base()}${e}`,{method:"POST",headers:o,body:JSON.stringify(t),credentials:"omit"})}async upload(e,t){let o=await fetch(this.resolve(e.uploadUrl),{method:e.method,headers:{"Content-Type":e.contentType,"X-Ingest-Key":this.ingestKey},body:t.blob,credentials:"omit"});if(!o.ok)throw await R(o);await this.post(`/ingest/v1/attachments/${e.id}/confirm`,{})}};function Ye(n,e){let t=n.attachments.find(o=>o.index===e);return t!=null?t:n.attachments.some(o=>typeof o.index=="number")?void 0:n.attachments[e]}function V(n){let e=ue();e.push(n),me(e.slice(-20))}function ue(){try{let n=localStorage.getItem(W);return n?JSON.parse(n):[]}catch{return[]}}function me(n){try{n.length===0?localStorage.removeItem(W):localStorage.setItem(W,JSON.stringify(n))}catch{}}async function R(n){let e=`http_${n.status}`;try{let t=await n.json();if(t.code&&(e=t.code),t.message)return Object.assign(new Error(t.message),{code:e})}catch{}return Object.assign(new Error(`Ingest failed (${n.status})`),{code:e})}function pe(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function he(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=new Uint8Array(n);return crypto.getRandomValues(t),Array.from(t,o=>e[o%e.length]).join("")}async function Je(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function J(n){var o,r;let e={platform:"web",route:location.pathname,title:document.title.slice(0,200),locale:navigator.language,timezone:Ge(),viewport:{width:window.innerWidth,height:window.innerHeight,dpr:(o=window.devicePixelRatio)!=null?o:1},device:Qe(),sdk:{name:"js",version:S}};document.referrer&&(e.referrer=L(document.referrer)),n.app&&(e.app=n.app);let t=(r=n.anchors)!=null?r:[];return t[0]&&(e.anchor=t[0]),t.length>1&&(e.anchors=t),n.breadcrumbs&&n.breadcrumbs.length>0&&(e.breadcrumbs=n.breadcrumbs),e}function Qe(){var r;let n=navigator.userAgent,e=/Edg\//.test(n)?"Edge":/OPR\//.test(n)?"Opera":/Firefox\//.test(n)?"Firefox":/Chrome\//.test(n)?"Chrome":/Safari\//.test(n)?"Safari":"Unknown",t=/Windows NT/.test(n)?"Windows":/iPhone|iPad|iPod/.test(n)?"iOS":/Mac OS X/.test(n)?"macOS":/Android/.test(n)?"Android":/Linux/.test(n)?"Linux":"Unknown",o=(r=n.match(/(?:Edg|OPR|Firefox|Chrome|Version)\/(\d+)/))==null?void 0:r[1];return{browser:o?`${e} ${o}`:e,os:t,touch:navigator.maxTouchPoints>0,userAgent:n.slice(0,300)}}function Ge(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return`UTC${-new Date().getTimezoneOffset()/60}`}}async function be(n,e=()=>()=>{}){var i;if(typeof((i=navigator.mediaDevices)==null?void 0:i.getDisplayMedia)!="function")return null;let t=n?nt():()=>{},o=e(),r=null;try{return r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude",monitorTypeSurfaces:"exclude"}),r.getVideoTracks()[0]?(await new Promise(a=>setTimeout(a,250)),await et(r)):null}catch{return null}finally{r==null||r.getTracks().forEach(s=>s.stop()),o(),t()}}var fe=1920,Ze=.82;async function et(n){let e=document.createElement("video");e.srcObject=n,e.muted=!0,await e.play().catch(()=>{});let t=e.videoWidth||window.innerWidth,o=e.videoHeight||window.innerHeight,r=t>fe?fe/t:1,i=document.createElement("canvas");i.width=Math.round(t*r),i.height=Math.round(o*r);let s=i.getContext("2d");if(!s)return null;s.imageSmoothingQuality="high",s.drawImage(e,0,0,i.width,i.height),e.pause(),e.srcObject=null;let a=await tt(i);if(!a)return null;let c=a.type||"image/png";return{blob:a,filename:`screenshot.${c==="image/webp"?"webp":c==="image/jpeg"?"jpg":"png"}`,contentType:c}}async function tt(n){for(let e of["image/webp","image/jpeg"]){let t=await ge(n,e,Ze);if((t==null?void 0:t.type)===e)return t}return ge(n,"image/png")}function ge(n,e,t){return new Promise(o=>n.toBlob(r=>o(r),e,t))}function nt(){let n=[...document.querySelectorAll(`[${$}]`),...document.querySelectorAll('input[type="password"]')],e=n.map(t=>t.style.filter);return n.forEach(t=>{t.style.filter="blur(12px)"}),()=>{n.forEach((t,o)=>{var r;t.style.filter=(r=e[o])!=null?r:""})}}var G=4e5,ye=300,we=600,ve=8e3,ot=new Set(["SCRIPT","NOSCRIPT","TEMPLATE"]),rt=["display","position","z-index","opacity","visibility","overflow","width","height","margin","padding","box-sizing","color","background-color","border","border-radius","box-shadow","font-family","font-size","font-weight","line-height","text-align","white-space","flex-direction","justify-content","align-items","gap","grid-template-columns","transform","transition","pointer-events","cursor"],it="The page at the moment this was reported. Field values are described rather than reproduced when redacted is true, and data-daybook-private subtrees are withheld. html is last because only the head of this file is inlined beside the report \u2014 download the attachment for the rest of it.";function Z(n){let e=[],t=n;for(let o=0;t&&o<4&&t.nodeType===1;o+=1){let r=t.localName;if(t.id){e.unshift(`${r}#${t.id}`);break}let i=Array.from(t.classList).slice(0,3).join(".");i&&(r+=`.${i}`),e.unshift(r),t=t.parentElement}return e.join(" > ")}var st=(n,e)=>e.length>ye?`${e.slice(0,ye)}\u2026[${e.length}]`:e,Q=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function at(n,e){let t=n;if(n.localName==="input"&&(t.type==="checkbox"||t.type==="radio"))return t.checked?"checked":"unchecked";let o=t.value;return typeof o!="string"||o===""?null:e?ce(o,t.name||t.id||t.type):o}function ke(n,e,t,o){var p,h;if(t.used>G)return!1;if(n.nodeType===3){let d=((p=n.textContent)!=null?p:"").replace(/\s+/g," ");if(!d.trim())return!0;let f=d.length>we?`${d.slice(0,we)}\u2026`:d;return e.push(Q(f)),t.used+=f.length,!0}if(n.nodeType!==1)return!0;let r=n,i=r.tagName;if(r.hasAttribute("data-daybook-feedback")||ot.has(i))return!0;let s=r.localName;if(o&&r.hasAttribute($))return e.push(`<${s} ${$}>[withheld]</${s}>`),t.used+=32,!0;let a=[];for(let d of Array.from(r.attributes))d.name!=="value"&&a.push(`${d.name}="${Q(st(d.name,d.value))}"`);let c=at(r,o);c!==null&&a.push(`value="${Q(c)}"`);let l=a.length>0?`<${s} ${a.join(" ")}>`:`<${s}>`;if(e.push(l),t.used+=l.length,s==="style"){let d=(h=r.textContent)!=null?h:"",f=d.length>ve?`${d.slice(0,ve)}
|
|
2
|
+
/* \u2026${d.length} chars */`:d;e.push(f),t.used+=f.length}else for(let d of Array.from(r.childNodes))if(!ke(d,e,t,o))break;return e.push(`</${s}>`),t.used+=s.length+3,t.used<=G}function ct(){var e,t;let n=[];for(let o of Array.from((t=(e=document.body)==null?void 0:e.querySelectorAll("*"))!=null?t:[]).slice(0,4e3)){let r=getComputedStyle(o);if(r.position!=="fixed"&&r.position!=="sticky"||r.visibility==="hidden"||r.display==="none"||Number(r.opacity)===0)continue;let i=o.getBoundingClientRect();if(!(i.width<4||i.height<4)&&!o.closest("[data-daybook-feedback]")&&(n.push({selector:Z(o),zIndex:r.zIndex,rect:{x:Math.round(i.x),y:Math.round(i.y),w:Math.round(i.width),h:Math.round(i.height)}}),n.length>=20))break}return n}function xe(n){if(!(n!=null&&n.selector))return;let e=null;try{e=document.querySelector(n.selector)}catch{return}if(!e)return;let t=[];for(let o=e;o&&t.length<5;o=o.parentElement){let r=getComputedStyle(o),i={};for(let s of rt){let a=r.getPropertyValue(s);a&&(i[s]=a)}t.push({selector:Z(o),computed:i})}return{selector:n.selector,path:t}}function lt(){return Array.from(document.styleSheets).slice(0,40).map(n=>{try{return{href:n.href,rules:n.cssRules.length}}catch{return{href:n.href,rules:"unreadable"}}})}function Ee(n,e){var o;let t=n==null?[]:Array.isArray(n)?n:[n];try{let r=[],i={used:0};return ke(document.documentElement,r,i,e),{note:it,capturedAtUtc:new Date().toISOString(),url:location.href,title:document.title,redacted:e,truncated:i.used>G,scroll:{x:Math.round(window.scrollX),y:Math.round(window.scrollY)},focus:document.activeElement&&document.activeElement!==document.body?Z(document.activeElement):null,anchor:xe((o=t[0])!=null?o:null),anchors:t.length>1?t.map(s=>xe(s)).filter(s=>!!s):void 0,layers:ct(),stylesheets:lt(),html:r.join("")}}catch{return null}}function I(n,e){let t=document.elementFromPoint(n,e);if(!(t instanceof HTMLElement))return{selector:null,offsetX:P(n/window.innerWidth),offsetY:P(e/window.innerHeight),elementText:null,page:Te()};let o=t.getBoundingClientRect();return{selector:dt(t),offsetX:o.width>0?P((n-o.left)/o.width):0,offsetY:o.height>0?P((e-o.top)/o.height):0,elementText:ut(t),page:Te()}}function Se(n){if(!n.selector)return{x:n.offsetX*window.innerWidth,y:n.offsetY*window.innerHeight};let e=null;try{e=document.querySelector(n.selector)}catch{return null}if(!e)return null;let t=e.getBoundingClientRect();return{x:t.left+n.offsetX*t.width,y:t.top+n.offsetY*t.height}}function dt(n){if(n===document.body)return"body";for(let r of["data-testid","data-test","data-daybook-id","data-cy"]){let i=n.getAttribute(r);if(i){let s=`[${r}="${M(i)}"]`;if(T(s))return s}}if(n.id&&!ee(n.id)){let r=`#${M(n.id)}`;if(T(r))return r}let e=[],t=n;for(;t&&t!==document.body&&e.length<8;){let r=t.tagName.toLowerCase(),i=Array.from(t.classList).filter(c=>!ee(c)).slice(0,2);i.length>0&&(r+=i.map(c=>`.${M(c)}`).join(""));let s=t.parentElement;if(s){let c=Array.from(s.children).filter(l=>l.tagName===t.tagName);c.length>1&&(r+=`:nth-of-type(${c.indexOf(t)+1})`)}e.unshift(r);let a=e.join(" > ");if(T(a))return a;t=s}let o=e.length>0?`body > ${e.join(" > ")}`:null;return o&&T(o)?o:pt(n)}function pt(n){let e=[],t=n;for(;t&&t!==document.body&&t!==document.documentElement;){let r=ht(t);if(r&&t!==n){e.unshift(r);break}let i=t.parentElement;if(!i)break;e.unshift(`${t.tagName.toLowerCase()}:nth-child(${Array.from(i.children).indexOf(t)+1})`),t=i}t===document.body&&e.unshift("body");let o=e.join(" > ");return o&&T(o)?o:null}function ht(n){for(let e of["data-testid","data-test","data-daybook-id","data-cy"]){let t=n.getAttribute(e);if(t){let o=`[${e}="${M(t)}"]`;if(T(o))return o}}if(n.id&&!ee(n.id)){let e=`#${M(n.id)}`;if(T(e))return e}return null}function T(n){try{return document.querySelectorAll(n).length===1}catch{return!1}}function ee(n){return/^[a-z]{1,3}[0-9a-f]{5,}$/i.test(n)||/--[0-9a-f]{5,}$/i.test(n)||/^_[0-9a-z]{5,}/i.test(n)||/^v-[0-9a-f]{6,}$/i.test(n)||/^ng-/.test(n)||/[0-9a-f]{8,}/i.test(n)}function ut(n){var o,r,i;let t=((r=(o=n.innerText)!=null?o:n.textContent)!=null?r:"").replace(/\s+/g," ").trim();if(!t){let s=(i=n.getAttribute("aria-label"))!=null?i:n.getAttribute("title");return(s==null?void 0:s.trim())||null}return t.length>80?`${t.slice(0,77)}\u2026`:t}function Te(){return location.pathname+location.search}function P(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function M(n){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/([^\w-])/g,"\\$1")}var mt=/^(image\/(png|jpeg|gif|webp)|video\/(mp4|quicktime|webm))$/;function Le(n,e){let t=[];for(let o of n){if(e+t.length>=5)break;let r=mt.test(o.type)?o.size>26214400?`Too large (${(o.size/1048576).toFixed(1)} MB, max 25).`:null:"Only images and short videos.";t.push({blob:o,filename:o.name||`pasted-${t.length+1}.${ft(o.type)}`,contentType:o.type,preview:r?null:URL.createObjectURL(o),error:r})}return t}function _e(n){var o;let e=(o=n.clipboardData)==null?void 0:o.items;if(!e)return[];let t=[];for(let r of e){if(r.kind!=="file")continue;let i=r.getAsFile();i&&t.push(i)}return t}function F(n){for(let e of n)e.preview&&URL.revokeObjectURL(e.preview)}function ft(n){var e,t;return(t=(e=n.split("/")[1])==null?void 0:e.replace("quicktime","mov"))!=null?t:"bin"}function Ae(n){var o;let t=(o=(typeof n.composedPath=="function"?n.composedPath():[])[0])!=null?o:n.target;return!t||t.nodeType!==1?!1:/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)?!0:typeof t.closest=="function"&&t.closest('[contenteditable=""], [contenteditable="true"]')!==null}function gt(n,e,t){let o=0;for(let s of e){if(s.right<=n.left||s.left>=n.right)continue;let a=n.v==="bottom"?t.height-s.top:s.bottom;a>o&&(o=a)}if(o===0)return 0;let r=n.v==="bottom"?t.height-n.bottom:n.top,i=Math.round(o+12-r);return i<=0||i>t.height*.35?0:i}function bt(n,e,t){if(n===e||e.contains(n)||n.contains(e)||n===document.body||n===document.documentElement)return!1;let o=getComputedStyle(n);if(o.position!=="fixed"&&o.position!=="sticky"||o.visibility==="hidden"||o.display==="none"||Number(o.opacity)===0)return!1;let r=n.getBoundingClientRect();return!(r.width<8||r.height<8||r.width*r.height>t.width*t.height*.25)}function yt(n,e,t){if(typeof document.elementsFromPoint!="function")return[];let o=new Map,r=[];for(let s=n.left+4;s<n.right;s+=32)r.push(s);r.push(n.right-4);let i=t.height*.35;for(let s=0;s<=i;s+=32){let a=n.v==="bottom"?n.bottom-s:n.top+s;if(a<0||a>t.height)break;for(let c of r)if(!(c<0||c>t.width))for(let l of document.elementsFromPoint(c,a)){if(o.has(l)||!bt(l,e,t))continue;let p=l.getBoundingClientRect();o.set(l,{top:p.top,bottom:p.bottom,left:p.left,right:p.right})}}return[...o.values()]}function $e(n,e){let t={width:window.innerWidth,height:window.innerHeight};return gt(n,yt(n,e,t),t)}var N=class{constructor(e,t){this.options=e;this.onSubmit=t;this.mode="idle";this.pins=[];this.cancelAdding=null;this.unmark=null;this.detach=[];this.buttonStyle="pill";this.clearance=0;this.state="ready";this.policy=null;this.redrawMarks=null;this.dragged=null;this.reference=null;this.uploadsFailed=0;this.host=document.createElement("div"),this.host.setAttribute("data-daybook-feedback",""),this.host.style.cssText="position:fixed;inset:0;z-index:2147483000;pointer-events:none",this.root=this.host.attachShadow({mode:"open"}),this.root.innerHTML=`<style>${je}</style><style id="theme"></style><style id="place"></style><div id="layer"></div>`}setTheme(e){let t=this.root.getElementById("theme");if(t){if(!e){t.textContent="";return}t.textContent=Pe(e),this.buttonStyle=Ie(e),this.themePlacement=e.position,this.applyPlacement(),this.launcherLabel=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):void 0}}get placement(){var e,t;return(t=(e=this.options.placement)!=null?e:this.themePlacement)!=null?t:"bottom-right"}applyPlacement(){let e=this.root.getElementById("place");if(!e)return;let t=this.placement,o=t.startsWith("bottom")?"bottom":"top",r=t.endsWith("right")?"right":"left",i=b+this.clearance;e.textContent=`:host {
|
|
3
3
|
--pm-${r}: ${b}px; --pm-${r==="right"?"left":"right"}: auto;
|
|
4
4
|
--pm-${o}: ${i}px; --pm-${o==="bottom"?"top":"bottom"}: auto;
|
|
5
|
-
}`}homeSlot(){let e=this.placement,t=220,o=48,r=e.endsWith("right")?window.innerWidth-b:b+t,i=e.startsWith("bottom")?window.innerHeight-b:b+o;return{left:r-t,right:r,top:i-o,bottom:i,v:e.startsWith("bottom")?"bottom":"top"}}watchClearance(){if(this.options.avoidOverlap===!1)return;let e=!1,t=()=>{if(e=!1,this.mode==="idle")try{let i
|
|
5
|
+
}`}homeSlot(){let e=this.placement,t=220,o=48,r=e.endsWith("right")?window.innerWidth-b:b+t,i=e.startsWith("bottom")?window.innerHeight-b:b+o;return{left:r-t,right:r,top:i-o,bottom:i,v:e.startsWith("bottom")?"bottom":"top"}}watchClearance(){if(this.options.avoidOverlap===!1)return;let e=!1,t=()=>{if(e=!1,this.mode==="idle")try{let i=$e(this.homeSlot(),this.host);if(Math.abs(i-this.clearance)<4)return;this.clearance=i,this.applyPlacement()}catch{}},o=typeof requestAnimationFrame=="function"?i=>requestAnimationFrame(i):i=>setTimeout(i,16),r=()=>{e||(e=!0,o(t))};if(window.addEventListener("scroll",r,{passive:!0,capture:!0}),window.addEventListener("resize",r),this.detach.push(()=>{window.removeEventListener("scroll",r,{capture:!0}),window.removeEventListener("resize",r)}),typeof MutationObserver=="function"){let i=new MutationObserver(r);i.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","hidden"]}),this.detach.push(()=>i.disconnect())}r()}setState(e){this.state=e,this.host.isConnected&&this.render()}mount(){var e;if(document.body.appendChild(this.host),this.applyPlacement(),this.render(),this.watchClearance(),this.options.hotkey!==null){let t=((e=this.options.hotkey)!=null?e:"f").toLowerCase(),o=r=>{if(r.key==="Escape"&&this.cancelAdding){this.cancelAdding();return}if(r.key==="Escape"){this.mode==="picking"&&(this.mode="idle",this.pins=[],this.dragged=null,this.render());return}r.metaKey||r.ctrlKey||r.altKey||Ae(r)||this.mode!=="composing"&&r.key.toLowerCase()===t&&(this.mode=this.mode==="picking"?"idle":"picking",this.render())};window.addEventListener("keydown",o),this.detach.push(()=>window.removeEventListener("keydown",o))}}unmount(){for(let e of this.detach.splice(0))e();this.host.remove()}open(){this.mode="picking",this.render()}setReporter(e){this.reporter=e}setPolicy(e){this.policy=e}capture(){var t,o;let e=(t=this.options.screenshots)!=null?t:!0;return e===!1||((o=this.policy)==null?void 0:o.screenshots)===!1?{offered:!1,checked:!1}:{offered:!0,checked:e!=="optional"}}conceal(){let e=this.root.getElementById("layer"),t=e.style.visibility;e.style.visibility="hidden";let o=this.ringPins();return()=>{e.style.visibility=t,o.forEach(r=>r.remove())}}ringPins(){let e=this.pins.length>1;return this.pins.flatMap((t,o)=>{let r=this.pinRect(t);if(!r)return[];let i=this.origin(),s=document.createElement("div");if(s.className="ring",s.style.left=`${r.left-i.left-k}px`,s.style.top=`${r.top-i.top-k}px`,s.style.width=`${r.width+k*2}px`,s.style.height=`${r.height+k*2}px`,e){let a=document.createElement("span");a.className="ring__n",a.textContent=String(o+1),s.appendChild(a)}return this.root.appendChild(s),[s]})}pinRect(e){var o,r;if(((o=e.anchor.page)!=null?o:Me())!==Me())return null;let t=(r=e.element)!=null&&r.isConnected?e.element:null;if(!t&&e.anchor.selector&&e.anchor.selector!=="body")try{t=document.querySelector(e.anchor.selector)}catch{t=null}if(t){let i=t.getBoundingClientRect();if(i.width>=1&&i.height>=1)return{left:i.left,top:i.top,width:i.width,height:i.height}}return{left:e.box.left-window.scrollX,top:e.box.top-window.scrollY,width:e.box.width,height:e.box.height}}origin(){let e=this.host.getBoundingClientRect();return{left:e.left,top:e.top}}markPins(e){var s;(s=this.unmark)==null||s.call(this);let t=document.createElement("div");e.appendChild(t);let o=0,r=()=>{if(o=0,t.innerHTML="",this.pins.length<1)return;let a=this.origin();this.pins.forEach((c,l)=>{let p=this.pinRect(c);if(!p)return;let h=document.createElement("div");h.className="marker",h.style.left=`${p.left-a.left-k}px`,h.style.top=`${p.top-a.top-k}px`,h.style.width=`${p.width+k*2}px`,h.style.height=`${p.height+k*2}px`;let d=document.createElement("span");d.className="marker__n",d.textContent=String(l+1),h.appendChild(d),t.appendChild(h)})},i=()=>{o||(o=requestAnimationFrame(r))};window.addEventListener("scroll",i,{capture:!0,passive:!0}),window.addEventListener("resize",i),r(),this.redrawMarks=r,this.unmark=()=>{o&&cancelAnimationFrame(o),window.removeEventListener("scroll",i,{capture:!0}),window.removeEventListener("resize",i),t.remove(),this.redrawMarks=null,this.unmark=null}}pickAnother(e,t){let o=this.root.getElementById("layer"),r=()=>{var s;i.remove(),e.style.visibility="",this.cancelAdding=null,(s=this.redrawMarks)==null||s.call(this)},i=this.picker(s=>{this.pins.push(s),r(),t()},`Click what else is involved (pin ${this.pins.length+1})`);e.style.visibility="hidden",this.cancelAdding=r,o.appendChild(i)}movable(e,t){this.place(e),t.classList.add("drag"),t.title="Drag to move \xB7 double-click to reset",t.addEventListener("dblclick",()=>{this.dragged=null,this.place(e)}),t.addEventListener("pointerdown",o=>{if(o.target.closest("button")||o.button!==0)return;o.preventDefault();let r=e.getBoundingClientRect(),i=o.clientX-r.left,s=o.clientY-r.top;t.setPointerCapture(o.pointerId),e.classList.add("panel--dragging");let a=l=>{let p=B(l.clientX-i,b-r.width+te,window.innerWidth-te),h=B(l.clientY-s,0,window.innerHeight-te);e.style.left=`${p}px`,e.style.top=`${h}px`,e.style.right="auto",e.style.bottom="auto"},c=()=>{t.releasePointerCapture(o.pointerId),t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",c),t.removeEventListener("pointercancel",c),e.classList.remove("panel--dragging"),this.dragged=Et(e.getBoundingClientRect()),this.place(e)};t.addEventListener("pointermove",a),t.addEventListener("pointerup",c),t.addEventListener("pointercancel",c)})}place(e){let t=this.dragged;if(!t){e.style.left=e.style.right=e.style.top=e.style.bottom="";return}let o=e.offsetWidth||380,r=e.offsetHeight||240,i=B(t.dx,b,Math.max(b,window.innerWidth-o-b)),s=B(t.dy,b,Math.max(b,window.innerHeight-r-b));e.style.left=t.h==="left"?`${i}px`:"auto",e.style.right=t.h==="right"?`${i}px`:"auto",e.style.top=t.v==="top"?`${s}px`:"auto",e.style.bottom=t.v==="bottom"?`${s}px`:"auto"}render(){var o;let e=this.root.getElementById("layer");if((o=this.unmark)==null||o.call(this),this.cancelAdding=null,e.innerHTML="",this.mode==="idle"){e.appendChild(this.state==="pending"?this.pending():this.launcher());return}if(this.mode==="sent"){this.dragged=null,e.appendChild(this.sent());return}if(this.mode==="picking"){e.appendChild(this.picker());return}let t=this.composer();e.appendChild(t),this.place(t),this.markPins(e)}pending(){let e=document.createElement("div");return e.className="launcher launcher--pending",e.setAttribute("role","status"),e.textContent="Feedback access pending approval",e}sent(){var c;let e=document.createElement("div");e.className="panel panel--sent",e.setAttribute("role","status");let t=this.reference,o=this.uploadsFailed;e.innerHTML=`
|
|
6
6
|
<div class="sent__tick" aria-hidden="true">✓</div>
|
|
7
7
|
<div class="sent__body">
|
|
8
8
|
<div class="panel__title">Thank you \u2014 that is on its way.</div>
|
|
9
9
|
${t?`<div class="sent__ref">
|
|
10
|
-
<code class="sent__id">${
|
|
10
|
+
<code class="sent__id">${O(t)}</code>
|
|
11
11
|
<button type="button" class="sent__copy" data-copy>Copy</button>
|
|
12
12
|
</div>
|
|
13
13
|
<div class="panel__anchor">Quote it if you follow it up.</div>`:""}
|
|
14
14
|
${o>0?`<div class="sent__warn">${o===1?"One attachment could not be uploaded.":`${o} attachments could not be uploaded.`} The report was filed without it.</div>`:""}
|
|
15
15
|
</div>
|
|
16
|
-
${t?'<button type="button" class="panel__close" data-dismiss aria-label="Dismiss">×</button>':""}`;let r=()=>{this.mode==="sent"&&(this.mode="idle",this.render())},i=window.setTimeout(r,o>0?2e4:t?12e3:6e3),s=()=>window.clearTimeout(i);if(this.detach.push(()=>window.clearTimeout(i)),this.contain(e),this.place(e),!t)return e;e.addEventListener("pointerenter",s),e.addEventListener("focusin",s),(c=e.querySelector("[data-dismiss]"))==null||c.addEventListener("click",r);let a=e.querySelector("[data-copy]");return a&&(a.onclick=async()=>{s();let l=await
|
|
16
|
+
${t?'<button type="button" class="panel__close" data-dismiss aria-label="Dismiss">×</button>':""}`;let r=()=>{this.mode==="sent"&&(this.mode="idle",this.render())},i=window.setTimeout(r,o>0?2e4:t?12e3:6e3),s=()=>window.clearTimeout(i);if(this.detach.push(()=>window.clearTimeout(i)),this.contain(e),this.place(e),!t)return e;e.addEventListener("pointerenter",s),e.addEventListener("focusin",s),(c=e.querySelector("[data-dismiss]"))==null||c.addEventListener("click",r);let a=e.querySelector("[data-copy]");return a&&(a.onclick=async()=>{s();let l=await vt(t);a.textContent=l?"Copied":"Copy failed",a.classList.toggle("sent__copy--done",l)}),e}launcher(){var t,o;let e=Fe(this.buttonStyle,(t=this.launcherLabel)!=null?t:"Feedback");return e.title=this.options.hotkey===null?"Report a problem":`Report a problem (${((o=this.options.hotkey)!=null?o:"f").toUpperCase()})`,e.onclick=()=>{this.mode="picking",this.render()},e}picker(e,t="Click the thing that is wrong"){let o=document.createElement("div");o.className="mask",o.innerHTML=`<div class="hover" hidden></div><div class="hint">${O(t)} \xB7 <kbd>Esc</kbd> to cancel</div>`;let r=o.querySelector(".hover"),i=(a,c)=>{o.style.pointerEvents="none";let l=document.elementFromPoint(a,c);return o.style.pointerEvents="",l},s=0;return o.onmousemove=a=>{if(s)return;let{clientX:c,clientY:l}=a;s=requestAnimationFrame(()=>{s=0;let p=i(c,l);if(!p||p===document.body||p===document.documentElement){r.hidden=!0;return}let h=p.getBoundingClientRect(),d=this.origin();r.hidden=!1,r.style.left=`${h.left-d.left}px`,r.style.top=`${h.top-d.top}px`,r.style.width=`${h.width}px`,r.style.height=`${h.height}px`})},o.onclick=a=>{o.style.pointerEvents="none";let c=kt(a.clientX,a.clientY);if(o.style.pointerEvents="",e){e(c);return}this.pins=[c],this.mode="composing",this.render()},o}composer(){var re,ie,se;let e=document.createElement("div");e.className="panel";let t=Ce(this.pins),o=this.capture();e.innerHTML=`
|
|
17
17
|
<div class="panel__head" id="head">
|
|
18
18
|
<span class="panel__grip" aria-hidden="true">\u283F</span>
|
|
19
19
|
<div class="panel__heading">
|
|
20
|
-
<div class="panel__anchor">${
|
|
20
|
+
<div class="panel__anchor">${O(t)}</div>
|
|
21
21
|
<div class="panel__title">Report a problem</div>
|
|
22
22
|
</div>
|
|
23
23
|
<button id="close" class="panel__close" aria-label="Close">×</button>
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
<span class="panel__note">Sends this page's contents, your browser, and recent errors.</span>
|
|
61
61
|
<button id="cancel" class="ghost">Cancel</button>
|
|
62
62
|
<button id="send" class="primary">Send</button>
|
|
63
|
-
</div>`;let r=[],i=e.querySelector("#files"),s=e.querySelector("#drop"),a=e.querySelector("#file"),c=()=>{i.innerHTML="",r.forEach((u,m)=>{var E;let g=document.createElement("div");g.className=u.error?"file file--bad":"file",g.innerHTML=u.preview?`<img src="${u.preview}" alt="" />`:'<span class="file__icon">\u25A6</span>';let v=document.createElement("span");v.className="file__name",v.textContent=(E=u.error)!=null?E:u.filename,g.appendChild(v);let x=document.createElement("button");x.className="link",x.textContent="\xD7",x.onclick=()=>{
|
|
63
|
+
</div>`;let r=[],i=e.querySelector("#files"),s=e.querySelector("#drop"),a=e.querySelector("#file"),c=()=>{i.innerHTML="",r.forEach((u,m)=>{var E;let g=document.createElement("div");g.className=u.error?"file file--bad":"file",g.innerHTML=u.preview?`<img src="${u.preview}" alt="" />`:'<span class="file__icon">\u25A6</span>';let v=document.createElement("span");v.className="file__name",v.textContent=(E=u.error)!=null?E:u.filename,g.appendChild(v);let x=document.createElement("button");x.className="link",x.textContent="\xD7",x.onclick=()=>{F([u]),r.splice(m,1),c()},g.appendChild(x),i.appendChild(g)}),s.style.display=r.length>=5?"none":""},l=u=>{r.push(...Le(u,r.length)),c()};a.onchange=()=>{a.files&&l(a.files)},e.querySelector("#browse").onclick=()=>a.click(),e.addEventListener("paste",u=>{let m=_e(u);m.length>0&&(u.preventDefault(),l(m))}),s.addEventListener("dragover",u=>{u.preventDefault(),s.classList.add("drop--over")}),s.addEventListener("dragleave",()=>s.classList.remove("drop--over")),s.addEventListener("drop",u=>{var m,g;u.preventDefault(),s.classList.remove("drop--over"),l(Array.from((g=(m=u.dataTransfer)==null?void 0:m.files)!=null?g:[]))});let p="bug";e.querySelectorAll(".kind").forEach(u=>{u.onclick=()=>{var m;p=(m=u.dataset.kind)!=null?m:"bug",e.querySelectorAll(".kind").forEach(g=>g.classList.remove("kind--on")),u.classList.add("kind--on")}});let h=e.querySelector("#pins"),d=e.querySelector(".panel__anchor"),f=()=>{var u;if(d.textContent=Ce(this.pins),h.innerHTML="",this.pins.length>1&&this.pins.forEach((m,g)=>{var ae;let v=document.createElement("div");v.className="pin";let x=document.createElement("span");x.className="pin__n",x.textContent=String(g+1),v.appendChild(x);let E=document.createElement("span");E.className="pin__label",E.textContent=He(m.anchor),E.title=(ae=m.anchor.page)!=null?ae:"",v.appendChild(E);let A=document.createElement("button");A.className="link",A.textContent="\xD7",A.setAttribute("aria-label",`Remove pin ${g+1}`),A.onclick=()=>{this.pins.splice(g,1),f()},v.appendChild(A),h.appendChild(v)}),this.pins.length<xt){let m=document.createElement("button");m.className="link pins__add",m.id="add-pin",m.textContent=this.pins.length>0?"+ Add another pin":"+ Pin something on the page",m.onclick=()=>this.pickAnother(e,f),h.appendChild(m)}(u=this.redrawMarks)==null||u.call(this)};f();let w=e.querySelector("#message"),y=e.querySelector("#email"),_=(se=(re=this.reporter)==null?void 0:re.email)!=null?se:(ie=this.options.reporter)==null?void 0:ie.email;_&&!y.value&&(y.value=_);let q=e.querySelector("#shot"),U=e.querySelector("#status"),z=e.querySelector("#send"),ne=()=>{F(r),this.mode="idle",this.pins=[],this.dragged=null,this.render()};e.querySelector("#cancel").onclick=ne,e.querySelector("#close").onclick=ne;let oe=async()=>{var u;if(!w.value.trim()){U.textContent="Say what happened first.";return}z.disabled=!0,U.textContent="Sending\u2026";try{let m=await this.onSubmit({message:w.value.trim(),kind:p,email:y.value.trim()||void 0,anchors:this.pins.map(g=>g.anchor),withScreenshot:(u=q==null?void 0:q.checked)!=null?u:!1,files:r.filter(g=>!g.error)});this.reference=m.reference,this.uploadsFailed=m.uploadsFailed,F(r),this.mode="sent",this.pins=[],this.render()}catch(m){z.disabled=!1,U.textContent=m instanceof Error?`${m.message} \u2014 saved, will retry.`:"Failed, saved and will retry."}};return z.onclick=oe,w.onkeydown=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&oe()},setTimeout(()=>w.focus(),0),this.contain(e),this.movable(e,e.querySelector("#head")),e}contain(e){for(let t of["pointerdown","mousedown","click"])e.addEventListener(t,o=>o.stopPropagation())}};async function vt(n){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(n),!0}catch{}let e=document.createElement("textarea");e.value=n,e.setAttribute("readonly",""),e.style.cssText="position:fixed;top:0;left:0;width:1px;height:1px;opacity:0",document.body.appendChild(e);try{return e.select(),document.execCommand("copy")}catch{return!1}finally{e.remove()}}var b=16,k=3,xt=10;function Me(){return location.pathname+location.search}function kt(n,e){let t=I(n,e),o=document.elementFromPoint(n,e),r=o&&o!==document.body&&o!==document.documentElement?o:null,i=r==null?void 0:r.getBoundingClientRect(),s=i&&i.width>=1&&i.height>=1?{left:i.left+window.scrollX,top:i.top+window.scrollY,width:i.width,height:i.height}:{left:n-12+window.scrollX,top:e-12+window.scrollY,width:24,height:24};return{anchor:t,element:r,box:s}}function He(n){return n.elementText?`\u201C${n.elementText}\u201D`:n.selector&&n.selector!=="body"?n.selector:"a spot on the page"}function Ce(n){if(n.length===0)return"on this page";let[e]=n;if(!e)return"on this page";let t=`on ${He(e.anchor)}`;return n.length===1?t:`${t} and ${n.length-1} more`}var te=56;function Et(n){let e={left:n.left,right:window.innerWidth-n.right,top:n.top,bottom:window.innerHeight-n.bottom},t=Object.keys(e).reduce((i,s)=>e[s]<e[i]?s:i),o=t==="left"||t==="right"?t:e.left<=e.right?"left":"right",r=t==="top"||t==="bottom"?t:e.top<=e.bottom?"top":"bottom";return{h:o,v:r,dx:t===o?b:Math.max(b,Math.round(e[o])),dy:t===r?b:Math.max(b,Math.round(e[r]))}}function B(n,e,t){return Math.min(Math.max(n,e),t)}function O(n){return n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}function Tt(n){return typeof n=="string"&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%/]+\)|hsla?\([\d\s.,%/deg]+\)|[a-z]{3,20})$/i.test(n.trim())}var Re='<svg class="launcher__icon" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M2 6.2C2 4.4 3.4 3 5.2 3h5.6C12.6 3 14 4.4 14 6.2v2.6c0 1.8-1.4 3.2-3.2 3.2H7l-3 2.4v-2.5A3.2 3.2 0 0 1 2 8.8V6.2Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>';function Pe(n){var o;let e=[];Tt(n.accent)&&e.push(`--pm-accent: ${n.accent}`);let t={none:"0",sm:"6px",md:"12px",lg:"18px"}[(o=n.cornerRadius)!=null?o:"md"];return t&&e.push(`--pm-radius: ${t}`),n.colorScheme==="dark"?e.push(Ne):n.colorScheme==="light"&&e.push(Oe),e.length>0?`:host { ${e.join("; ")} }`:""}var Ie=n=>St.includes(n.buttonStyle)?n.buttonStyle:"pill";function Fe(n,e){let t=document.createElement("button");return t.className=`launcher launcher--${n}`,n==="icon"?(t.innerHTML=Re,t.setAttribute("aria-label",e)):n==="pill-icon"?t.innerHTML=`${Re}<span>${O(e)}</span>`:t.textContent=e,t}function Be(n,e={}){var i;let t=(i=n.shadowRoot)!=null?i:n.attachShadow({mode:"open"}),o=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):"Feedback";t.innerHTML=`<style>${je}</style><style>${Pe(e)}</style>`;let r=Fe(Ie(e),o);r.classList.add("launcher--preview"),r.disabled=!0,t.appendChild(r)}var St=["pill","pill-icon","icon","text","outline"],Oe="--pm-surface: #fff; --pm-ink: #171717; --pm-muted: #525252; --pm-faint: #a3a3a3; --pm-line: #e5e5e5; --pm-line-strong: #d4d4d4; --pm-sunken: #f5f5f5; --pm-kbd: #404040; --pm-warn: #b45309; --pm-good: #047857; --pm-good-bg: #ecfdf5; --pm-good-line: #a7f3d0; --pm-accent: #171717; --pm-on-accent: #fafafa;",Ne="--pm-surface: #1c1c1c; --pm-ink: #fafafa; --pm-muted: #a3a3a3; --pm-faint: #737373; --pm-line: #333; --pm-line-strong: #454545; --pm-sunken: #262626; --pm-kbd: #d4d4d4; --pm-warn: #fbbf24; --pm-good: #34d399; --pm-good-bg: #05271f; --pm-good-line: #065f46; --pm-accent: #fafafa; --pm-on-accent: #171717;",je=`
|
|
64
64
|
/*
|
|
65
65
|
Every colour in this file is one of these, and there are two sets of them.
|
|
66
66
|
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
:host {
|
|
83
83
|
all: initial;
|
|
84
84
|
|
|
85
|
-
${
|
|
85
|
+
${Oe}
|
|
86
86
|
|
|
87
87
|
--pm-radius: 12px;
|
|
88
88
|
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
@media (prefers-color-scheme: dark) {
|
|
98
|
-
:host { ${
|
|
98
|
+
:host { ${Ne} }
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
* { box-sizing: border-box; font-family: system-ui, -apple-system, sans-serif }
|
|
@@ -337,4 +337,4 @@ textarea:focus, input:focus { outline: 2px solid var(--pm-ink); outline-offset:
|
|
|
337
337
|
.file__icon { width: 28px; text-align: center }
|
|
338
338
|
.file__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
|
|
339
339
|
.link { border: 0; background: transparent; color: var(--pm-muted); cursor: pointer; font-size: 11px; text-decoration: underline }
|
|
340
|
-
`;var
|
|
340
|
+
`;var qe="https://api.daybook.team",j=class{constructor(e){this.options=e;this.widget=null;this.started=!1;this.inFlight=null;this.epoch=0;this.ready=null;this.stopped=!1;var t;if(!e.ingestKey)throw new Error("ingestKey is required");this.client=new H((t=e.apiUrl)!=null?t:qe,e.ingestKey),this.trail=e.breadcrumbs===!1?null:new C(40,e.redact!==!1)}start(){var e;return this.stopped=!1,(e=this.trail)==null||e.start(),this.mount(),this.started||(this.started=!0,this.client.flush()),this.handshake(),this}mount(){this.widget||this.stopped||(this.widget=new N(this.options,e=>this.submit(e)),this.widget.setReporter(this.options.reporter),this.widget.mount())}handshake(){var o,r,i;let e=JSON.stringify([(o=this.options.reporter)!=null?o:null,(r=this.options.signature)!=null?r:null,this.epoch]);if(((i=this.inFlight)==null?void 0:i.key)===e)return this.inFlight.promise;let t=this.runHandshake().finally(()=>{var s;((s=this.inFlight)==null?void 0:s.promise)===t&&(this.inFlight=null)});return this.inFlight={key:e,promise:t},t}async runHandshake(){var e,t,o,r,i,s,a;try{let c=await this.client.handshake({identity:this.options.reporter,signature:this.options.signature,locale:typeof navigator!="undefined"?navigator.language:void 0,sdk:{name:"js",version:S}});if(this.ready=c,(t=(e=this.options).onReady)==null||t.call(e,c),c.reporterStatus==="Blocked"){(o=this.widget)==null||o.unmount(),this.widget=null;return}this.mount();let l=this.widget;if(!l)return;l.setTheme(At(c.theme)),l.setPolicy((r=c.policy)!=null?r:null),l.setState(c.reporterStatus==="Pending"?"pending":"ready")}catch(c){(s=(i=this.options).onError)==null||s.call(i,c),console.warn("[feedback] handshake failed; the widget will not appear",c),(a=this.widget)==null||a.unmount(),this.widget=null}}identify(e){var t;this.options={...this.options,reporter:e?{...this.options.reporter,...e}:void 0},(t=this.widget)==null||t.setReporter(this.options.reporter),this.widget&&this.handshake()}async signIn(){await this.client.signIn(),this.epoch++,await this.handshake()}authenticate(e){this.options={...this.options,signature:e!=null?e:void 0},this.widget&&this.handshake()}stop(){var e,t;this.started=!1,this.stopped=!0,(e=this.trail)==null||e.stop(),(t=this.widget)==null||t.unmount(),this.widget=null}open(){var e;(e=this.widget)==null||e.open()}async report(e,t={}){var o,r,i;return this.client.send({message:e,surface:this.options.surface,...t,context:{...J({breadcrumbs:(o=this.trail)==null?void 0:o.list(),app:this.options.app}),...(r=t.context)!=null?r:{}},reporter:(i=t.reporter)!=null?i:this.options.reporter})}async submit(e){var a,c,l,p,h;let t=e.withScreenshot?await be(this.options.redact!==!1,()=>{var d,f;return(f=(d=this.widget)==null?void 0:d.conceal())!=null?f:(()=>{})}):null,o=this.options.dom===!1?null:Ee(e.anchors,this.options.redact!==!1),r=[...e.files,...t?[t]:[],...o?[Lt(o)]:[]],i={message:e.message,kind:e.kind,app:this.options.app,surface:this.options.surface,reporter:e.email?{...this.options.reporter,email:e.email}:this.options.reporter,context:J({anchors:e.anchors,breadcrumbs:(a=this.trail)==null?void 0:a.list(),app:this.options.app})},s=[];try{let d=await this.client.send(i,r,(f,w)=>{var y,_;s.push(w),console.warn(`[feedback] "${f.filename}" did not upload`,w),(_=(y=this.options).onError)==null||_.call(y,w)});return d.uploadsFailed=s.length,(l=(c=this.options).onSent)==null||l.call(c,d),{reference:d.reference,uploadsFailed:s.length}}catch(d){throw this.client.queue(i),(h=(p=this.options).onError)==null||h.call(p,d),d}}};function Lt(n){let e=JSON.stringify(n);return{blob:new Blob([e],{type:"application/json"}),filename:"page-snapshot.json",contentType:"application/json"}}function _t(n){return new j(n).start()}function At(n){if(!n)return null;try{let e=JSON.parse(n);return e&&typeof e=="object"?e:null}catch{return null}}return Ve($t);})();
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type { Anchor, Breadcrumb, FeedbackKind, FeedbackTheme, HandshakeRequest,
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const DEFAULT_API_URL = "https://api.daybook.team";
|
|
15
15
|
export { captureAnchor, resolveAnchor } from './anchor.js';
|
|
16
|
+
export { SDK_VERSION } from './version.js';
|
|
16
17
|
/** Draws the launcher into an element you own, for a settings screen that previews a theme. */
|
|
17
18
|
export { previewLauncher, type ButtonStyle } from './widget.js';
|
|
18
19
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SDK_NAME, SDK_VERSION } from './version.js';
|
|
1
2
|
import { BreadcrumbTrail } from './breadcrumbs.js';
|
|
2
3
|
import { IngestClient } from './client.js';
|
|
3
4
|
import { captureContext } from './context.js';
|
|
@@ -17,6 +18,7 @@ import { FeedbackWidget } from './widget.js';
|
|
|
17
18
|
*/
|
|
18
19
|
export const DEFAULT_API_URL = 'https://api.daybook.team';
|
|
19
20
|
export { captureAnchor, resolveAnchor } from './anchor.js';
|
|
21
|
+
export { SDK_VERSION } from './version.js';
|
|
20
22
|
/** Draws the launcher into an element you own, for a settings screen that previews a theme. */
|
|
21
23
|
export { previewLauncher } from './widget.js';
|
|
22
24
|
/**
|
|
@@ -127,6 +129,7 @@ export class DaybookFeedback {
|
|
|
127
129
|
identity: this.options.reporter,
|
|
128
130
|
signature: this.options.signature,
|
|
129
131
|
locale: typeof navigator !== 'undefined' ? navigator.language : undefined,
|
|
132
|
+
sdk: { name: SDK_NAME, version: SDK_VERSION },
|
|
130
133
|
});
|
|
131
134
|
this.ready = result;
|
|
132
135
|
this.options.onReady?.(result);
|
|
@@ -139,12 +142,19 @@ export class DaybookFeedback {
|
|
|
139
142
|
return;
|
|
140
143
|
}
|
|
141
144
|
this.mount();
|
|
142
|
-
|
|
145
|
+
// mount() declines once the host has stopped the widget, and stop() can land while the
|
|
146
|
+
// handshake is in flight. Asserting a widget here threw "Cannot read properties of null
|
|
147
|
+
// (reading 'setTheme')", which the catch below then reported to the host as a failed
|
|
148
|
+
// handshake — for a widget that had been taken away on purpose.
|
|
149
|
+
const widget = this.widget;
|
|
150
|
+
if (!widget)
|
|
151
|
+
return;
|
|
152
|
+
widget.setTheme(parseTheme(result.theme));
|
|
143
153
|
// What the integration allows, so the composer offers only controls that can act. Served
|
|
144
154
|
// since the handshake existed and never read until now — which is why an integration with
|
|
145
155
|
// screenshots turned off still showed a tick box for them.
|
|
146
|
-
|
|
147
|
-
|
|
156
|
+
widget.setPolicy(result.policy ?? null);
|
|
157
|
+
widget.setState(result.reporterStatus === 'Pending' ? 'pending' : 'ready');
|
|
148
158
|
}
|
|
149
159
|
catch (error) {
|
|
150
160
|
// Told to the host as well as the console. In the Daybook sign-in mode the widget is *meant*
|
package/dist/types.d.ts
CHANGED
|
@@ -78,6 +78,11 @@ export interface HandshakeRequest {
|
|
|
78
78
|
email?: string;
|
|
79
79
|
name?: string;
|
|
80
80
|
};
|
|
81
|
+
/** Which widget this is, so the project can see when an install is behind. From 1.4.1. */
|
|
82
|
+
sdk?: {
|
|
83
|
+
name: string;
|
|
84
|
+
version: string;
|
|
85
|
+
};
|
|
81
86
|
/**
|
|
82
87
|
* HMAC-SHA256 of the identity, computed by YOUR BACKEND with the integration secret and hex
|
|
83
88
|
* encoded. Never compute this in the browser: the secret would be in the bundle, and a signature
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This build's own version, sent with the handshake and every report. PM-T-0363.
|
|
3
|
+
*
|
|
4
|
+
* Without it Daybook could not tell which project runs which widget, so a release reached nobody
|
|
5
|
+
* who did not read npm. A constant rather than read from package.json at build time, because the
|
|
6
|
+
* npm build is plain tsc and has no bundler to inline it; test/version.test.js and publish-sdk.sh
|
|
7
|
+
* both refuse a build where this and package.json disagree.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SDK_VERSION = "1.4.2";
|
|
10
|
+
export declare const SDK_NAME = "js";
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This build's own version, sent with the handshake and every report. PM-T-0363.
|
|
3
|
+
*
|
|
4
|
+
* Without it Daybook could not tell which project runs which widget, so a release reached nobody
|
|
5
|
+
* who did not read npm. A constant rather than read from package.json at build time, because the
|
|
6
|
+
* npm build is plain tsc and has no bundler to inline it; test/version.test.js and publish-sdk.sh
|
|
7
|
+
* both refuse a build where this and package.json disagree.
|
|
8
|
+
*/
|
|
9
|
+
export const SDK_VERSION = '1.4.2';
|
|
10
|
+
export const SDK_NAME = 'js';
|
package/package.json
CHANGED