@blipit/browser 0.3.7 → 0.3.8
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/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.global.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.3.8
|
|
2
|
+
|
|
3
|
+
- Works with a strict Content Security Policy: the Report a bug button, `reportButton()`, the reporter and the video editor use constructable stylesheets and CSSOM styles instead of `<style>` elements and `style` attributes, so `style-src` needs no `'unsafe-inline'`. The screenshot no longer fails in Chromium when the page has web fonts and `style-src` blocks inline styles.
|
|
4
|
+
- If `img-src` does not allow `data:`, the reporter says the screenshot could not be taken instead of showing a blank one; with `debug` the console names the blocked directive. Any screenshot failure is logged with `debug`.
|
|
5
|
+
- Videos keep their place and size in the screenshot: an empty or still loading `<video>` is drawn as an empty box and a live camera stream (`srcObject`) as its current frame, so the layout and the picked element's highlight line up. This replaces the 0.3.6 filter that left such videos out.
|
|
6
|
+
- The same `Error` object captured twice (for example by `error.tsx` under React StrictMode, or by an error boundary and `onCaughtError`) is sent once.
|
|
7
|
+
- The script tag build loads the simple fallback form (shown when the reporter cannot load, and by `showFeedback()`) from `blipit-feedback.js` on first use, so `blipit.js` is 9.8 KB gzipped; npm builds still bundle it.
|
|
8
|
+
|
|
1
9
|
## 0.3.7
|
|
2
10
|
|
|
3
11
|
- `reportButton(options?)` returns the official Report a bug button: the Blipit icon and "Report a bug" in the visitor's language, `type="button"`, opens the reporter and shows a spinner (`aria-busy`) while it loads. Options: `label`, `variant` (`solid`, `outline`, `ghost`), `size` (`md`, `sm`), `theme` (`auto`, `light`, `dark`). Styles are scoped to `.blipit-rb` and injected once, so page CSS does not change the button and the button does not change the page.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @blipit/browser
|
|
2
2
|
|
|
3
|
-
Blipit error monitoring SDK for browsers.
|
|
3
|
+
Blipit error monitoring SDK for browsers. 10 KB gzipped, with the Report a bug button. Know your app broke before your users tell you.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var j=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var Me=Object.prototype.hasOwnProperty;var Oe=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Le(t))!Me.call(e,r)&&r!==n&&j(e,r,{get:()=>t[r],enumerable:!(i=Ce(t,r))||i.enumerable});return e};var Ae=e=>Ie(j({},"__esModule",{value:!0}),e);var vt={};Oe(vt,{addBreadcrumb:()=>ft,attachReport:()=>gt,captureException:()=>dt,captureMessage:()=>ct,captureSecurity:()=>ut,flush:()=>yt,init:()=>at,openReport:()=>ee,reportButton:()=>ht,setReportMetadata:()=>we,setTag:()=>lt,setUser:()=>pt,showFeedback:()=>mt,updateWidget:()=>bt});module.exports=Ae(vt);var ne=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var N=class{constructor(t,n,i,r){this.endpoint=t;this.key=n;this.debug=i;this.instance=r;typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flushWithBeacon()})}endpoint;key;debug;instance;queue=[];timer;sending=!1;enqueue(t){this.queue.push(t),this.queue.length>30&&this.queue.shift(),this.timer||(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},1e3))}async flush(){if(!this.sending){this.sending=!0;try{for(;this.queue.length>0;){let t=this.queue[0];if(!await this.send(t))break;this.queue.shift()}}finally{this.sending=!1}}}async send(t,n=0){try{let i=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key,...this.instance?{"X-Blipit-Instance":this.instance}:{}},body:JSON.stringify(t),keepalive:!0});return i.status===429||i.status>=500?this.retry(t,n):(this.debug&&i.status>=400&&console.warn("[blipit] event rejected",i.status,await i.text()),!0)}catch{return this.retry(t,n)}}async retry(t,n){return n>=2?(this.debug&&console.warn("[blipit] dropping event after retries",t.event_id),!0):(await new Promise(i=>setTimeout(i,1e3*2**n)),this.send(t,n+1))}flushWithBeacon(){if(!(typeof navigator>"u"||!navigator.sendBeacon))for(;this.queue.length>0;){let t=this.queue.shift(),n=`key=${encodeURIComponent(this.key)}${this.instance?`&instance=${encodeURIComponent(this.instance)}`:""}`,i=`${this.endpoint}${this.endpoint.includes("?")?"&":"?"}${n}`;navigator.sendBeacon(i,JSON.stringify(t))}}};function L(){let e=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0");return t}function v(){return new Date().toISOString()}var Ne=/token|key|password|secret|auth|session|passwd|api/i;function C(e){let t=e.indexOf("?");if(t===-1)return e.slice(0,2048);let n=e.slice(0,t),r=e.slice(t+1).split("&").map(o=>{let c=o.indexOf("=");if(c===-1)return o;let d=o.slice(0,c);return Ne.test(d)?`${d}=[redacted]`:o}).join("&");return`${n}?${r}`.slice(0,2048)}var Fe=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function ie(e){return e.replace(Fe,"$1[redacted]")}function f(e,t){return e.length>t?e.slice(0,t):e}var re=".blipit-mask,[data-blipit-mask]";function q(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function E(e,t,n){e.push(t),e.length>n&&e.shift()}function W(e){let t=e.id?`#${e.id}`:"",n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return f(`${e.tagName.toLowerCase()}${t}${n}`,128)}function S(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function oe(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}function Ue(e){let t=e.match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?/);if(!t||(t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]))<.5)return null;let[i,r,o]=[t[1],t[2],t[3]].map(c=>{let d=parseFloat(c)/255;return d<=.03928?d/12.92:((d+.055)/1.055)**2.4});return .2126*i+.7152*r+.0722*o}function se(e){if(e==="light"||e==="dark")return e;if(typeof document<"u"){for(let n of[document.body,document.documentElement]){if(!n)continue;let i=Ue(getComputedStyle(n).backgroundColor);if(i!==null)return i<.4?"dark":"light"}let t=getComputedStyle(document.documentElement).colorScheme;if(t==="dark")return"dark";if(t&&t!=="normal"&&!t.includes("dark"))return"light"}return typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ae={ok:0,errored:1,crashed:2},F=class{constructor(t,n,i,r){this.url=t;this.key=n;this.release=i;this.environment=r;this.start(),typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.end():this.sid||this.start()})}url;key;release;environment;sid="";started="";status="ok";errors=0;did;setUser(t){this.did=t}markError(t){if(!this.sid)return;this.errors+=1;let n=t?"crashed":"errored";ae[n]<=ae[this.status]||(this.status=n,this.send(!1))}start(){this.sid=L(),this.started=v(),this.status="ok",this.errors=0,this.send(!1)}end(){this.sid&&(this.send(!0),this.sid="")}send(t){let n=JSON.stringify({sid:this.sid,did:this.did,status:this.status==="ok"&&t?"exited":this.status,errors:this.errors,started:this.started,release:this.release,environment:this.environment}),i=`${this.url}?key=${encodeURIComponent(this.key)}`;try{if(t&&typeof navigator<"u"&&navigator.sendBeacon){navigator.sendBeacon(i,n);return}if(typeof fetch>"u")return;fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key},body:n,keepalive:!0}).catch(()=>{})}catch{return}}};var Pe=/^\s*at (?:async )?(?:new )?(?:(.+?) )?\(?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack):.*?|[^()]+?)(?::(\d+))?(?::(\d+))?\)?\s*$/,De=/^\s*(?:(.*?)@)?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack).*?|[^@]*?)(?::(\d+))?(?::(\d+))?\s*$/,de=/^(chrome|moz|safari-web)-extension:/;function ze(){if(typeof location<"u"&&location.origin)return location.origin}function Ke(e){if(de.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=ze();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function ce(e){if(!e)return[];let t=[];for(let n of e.split(`
|
|
2
|
-
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let i=Pe.exec(n)??De.exec(n);if(!i)continue;let[,r,o,c,d]=i;if(!o)continue;let s={filename:f(o,1024),in_app:Ke(o)};r&&(s.function=f(r,512)),c&&(s.lineno=Number(c)),d&&(s.colno=Number(d)),t.push(s)}return t.reverse(),t.slice(-128)}function ue(e){return e.length===0?!1:e.every(t=>de.test(t.filename))}var H="@blipit/browser",M="0.3.7",P=oe(typeof document<"u"?document.currentScript?.src:void 0,M),D="https://in.blipit.io/api/v1/events",je=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],qe={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},We={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function He(e){if(!ne.includes(e?.kind))return;let t=f(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=f(String(e.actorId),128)),e.ip&&(n.ip=f(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=f(String(e.userAgent),512)),e.database&&(n.database=f(String(e.database),64)),e.outcome&&(n.outcome=f(String(e.outcome),64)),e.target&&(n.target=f(String(e.target),256)),n}var U=class{constructor(t){this.options=t;this.endpoint=t.endpoint??D,this.transport=new N(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new F(S(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...je,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[f(t,64)]=f(n,256)}addBreadcrumb(t){let n={timestamp:v(),...t};n.message&&(n.message=ie(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:C(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){let i=t instanceof Error?t:new Error(String(t)),r={type:i.name||"Error",value:f(i.message||String(i),4096),handled:n},o=ce(i.stack);return o.length>0&&(r.stacktrace={frames:o}),this.processAndSend({exception:r,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:f(t,8192),level:n})}captureSecurity(t){let n=He(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${qe[n.kind]} for ${n.actor}`,level:We[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let i=t.exception?.value??t.message??"";if(n){for(let d of this.ignoreErrors)if(typeof d=="string"?i.includes(d):d.test(i))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&ue(t.exception.stacktrace.frames))return;let c=`${t.exception?.type??""}|${i}`;if(t.exception?.handled===!1){if(this.seen.has(c)&&this.seen.size<100)return;this.seen.add(c),setTimeout(()=>this.seen.delete(c),5e3)}}let r={event_id:L(),timestamp:v(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:C(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:H,version:M},...t};for(let c of Object.keys(r))r[c]===void 0&&delete r[c];let o=this.replay?.active()&&(r.level==="error"||r.level==="fatal")?this.replay:void 0;if(o&&(r.tags={...r.tags,replay_id:o.id}),this.options.beforeSend){let c=this.options.beforeSend(r);if(!c)return;r=c}return this.transport.enqueue(r),this.lastEventId=r.event_id,(r.level==="error"||r.level==="fatal")&&E(this.errorIds,r.event_id,20),r.exception&&this.session?.markError(r.exception.handled===!1),o?.error(r.event_id),r.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",i=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;i&&(t.browser={name:i[1],version:i[2]});let r=/\(([^)]+)\)/.exec(n);return r&&r[1]&&(t.os={name:f(r[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};function X(e){return typeof e=="string"?e.length:e?.size}function pe(e){return e&&Number(e)||void 0}function Xe(e,t){return async(n,i)=>{let r=typeof n=="string"?n:n instanceof URL?n.href:n.url,o=(i?.method??n.method??"GET").toUpperCase(),c=Date.now();try{let d=await e(n,i);return t(o,r,d.status,c,X(i?.body),pe(d.headers.get("content-length"))),d}catch(d){throw t(o,r,0,c,X(i?.body)),d}}}function Ve(e,t){let n=e.open,i=e.send;e.open=function(r,o){return this._blipit=[String(r).toUpperCase(),String(o)],n.apply(this,arguments)},e.send=function(r){let o=this._blipit;if(o){let c=Date.now();this.addEventListener("loadend",()=>t(o[0],o[1],this.status,c,X(r),pe(this.getResponseHeader("content-length"))))}return i.apply(this,arguments)}}function le(e){if(typeof window>"u")return;let t=S(e.endpoint,""),{console:n,network:i,actions:r}=e.logs;window.addEventListener("error",s=>{e.captureException(s.error??s.message,!1)}),window.addEventListener("unhandledrejection",s=>{e.captureException(s.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",s=>{let a=s.target;if(!(a instanceof Element)||a.closest("[data-blipit-ui]"))return;let u=W(a);e.addBreadcrumb({category:"ui.click",message:`Clicked ${u}`});let b=a.closest(re)?"***":f((a.textContent??"").trim().replace(/\s+/g," "),80);E(r,{timestamp:v(),type:"click",selector:u,text:b},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",s=>{let a=s.target;a instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(a.tagName)&&E(r,{timestamp:v(),type:"focus",selector:W(a)},50)},{capture:!0,passive:!0}));let o=(s,a,u,b,l,g)=>{t&&a.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${s} ${C(a)} \u2192 ${u||"network error"}`,level:u>=400||!u?"error":"info",data:{url:C(a),method:s,status_code:u||void 0}}),E(i,{timestamp:v(),method:s,url:q(a),status:u,duration:Date.now()-b,request_size:l,response_size:g},50))};typeof window.fetch=="function"&&(window.fetch=Xe(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&Ve(XMLHttpRequest.prototype,o);for(let s of["log","info","debug","warn","error"]){let a=console[s].bind(console);console[s]=(...u)=>{let b=f(u.map(l=>typeof l=="string"?l:Ge(l)).join(" "),1024);if(s==="warn"||s==="error"){e.addBreadcrumb({category:"console",level:s==="warn"?"warning":"error",message:b});let l=u.find(g=>g instanceof Error);E(n,{timestamp:v(),level:s,message:b,stack:f((l??new Error).stack??"",2e3)},100)}else E(n,{timestamp:v(),level:s,message:b},100);a(...u)}}let c=()=>E(r,{timestamp:v(),type:"navigation",url:q(location.href)},50),d=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${C(location.href)}`}),c()};if(c(),window.history){let s=window.history.pushState.bind(window.history);window.history.pushState=(...a)=>{s(...a),d()},window.addEventListener("popstate",d)}}function Ge(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function fe(){let e=0,t=0,n=0,i=0;return r=>(r.hadRecentInput||(t>0&&r.startTime-i<1e3&&r.startTime-n<5e3?t+=r.value:(t=r.value,n=r.startTime),i=r.startTime,t>e&&(e=t)),e)}function Ye(e){if(e.size===0)return;let t=[...e.values()].sort((n,i)=>i-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function Je(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function O(e,t,n){try{new PerformanceObserver(i=>i.getEntries().forEach(r=>t(r))).observe({type:e,buffered:!0,...n})}catch{}}function me(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let i=performance.getEntriesByType("navigation")[0],r=i?.activationStart??0,o=y=>Math.max(0,Math.round(y-r)),c=document.visibilityState==="hidden",d=location.pathname,s=i?.type,a={},u=fe(),b=new Map,l=!1,g=!1;i&&i.responseStart>0&&(a.ttfb=o(i.responseStart)),c||(O("paint",y=>{y.name==="first-contentful-paint"&&(a.fcp=o(y.startTime))}),O("largest-contentful-paint",y=>{l||(a.lcp=o(y.startTime))}));let $=()=>{l=!0};addEventListener("keydown",$,{once:!0,capture:!0}),addEventListener("pointerdown",$,{once:!0,capture:!0}),O("layout-shift",y=>{a.cls=Math.round(u(y)*1e4)/1e4});let B=y=>{if(!y.interactionId)return;b.set(y.interactionId,Math.max(b.get(y.interactionId)??0,y.duration));let te=Ye(b);te!==void 0&&(a.inp=Math.round(te))};O("event",B,{durationThreshold:40}),O("first-input",B);let w=navigator.connection?.effectiveType,h=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,k=()=>{if(g||Object.keys(a).length===0)return;g=!0;let y=JSON.stringify({path:d.slice(0,512),metrics:a,nav:s,connection:w&&/^(slow-2g|2g|3g|4g)$/.test(w)?w:void 0,device:Je(navigator.userAgent)});try{if(navigator.sendBeacon?.(h,y))return}catch{}fetch(h,{method:"POST",body:y,keepalive:!0}).catch(()=>{})},T=()=>{location.pathname!==d&&(k(),d=location.pathname,s="route",a={},u=fe(),b=new Map,l=!0,g=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&k()),addEventListener("pagehide",k),addEventListener("popstate",T);let A=history.pushState;history.pushState=function(...y){A.apply(this,y),T()}}function Ze(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function ge(e,t,n,i,r){let o=Ze(e);if(!o||typeof document>"u")return;let c=L(),d,s=document.createElement("script");return s.src=e.src??`${r}blipit-replay.js`,s.async=!0,s.onload=()=>{let a=window.BlipitReplay?.start;d=a?.({id:c,mode:o,endpoint:t,key:n,instance:i})},document.head.appendChild(s),{id:c,active:()=>d?.active()??!1,error:a=>d?.error(a),report:a=>d?.report?.(a)}}var he={en:["Report {ref} sent.","We will email you updates."],ar:["\u062A\u0645 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0628\u0644\u0627\u063A {ref}.","\u0633\u0646\u0631\u0627\u0633\u0644\u0643 \u0628\u0627\u0644\u062A\u062D\u062F\u064A\u062B\u0627\u062A."],de:["Meldung {ref} gesendet.","Wir informieren Sie per E-Mail."],es:["Reporte {ref} enviado.","Te enviaremos novedades por correo."],fr:["Signalement {ref} envoy\xE9.","Nous vous tiendrons au courant par e-mail."],it:["Segnalazione {ref} inviata.","Ti invieremo aggiornamenti via email."],ja:["\u5831\u544A {ref} \u3092\u9001\u4FE1\u3057\u307E\u3057\u305F\u3002","\u9032\u6357\u306F\u30E1\u30FC\u30EB\u3067\u304A\u77E5\u3089\u305B\u3057\u307E\u3059\u3002"],nl:["Melding {ref} verstuurd.","We mailen je updates."],pt:["Relato {ref} enviado.","Vamos enviar novidades por e-mail."],tr:["{ref} numaral\u0131 bildirim g\xF6nderildi.","Geli\u015Fmeleri e-postayla bildirece\u011Fiz."],zh:["\u62A5\u544A {ref} \u5DF2\u53D1\u9001\u3002","\u6211\u4EEC\u4F1A\u901A\u8FC7\u90AE\u4EF6\u544A\u77E5\u8FDB\u5C55\u3002"]};function Qe(e,t,n){if(typeof e!="string"||!/^BR-\d{1,12}$/.test(e))return null;let[i,r]=he[n.toLowerCase().split(/[-_]/)[0]]??he.en;return`${i.replace("{ref}",e)}${t===!0?` ${r}`:""}`}function x(e,t,n){let i=document.createElement(e);return i.style.cssText=t,n!==void 0&&(i.textContent=n),i}var V="display:block;width:100%;box-sizing:border-box;margin:4px 0 12px;padding:8px 10px;font:inherit;border:1px solid #c5ccd6;border-radius:6px;background:#fff;color:#111",be="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",G=!1;function z(e,t,n){if(G||typeof document>"u"||!document.body)return;G=!0;let i=x("dialog","max-width:420px;width:calc(100% - 32px);padding:20px;border:1px solid #c5ccd6;border-radius:10px;font:14px/1.45 system-ui,sans-serif;color:#111;background:#fff");i.setAttribute("aria-labelledby","blipit-fb-title");let r=x("form","margin:0"),o=x("h2","margin:0 0 12px;font-size:17px",n.title??"Tell us what happened");o.id="blipit-fb-title";let c=(w,h,k)=>{let T=x("label","display:block;font-weight:600",w);T.htmlFor=k,h.id=k,r.append(T,h)},d=x("input",V);d.type="text",d.maxLength=128,d.autocomplete="name",d.value=n.name??"";let s=x("input",V);s.type="email",s.maxLength=254,s.autocomplete="email",s.value=n.email??"";let a=x("textarea",`${V};min-height:110px;resize:vertical`);a.required=!0,a.maxLength=5e3;let u=x("p","margin:0 0 12px;min-height:1.2em;font-size:13px");u.setAttribute("role","status"),u.setAttribute("aria-live","polite");let b=x("div","display:flex;gap:8px;justify-content:flex-end"),l=x("button",be,"Cancel");l.type="button";let g=x("button",`${be};background:#111;color:#fff;border-color:#111`,"Send");g.type="submit",r.append(o),c("Name (optional)",d,"blipit-fb-name"),c("Email (optional)",s,"blipit-fb-email"),c("What went wrong?",a,"blipit-fb-message"),b.append(l,g),r.append(u,b),i.append(r),document.body.append(i);let $=()=>{G=!1,i.remove()},B=()=>typeof i.close=="function"&&i.open?i.close():$();l.addEventListener("click",B),i.addEventListener("close",$),r.addEventListener("submit",async w=>{w.preventDefault();let h=a.value.trim();if(!h){u.textContent="Please describe what happened.",a.focus();return}g.disabled=!0,l.disabled=!0,g.setAttribute("aria-busy","true"),g.textContent="Sending\u2026",u.textContent="";try{let k=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":t},body:JSON.stringify({name:d.value.trim()||void 0,email:s.value.trim()||void 0,message:h,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!k.ok)throw new Error(String(k.status));let T=await k.json().catch(()=>({})),A=Qe(T.ref,T.emails,typeof navigator>"u"?"en":navigator.language??"en");u.textContent=A??"Thanks, your message was sent.",g.textContent="Sent",setTimeout(B,A?4e3:1200)}catch{u.textContent="That did not send. Please try again.",g.disabled=!1,l.disabled=!1,g.removeAttribute("aria-busy"),g.textContent="Send"}}),typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),a.focus()}var J={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},et="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",tt='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',ve,Y={},xe,R,Z=()=>{},_,ye=0;function I(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function we(e){ve=e}function nt(e,t){return Y[t]??=new Promise((n,i)=>{let r=document.createElement("script");r.src=e,r.async=!0,r.onload=()=>{let o=window[t];o?n(o):i(new Error(t))},r.onerror=i,document.head.appendChild(r)}).catch(n=>{throw delete Y[t],n}),Y[t]}function ke(){let e=(navigator.language??"en").slice(0,2);return J[e]?e:"en"}function Se(e,t){let n=document.createElement("button");return n.type="button",n.className="blipit-rb",n.setAttribute("aria-haspopup","dialog"),e?n.textContent=e:(n.lang=ke(),n.textContent=J[n.lang][0]),n.addEventListener("click",()=>n.hasAttribute("aria-busy")||t()),n}function K(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{},n=document.querySelectorAll("button.blipit-rb"),i=r=>{Z(r),n.forEach(o=>r?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))};i(!0),Promise.all([nt(t.src??`${P}blipit-report.js`,"BlipitReport"),xe??=Ee(e)]).then(([r,o])=>o.enabled!==!1&&r.open(e,{metadata:ve,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:c=>R&&(R.style.display=c?"none":"")}),()=>z(S(e.endpoint,"/api/v1/feedback"),e.options.key,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>i(!1))}async function Ee(e){let t=`blipit_fb_${M}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(S(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return I(e,`widget settings failed (HTTP ${n.status}), using defaults`),{};let i=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:i}))}catch{}return i}catch{return I(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function Q(e){let t=e.options.feedbackWidget,n=++ye;if(typeof document>"u")return;if(t===!1)return I(e,"Report a bug button off: feedbackWidget is false");let i=await(xe??=Ee(e));if(n!==ye)return;if(i.enabled===!1)return I(e,"Report a bug button hidden by the project's Bug report widget setting");let r={...i,...typeof t=="object"?t:{}},[o,c]=J[ke()],d=r.text||o;R=document.createElement("div"),R.setAttribute("data-blipit-ui","");let s=R.attachShadow({mode:"open"}),a=document.createElement("style");a.textContent=et;let u=document.createElement("button");u.type="button";let[b,l]=(/^(bottom|middle)-(left|right)$/.test(r.position??"")?r.position:"bottom-right").split("-");u.style.cssText=`${r.color?`--c:${r.color};`:""}${l}:calc(20px + env(safe-area-inset-${l},0px));${b==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,u.setAttribute("aria-haspopup","dialog"),r.style==="icon"&&(u.className="o",u.title=d);let g=h=>{u.disabled=h,u.setAttribute("aria-label",h?c:d),u.innerHTML=h?"<i></i><span></span>":`${tt}<span></span>`,u.lastChild.textContent=h?c:d};Z=g,g(!1),u.addEventListener("click",()=>K(e)),s.append(a,u);let $=r.shortcut?.toLowerCase().replace(/\s/g,"");_&&document.removeEventListener("keydown",_),_=void 0,$&&(_=h=>{[h.ctrlKey&&"ctrl",h.shiftKey&&"shift",h.altKey&&"alt",h.metaKey&&"meta",h.key.toLowerCase()].filter(Boolean).join("+")===$&&(h.preventDefault(),K(e))},document.addEventListener("keydown",_));let B=R,w=()=>{R===B&&(document.body.append(B),I(e,`Report a bug button shown at ${b}-${l}`))};document.body?w():document.addEventListener("DOMContentLoaded",w)}function Re(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},R?.remove(),R=void 0,_&&document.removeEventListener("keydown",_),_=void 0,Z=()=>{},Q(e)}var $e='<svg viewBox="0 0 242.4 208.7" aria-hidden="true"><defs><linearGradient id="bm1" x1="0" y1="1" x2=".5" y2="0"><stop offset="0" stop-color="#00C2FF"/><stop offset=".35" stop-color="#3882F6"/><stop offset="1" stop-color="#0F172A"/></linearGradient><linearGradient id="bm2" x1="0" y1="1" x2="1" y2="0"><stop offset="0" stop-color="#3882F6"/><stop offset=".5" stop-color="#00C2FF"/><stop offset="1" stop-color="#3882F6"/></linearGradient></defs><path fill="url(#bm1)" d="M115.5,164.5c-3.9,0-7.8-.4-11.5-1.2-3.7-.8-7.3-1.9-10.8-3.4-3.4-1.4-6.7-3.2-9.7-5.3-3.0-2.0-5.9-4.4-8.5-7.0s-4.9-5.4-7.0-8.5c-2.1-3.1-3.9-6.3-5.3-9.8-1.5-3.5-2.6-7.1-3.4-10.8-.8-3.8-1.2-7.7-1.2-11.5V19.1c0-6.6,5.4-12.0,12.0-12.0s12.0,5.4,12.0,12.0v88.2c0,2.2.2,4.5.7,6.7.4,2.1,1.1,4.2,1.9,6.2.8,2.0,1.9,3.9,3.1,5.7,1.2,1.8,2.6,3.4,4.1,4.9s3.2,2.9,4.9,4.1c1.8,1.2,3.7,2.2,5.6,3.1,2.0.8,4.1,1.5,6.2,1.9,4.4.9,9.1.9,13.4,0,2.1-.4,4.2-1.1,6.2-1.9,2.0-.8,3.9-1.9,5.7-3.1,1.8-1.2,3.4-2.6,4.9-4.1s2.9-3.2,4.1-4.9c1.2-1.8,2.2-3.7,3.1-5.7.8-2.0,1.5-4.1,1.9-6.2.5-2.2.7-4.5.7-6.7s-.2-4.5-.7-6.7c-.4-2.1-1.1-4.2-1.9-6.2-.8-2.0-1.9-3.9-3.1-5.7-1.2-1.8-2.6-3.4-4.1-4.9s-3.2-2.9-4.9-4.1c-1.8-1.2-3.7-2.2-5.7-3.1-2.0-.8-4.1-1.5-6.2-1.9-4.4-.9-9.1-.9-13.4,0-6.5,1.3-12.9-2.9-14.2-9.4-1.3-6.5,2.9-12.9,9.4-14.2,7.6-1.6,15.5-1.6,23.1,0,3.7.8,7.3,1.9,10.8,3.4,3.4,1.4,6.7,3.2,9.7,5.3,3.0,2.0,5.9,4.4,8.5,7.0s4.9,5.4,7.0,8.5c2.1,3.1,3.9,6.3,5.3,9.8,1.5,3.5,2.6,7.1,3.4,10.8.8,3.8,1.2,7.7,1.2,11.5s-.4,7.8-1.2,11.5c-.8,3.7-1.9,7.3-3.4,10.8-1.4,3.4-3.2,6.7-5.3,9.7-2.0,3.0-4.4,5.9-7.0,8.5s-5.4,4.9-8.5,7.0c-3.1,2.1-6.3,3.9-9.8,5.3-3.5,1.5-7.1,2.6-10.8,3.4-3.8.8-7.7,1.2-11.5,1.2Z"/><path fill="url(#bm2)" d="M208.1,103.0c-.0-.6-.8-.9-1.2-.5-3.2,3.1-7.6,5.0-12.4,5.0-3.9,0-9.1-1.6-10.2-2.5-.3-.1-.1,1.4-.1,2.5,0,40.5-34.4,73.0-75.5,70.0-33.4-2.5-60.8-28.8-64.4-62.1-1.0-9.4-.2-18.6,2.2-27.0,1.6-5.6,2.6-11.4,2.6-17.3v-22.4c0-3.4-4.3-5.0-6.5-2.4-13.2,15.4-21.6,35.1-22.7,56.6-2.6,54.1,40.6,98.9,94.1,98.9s94.2-42.3,94.2-94.2c0-1.5-.1-3.0-.1-4.5Z"/><path fill="url(#bm2)" d="M201.2,70.1c-14.8-35.8-50.9-60.5-92.3-58.3h-.1c-8.2.5-14.6,7.4-14.6,15.7v.1c0,5.4,4.7,9.6,10.0,8.8,3.2-.5,6.5-.7,9.9-.7,28.7,0,53.5,17.4,64.3,42.1.2.5.9.6,1.2.1,3.2-4.8,8.7-7.9,14.9-7.9,2.0,0,4.0.3,5.8,1.0.6.2,1.1-.4.9-1.0Z"/><circle fill="#00C2FF" cx="194.5" cy="88" r="15.8"/></svg>';var p=".blipit-rb.blipit-rb",it=`${p}{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:9px;height:40px;padding-inline:5px 17px;border-radius:99px;font:600 14px/1 system-ui,-apple-system,"Segoe UI",sans-serif;letter-spacing:-.01em;white-space:nowrap;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;color:#fff;background:linear-gradient(135deg,#3882F6,#2F5BEA);box-shadow:0 10px 24px -12px rgba(56,130,246,.8),0 1px 3px rgba(11,26,58,.16),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s}${p}:hover{transform:translateY(-1px);box-shadow:0 16px 32px -12px rgba(56,130,246,.85),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22)}${p}:active{transform:scale(.97)}${p}:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}${p}[aria-busy=true]{cursor:progress}${p}>span{all:unset}${p}>.blipit-rb-m{position:relative;display:grid;place-items:center;flex:none;width:30px;height:30px;border-radius:99px;background:#fff;box-shadow:0 0 0 1px rgba(11,26,58,.08),0 1px 2px rgba(11,26,58,.12)}${p} svg{display:block;width:19px;height:17px}${p}[data-size=sm]{height:32px;gap:7px;padding-inline:4px 13px;font-size:13px}${p}[data-size=sm]>.blipit-rb-m{width:24px;height:24px}${p}[data-size=sm] svg{width:15px;height:13px}${p}[data-variant=outline],${p}[data-variant=ghost]{color:#0B1A3A;background:transparent;box-shadow:inset 0 0 0 1px #CBD7EA}${p}[data-variant=ghost]{box-shadow:none}${p}[data-variant=outline]:hover,${p}[data-variant=ghost]:hover{transform:none;background:rgba(56,130,246,.08);box-shadow:inset 0 0 0 1px rgba(56,130,246,.45)}${p}[data-variant=ghost]:hover{box-shadow:none}${p}[data-theme=dark]{background:linear-gradient(135deg,#5B9BFF,#3D6BF0);box-shadow:0 10px 24px -12px rgba(91,155,255,.7),inset 0 1px 0 rgba(255,255,255,.2)}${p}[data-theme=dark][data-variant=outline],${p}[data-theme=dark][data-variant=ghost]{color:#E8EEF8;background:transparent;box-shadow:inset 0 0 0 1px rgba(255,255,255,.16)}${p}[data-theme=dark][data-variant=ghost]{box-shadow:none}${p}[data-theme=dark][data-variant=outline]:hover,${p}[data-theme=dark][data-variant=ghost]:hover{background:rgba(91,155,255,.16);box-shadow:inset 0 0 0 1px rgba(91,155,255,.45)}${p}[data-theme=dark][data-variant=ghost]:hover{box-shadow:none}${p}[data-theme=dark]>.blipit-rb-m{box-shadow:0 0 0 1px rgba(255,255,255,.1)}${p}[aria-busy=true] svg{visibility:hidden}${p}[aria-busy=true]>.blipit-rb-m::after{content:"";position:absolute;inset:4px;border:2px solid #3882F6;border-right-color:transparent;border-radius:50%;animation:blipit-rb-r .8s linear infinite}@keyframes blipit-rb-r{to{transform:rotate(1turn)}}@media(pointer:coarse){${p}{min-height:44px}}@media(prefers-reduced-motion:reduce){${p}{transition:none}${p}:hover,${p}:active{transform:none}${p}[aria-busy=true]>.blipit-rb-m::after{animation-duration:3s}}@media(forced-colors:active){${p}{border:1px solid ButtonText}}`,rt=0;function Be(e,t={}){if(!document.getElementById("blipit-rb-css")){let o=document.createElement("style");o.id="blipit-rb-css",o.textContent=it,document.head.append(o)}let n=++rt,i=document.createElement("span");i.className="blipit-rb-m",i.innerHTML=$e.replace(/bm(\d)/g,`bm$1-${n}`);let r=document.createElement("span");r.textContent=e.textContent,e.replaceChildren(i,r),e.classList.add("blipit-rb"),e.setAttribute("data-variant",t.variant==="outline"||t.variant==="ghost"?t.variant:"solid"),e.setAttribute("data-size",t.size==="sm"?"sm":"md"),e.setAttribute("data-theme",se(t.theme==="light"||t.theme==="dark"?t.theme:void 0))}var m,Te=new Set;function _e(e,t){Te.has(t)||(Te.add(t),console[e](t))}var ot="[blipit] init() has no key, so error tracking and the Report a bug button are off. Pass your public key (blipit_pk_...) from app.blipit.io, API keys.",st="[blipit] init() got a secret key (blipit_sk_...), so Blipit did not start: secret keys must never be in browser code. Use the public key (blipit_pk_...) and create a new secret key in app.blipit.io, API keys.";function at(e){if(m)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return _e("warn",ot);if(t.startsWith("blipit_sk_"))return _e("error",st);if(m=new U({...e,key:t}),e.user){let{id:n,name:i,email:r,username:o}=e.user;m.setUser({id:n===void 0?void 0:String(n),email:r,username:o??i})}le(m),e.webVitals!==!1&&typeof window<"u"&&me(e.endpoint??D,t,e.instance),e.replay&&(m.replay=ge(e.replay,e.endpoint??D,t,e.instance,P)),typeof window<"u"&&Q(m),e.debug&&console.log(`[blipit] ${H}@${M} initialized`)}function dt(e){return m?.captureException(e,!0)}function ct(e,t){return m?.captureMessage(e,t)}function ut(e){return m?.captureSecurity(e)}function pt(e){m?.setUser(e)}function lt(e,t){m?.setTag(e,t)}function ft(e){m?.addBreadcrumb(e)}function mt(e={}){m&&z(S(m.endpoint,"/api/v1/feedback"),m.options.key,{...e,eventId:e.eventId??m.lastEventId})}function ee(){m&&K(m)}function gt(e){e.addEventListener("click",t=>{t.preventDefault(),ee()})}function ht(e={}){let t=Se(e.label,ee);return Be(t,e),t}function bt(e){m&&Re(m,e)}function yt(){return m?.flush()??Promise.resolve()}0&&(module.exports={addBreadcrumb,attachReport,captureException,captureMessage,captureSecurity,flush,init,openReport,reportButton,setReportMetadata,setTag,setUser,showFeedback,updateWidget});
|
|
1
|
+
"use strict";var j=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var De=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},Pe=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Fe(t))!Ne.call(e,r)&&r!==n&&j(e,r,{get:()=>t[r],enumerable:!(i=Ae(t,r))||i.enumerable});return e};var Ue=e=>Pe(j({},"__esModule",{value:!0}),e);var St={};De(St,{addBreadcrumb:()=>bt,attachReport:()=>vt,captureException:()=>lt,captureMessage:()=>ft,captureSecurity:()=>mt,flush:()=>wt,init:()=>pt,openReport:()=>te,reportButton:()=>xt,setReportMetadata:()=>ye,setTag:()=>ht,setUser:()=>gt,showFeedback:()=>yt,updateWidget:()=>kt});module.exports=Ue(St);var ie={en:["Report {ref} sent.","We will email you updates."],ar:["\u062A\u0645 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0628\u0644\u0627\u063A {ref}.","\u0633\u0646\u0631\u0627\u0633\u0644\u0643 \u0628\u0627\u0644\u062A\u062D\u062F\u064A\u062B\u0627\u062A."],de:["Meldung {ref} gesendet.","Wir informieren Sie per E-Mail."],es:["Reporte {ref} enviado.","Te enviaremos novedades por correo."],fr:["Signalement {ref} envoy\xE9.","Nous vous tiendrons au courant par e-mail."],it:["Segnalazione {ref} inviata.","Ti invieremo aggiornamenti via email."],ja:["\u5831\u544A {ref} \u3092\u9001\u4FE1\u3057\u307E\u3057\u305F\u3002","\u9032\u6357\u306F\u30E1\u30FC\u30EB\u3067\u304A\u77E5\u3089\u305B\u3057\u307E\u3059\u3002"],nl:["Melding {ref} verstuurd.","We mailen je updates."],pt:["Relato {ref} enviado.","Vamos enviar novidades por e-mail."],tr:["{ref} numaral\u0131 bildirim g\xF6nderildi.","Geli\u015Fmeleri e-postayla bildirece\u011Fiz."],zh:["\u62A5\u544A {ref} \u5DF2\u53D1\u9001\u3002","\u6211\u4EEC\u4F1A\u901A\u8FC7\u90AE\u4EF6\u544A\u77E5\u8FDB\u5C55\u3002"]};function ze(e,t,n){if(typeof e!="string"||!/^BR-\d{1,12}$/.test(e))return null;let[i,r]=ie[n.toLowerCase().split(/[-_]/)[0]]??ie.en;return`${i.replace("{ref}",e)}${t===!0?` ${r}`:""}`}function x(e,t,n){let i=document.createElement(e);return i.style.cssText=t,n!==void 0&&(i.textContent=n),i}var W="display:block;width:100%;box-sizing:border-box;margin:4px 0 12px;padding:8px 10px;font:inherit;border:1px solid #c5ccd6;border-radius:6px;background:#fff;color:#111",re="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",q=!1;function oe(e,t,n){if(q||typeof document>"u"||!document.body)return;q=!0;let i=x("dialog","max-width:420px;width:calc(100% - 32px);padding:20px;border:1px solid #c5ccd6;border-radius:10px;font:14px/1.45 system-ui,sans-serif;color:#111;background:#fff");i.setAttribute("aria-labelledby","blipit-fb-title");let r=x("form","margin:0"),o=x("h2","margin:0 0 12px;font-size:17px",n.title??"Tell us what happened");o.id="blipit-fb-title";let c=(b,$,k)=>{let B=x("label","display:block;font-weight:600",b);B.htmlFor=k,$.id=k,r.append(B,$)},d=x("input",W);d.type="text",d.maxLength=128,d.autocomplete="name",d.value=n.name??"";let a=x("input",W);a.type="email",a.maxLength=254,a.autocomplete="email",a.value=n.email??"";let s=x("textarea",`${W};min-height:110px;resize:vertical`);s.required=!0,s.maxLength=5e3;let p=x("p","margin:0 0 12px;min-height:1.2em;font-size:13px");p.setAttribute("role","status"),p.setAttribute("aria-live","polite");let h=x("div","display:flex;gap:8px;justify-content:flex-end"),f=x("button",re,"Cancel");f.type="button";let m=x("button",`${re};background:#111;color:#fff;border-color:#111`,"Send");m.type="submit",r.append(o),c("Name (optional)",d,"blipit-fb-name"),c("Email (optional)",a,"blipit-fb-email"),c("What went wrong?",s,"blipit-fb-message"),h.append(f,m),r.append(p,h),i.append(r),document.body.append(i);let E=()=>{q=!1,i.remove()},R=()=>typeof i.close=="function"&&i.open?i.close():E();f.addEventListener("click",R),i.addEventListener("close",E),r.addEventListener("submit",async b=>{b.preventDefault();let $=s.value.trim();if(!$){p.textContent="Please describe what happened.",s.focus();return}m.disabled=!0,f.disabled=!0,m.setAttribute("aria-busy","true"),m.textContent="Sending\u2026",p.textContent="";try{let k=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":t},body:JSON.stringify({name:d.value.trim()||void 0,email:a.value.trim()||void 0,message:$,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!k.ok)throw new Error(String(k.status));let B=await k.json().catch(()=>({})),A=ze(B.ref,B.emails,typeof navigator>"u"?"en":navigator.language??"en");p.textContent=A??"Thanks, your message was sent.",m.textContent="Sent",setTimeout(R,A?4e3:1200)}catch{p.textContent="That did not send. Please try again.",m.disabled=!1,f.disabled=!1,m.removeAttribute("aria-busy"),m.textContent="Send"}}),typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),s.focus()}var se=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var F=class{constructor(t,n,i,r){this.endpoint=t;this.key=n;this.debug=i;this.instance=r;typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flushWithBeacon()})}endpoint;key;debug;instance;queue=[];timer;sending=!1;enqueue(t){this.queue.push(t),this.queue.length>30&&this.queue.shift(),this.timer||(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},1e3))}async flush(){if(!this.sending){this.sending=!0;try{for(;this.queue.length>0;){let t=this.queue[0];if(!await this.send(t))break;this.queue.shift()}}finally{this.sending=!1}}}async send(t,n=0){try{let i=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key,...this.instance?{"X-Blipit-Instance":this.instance}:{}},body:JSON.stringify(t),keepalive:!0});return i.status===429||i.status>=500?this.retry(t,n):(this.debug&&i.status>=400&&console.warn("[blipit] event rejected",i.status,await i.text()),!0)}catch{return this.retry(t,n)}}async retry(t,n){return n>=2?(this.debug&&console.warn("[blipit] dropping event after retries",t.event_id),!0):(await new Promise(i=>setTimeout(i,1e3*2**n)),this.send(t,n+1))}flushWithBeacon(){if(!(typeof navigator>"u"||!navigator.sendBeacon))for(;this.queue.length>0;){let t=this.queue.shift(),n=`key=${encodeURIComponent(this.key)}${this.instance?`&instance=${encodeURIComponent(this.instance)}`:""}`,i=`${this.endpoint}${this.endpoint.includes("?")?"&":"?"}${n}`;navigator.sendBeacon(i,JSON.stringify(t))}}};function L(){let e=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0");return t}function v(){return new Date().toISOString()}var Ke=/token|key|password|secret|auth|session|passwd|api/i;function C(e){let t=e.indexOf("?");if(t===-1)return e.slice(0,2048);let n=e.slice(0,t),r=e.slice(t+1).split("&").map(o=>{let c=o.indexOf("=");if(c===-1)return o;let d=o.slice(0,c);return Ke.test(d)?`${d}=[redacted]`:o}).join("&");return`${n}?${r}`.slice(0,2048)}var je=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function ae(e){return e.replace(je,"$1[redacted]")}function l(e,t){return e.length>t?e.slice(0,t):e}var de=".blipit-mask,[data-blipit-mask]";function H(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function w(e,t,n){e.push(t),e.length>n&&e.shift()}function X(e){let t=e.id?`#${e.id}`:"",n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return l(`${e.tagName.toLowerCase()}${t}${n}`,128)}function N(e,t){try{let n=new CSSStyleSheet;n.replaceSync(t),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]}catch{let n=document.createElement("style");n.textContent=t,(e===document?document.head:e).append(n)}}function T(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function ce(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}function We(e){let t=e.match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?/);if(!t||(t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]))<.5)return null;let[i,r,o]=[t[1],t[2],t[3]].map(c=>{let d=parseFloat(c)/255;return d<=.03928?d/12.92:((d+.055)/1.055)**2.4});return .2126*i+.7152*r+.0722*o}function ue(e){if(e==="light"||e==="dark")return e;if(typeof document<"u"){for(let n of[document.body,document.documentElement]){if(!n)continue;let i=We(getComputedStyle(n).backgroundColor);if(i!==null)return i<.4?"dark":"light"}let t=getComputedStyle(document.documentElement).colorScheme;if(t==="dark")return"dark";if(t&&t!=="normal"&&!t.includes("dark"))return"light"}return typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var pe={ok:0,errored:1,crashed:2},D=class{constructor(t,n,i,r){this.url=t;this.key=n;this.release=i;this.environment=r;this.start(),typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.end():this.sid||this.start()})}url;key;release;environment;sid="";started="";status="ok";errors=0;did;setUser(t){this.did=t}markError(t){if(!this.sid)return;this.errors+=1;let n=t?"crashed":"errored";pe[n]<=pe[this.status]||(this.status=n,this.send(!1))}start(){this.sid=L(),this.started=v(),this.status="ok",this.errors=0,this.send(!1)}end(){this.sid&&(this.send(!0),this.sid="")}send(t){let n=JSON.stringify({sid:this.sid,did:this.did,status:this.status==="ok"&&t?"exited":this.status,errors:this.errors,started:this.started,release:this.release,environment:this.environment}),i=`${this.url}?key=${encodeURIComponent(this.key)}`;try{if(t&&typeof navigator<"u"&&navigator.sendBeacon){navigator.sendBeacon(i,n);return}if(typeof fetch>"u")return;fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key},body:n,keepalive:!0}).catch(()=>{})}catch{return}}};var qe=/^\s*at (?:async )?(?:new )?(?:(.+?) )?\(?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack):.*?|[^()]+?)(?::(\d+))?(?::(\d+))?\)?\s*$/,He=/^\s*(?:(.*?)@)?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack).*?|[^@]*?)(?::(\d+))?(?::(\d+))?\s*$/,le=/^(chrome|moz|safari-web)-extension:/;function Xe(){if(typeof location<"u"&&location.origin)return location.origin}function Ve(e){if(le.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=Xe();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function fe(e){if(!e)return[];let t=[];for(let n of e.split(`
|
|
2
|
+
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let i=qe.exec(n)??He.exec(n);if(!i)continue;let[,r,o,c,d]=i;if(!o)continue;let a={filename:l(o,1024),in_app:Ve(o)};r&&(a.function=l(r,512)),c&&(a.lineno=Number(c)),d&&(a.colno=Number(d)),t.push(a)}return t.reverse(),t.slice(-128)}function me(e){return e.length===0?!1:e.every(t=>le.test(t.filename))}var V="@blipit/browser",M="0.3.8",U=ce(typeof document<"u"?document.currentScript?.src:void 0,M),z="https://in.blipit.io/api/v1/events",Ge=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Ye={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},Je={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function Ze(e){if(!se.includes(e?.kind))return;let t=l(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=l(String(e.actorId),128)),e.ip&&(n.ip=l(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=l(String(e.userAgent),512)),e.database&&(n.database=l(String(e.database),64)),e.outcome&&(n.outcome=l(String(e.outcome),64)),e.target&&(n.target=l(String(e.target),256)),n}var P=class{constructor(t){this.options=t;this.endpoint=t.endpoint??z,this.transport=new F(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new D(T(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...Ge,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;captured=new WeakSet;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[l(t,64)]=l(n,256)}addBreadcrumb(t){let n={timestamp:v(),...t};n.message&&(n.message=ae(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:C(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){if(t&&typeof t=="object"){if(this.captured.has(t))return;this.captured.add(t)}let i=t instanceof Error?t:new Error(String(t)),r={type:i.name||"Error",value:l(i.message||String(i),4096),handled:n},o=fe(i.stack);return o.length>0&&(r.stacktrace={frames:o}),this.processAndSend({exception:r,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:l(t,8192),level:n})}captureSecurity(t){let n=Ze(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${Ye[n.kind]} for ${n.actor}`,level:Je[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let i=t.exception?.value??t.message??"";if(n){for(let d of this.ignoreErrors)if(typeof d=="string"?i.includes(d):d.test(i))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&me(t.exception.stacktrace.frames))return;let c=`${t.exception?.type??""}|${i}`;if(t.exception?.handled===!1){if(this.seen.has(c)&&this.seen.size<100)return;this.seen.add(c),setTimeout(()=>this.seen.delete(c),5e3)}}let r={event_id:L(),timestamp:v(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:C(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:V,version:M},...t};for(let c of Object.keys(r))r[c]===void 0&&delete r[c];let o=this.replay?.active()&&(r.level==="error"||r.level==="fatal")?this.replay:void 0;if(o&&(r.tags={...r.tags,replay_id:o.id}),this.options.beforeSend){let c=this.options.beforeSend(r);if(!c)return;r=c}return this.transport.enqueue(r),this.lastEventId=r.event_id,(r.level==="error"||r.level==="fatal")&&w(this.errorIds,r.event_id,20),r.exception&&this.session?.markError(r.exception.handled===!1),o?.error(r.event_id),r.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",i=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;i&&(t.browser={name:i[1],version:i[2]});let r=/\(([^)]+)\)/.exec(n);return r&&r[1]&&(t.os={name:l(r[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};var Y={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},Qe="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",et='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',he,G={},be,S,J=()=>{},_,ge=0;function O(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function ye(e){he=e}function tt(e,t){return G[t]??=new Promise((n,i)=>{let r=document.createElement("script");r.src=e,r.async=!0,r.onload=()=>{let o=window[t];o?n(o):i(new Error(t))},r.onerror=i,document.head.appendChild(r)}).catch(n=>{throw delete G[t],n}),G[t]}function ve(){let e=(navigator.language??"en").slice(0,2);return Y[e]?e:"en"}function xe(e,t){let n=document.createElement("button");return n.type="button",n.className="blipit-rb",n.setAttribute("aria-haspopup","dialog"),e?n.textContent=e:(n.lang=ve(),n.textContent=Y[n.lang][0]),n.addEventListener("click",()=>n.hasAttribute("aria-busy")||t()),n}var ke=()=>{};function we(e){ke=e}function Z(e,t){ke(T(e.endpoint,"/api/v1/feedback"),e.options.key,t)}function K(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{},n=document.querySelectorAll("button.blipit-rb"),i=r=>{J(r),n.forEach(o=>r?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))};i(!0),Promise.all([tt(t.src??`${U}blipit-report.js`,"BlipitReport"),be??=Se(e)]).then(([r,o])=>o.enabled!==!1&&r.open(e,{metadata:he,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:c=>S&&(S.style.display=c?"none":"")}),()=>Z(e,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>i(!1))}async function Se(e){let t=`blipit_fb_${M}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(T(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return O(e,`widget settings failed (HTTP ${n.status}), using defaults`),{};let i=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:i}))}catch{}return i}catch{return O(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function Q(e){let t=e.options.feedbackWidget,n=++ge;if(typeof document>"u")return;if(t===!1)return O(e,"Report a bug button off: feedbackWidget is false");let i=await(be??=Se(e));if(n!==ge)return;if(i.enabled===!1)return O(e,"Report a bug button hidden by the project's Bug report widget setting");let r={...i,...typeof t=="object"?t:{}},[o,c]=Y[ve()],d=r.text||o;S=document.createElement("div"),S.setAttribute("data-blipit-ui","");let a=S.attachShadow({mode:"open"}),s=document.createElement("button");s.type="button";let[p,h]=(/^(bottom|middle)-(left|right)$/.test(r.position??"")?r.position:"bottom-right").split("-");s.style.cssText=`${r.color?`--c:${r.color};`:""}${h}:calc(20px + env(safe-area-inset-${h},0px));${p==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,s.setAttribute("aria-haspopup","dialog"),r.style==="icon"&&(s.className="o",s.title=d);let f=b=>{s.disabled=b,s.setAttribute("aria-label",b?c:d),s.innerHTML=b?"<i></i><span></span>":`${et}<span></span>`,s.lastChild.textContent=b?c:d};J=f,f(!1),s.addEventListener("click",()=>K(e)),N(a,Qe),a.append(s);let m=r.shortcut?.toLowerCase().replace(/\s/g,"");_&&document.removeEventListener("keydown",_),_=void 0,m&&(_=b=>{[b.ctrlKey&&"ctrl",b.shiftKey&&"shift",b.altKey&&"alt",b.metaKey&&"meta",b.key.toLowerCase()].filter(Boolean).join("+")===m&&(b.preventDefault(),K(e))},document.addEventListener("keydown",_));let E=S,R=()=>{S===E&&(document.body.append(E),O(e,`Report a bug button shown at ${p}-${h}`))};document.body?R():document.addEventListener("DOMContentLoaded",R)}function Ee(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},S?.remove(),S=void 0,_&&document.removeEventListener("keydown",_),_=void 0,J=()=>{},Q(e)}function ee(e){return typeof e=="string"?e.length:e?.size}function Re(e){return e&&Number(e)||void 0}function nt(e,t){return async(n,i)=>{let r=typeof n=="string"?n:n instanceof URL?n.href:n.url,o=(i?.method??n.method??"GET").toUpperCase(),c=Date.now();try{let d=await e(n,i);return t(o,r,d.status,c,ee(i?.body),Re(d.headers.get("content-length"))),d}catch(d){throw t(o,r,0,c,ee(i?.body)),d}}}function it(e,t){let n=e.open,i=e.send;e.open=function(r,o){return this._blipit=[String(r).toUpperCase(),String(o)],n.apply(this,arguments)},e.send=function(r){let o=this._blipit;if(o){let c=Date.now();this.addEventListener("loadend",()=>t(o[0],o[1],this.status,c,ee(r),Re(this.getResponseHeader("content-length"))))}return i.apply(this,arguments)}}function $e(e){if(typeof window>"u")return;let t=T(e.endpoint,""),{console:n,network:i,actions:r}=e.logs;window.addEventListener("error",a=>{e.captureException(a.error??a.message,!1)}),window.addEventListener("unhandledrejection",a=>{e.captureException(a.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",a=>{let s=a.target;if(!(s instanceof Element)||s.closest("[data-blipit-ui]"))return;let p=X(s);e.addBreadcrumb({category:"ui.click",message:`Clicked ${p}`});let h=s.closest(de)?"***":l((s.textContent??"").trim().replace(/\s+/g," "),80);w(r,{timestamp:v(),type:"click",selector:p,text:h},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",a=>{let s=a.target;s instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(s.tagName)&&w(r,{timestamp:v(),type:"focus",selector:X(s)},50)},{capture:!0,passive:!0}));let o=(a,s,p,h,f,m)=>{t&&s.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${a} ${C(s)} \u2192 ${p||"network error"}`,level:p>=400||!p?"error":"info",data:{url:C(s),method:a,status_code:p||void 0}}),w(i,{timestamp:v(),method:a,url:H(s),status:p,duration:Date.now()-h,request_size:f,response_size:m},50))};typeof window.fetch=="function"&&(window.fetch=nt(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&it(XMLHttpRequest.prototype,o);for(let a of["log","info","debug","warn","error"]){let s=console[a].bind(console);console[a]=(...p)=>{let h=l(p.map(f=>typeof f=="string"?f:rt(f)).join(" "),1024);if(a==="warn"||a==="error"){e.addBreadcrumb({category:"console",level:a==="warn"?"warning":"error",message:h});let f=p.find(m=>m instanceof Error);w(n,{timestamp:v(),level:a,message:h,stack:l((f??new Error).stack??"",2e3)},100)}else w(n,{timestamp:v(),level:a,message:h},100);s(...p)}}let c=()=>w(r,{timestamp:v(),type:"navigation",url:H(location.href)},50),d=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${C(location.href)}`}),c()};if(c(),window.history){let a=window.history.pushState.bind(window.history);window.history.pushState=(...s)=>{a(...s),d()},window.addEventListener("popstate",d)}}function rt(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function Be(){let e=0,t=0,n=0,i=0;return r=>(r.hadRecentInput||(t>0&&r.startTime-i<1e3&&r.startTime-n<5e3?t+=r.value:(t=r.value,n=r.startTime),i=r.startTime,t>e&&(e=t)),e)}function ot(e){if(e.size===0)return;let t=[...e.values()].sort((n,i)=>i-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function st(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function I(e,t,n){try{new PerformanceObserver(i=>i.getEntries().forEach(r=>t(r))).observe({type:e,buffered:!0,...n})}catch{}}function Te(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let i=performance.getEntriesByType("navigation")[0],r=i?.activationStart??0,o=y=>Math.max(0,Math.round(y-r)),c=document.visibilityState==="hidden",d=location.pathname,a=i?.type,s={},p=Be(),h=new Map,f=!1,m=!1;i&&i.responseStart>0&&(s.ttfb=o(i.responseStart)),c||(I("paint",y=>{y.name==="first-contentful-paint"&&(s.fcp=o(y.startTime))}),I("largest-contentful-paint",y=>{f||(s.lcp=o(y.startTime))}));let E=()=>{f=!0};addEventListener("keydown",E,{once:!0,capture:!0}),addEventListener("pointerdown",E,{once:!0,capture:!0}),I("layout-shift",y=>{s.cls=Math.round(p(y)*1e4)/1e4});let R=y=>{if(!y.interactionId)return;h.set(y.interactionId,Math.max(h.get(y.interactionId)??0,y.duration));let ne=ot(h);ne!==void 0&&(s.inp=Math.round(ne))};I("event",R,{durationThreshold:40}),I("first-input",R);let b=navigator.connection?.effectiveType,$=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,k=()=>{if(m||Object.keys(s).length===0)return;m=!0;let y=JSON.stringify({path:d.slice(0,512),metrics:s,nav:a,connection:b&&/^(slow-2g|2g|3g|4g)$/.test(b)?b:void 0,device:st(navigator.userAgent)});try{if(navigator.sendBeacon?.($,y))return}catch{}fetch($,{method:"POST",body:y,keepalive:!0}).catch(()=>{})},B=()=>{location.pathname!==d&&(k(),d=location.pathname,a="route",s={},p=Be(),h=new Map,f=!0,m=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&k()),addEventListener("pagehide",k),addEventListener("popstate",B);let A=history.pushState;history.pushState=function(...y){A.apply(this,y),B()}}function at(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function _e(e,t,n,i,r){let o=at(e);if(!o||typeof document>"u")return;let c=L(),d,a=document.createElement("script");return a.src=e.src??`${r}blipit-replay.js`,a.async=!0,a.onload=()=>{let s=window.BlipitReplay?.start;d=s?.({id:c,mode:o,endpoint:t,key:n,instance:i})},document.head.appendChild(a),{id:c,active:()=>d?.active()??!1,error:s=>d?.error(s),report:s=>d?.report?.(s)}}var Ce='<svg viewBox="0 0 242.4 208.7" aria-hidden="true"><defs><linearGradient id="bm1" x1="0" y1="1" x2=".5" y2="0"><stop offset="0" stop-color="#00C2FF"/><stop offset=".35" stop-color="#3882F6"/><stop offset="1" stop-color="#0F172A"/></linearGradient><linearGradient id="bm2" x1="0" y1="1" x2="1" y2="0"><stop offset="0" stop-color="#3882F6"/><stop offset=".5" stop-color="#00C2FF"/><stop offset="1" stop-color="#3882F6"/></linearGradient></defs><path fill="url(#bm1)" d="M115.5,164.5c-3.9,0-7.8-.4-11.5-1.2-3.7-.8-7.3-1.9-10.8-3.4-3.4-1.4-6.7-3.2-9.7-5.3-3.0-2.0-5.9-4.4-8.5-7.0s-4.9-5.4-7.0-8.5c-2.1-3.1-3.9-6.3-5.3-9.8-1.5-3.5-2.6-7.1-3.4-10.8-.8-3.8-1.2-7.7-1.2-11.5V19.1c0-6.6,5.4-12.0,12.0-12.0s12.0,5.4,12.0,12.0v88.2c0,2.2.2,4.5.7,6.7.4,2.1,1.1,4.2,1.9,6.2.8,2.0,1.9,3.9,3.1,5.7,1.2,1.8,2.6,3.4,4.1,4.9s3.2,2.9,4.9,4.1c1.8,1.2,3.7,2.2,5.6,3.1,2.0.8,4.1,1.5,6.2,1.9,4.4.9,9.1.9,13.4,0,2.1-.4,4.2-1.1,6.2-1.9,2.0-.8,3.9-1.9,5.7-3.1,1.8-1.2,3.4-2.6,4.9-4.1s2.9-3.2,4.1-4.9c1.2-1.8,2.2-3.7,3.1-5.7.8-2.0,1.5-4.1,1.9-6.2.5-2.2.7-4.5.7-6.7s-.2-4.5-.7-6.7c-.4-2.1-1.1-4.2-1.9-6.2-.8-2.0-1.9-3.9-3.1-5.7-1.2-1.8-2.6-3.4-4.1-4.9s-3.2-2.9-4.9-4.1c-1.8-1.2-3.7-2.2-5.7-3.1-2.0-.8-4.1-1.5-6.2-1.9-4.4-.9-9.1-.9-13.4,0-6.5,1.3-12.9-2.9-14.2-9.4-1.3-6.5,2.9-12.9,9.4-14.2,7.6-1.6,15.5-1.6,23.1,0,3.7.8,7.3,1.9,10.8,3.4,3.4,1.4,6.7,3.2,9.7,5.3,3.0,2.0,5.9,4.4,8.5,7.0s4.9,5.4,7.0,8.5c2.1,3.1,3.9,6.3,5.3,9.8,1.5,3.5,2.6,7.1,3.4,10.8.8,3.8,1.2,7.7,1.2,11.5s-.4,7.8-1.2,11.5c-.8,3.7-1.9,7.3-3.4,10.8-1.4,3.4-3.2,6.7-5.3,9.7-2.0,3.0-4.4,5.9-7.0,8.5s-5.4,4.9-8.5,7.0c-3.1,2.1-6.3,3.9-9.8,5.3-3.5,1.5-7.1,2.6-10.8,3.4-3.8.8-7.7,1.2-11.5,1.2Z"/><path fill="url(#bm2)" d="M208.1,103.0c-.0-.6-.8-.9-1.2-.5-3.2,3.1-7.6,5.0-12.4,5.0-3.9,0-9.1-1.6-10.2-2.5-.3-.1-.1,1.4-.1,2.5,0,40.5-34.4,73.0-75.5,70.0-33.4-2.5-60.8-28.8-64.4-62.1-1.0-9.4-.2-18.6,2.2-27.0,1.6-5.6,2.6-11.4,2.6-17.3v-22.4c0-3.4-4.3-5.0-6.5-2.4-13.2,15.4-21.6,35.1-22.7,56.6-2.6,54.1,40.6,98.9,94.1,98.9s94.2-42.3,94.2-94.2c0-1.5-.1-3.0-.1-4.5Z"/><path fill="url(#bm2)" d="M201.2,70.1c-14.8-35.8-50.9-60.5-92.3-58.3h-.1c-8.2.5-14.6,7.4-14.6,15.7v.1c0,5.4,4.7,9.6,10.0,8.8,3.2-.5,6.5-.7,9.9-.7,28.7,0,53.5,17.4,64.3,42.1.2.5.9.6,1.2.1,3.2-4.8,8.7-7.9,14.9-7.9,2.0,0,4.0.3,5.8,1.0.6.2,1.1-.4.9-1.0Z"/><circle fill="#00C2FF" cx="194.5" cy="88" r="15.8"/></svg>';var u=".blipit-rb.blipit-rb",dt=`${u}{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:9px;height:40px;padding-inline:5px 17px;border-radius:99px;font:600 14px/1 system-ui,-apple-system,"Segoe UI",sans-serif;letter-spacing:-.01em;white-space:nowrap;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;color:#fff;background:linear-gradient(135deg,#3882F6,#2F5BEA);box-shadow:0 10px 24px -12px rgba(56,130,246,.8),0 1px 3px rgba(11,26,58,.16),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s}${u}:hover{transform:translateY(-1px);box-shadow:0 16px 32px -12px rgba(56,130,246,.85),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22)}${u}:active{transform:scale(.97)}${u}:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}${u}[aria-busy=true]{cursor:progress}${u}>span{all:unset}${u}>.blipit-rb-m{position:relative;display:grid;place-items:center;flex:none;width:30px;height:30px;border-radius:99px;background:#fff;box-shadow:0 0 0 1px rgba(11,26,58,.08),0 1px 2px rgba(11,26,58,.12)}${u} svg{display:block;width:19px;height:17px}${u}[data-size=sm]{height:32px;gap:7px;padding-inline:4px 13px;font-size:13px}${u}[data-size=sm]>.blipit-rb-m{width:24px;height:24px}${u}[data-size=sm] svg{width:15px;height:13px}${u}[data-variant=outline],${u}[data-variant=ghost]{color:#0B1A3A;background:transparent;box-shadow:inset 0 0 0 1px #CBD7EA}${u}[data-variant=ghost]{box-shadow:none}${u}[data-variant=outline]:hover,${u}[data-variant=ghost]:hover{transform:none;background:rgba(56,130,246,.08);box-shadow:inset 0 0 0 1px rgba(56,130,246,.45)}${u}[data-variant=ghost]:hover{box-shadow:none}${u}[data-theme=dark]{background:linear-gradient(135deg,#5B9BFF,#3D6BF0);box-shadow:0 10px 24px -12px rgba(91,155,255,.7),inset 0 1px 0 rgba(255,255,255,.2)}${u}[data-theme=dark][data-variant=outline],${u}[data-theme=dark][data-variant=ghost]{color:#E8EEF8;background:transparent;box-shadow:inset 0 0 0 1px rgba(255,255,255,.16)}${u}[data-theme=dark][data-variant=ghost]{box-shadow:none}${u}[data-theme=dark][data-variant=outline]:hover,${u}[data-theme=dark][data-variant=ghost]:hover{background:rgba(91,155,255,.16);box-shadow:inset 0 0 0 1px rgba(91,155,255,.45)}${u}[data-theme=dark][data-variant=ghost]:hover{box-shadow:none}${u}[data-theme=dark]>.blipit-rb-m{box-shadow:0 0 0 1px rgba(255,255,255,.1)}${u}[aria-busy=true] svg{visibility:hidden}${u}[aria-busy=true]>.blipit-rb-m::after{content:"";position:absolute;inset:4px;border:2px solid #3882F6;border-right-color:transparent;border-radius:50%;animation:blipit-rb-r .8s linear infinite}@keyframes blipit-rb-r{to{transform:rotate(1turn)}}@media(pointer:coarse){${u}{min-height:44px}}@media(prefers-reduced-motion:reduce){${u}{transition:none}${u}:hover,${u}:active{transform:none}${u}[aria-busy=true]>.blipit-rb-m::after{animation-duration:3s}}@media(forced-colors:active){${u}{border:1px solid ButtonText}}`,Le=0;function Me(e,t={}){Le||N(document,dt);let n=++Le,i=document.createElement("span");i.className="blipit-rb-m",i.innerHTML=Ce.replace(/bm(\d)/g,`bm$1-${n}`);let r=document.createElement("span");r.textContent=e.textContent,e.replaceChildren(i,r),e.classList.add("blipit-rb"),e.setAttribute("data-variant",t.variant==="outline"||t.variant==="ghost"?t.variant:"solid"),e.setAttribute("data-size",t.size==="sm"?"sm":"md"),e.setAttribute("data-theme",ue(t.theme==="light"||t.theme==="dark"?t.theme:void 0))}var g,Oe=new Set;function Ie(e,t){Oe.has(t)||(Oe.add(t),console[e](t))}var ct="[blipit] init() has no key, so error tracking and the Report a bug button are off. Pass your public key (blipit_pk_...) from app.blipit.io, API keys.",ut="[blipit] init() got a secret key (blipit_sk_...), so Blipit did not start: secret keys must never be in browser code. Use the public key (blipit_pk_...) and create a new secret key in app.blipit.io, API keys.";function pt(e){if(g)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return Ie("warn",ct);if(t.startsWith("blipit_sk_"))return Ie("error",ut);if(g=new P({...e,key:t}),e.user){let{id:n,name:i,email:r,username:o}=e.user;g.setUser({id:n===void 0?void 0:String(n),email:r,username:o??i})}$e(g),e.webVitals!==!1&&typeof window<"u"&&Te(e.endpoint??z,t,e.instance),e.replay&&(g.replay=_e(e.replay,e.endpoint??z,t,e.instance,U)),typeof window<"u"&&Q(g),e.debug&&console.log(`[blipit] ${V}@${M} initialized`)}function lt(e){return g?.captureException(e,!0)}function ft(e,t){return g?.captureMessage(e,t)}function mt(e){return g?.captureSecurity(e)}function gt(e){g?.setUser(e)}function ht(e,t){g?.setTag(e,t)}function bt(e){g?.addBreadcrumb(e)}function yt(e={}){g&&Z(g,{...e,eventId:e.eventId??g.lastEventId})}function te(){g&&K(g)}function vt(e){e.addEventListener("click",t=>{t.preventDefault(),te()})}function xt(e={}){let t=xe(e.label,te);return Me(t,e),t}function kt(e){g&&Ee(g,e)}function wt(){return g?.flush()??Promise.resolve()}we(oe);0&&(module.exports={addBreadcrumb,attachReport,captureException,captureMessage,captureSecurity,flush,init,openReport,reportButton,setReportMetadata,setTag,setUser,showFeedback,updateWidget});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { BlipitEvent, SecurityKind, Breadcrumb, Level } from '@blipit/schema';
|
|
2
2
|
export { BlipitEvent, BlipitSecurity, Breadcrumb, Level, SecurityKind } from '@blipit/schema';
|
|
3
3
|
|
|
4
|
+
interface FeedbackOptions {
|
|
5
|
+
eventId?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
interface WidgetOptions {
|
|
5
12
|
position?: "bottom-right" | "bottom-left" | "middle-right" | "middle-left";
|
|
6
13
|
color?: string;
|
|
@@ -61,13 +68,6 @@ interface SecurityReport {
|
|
|
61
68
|
target?: string;
|
|
62
69
|
}
|
|
63
70
|
|
|
64
|
-
interface FeedbackOptions {
|
|
65
|
-
eventId?: string;
|
|
66
|
-
title?: string;
|
|
67
|
-
name?: string;
|
|
68
|
-
email?: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
71
|
interface ReportButtonOptions {
|
|
72
72
|
label?: string;
|
|
73
73
|
variant?: "solid" | "outline" | "ghost";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { BlipitEvent, SecurityKind, Breadcrumb, Level } from '@blipit/schema';
|
|
2
2
|
export { BlipitEvent, BlipitSecurity, Breadcrumb, Level, SecurityKind } from '@blipit/schema';
|
|
3
3
|
|
|
4
|
+
interface FeedbackOptions {
|
|
5
|
+
eventId?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
interface WidgetOptions {
|
|
5
12
|
position?: "bottom-right" | "bottom-left" | "middle-right" | "middle-left";
|
|
6
13
|
color?: string;
|
|
@@ -61,13 +68,6 @@ interface SecurityReport {
|
|
|
61
68
|
target?: string;
|
|
62
69
|
}
|
|
63
70
|
|
|
64
|
-
interface FeedbackOptions {
|
|
65
|
-
eventId?: string;
|
|
66
|
-
title?: string;
|
|
67
|
-
name?: string;
|
|
68
|
-
email?: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
71
|
interface ReportButtonOptions {
|
|
72
72
|
label?: string;
|
|
73
73
|
variant?: "solid" | "outline" | "ghost";
|
package/dist/index.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var Blipit=(()=>{var
|
|
2
|
-
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let r=Ae.exec(n)??Ne.exec(n);if(!r)continue;let[,i,o,c,d]=r;if(!o)continue;let s={filename:l(o,1024),in_app:Ue(o)};i&&(s.function=l(i,512)),c&&(s.lineno=Number(c)),d&&(s.colno=Number(d)),t.push(s)}return t.reverse(),t.slice(-128)}function ue(e){return e.length===0?!1:e.every(t=>de.test(t.filename))}var H="@blipit/browser",O="0.3.7",M=se(typeof document<"u"?document.currentScript?.src:void 0,O),D="https://in.blipit.io/api/v1/events",De=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Ke={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},je={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function Fe(e){if(!ie.includes(e?.kind))return;let t=l(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=l(String(e.actorId),128)),e.ip&&(n.ip=l(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=l(String(e.userAgent),512)),e.database&&(n.database=l(String(e.database),64)),e.outcome&&(n.outcome=l(String(e.outcome),64)),e.target&&(n.target=l(String(e.target),256)),n}var U=class{constructor(t){this.options=t;this.endpoint=t.endpoint??D,this.transport=new N(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new P(S(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...De,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[l(t,64)]=l(n,256)}addBreadcrumb(t){let n={timestamp:y(),...t};n.message&&(n.message=re(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:C(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){let r=t instanceof Error?t:new Error(String(t)),i={type:r.name||"Error",value:l(r.message||String(r),4096),handled:n},o=ce(r.stack);return o.length>0&&(i.stacktrace={frames:o}),this.processAndSend({exception:i,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:l(t,8192),level:n})}captureSecurity(t){let n=Fe(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${Ke[n.kind]} for ${n.actor}`,level:je[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let r=t.exception?.value??t.message??"";if(n){for(let d of this.ignoreErrors)if(typeof d=="string"?r.includes(d):d.test(r))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&ue(t.exception.stacktrace.frames))return;let c=`${t.exception?.type??""}|${r}`;if(t.exception?.handled===!1){if(this.seen.has(c)&&this.seen.size<100)return;this.seen.add(c),setTimeout(()=>this.seen.delete(c),5e3)}}let i={event_id:L(),timestamp:y(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:C(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:H,version:O},...t};for(let c of Object.keys(i))i[c]===void 0&&delete i[c];let o=this.replay?.active()&&(i.level==="error"||i.level==="fatal")?this.replay:void 0;if(o&&(i.tags={...i.tags,replay_id:o.id}),this.options.beforeSend){let c=this.options.beforeSend(i);if(!c)return;i=c}return this.transport.enqueue(i),this.lastEventId=i.event_id,(i.level==="error"||i.level==="fatal")&&k(this.errorIds,i.event_id,20),i.exception&&this.session?.markError(i.exception.handled===!1),o?.error(i.event_id),i.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",r=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;r&&(t.browser={name:r[1],version:r[2]});let i=/\(([^)]+)\)/.exec(n);return i&&i[1]&&(t.os={name:l(i[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};function X(e){return typeof e=="string"?e.length:e?.size}function pe(e){return e&&Number(e)||void 0}function qe(e,t){return async(n,r)=>{let i=typeof n=="string"?n:n instanceof URL?n.href:n.url,o=(r?.method??n.method??"GET").toUpperCase(),c=Date.now();try{let d=await e(n,r);return t(o,i,d.status,c,X(r?.body),pe(d.headers.get("content-length"))),d}catch(d){throw t(o,i,0,c,X(r?.body)),d}}}function We(e,t){let n=e.open,r=e.send;e.open=function(i,o){return this._blipit=[String(i).toUpperCase(),String(o)],n.apply(this,arguments)},e.send=function(i){let o=this._blipit;if(o){let c=Date.now();this.addEventListener("loadend",()=>t(o[0],o[1],this.status,c,X(i),pe(this.getResponseHeader("content-length"))))}return r.apply(this,arguments)}}function le(e){if(typeof window>"u")return;let t=S(e.endpoint,""),{console:n,network:r,actions:i}=e.logs;window.addEventListener("error",s=>{e.captureException(s.error??s.message,!1)}),window.addEventListener("unhandledrejection",s=>{e.captureException(s.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",s=>{let a=s.target;if(!(a instanceof Element)||a.closest("[data-blipit-ui]"))return;let u=z(a);e.addBreadcrumb({category:"ui.click",message:`Clicked ${u}`});let h=a.closest(oe)?"***":l((a.textContent??"").trim().replace(/\s+/g," "),80);k(i,{timestamp:y(),type:"click",selector:u,text:h},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",s=>{let a=s.target;a instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(a.tagName)&&k(i,{timestamp:y(),type:"focus",selector:z(a)},50)},{capture:!0,passive:!0}));let o=(s,a,u,h,p,m)=>{t&&a.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${s} ${C(a)} \u2192 ${u||"network error"}`,level:u>=400||!u?"error":"info",data:{url:C(a),method:s,status_code:u||void 0}}),k(r,{timestamp:y(),method:s,url:W(a),status:u,duration:Date.now()-h,request_size:p,response_size:m},50))};typeof window.fetch=="function"&&(window.fetch=qe(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&We(XMLHttpRequest.prototype,o);for(let s of["log","info","debug","warn","error"]){let a=console[s].bind(console);console[s]=(...u)=>{let h=l(u.map(p=>typeof p=="string"?p:ze(p)).join(" "),1024);if(s==="warn"||s==="error"){e.addBreadcrumb({category:"console",level:s==="warn"?"warning":"error",message:h});let p=u.find(m=>m instanceof Error);k(n,{timestamp:y(),level:s,message:h,stack:l((p??new Error).stack??"",2e3)},100)}else k(n,{timestamp:y(),level:s,message:h},100);a(...u)}}let c=()=>k(i,{timestamp:y(),type:"navigation",url:W(location.href)},50),d=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${C(location.href)}`}),c()};if(c(),window.history){let s=window.history.pushState.bind(window.history);window.history.pushState=(...a)=>{s(...a),d()},window.addEventListener("popstate",d)}}function ze(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function fe(){let e=0,t=0,n=0,r=0;return i=>(i.hadRecentInput||(t>0&&i.startTime-r<1e3&&i.startTime-n<5e3?t+=i.value:(t=i.value,n=i.startTime),r=i.startTime,t>e&&(e=t)),e)}function He(e){if(e.size===0)return;let t=[...e.values()].sort((n,r)=>r-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function Xe(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function I(e,t,n){try{new PerformanceObserver(r=>r.getEntries().forEach(i=>t(i))).observe({type:e,buffered:!0,...n})}catch{}}function me(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let r=performance.getEntriesByType("navigation")[0],i=r?.activationStart??0,o=b=>Math.max(0,Math.round(b-i)),c=document.visibilityState==="hidden",d=location.pathname,s=r?.type,a={},u=fe(),h=new Map,p=!1,m=!1;r&&r.responseStart>0&&(a.ttfb=o(r.responseStart)),c||(I("paint",b=>{b.name==="first-contentful-paint"&&(a.fcp=o(b.startTime))}),I("largest-contentful-paint",b=>{p||(a.lcp=o(b.startTime))}));let R=()=>{p=!0};addEventListener("keydown",R,{once:!0,capture:!0}),addEventListener("pointerdown",R,{once:!0,capture:!0}),I("layout-shift",b=>{a.cls=Math.round(u(b)*1e4)/1e4});let _=b=>{if(!b.interactionId)return;h.set(b.interactionId,Math.max(h.get(b.interactionId)??0,b.duration));let ne=He(h);ne!==void 0&&(a.inp=Math.round(ne))};I("event",_,{durationThreshold:40}),I("first-input",_);let x=navigator.connection?.effectiveType,g=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,w=()=>{if(m||Object.keys(a).length===0)return;m=!0;let b=JSON.stringify({path:d.slice(0,512),metrics:a,nav:s,connection:x&&/^(slow-2g|2g|3g|4g)$/.test(x)?x:void 0,device:Xe(navigator.userAgent)});try{if(navigator.sendBeacon?.(g,b))return}catch{}fetch(g,{method:"POST",body:b,keepalive:!0}).catch(()=>{})},T=()=>{location.pathname!==d&&(w(),d=location.pathname,s="route",a={},u=fe(),h=new Map,p=!0,m=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&w()),addEventListener("pagehide",w),addEventListener("popstate",T);let A=history.pushState;history.pushState=function(...b){A.apply(this,b),T()}}function Ve(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function ge(e,t,n,r,i){let o=Ve(e);if(!o||typeof document>"u")return;let c=L(),d,s=document.createElement("script");return s.src=e.src??`${i}blipit-replay.js`,s.async=!0,s.onload=()=>{let a=window.BlipitReplay?.start;d=a?.({id:c,mode:o,endpoint:t,key:n,instance:r})},document.head.appendChild(s),{id:c,active:()=>d?.active()??!1,error:a=>d?.error(a),report:a=>d?.report?.(a)}}var he={en:["Report {ref} sent.","We will email you updates."],ar:["\u062A\u0645 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0628\u0644\u0627\u063A {ref}.","\u0633\u0646\u0631\u0627\u0633\u0644\u0643 \u0628\u0627\u0644\u062A\u062D\u062F\u064A\u062B\u0627\u062A."],de:["Meldung {ref} gesendet.","Wir informieren Sie per E-Mail."],es:["Reporte {ref} enviado.","Te enviaremos novedades por correo."],fr:["Signalement {ref} envoy\xE9.","Nous vous tiendrons au courant par e-mail."],it:["Segnalazione {ref} inviata.","Ti invieremo aggiornamenti via email."],ja:["\u5831\u544A {ref} \u3092\u9001\u4FE1\u3057\u307E\u3057\u305F\u3002","\u9032\u6357\u306F\u30E1\u30FC\u30EB\u3067\u304A\u77E5\u3089\u305B\u3057\u307E\u3059\u3002"],nl:["Melding {ref} verstuurd.","We mailen je updates."],pt:["Relato {ref} enviado.","Vamos enviar novidades por e-mail."],tr:["{ref} numaral\u0131 bildirim g\xF6nderildi.","Geli\u015Fmeleri e-postayla bildirece\u011Fiz."],zh:["\u62A5\u544A {ref} \u5DF2\u53D1\u9001\u3002","\u6211\u4EEC\u4F1A\u901A\u8FC7\u90AE\u4EF6\u544A\u77E5\u8FDB\u5C55\u3002"]};function Ye(e,t,n){if(typeof e!="string"||!/^BR-\d{1,12}$/.test(e))return null;let[r,i]=he[n.toLowerCase().split(/[-_]/)[0]]??he.en;return`${r.replace("{ref}",e)}${t===!0?` ${i}`:""}`}function v(e,t,n){let r=document.createElement(e);return r.style.cssText=t,n!==void 0&&(r.textContent=n),r}var V="display:block;width:100%;box-sizing:border-box;margin:4px 0 12px;padding:8px 10px;font:inherit;border:1px solid #c5ccd6;border-radius:6px;background:#fff;color:#111",be="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",Y=!1;function K(e,t,n){if(Y||typeof document>"u"||!document.body)return;Y=!0;let r=v("dialog","max-width:420px;width:calc(100% - 32px);padding:20px;border:1px solid #c5ccd6;border-radius:10px;font:14px/1.45 system-ui,sans-serif;color:#111;background:#fff");r.setAttribute("aria-labelledby","blipit-fb-title");let i=v("form","margin:0"),o=v("h2","margin:0 0 12px;font-size:17px",n.title??"Tell us what happened");o.id="blipit-fb-title";let c=(x,g,w)=>{let T=v("label","display:block;font-weight:600",x);T.htmlFor=w,g.id=w,i.append(T,g)},d=v("input",V);d.type="text",d.maxLength=128,d.autocomplete="name",d.value=n.name??"";let s=v("input",V);s.type="email",s.maxLength=254,s.autocomplete="email",s.value=n.email??"";let a=v("textarea",`${V};min-height:110px;resize:vertical`);a.required=!0,a.maxLength=5e3;let u=v("p","margin:0 0 12px;min-height:1.2em;font-size:13px");u.setAttribute("role","status"),u.setAttribute("aria-live","polite");let h=v("div","display:flex;gap:8px;justify-content:flex-end"),p=v("button",be,"Cancel");p.type="button";let m=v("button",`${be};background:#111;color:#fff;border-color:#111`,"Send");m.type="submit",i.append(o),c("Name (optional)",d,"blipit-fb-name"),c("Email (optional)",s,"blipit-fb-email"),c("What went wrong?",a,"blipit-fb-message"),h.append(p,m),i.append(u,h),r.append(i),document.body.append(r);let R=()=>{Y=!1,r.remove()},_=()=>typeof r.close=="function"&&r.open?r.close():R();p.addEventListener("click",_),r.addEventListener("close",R),i.addEventListener("submit",async x=>{x.preventDefault();let g=a.value.trim();if(!g){u.textContent="Please describe what happened.",a.focus();return}m.disabled=!0,p.disabled=!0,m.setAttribute("aria-busy","true"),m.textContent="Sending\u2026",u.textContent="";try{let w=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":t},body:JSON.stringify({name:d.value.trim()||void 0,email:s.value.trim()||void 0,message:g,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!w.ok)throw new Error(String(w.status));let T=await w.json().catch(()=>({})),A=Ye(T.ref,T.emails,typeof navigator>"u"?"en":navigator.language??"en");u.textContent=A??"Thanks, your message was sent.",m.textContent="Sent",setTimeout(_,A?4e3:1200)}catch{u.textContent="That did not send. Please try again.",m.disabled=!1,p.disabled=!1,m.removeAttribute("aria-busy"),m.textContent="Send"}}),typeof r.showModal=="function"?r.showModal():r.setAttribute("open",""),a.focus()}var G={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},Je="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",Ge='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',ve,J={},xe,E,Q=()=>{},B,ye=0;function $(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function we(e){ve=e}function Z(e,t){return J[t]??=new Promise((n,r)=>{let i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>{let o=window[t];o?n(o):r(new Error(t))},i.onerror=r,document.head.appendChild(i)}).catch(n=>{throw delete J[t],n}),J[t]}function Se(){let e=(navigator.language??"en").slice(0,2);return G[e]?e:"en"}function ee(e,t){let n=document.createElement("button");return n.type="button",n.className="blipit-rb",n.setAttribute("aria-haspopup","dialog"),e?n.textContent=e:(n.lang=Se(),n.textContent=G[n.lang][0]),n.addEventListener("click",()=>n.hasAttribute("aria-busy")||t()),n}function j(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{},n=document.querySelectorAll("button.blipit-rb"),r=i=>{Q(i),n.forEach(o=>i?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))};r(!0),Promise.all([Z(t.src??`${M}blipit-report.js`,"BlipitReport"),xe??=ke(e)]).then(([i,o])=>o.enabled!==!1&&i.open(e,{metadata:ve,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:c=>E&&(E.style.display=c?"none":"")}),()=>K(S(e.endpoint,"/api/v1/feedback"),e.options.key,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>r(!1))}async function ke(e){let t=`blipit_fb_${O}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(S(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return $(e,`widget settings failed (HTTP ${n.status}), using defaults`),{};let r=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:r}))}catch{}return r}catch{return $(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function te(e){let t=e.options.feedbackWidget,n=++ye;if(typeof document>"u")return;if(t===!1)return $(e,"Report a bug button off: feedbackWidget is false");let r=await(xe??=ke(e));if(n!==ye)return;if(r.enabled===!1)return $(e,"Report a bug button hidden by the project's Bug report widget setting");let i={...r,...typeof t=="object"?t:{}},[o,c]=G[Se()],d=i.text||o;E=document.createElement("div"),E.setAttribute("data-blipit-ui","");let s=E.attachShadow({mode:"open"}),a=document.createElement("style");a.textContent=Je;let u=document.createElement("button");u.type="button";let[h,p]=(/^(bottom|middle)-(left|right)$/.test(i.position??"")?i.position:"bottom-right").split("-");u.style.cssText=`${i.color?`--c:${i.color};`:""}${p}:calc(20px + env(safe-area-inset-${p},0px));${h==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,u.setAttribute("aria-haspopup","dialog"),i.style==="icon"&&(u.className="o",u.title=d);let m=g=>{u.disabled=g,u.setAttribute("aria-label",g?c:d),u.innerHTML=g?"<i></i><span></span>":`${Ge}<span></span>`,u.lastChild.textContent=g?c:d};Q=m,m(!1),u.addEventListener("click",()=>j(e)),s.append(a,u);let R=i.shortcut?.toLowerCase().replace(/\s/g,"");B&&document.removeEventListener("keydown",B),B=void 0,R&&(B=g=>{[g.ctrlKey&&"ctrl",g.shiftKey&&"shift",g.altKey&&"alt",g.metaKey&&"meta",g.key.toLowerCase()].filter(Boolean).join("+")===R&&(g.preventDefault(),j(e))},document.addEventListener("keydown",B));let _=E,x=()=>{E===_&&(document.body.append(_),$(e,`Report a bug button shown at ${h}-${p}`))};document.body?x():document.addEventListener("DOMContentLoaded",x)}function Ee(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},E?.remove(),E=void 0,B&&document.removeEventListener("keydown",B),B=void 0,Q=()=>{},te(e)}var f,Re=new Set;function _e(e,t){Re.has(t)||(Re.add(t),console[e](t))}var Qe="[blipit] init() has no key, so error tracking and the Report a bug button are off. Pass your public key (blipit_pk_...) from app.blipit.io, API keys.",Ze="[blipit] init() got a secret key (blipit_sk_...), so Blipit did not start: secret keys must never be in browser code. Use the public key (blipit_pk_...) and create a new secret key in app.blipit.io, API keys.";function et(e){if(f)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return _e("warn",Qe);if(t.startsWith("blipit_sk_"))return _e("error",Ze);if(f=new U({...e,key:t}),e.user){let{id:n,name:r,email:i,username:o}=e.user;f.setUser({id:n===void 0?void 0:String(n),email:i,username:o??r})}le(f),e.webVitals!==!1&&typeof window<"u"&&me(e.endpoint??D,t,e.instance),e.replay&&(f.replay=ge(e.replay,e.endpoint??D,t,e.instance,M)),typeof window<"u"&&te(f),e.debug&&console.log(`[blipit] ${H}@${O} initialized`)}function tt(e){return f?.captureException(e,!0)}function nt(e,t){return f?.captureMessage(e,t)}function it(e){return f?.captureSecurity(e)}function rt(e){f?.setUser(e)}function ot(e,t){f?.setTag(e,t)}function st(e){f?.addBreadcrumb(e)}function at(e={}){f&&K(S(f.endpoint,"/api/v1/feedback"),f.options.key,{...e,eventId:e.eventId??f.lastEventId})}function F(){f&&j(f)}function dt(e){e.addEventListener("click",t=>{t.preventDefault(),F()})}function ct(e){f&&Ee(f,e)}function ut(){return f?.flush()??Promise.resolve()}function pt(e={}){let t=ee(e.label,F);return t.style.visibility="hidden",Z(`${M}blipit-button.js`,"BlipitButton").then(n=>n.paint(t,e)).catch(()=>{}).then(()=>t.style.removeProperty("visibility")),t}return Me(lt);})();
|
|
1
|
+
"use strict";var Blipit=(()=>{var U=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Be=Object.prototype.hasOwnProperty;var Te=(e,t)=>{for(var n in t)U(e,n,{get:t[n],enumerable:!0})},Oe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of _e(t))!Be.call(e,i)&&i!==n&&U(e,i,{get:()=>t[i],enumerable:!(r=Re(t,i))||r.enumerable});return e};var Ce=e=>Oe(U({},"__esModule",{value:!0}),e);var ct={};Te(ct,{addBreadcrumb:()=>it,attachReport:()=>ot,captureException:()=>Qe,captureMessage:()=>Ze,captureSecurity:()=>et,flush:()=>at,init:()=>Ge,openReport:()=>D,reportButton:()=>dt,setReportMetadata:()=>he,setTag:()=>nt,setUser:()=>tt,showFeedback:()=>rt,updateWidget:()=>st});var Z=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var I=class{constructor(t,n,r,i){this.endpoint=t;this.key=n;this.debug=r;this.instance=i;typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flushWithBeacon()})}endpoint;key;debug;instance;queue=[];timer;sending=!1;enqueue(t){this.queue.push(t),this.queue.length>30&&this.queue.shift(),this.timer||(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},1e3))}async flush(){if(!this.sending){this.sending=!0;try{for(;this.queue.length>0;){let t=this.queue[0];if(!await this.send(t))break;this.queue.shift()}}finally{this.sending=!1}}}async send(t,n=0){try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key,...this.instance?{"X-Blipit-Instance":this.instance}:{}},body:JSON.stringify(t),keepalive:!0});return r.status===429||r.status>=500?this.retry(t,n):(this.debug&&r.status>=400&&console.warn("[blipit] event rejected",r.status,await r.text()),!0)}catch{return this.retry(t,n)}}async retry(t,n){return n>=2?(this.debug&&console.warn("[blipit] dropping event after retries",t.event_id),!0):(await new Promise(r=>setTimeout(r,1e3*2**n)),this.send(t,n+1))}flushWithBeacon(){if(!(typeof navigator>"u"||!navigator.sendBeacon))for(;this.queue.length>0;){let t=this.queue.shift(),n=`key=${encodeURIComponent(this.key)}${this.instance?`&instance=${encodeURIComponent(this.instance)}`:""}`,r=`${this.endpoint}${this.endpoint.includes("?")?"&":"?"}${n}`;navigator.sendBeacon(r,JSON.stringify(t))}}};function R(){let e=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0");return t}function b(){return new Date().toISOString()}var Ie=/token|key|password|secret|auth|session|passwd|api/i;function w(e){let t=e.indexOf("?");if(t===-1)return e.slice(0,2048);let n=e.slice(0,t),i=e.slice(t+1).split("&").map(o=>{let d=o.indexOf("=");if(d===-1)return o;let c=o.slice(0,d);return Ie.test(c)?`${c}=[redacted]`:o}).join("&");return`${n}?${i}`.slice(0,2048)}var Le=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function ee(e){return e.replace(Le,"$1[redacted]")}function u(e,t){return e.length>t?e.slice(0,t):e}var te=".blipit-mask,[data-blipit-mask]";function F(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function v(e,t,n){e.push(t),e.length>n&&e.shift()}function j(e){let t=e.id?`#${e.id}`:"",n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return u(`${e.tagName.toLowerCase()}${t}${n}`,128)}function ne(e,t){try{let n=new CSSStyleSheet;n.replaceSync(t),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]}catch{let n=document.createElement("style");n.textContent=t,(e===document?document.head:e).append(n)}}function S(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function ie(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}var re={ok:0,errored:1,crashed:2},L=class{constructor(t,n,r,i){this.url=t;this.key=n;this.release=r;this.environment=i;this.start(),typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.end():this.sid||this.start()})}url;key;release;environment;sid="";started="";status="ok";errors=0;did;setUser(t){this.did=t}markError(t){if(!this.sid)return;this.errors+=1;let n=t?"crashed":"errored";re[n]<=re[this.status]||(this.status=n,this.send(!1))}start(){this.sid=R(),this.started=b(),this.status="ok",this.errors=0,this.send(!1)}end(){this.sid&&(this.send(!0),this.sid="")}send(t){let n=JSON.stringify({sid:this.sid,did:this.did,status:this.status==="ok"&&t?"exited":this.status,errors:this.errors,started:this.started,release:this.release,environment:this.environment}),r=`${this.url}?key=${encodeURIComponent(this.key)}`;try{if(t&&typeof navigator<"u"&&navigator.sendBeacon){navigator.sendBeacon(r,n);return}if(typeof fetch>"u")return;fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key},body:n,keepalive:!0}).catch(()=>{})}catch{return}}};var $e=/^\s*at (?:async )?(?:new )?(?:(.+?) )?\(?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack):.*?|[^()]+?)(?::(\d+))?(?::(\d+))?\)?\s*$/,Me=/^\s*(?:(.*?)@)?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack).*?|[^@]*?)(?::(\d+))?(?::(\d+))?\s*$/,oe=/^(chrome|moz|safari-web)-extension:/;function Ae(){if(typeof location<"u"&&location.origin)return location.origin}function Ne(e){if(oe.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=Ae();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function se(e){if(!e)return[];let t=[];for(let n of e.split(`
|
|
2
|
+
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let r=$e.exec(n)??Me.exec(n);if(!r)continue;let[,i,o,d,c]=r;if(!o)continue;let a={filename:u(o,1024),in_app:Ne(o)};i&&(a.function=u(i,512)),d&&(a.lineno=Number(d)),c&&(a.colno=Number(c)),t.push(a)}return t.reverse(),t.slice(-128)}function ae(e){return e.length===0?!1:e.every(t=>oe.test(t.filename))}var K="@blipit/browser",_="0.3.8",E=ie(typeof document<"u"?document.currentScript?.src:void 0,_),M="https://in.blipit.io/api/v1/events",De=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Pe={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},Ue={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function Fe(e){if(!Z.includes(e?.kind))return;let t=u(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=u(String(e.actorId),128)),e.ip&&(n.ip=u(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=u(String(e.userAgent),512)),e.database&&(n.database=u(String(e.database),64)),e.outcome&&(n.outcome=u(String(e.outcome),64)),e.target&&(n.target=u(String(e.target),256)),n}var $=class{constructor(t){this.options=t;this.endpoint=t.endpoint??M,this.transport=new I(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new L(S(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...De,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;captured=new WeakSet;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[u(t,64)]=u(n,256)}addBreadcrumb(t){let n={timestamp:b(),...t};n.message&&(n.message=ee(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:w(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){if(t&&typeof t=="object"){if(this.captured.has(t))return;this.captured.add(t)}let r=t instanceof Error?t:new Error(String(t)),i={type:r.name||"Error",value:u(r.message||String(r),4096),handled:n},o=se(r.stack);return o.length>0&&(i.stacktrace={frames:o}),this.processAndSend({exception:i,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:u(t,8192),level:n})}captureSecurity(t){let n=Fe(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${Pe[n.kind]} for ${n.actor}`,level:Ue[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let r=t.exception?.value??t.message??"";if(n){for(let c of this.ignoreErrors)if(typeof c=="string"?r.includes(c):c.test(r))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&ae(t.exception.stacktrace.frames))return;let d=`${t.exception?.type??""}|${r}`;if(t.exception?.handled===!1){if(this.seen.has(d)&&this.seen.size<100)return;this.seen.add(d),setTimeout(()=>this.seen.delete(d),5e3)}}let i={event_id:R(),timestamp:b(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:w(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:K,version:_},...t};for(let d of Object.keys(i))i[d]===void 0&&delete i[d];let o=this.replay?.active()&&(i.level==="error"||i.level==="fatal")?this.replay:void 0;if(o&&(i.tags={...i.tags,replay_id:o.id}),this.options.beforeSend){let d=this.options.beforeSend(i);if(!d)return;i=d}return this.transport.enqueue(i),this.lastEventId=i.event_id,(i.level==="error"||i.level==="fatal")&&v(this.errorIds,i.event_id,20),i.exception&&this.session?.markError(i.exception.handled===!1),o?.error(i.event_id),i.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",r=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;r&&(t.browser={name:r[1],version:r[2]});let i=/\(([^)]+)\)/.exec(n);return i&&i[1]&&(t.os={name:u(i[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};function q(e){return typeof e=="string"?e.length:e?.size}function de(e){return e&&Number(e)||void 0}function je(e,t){return async(n,r)=>{let i=typeof n=="string"?n:n instanceof URL?n.href:n.url,o=(r?.method??n.method??"GET").toUpperCase(),d=Date.now();try{let c=await e(n,r);return t(o,i,c.status,d,q(r?.body),de(c.headers.get("content-length"))),c}catch(c){throw t(o,i,0,d,q(r?.body)),c}}}function Ke(e,t){let n=e.open,r=e.send;e.open=function(i,o){return this._blipit=[String(i).toUpperCase(),String(o)],n.apply(this,arguments)},e.send=function(i){let o=this._blipit;if(o){let d=Date.now();this.addEventListener("loadend",()=>t(o[0],o[1],this.status,d,q(i),de(this.getResponseHeader("content-length"))))}return r.apply(this,arguments)}}function ce(e){if(typeof window>"u")return;let t=S(e.endpoint,""),{console:n,network:r,actions:i}=e.logs;window.addEventListener("error",a=>{e.captureException(a.error??a.message,!1)}),window.addEventListener("unhandledrejection",a=>{e.captureException(a.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",a=>{let s=a.target;if(!(s instanceof Element)||s.closest("[data-blipit-ui]"))return;let l=j(s);e.addBreadcrumb({category:"ui.click",message:`Clicked ${l}`});let m=s.closest(te)?"***":u((s.textContent??"").trim().replace(/\s+/g," "),80);v(i,{timestamp:b(),type:"click",selector:l,text:m},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",a=>{let s=a.target;s instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(s.tagName)&&v(i,{timestamp:b(),type:"focus",selector:j(s)},50)},{capture:!0,passive:!0}));let o=(a,s,l,m,h,y)=>{t&&s.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${a} ${w(s)} \u2192 ${l||"network error"}`,level:l>=400||!l?"error":"info",data:{url:w(s),method:a,status_code:l||void 0}}),v(r,{timestamp:b(),method:a,url:F(s),status:l,duration:Date.now()-m,request_size:h,response_size:y},50))};typeof window.fetch=="function"&&(window.fetch=je(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&Ke(XMLHttpRequest.prototype,o);for(let a of["log","info","debug","warn","error"]){let s=console[a].bind(console);console[a]=(...l)=>{let m=u(l.map(h=>typeof h=="string"?h:qe(h)).join(" "),1024);if(a==="warn"||a==="error"){e.addBreadcrumb({category:"console",level:a==="warn"?"warning":"error",message:m});let h=l.find(y=>y instanceof Error);v(n,{timestamp:b(),level:a,message:m,stack:u((h??new Error).stack??"",2e3)},100)}else v(n,{timestamp:b(),level:a,message:m},100);s(...l)}}let d=()=>v(i,{timestamp:b(),type:"navigation",url:F(location.href)},50),c=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${w(location.href)}`}),d()};if(d(),window.history){let a=window.history.pushState.bind(window.history);window.history.pushState=(...s)=>{a(...s),c()},window.addEventListener("popstate",c)}}function qe(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function ue(){let e=0,t=0,n=0,r=0;return i=>(i.hadRecentInput||(t>0&&i.startTime-r<1e3&&i.startTime-n<5e3?t+=i.value:(t=i.value,n=i.startTime),r=i.startTime,t>e&&(e=t)),e)}function We(e){if(e.size===0)return;let t=[...e.values()].sort((n,r)=>r-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function He(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function O(e,t,n){try{new PerformanceObserver(r=>r.getEntries().forEach(i=>t(i))).observe({type:e,buffered:!0,...n})}catch{}}function pe(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let r=performance.getEntriesByType("navigation")[0],i=r?.activationStart??0,o=f=>Math.max(0,Math.round(f-i)),d=document.visibilityState==="hidden",c=location.pathname,a=r?.type,s={},l=ue(),m=new Map,h=!1,y=!1;r&&r.responseStart>0&&(s.ttfb=o(r.responseStart)),d||(O("paint",f=>{f.name==="first-contentful-paint"&&(s.fcp=o(f.startTime))}),O("largest-contentful-paint",f=>{h||(s.lcp=o(f.startTime))}));let B=()=>{h=!0};addEventListener("keydown",B,{once:!0,capture:!0}),addEventListener("pointerdown",B,{once:!0,capture:!0}),O("layout-shift",f=>{s.cls=Math.round(l(f)*1e4)/1e4});let T=f=>{if(!f.interactionId)return;m.set(f.interactionId,Math.max(m.get(f.interactionId)??0,f.duration));let Q=We(m);Q!==void 0&&(s.inp=Math.round(Q))};O("event",T,{durationThreshold:40}),O("first-input",T);let g=navigator.connection?.effectiveType,J=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,P=()=>{if(y||Object.keys(s).length===0)return;y=!0;let f=JSON.stringify({path:c.slice(0,512),metrics:s,nav:a,connection:g&&/^(slow-2g|2g|3g|4g)$/.test(g)?g:void 0,device:He(navigator.userAgent)});try{if(navigator.sendBeacon?.(J,f))return}catch{}fetch(J,{method:"POST",body:f,keepalive:!0}).catch(()=>{})},G=()=>{location.pathname!==c&&(P(),c=location.pathname,a="route",s={},l=ue(),m=new Map,h=!0,y=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&P()),addEventListener("pagehide",P),addEventListener("popstate",G);let Ee=history.pushState;history.pushState=function(...f){Ee.apply(this,f),G()}}function ze(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function le(e,t,n,r,i){let o=ze(e);if(!o||typeof document>"u")return;let d=R(),c,a=document.createElement("script");return a.src=e.src??`${i}blipit-replay.js`,a.async=!0,a.onload=()=>{let s=window.BlipitReplay?.start;c=s?.({id:d,mode:o,endpoint:t,key:n,instance:r})},document.head.appendChild(a),{id:d,active:()=>c?.active()??!1,error:s=>c?.error(s),report:s=>c?.report?.(s)}}var H={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},Xe="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",Ve='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',me,W={},ge,x,z=()=>{},k,fe=0;function C(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function he(e){me=e}function N(e,t){return W[t]??=new Promise((n,r)=>{let i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>{let o=window[t];o?n(o):r(new Error(t))},i.onerror=r,document.head.appendChild(i)}).catch(n=>{throw delete W[t],n}),W[t]}function be(){let e=(navigator.language??"en").slice(0,2);return H[e]?e:"en"}function X(e,t){let n=document.createElement("button");return n.type="button",n.className="blipit-rb",n.setAttribute("aria-haspopup","dialog"),e?n.textContent=e:(n.lang=be(),n.textContent=H[n.lang][0]),n.addEventListener("click",()=>n.hasAttribute("aria-busy")||t()),n}var ye=()=>{};function ve(e){ye=e}function V(e,t){ye(S(e.endpoint,"/api/v1/feedback"),e.options.key,t)}function A(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{},n=document.querySelectorAll("button.blipit-rb"),r=i=>{z(i),n.forEach(o=>i?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))};r(!0),Promise.all([N(t.src??`${E}blipit-report.js`,"BlipitReport"),ge??=xe(e)]).then(([i,o])=>o.enabled!==!1&&i.open(e,{metadata:me,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:d=>x&&(x.style.display=d?"none":"")}),()=>V(e,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>r(!1))}async function xe(e){let t=`blipit_fb_${_}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(S(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return C(e,`widget settings failed (HTTP ${n.status}), using defaults`),{};let r=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:r}))}catch{}return r}catch{return C(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function Y(e){let t=e.options.feedbackWidget,n=++fe;if(typeof document>"u")return;if(t===!1)return C(e,"Report a bug button off: feedbackWidget is false");let r=await(ge??=xe(e));if(n!==fe)return;if(r.enabled===!1)return C(e,"Report a bug button hidden by the project's Bug report widget setting");let i={...r,...typeof t=="object"?t:{}},[o,d]=H[be()],c=i.text||o;x=document.createElement("div"),x.setAttribute("data-blipit-ui","");let a=x.attachShadow({mode:"open"}),s=document.createElement("button");s.type="button";let[l,m]=(/^(bottom|middle)-(left|right)$/.test(i.position??"")?i.position:"bottom-right").split("-");s.style.cssText=`${i.color?`--c:${i.color};`:""}${m}:calc(20px + env(safe-area-inset-${m},0px));${l==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,s.setAttribute("aria-haspopup","dialog"),i.style==="icon"&&(s.className="o",s.title=c);let h=g=>{s.disabled=g,s.setAttribute("aria-label",g?d:c),s.innerHTML=g?"<i></i><span></span>":`${Ve}<span></span>`,s.lastChild.textContent=g?d:c};z=h,h(!1),s.addEventListener("click",()=>A(e)),ne(a,Xe),a.append(s);let y=i.shortcut?.toLowerCase().replace(/\s/g,"");k&&document.removeEventListener("keydown",k),k=void 0,y&&(k=g=>{[g.ctrlKey&&"ctrl",g.shiftKey&&"shift",g.altKey&&"alt",g.metaKey&&"meta",g.key.toLowerCase()].filter(Boolean).join("+")===y&&(g.preventDefault(),A(e))},document.addEventListener("keydown",k));let B=x,T=()=>{x===B&&(document.body.append(B),C(e,`Report a bug button shown at ${l}-${m}`))};document.body?T():document.addEventListener("DOMContentLoaded",T)}function Se(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},x?.remove(),x=void 0,k&&document.removeEventListener("keydown",k),k=void 0,z=()=>{},Y(e)}var p,ke=new Set;function we(e,t){ke.has(t)||(ke.add(t),console[e](t))}var Ye="[blipit] init() has no key, so error tracking and the Report a bug button are off. Pass your public key (blipit_pk_...) from app.blipit.io, API keys.",Je="[blipit] init() got a secret key (blipit_sk_...), so Blipit did not start: secret keys must never be in browser code. Use the public key (blipit_pk_...) and create a new secret key in app.blipit.io, API keys.";function Ge(e){if(p)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return we("warn",Ye);if(t.startsWith("blipit_sk_"))return we("error",Je);if(p=new $({...e,key:t}),e.user){let{id:n,name:r,email:i,username:o}=e.user;p.setUser({id:n===void 0?void 0:String(n),email:i,username:o??r})}ce(p),e.webVitals!==!1&&typeof window<"u"&&pe(e.endpoint??M,t,e.instance),e.replay&&(p.replay=le(e.replay,e.endpoint??M,t,e.instance,E)),typeof window<"u"&&Y(p),e.debug&&console.log(`[blipit] ${K}@${_} initialized`)}function Qe(e){return p?.captureException(e,!0)}function Ze(e,t){return p?.captureMessage(e,t)}function et(e){return p?.captureSecurity(e)}function tt(e){p?.setUser(e)}function nt(e,t){p?.setTag(e,t)}function it(e){p?.addBreadcrumb(e)}function rt(e={}){p&&V(p,{...e,eventId:e.eventId??p.lastEventId})}function D(){p&&A(p)}function ot(e){e.addEventListener("click",t=>{t.preventDefault(),D()})}function st(e){p&&Se(p,e)}function at(){return p?.flush()??Promise.resolve()}ve((e,t,n)=>N(`${E}blipit-feedback.js`,"BlipitFeedback").then(r=>r.showFeedbackDialog(e,t,n),()=>{}));function dt(e={}){let t=X(e.label,D);return t.style.visibility="hidden",N(`${E}blipit-button.js`,"BlipitButton").then(n=>n.paint(t,e)).catch(()=>{}).then(()=>t.style.removeProperty("visibility")),t}return Ce(ct);})();
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var ee=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var N=class{constructor(t,n,i,r){this.endpoint=t;this.key=n;this.debug=i;this.instance=r;typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flushWithBeacon()})}endpoint;key;debug;instance;queue=[];timer;sending=!1;enqueue(t){this.queue.push(t),this.queue.length>30&&this.queue.shift(),this.timer||(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},1e3))}async flush(){if(!this.sending){this.sending=!0;try{for(;this.queue.length>0;){let t=this.queue[0];if(!await this.send(t))break;this.queue.shift()}}finally{this.sending=!1}}}async send(t,n=0){try{let i=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key,...this.instance?{"X-Blipit-Instance":this.instance}:{}},body:JSON.stringify(t),keepalive:!0});return i.status===429||i.status>=500?this.retry(t,n):(this.debug&&i.status>=400&&console.warn("[blipit] event rejected",i.status,await i.text()),!0)}catch{return this.retry(t,n)}}async retry(t,n){return n>=2?(this.debug&&console.warn("[blipit] dropping event after retries",t.event_id),!0):(await new Promise(i=>setTimeout(i,1e3*2**n)),this.send(t,n+1))}flushWithBeacon(){if(!(typeof navigator>"u"||!navigator.sendBeacon))for(;this.queue.length>0;){let t=this.queue.shift(),n=`key=${encodeURIComponent(this.key)}${this.instance?`&instance=${encodeURIComponent(this.instance)}`:""}`,i=`${this.endpoint}${this.endpoint.includes("?")?"&":"?"}${n}`;navigator.sendBeacon(i,JSON.stringify(t))}}};function L(){let e=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0");return t}function v(){return new Date().toISOString()}var Te=/token|key|password|secret|auth|session|passwd|api/i;function C(e){let t=e.indexOf("?");if(t===-1)return e.slice(0,2048);let n=e.slice(0,t),r=e.slice(t+1).split("&").map(o=>{let c=o.indexOf("=");if(c===-1)return o;let d=o.slice(0,c);return Te.test(d)?`${d}=[redacted]`:o}).join("&");return`${n}?${r}`.slice(0,2048)}var _e=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function te(e){return e.replace(_e,"$1[redacted]")}function f(e,t){return e.length>t?e.slice(0,t):e}var ne=".blipit-mask,[data-blipit-mask]";function j(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function E(e,t,n){e.push(t),e.length>n&&e.shift()}function q(e){let t=e.id?`#${e.id}`:"",n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return f(`${e.tagName.toLowerCase()}${t}${n}`,128)}function S(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function ie(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}function Ce(e){let t=e.match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?/);if(!t||(t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]))<.5)return null;let[i,r,o]=[t[1],t[2],t[3]].map(c=>{let d=parseFloat(c)/255;return d<=.03928?d/12.92:((d+.055)/1.055)**2.4});return .2126*i+.7152*r+.0722*o}function re(e){if(e==="light"||e==="dark")return e;if(typeof document<"u"){for(let n of[document.body,document.documentElement]){if(!n)continue;let i=Ce(getComputedStyle(n).backgroundColor);if(i!==null)return i<.4?"dark":"light"}let t=getComputedStyle(document.documentElement).colorScheme;if(t==="dark")return"dark";if(t&&t!=="normal"&&!t.includes("dark"))return"light"}return typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var oe={ok:0,errored:1,crashed:2},F=class{constructor(t,n,i,r){this.url=t;this.key=n;this.release=i;this.environment=r;this.start(),typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.end():this.sid||this.start()})}url;key;release;environment;sid="";started="";status="ok";errors=0;did;setUser(t){this.did=t}markError(t){if(!this.sid)return;this.errors+=1;let n=t?"crashed":"errored";oe[n]<=oe[this.status]||(this.status=n,this.send(!1))}start(){this.sid=L(),this.started=v(),this.status="ok",this.errors=0,this.send(!1)}end(){this.sid&&(this.send(!0),this.sid="")}send(t){let n=JSON.stringify({sid:this.sid,did:this.did,status:this.status==="ok"&&t?"exited":this.status,errors:this.errors,started:this.started,release:this.release,environment:this.environment}),i=`${this.url}?key=${encodeURIComponent(this.key)}`;try{if(t&&typeof navigator<"u"&&navigator.sendBeacon){navigator.sendBeacon(i,n);return}if(typeof fetch>"u")return;fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key},body:n,keepalive:!0}).catch(()=>{})}catch{return}}};var Le=/^\s*at (?:async )?(?:new )?(?:(.+?) )?\(?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack):.*?|[^()]+?)(?::(\d+))?(?::(\d+))?\)?\s*$/,Me=/^\s*(?:(.*?)@)?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack).*?|[^@]*?)(?::(\d+))?(?::(\d+))?\s*$/,se=/^(chrome|moz|safari-web)-extension:/;function Oe(){if(typeof location<"u"&&location.origin)return location.origin}function Ie(e){if(se.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=Oe();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function ae(e){if(!e)return[];let t=[];for(let n of e.split(`
|
|
2
|
-
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let i=Le.exec(n)??Me.exec(n);if(!i)continue;let[,r,o,c,d]=i;if(!o)continue;let s={filename:f(o,1024),in_app:Ie(o)};r&&(s.function=f(r,512)),c&&(s.lineno=Number(c)),d&&(s.colno=Number(d)),t.push(s)}return t.reverse(),t.slice(-128)}function de(e){return e.length===0?!1:e.every(t=>se.test(t.filename))}var W="@blipit/browser",M="0.3.7",P=ie(typeof document<"u"?document.currentScript?.src:void 0,M),D="https://in.blipit.io/api/v1/events",Ae=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Ne={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},Fe={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function Ue(e){if(!ee.includes(e?.kind))return;let t=f(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=f(String(e.actorId),128)),e.ip&&(n.ip=f(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=f(String(e.userAgent),512)),e.database&&(n.database=f(String(e.database),64)),e.outcome&&(n.outcome=f(String(e.outcome),64)),e.target&&(n.target=f(String(e.target),256)),n}var U=class{constructor(t){this.options=t;this.endpoint=t.endpoint??D,this.transport=new N(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new F(S(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...Ae,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[f(t,64)]=f(n,256)}addBreadcrumb(t){let n={timestamp:v(),...t};n.message&&(n.message=te(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:C(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){let i=t instanceof Error?t:new Error(String(t)),r={type:i.name||"Error",value:f(i.message||String(i),4096),handled:n},o=ae(i.stack);return o.length>0&&(r.stacktrace={frames:o}),this.processAndSend({exception:r,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:f(t,8192),level:n})}captureSecurity(t){let n=Ue(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${Ne[n.kind]} for ${n.actor}`,level:Fe[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let i=t.exception?.value??t.message??"";if(n){for(let d of this.ignoreErrors)if(typeof d=="string"?i.includes(d):d.test(i))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&de(t.exception.stacktrace.frames))return;let c=`${t.exception?.type??""}|${i}`;if(t.exception?.handled===!1){if(this.seen.has(c)&&this.seen.size<100)return;this.seen.add(c),setTimeout(()=>this.seen.delete(c),5e3)}}let r={event_id:L(),timestamp:v(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:C(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:W,version:M},...t};for(let c of Object.keys(r))r[c]===void 0&&delete r[c];let o=this.replay?.active()&&(r.level==="error"||r.level==="fatal")?this.replay:void 0;if(o&&(r.tags={...r.tags,replay_id:o.id}),this.options.beforeSend){let c=this.options.beforeSend(r);if(!c)return;r=c}return this.transport.enqueue(r),this.lastEventId=r.event_id,(r.level==="error"||r.level==="fatal")&&E(this.errorIds,r.event_id,20),r.exception&&this.session?.markError(r.exception.handled===!1),o?.error(r.event_id),r.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",i=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;i&&(t.browser={name:i[1],version:i[2]});let r=/\(([^)]+)\)/.exec(n);return r&&r[1]&&(t.os={name:f(r[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};function H(e){return typeof e=="string"?e.length:e?.size}function ce(e){return e&&Number(e)||void 0}function Pe(e,t){return async(n,i)=>{let r=typeof n=="string"?n:n instanceof URL?n.href:n.url,o=(i?.method??n.method??"GET").toUpperCase(),c=Date.now();try{let d=await e(n,i);return t(o,r,d.status,c,H(i?.body),ce(d.headers.get("content-length"))),d}catch(d){throw t(o,r,0,c,H(i?.body)),d}}}function De(e,t){let n=e.open,i=e.send;e.open=function(r,o){return this._blipit=[String(r).toUpperCase(),String(o)],n.apply(this,arguments)},e.send=function(r){let o=this._blipit;if(o){let c=Date.now();this.addEventListener("loadend",()=>t(o[0],o[1],this.status,c,H(r),ce(this.getResponseHeader("content-length"))))}return i.apply(this,arguments)}}function ue(e){if(typeof window>"u")return;let t=S(e.endpoint,""),{console:n,network:i,actions:r}=e.logs;window.addEventListener("error",s=>{e.captureException(s.error??s.message,!1)}),window.addEventListener("unhandledrejection",s=>{e.captureException(s.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",s=>{let a=s.target;if(!(a instanceof Element)||a.closest("[data-blipit-ui]"))return;let u=q(a);e.addBreadcrumb({category:"ui.click",message:`Clicked ${u}`});let b=a.closest(ne)?"***":f((a.textContent??"").trim().replace(/\s+/g," "),80);E(r,{timestamp:v(),type:"click",selector:u,text:b},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",s=>{let a=s.target;a instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(a.tagName)&&E(r,{timestamp:v(),type:"focus",selector:q(a)},50)},{capture:!0,passive:!0}));let o=(s,a,u,b,l,g)=>{t&&a.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${s} ${C(a)} \u2192 ${u||"network error"}`,level:u>=400||!u?"error":"info",data:{url:C(a),method:s,status_code:u||void 0}}),E(i,{timestamp:v(),method:s,url:j(a),status:u,duration:Date.now()-b,request_size:l,response_size:g},50))};typeof window.fetch=="function"&&(window.fetch=Pe(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&De(XMLHttpRequest.prototype,o);for(let s of["log","info","debug","warn","error"]){let a=console[s].bind(console);console[s]=(...u)=>{let b=f(u.map(l=>typeof l=="string"?l:ze(l)).join(" "),1024);if(s==="warn"||s==="error"){e.addBreadcrumb({category:"console",level:s==="warn"?"warning":"error",message:b});let l=u.find(g=>g instanceof Error);E(n,{timestamp:v(),level:s,message:b,stack:f((l??new Error).stack??"",2e3)},100)}else E(n,{timestamp:v(),level:s,message:b},100);a(...u)}}let c=()=>E(r,{timestamp:v(),type:"navigation",url:j(location.href)},50),d=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${C(location.href)}`}),c()};if(c(),window.history){let s=window.history.pushState.bind(window.history);window.history.pushState=(...a)=>{s(...a),d()},window.addEventListener("popstate",d)}}function ze(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function pe(){let e=0,t=0,n=0,i=0;return r=>(r.hadRecentInput||(t>0&&r.startTime-i<1e3&&r.startTime-n<5e3?t+=r.value:(t=r.value,n=r.startTime),i=r.startTime,t>e&&(e=t)),e)}function Ke(e){if(e.size===0)return;let t=[...e.values()].sort((n,i)=>i-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function je(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function O(e,t,n){try{new PerformanceObserver(i=>i.getEntries().forEach(r=>t(r))).observe({type:e,buffered:!0,...n})}catch{}}function le(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let i=performance.getEntriesByType("navigation")[0],r=i?.activationStart??0,o=y=>Math.max(0,Math.round(y-r)),c=document.visibilityState==="hidden",d=location.pathname,s=i?.type,a={},u=pe(),b=new Map,l=!1,g=!1;i&&i.responseStart>0&&(a.ttfb=o(i.responseStart)),c||(O("paint",y=>{y.name==="first-contentful-paint"&&(a.fcp=o(y.startTime))}),O("largest-contentful-paint",y=>{l||(a.lcp=o(y.startTime))}));let $=()=>{l=!0};addEventListener("keydown",$,{once:!0,capture:!0}),addEventListener("pointerdown",$,{once:!0,capture:!0}),O("layout-shift",y=>{a.cls=Math.round(u(y)*1e4)/1e4});let B=y=>{if(!y.interactionId)return;b.set(y.interactionId,Math.max(b.get(y.interactionId)??0,y.duration));let Q=Ke(b);Q!==void 0&&(a.inp=Math.round(Q))};O("event",B,{durationThreshold:40}),O("first-input",B);let w=navigator.connection?.effectiveType,h=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,k=()=>{if(g||Object.keys(a).length===0)return;g=!0;let y=JSON.stringify({path:d.slice(0,512),metrics:a,nav:s,connection:w&&/^(slow-2g|2g|3g|4g)$/.test(w)?w:void 0,device:je(navigator.userAgent)});try{if(navigator.sendBeacon?.(h,y))return}catch{}fetch(h,{method:"POST",body:y,keepalive:!0}).catch(()=>{})},T=()=>{location.pathname!==d&&(k(),d=location.pathname,s="route",a={},u=pe(),b=new Map,l=!0,g=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&k()),addEventListener("pagehide",k),addEventListener("popstate",T);let A=history.pushState;history.pushState=function(...y){A.apply(this,y),T()}}function qe(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function fe(e,t,n,i,r){let o=qe(e);if(!o||typeof document>"u")return;let c=L(),d,s=document.createElement("script");return s.src=e.src??`${r}blipit-replay.js`,s.async=!0,s.onload=()=>{let a=window.BlipitReplay?.start;d=a?.({id:c,mode:o,endpoint:t,key:n,instance:i})},document.head.appendChild(s),{id:c,active:()=>d?.active()??!1,error:a=>d?.error(a),report:a=>d?.report?.(a)}}var me={en:["Report {ref} sent.","We will email you updates."],ar:["\u062A\u0645 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0628\u0644\u0627\u063A {ref}.","\u0633\u0646\u0631\u0627\u0633\u0644\u0643 \u0628\u0627\u0644\u062A\u062D\u062F\u064A\u062B\u0627\u062A."],de:["Meldung {ref} gesendet.","Wir informieren Sie per E-Mail."],es:["Reporte {ref} enviado.","Te enviaremos novedades por correo."],fr:["Signalement {ref} envoy\xE9.","Nous vous tiendrons au courant par e-mail."],it:["Segnalazione {ref} inviata.","Ti invieremo aggiornamenti via email."],ja:["\u5831\u544A {ref} \u3092\u9001\u4FE1\u3057\u307E\u3057\u305F\u3002","\u9032\u6357\u306F\u30E1\u30FC\u30EB\u3067\u304A\u77E5\u3089\u305B\u3057\u307E\u3059\u3002"],nl:["Melding {ref} verstuurd.","We mailen je updates."],pt:["Relato {ref} enviado.","Vamos enviar novidades por e-mail."],tr:["{ref} numaral\u0131 bildirim g\xF6nderildi.","Geli\u015Fmeleri e-postayla bildirece\u011Fiz."],zh:["\u62A5\u544A {ref} \u5DF2\u53D1\u9001\u3002","\u6211\u4EEC\u4F1A\u901A\u8FC7\u90AE\u4EF6\u544A\u77E5\u8FDB\u5C55\u3002"]};function We(e,t,n){if(typeof e!="string"||!/^BR-\d{1,12}$/.test(e))return null;let[i,r]=me[n.toLowerCase().split(/[-_]/)[0]]??me.en;return`${i.replace("{ref}",e)}${t===!0?` ${r}`:""}`}function x(e,t,n){let i=document.createElement(e);return i.style.cssText=t,n!==void 0&&(i.textContent=n),i}var X="display:block;width:100%;box-sizing:border-box;margin:4px 0 12px;padding:8px 10px;font:inherit;border:1px solid #c5ccd6;border-radius:6px;background:#fff;color:#111",ge="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",V=!1;function z(e,t,n){if(V||typeof document>"u"||!document.body)return;V=!0;let i=x("dialog","max-width:420px;width:calc(100% - 32px);padding:20px;border:1px solid #c5ccd6;border-radius:10px;font:14px/1.45 system-ui,sans-serif;color:#111;background:#fff");i.setAttribute("aria-labelledby","blipit-fb-title");let r=x("form","margin:0"),o=x("h2","margin:0 0 12px;font-size:17px",n.title??"Tell us what happened");o.id="blipit-fb-title";let c=(w,h,k)=>{let T=x("label","display:block;font-weight:600",w);T.htmlFor=k,h.id=k,r.append(T,h)},d=x("input",X);d.type="text",d.maxLength=128,d.autocomplete="name",d.value=n.name??"";let s=x("input",X);s.type="email",s.maxLength=254,s.autocomplete="email",s.value=n.email??"";let a=x("textarea",`${X};min-height:110px;resize:vertical`);a.required=!0,a.maxLength=5e3;let u=x("p","margin:0 0 12px;min-height:1.2em;font-size:13px");u.setAttribute("role","status"),u.setAttribute("aria-live","polite");let b=x("div","display:flex;gap:8px;justify-content:flex-end"),l=x("button",ge,"Cancel");l.type="button";let g=x("button",`${ge};background:#111;color:#fff;border-color:#111`,"Send");g.type="submit",r.append(o),c("Name (optional)",d,"blipit-fb-name"),c("Email (optional)",s,"blipit-fb-email"),c("What went wrong?",a,"blipit-fb-message"),b.append(l,g),r.append(u,b),i.append(r),document.body.append(i);let $=()=>{V=!1,i.remove()},B=()=>typeof i.close=="function"&&i.open?i.close():$();l.addEventListener("click",B),i.addEventListener("close",$),r.addEventListener("submit",async w=>{w.preventDefault();let h=a.value.trim();if(!h){u.textContent="Please describe what happened.",a.focus();return}g.disabled=!0,l.disabled=!0,g.setAttribute("aria-busy","true"),g.textContent="Sending\u2026",u.textContent="";try{let k=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":t},body:JSON.stringify({name:d.value.trim()||void 0,email:s.value.trim()||void 0,message:h,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!k.ok)throw new Error(String(k.status));let T=await k.json().catch(()=>({})),A=We(T.ref,T.emails,typeof navigator>"u"?"en":navigator.language??"en");u.textContent=A??"Thanks, your message was sent.",g.textContent="Sent",setTimeout(B,A?4e3:1200)}catch{u.textContent="That did not send. Please try again.",g.disabled=!1,l.disabled=!1,g.removeAttribute("aria-busy"),g.textContent="Send"}}),typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),a.focus()}var Y={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},He="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",Xe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',be,G={},ye,R,J=()=>{},_,he=0;function I(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function Ve(e){be=e}function Ge(e,t){return G[t]??=new Promise((n,i)=>{let r=document.createElement("script");r.src=e,r.async=!0,r.onload=()=>{let o=window[t];o?n(o):i(new Error(t))},r.onerror=i,document.head.appendChild(r)}).catch(n=>{throw delete G[t],n}),G[t]}function ve(){let e=(navigator.language??"en").slice(0,2);return Y[e]?e:"en"}function xe(e,t){let n=document.createElement("button");return n.type="button",n.className="blipit-rb",n.setAttribute("aria-haspopup","dialog"),e?n.textContent=e:(n.lang=ve(),n.textContent=Y[n.lang][0]),n.addEventListener("click",()=>n.hasAttribute("aria-busy")||t()),n}function K(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{},n=document.querySelectorAll("button.blipit-rb"),i=r=>{J(r),n.forEach(o=>r?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))};i(!0),Promise.all([Ge(t.src??`${P}blipit-report.js`,"BlipitReport"),ye??=we(e)]).then(([r,o])=>o.enabled!==!1&&r.open(e,{metadata:be,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:c=>R&&(R.style.display=c?"none":"")}),()=>z(S(e.endpoint,"/api/v1/feedback"),e.options.key,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>i(!1))}async function we(e){let t=`blipit_fb_${M}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(S(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return I(e,`widget settings failed (HTTP ${n.status}), using defaults`),{};let i=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:i}))}catch{}return i}catch{return I(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function Z(e){let t=e.options.feedbackWidget,n=++he;if(typeof document>"u")return;if(t===!1)return I(e,"Report a bug button off: feedbackWidget is false");let i=await(ye??=we(e));if(n!==he)return;if(i.enabled===!1)return I(e,"Report a bug button hidden by the project's Bug report widget setting");let r={...i,...typeof t=="object"?t:{}},[o,c]=Y[ve()],d=r.text||o;R=document.createElement("div"),R.setAttribute("data-blipit-ui","");let s=R.attachShadow({mode:"open"}),a=document.createElement("style");a.textContent=He;let u=document.createElement("button");u.type="button";let[b,l]=(/^(bottom|middle)-(left|right)$/.test(r.position??"")?r.position:"bottom-right").split("-");u.style.cssText=`${r.color?`--c:${r.color};`:""}${l}:calc(20px + env(safe-area-inset-${l},0px));${b==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,u.setAttribute("aria-haspopup","dialog"),r.style==="icon"&&(u.className="o",u.title=d);let g=h=>{u.disabled=h,u.setAttribute("aria-label",h?c:d),u.innerHTML=h?"<i></i><span></span>":`${Xe}<span></span>`,u.lastChild.textContent=h?c:d};J=g,g(!1),u.addEventListener("click",()=>K(e)),s.append(a,u);let $=r.shortcut?.toLowerCase().replace(/\s/g,"");_&&document.removeEventListener("keydown",_),_=void 0,$&&(_=h=>{[h.ctrlKey&&"ctrl",h.shiftKey&&"shift",h.altKey&&"alt",h.metaKey&&"meta",h.key.toLowerCase()].filter(Boolean).join("+")===$&&(h.preventDefault(),K(e))},document.addEventListener("keydown",_));let B=R,w=()=>{R===B&&(document.body.append(B),I(e,`Report a bug button shown at ${b}-${l}`))};document.body?w():document.addEventListener("DOMContentLoaded",w)}function ke(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},R?.remove(),R=void 0,_&&document.removeEventListener("keydown",_),_=void 0,J=()=>{},Z(e)}var Se='<svg viewBox="0 0 242.4 208.7" aria-hidden="true"><defs><linearGradient id="bm1" x1="0" y1="1" x2=".5" y2="0"><stop offset="0" stop-color="#00C2FF"/><stop offset=".35" stop-color="#3882F6"/><stop offset="1" stop-color="#0F172A"/></linearGradient><linearGradient id="bm2" x1="0" y1="1" x2="1" y2="0"><stop offset="0" stop-color="#3882F6"/><stop offset=".5" stop-color="#00C2FF"/><stop offset="1" stop-color="#3882F6"/></linearGradient></defs><path fill="url(#bm1)" d="M115.5,164.5c-3.9,0-7.8-.4-11.5-1.2-3.7-.8-7.3-1.9-10.8-3.4-3.4-1.4-6.7-3.2-9.7-5.3-3.0-2.0-5.9-4.4-8.5-7.0s-4.9-5.4-7.0-8.5c-2.1-3.1-3.9-6.3-5.3-9.8-1.5-3.5-2.6-7.1-3.4-10.8-.8-3.8-1.2-7.7-1.2-11.5V19.1c0-6.6,5.4-12.0,12.0-12.0s12.0,5.4,12.0,12.0v88.2c0,2.2.2,4.5.7,6.7.4,2.1,1.1,4.2,1.9,6.2.8,2.0,1.9,3.9,3.1,5.7,1.2,1.8,2.6,3.4,4.1,4.9s3.2,2.9,4.9,4.1c1.8,1.2,3.7,2.2,5.6,3.1,2.0.8,4.1,1.5,6.2,1.9,4.4.9,9.1.9,13.4,0,2.1-.4,4.2-1.1,6.2-1.9,2.0-.8,3.9-1.9,5.7-3.1,1.8-1.2,3.4-2.6,4.9-4.1s2.9-3.2,4.1-4.9c1.2-1.8,2.2-3.7,3.1-5.7.8-2.0,1.5-4.1,1.9-6.2.5-2.2.7-4.5.7-6.7s-.2-4.5-.7-6.7c-.4-2.1-1.1-4.2-1.9-6.2-.8-2.0-1.9-3.9-3.1-5.7-1.2-1.8-2.6-3.4-4.1-4.9s-3.2-2.9-4.9-4.1c-1.8-1.2-3.7-2.2-5.7-3.1-2.0-.8-4.1-1.5-6.2-1.9-4.4-.9-9.1-.9-13.4,0-6.5,1.3-12.9-2.9-14.2-9.4-1.3-6.5,2.9-12.9,9.4-14.2,7.6-1.6,15.5-1.6,23.1,0,3.7.8,7.3,1.9,10.8,3.4,3.4,1.4,6.7,3.2,9.7,5.3,3.0,2.0,5.9,4.4,8.5,7.0s4.9,5.4,7.0,8.5c2.1,3.1,3.9,6.3,5.3,9.8,1.5,3.5,2.6,7.1,3.4,10.8.8,3.8,1.2,7.7,1.2,11.5s-.4,7.8-1.2,11.5c-.8,3.7-1.9,7.3-3.4,10.8-1.4,3.4-3.2,6.7-5.3,9.7-2.0,3.0-4.4,5.9-7.0,8.5s-5.4,4.9-8.5,7.0c-3.1,2.1-6.3,3.9-9.8,5.3-3.5,1.5-7.1,2.6-10.8,3.4-3.8.8-7.7,1.2-11.5,1.2Z"/><path fill="url(#bm2)" d="M208.1,103.0c-.0-.6-.8-.9-1.2-.5-3.2,3.1-7.6,5.0-12.4,5.0-3.9,0-9.1-1.6-10.2-2.5-.3-.1-.1,1.4-.1,2.5,0,40.5-34.4,73.0-75.5,70.0-33.4-2.5-60.8-28.8-64.4-62.1-1.0-9.4-.2-18.6,2.2-27.0,1.6-5.6,2.6-11.4,2.6-17.3v-22.4c0-3.4-4.3-5.0-6.5-2.4-13.2,15.4-21.6,35.1-22.7,56.6-2.6,54.1,40.6,98.9,94.1,98.9s94.2-42.3,94.2-94.2c0-1.5-.1-3.0-.1-4.5Z"/><path fill="url(#bm2)" d="M201.2,70.1c-14.8-35.8-50.9-60.5-92.3-58.3h-.1c-8.2.5-14.6,7.4-14.6,15.7v.1c0,5.4,4.7,9.6,10.0,8.8,3.2-.5,6.5-.7,9.9-.7,28.7,0,53.5,17.4,64.3,42.1.2.5.9.6,1.2.1,3.2-4.8,8.7-7.9,14.9-7.9,2.0,0,4.0.3,5.8,1.0.6.2,1.1-.4.9-1.0Z"/><circle fill="#00C2FF" cx="194.5" cy="88" r="15.8"/></svg>';var p=".blipit-rb.blipit-rb",Ye=`${p}{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:9px;height:40px;padding-inline:5px 17px;border-radius:99px;font:600 14px/1 system-ui,-apple-system,"Segoe UI",sans-serif;letter-spacing:-.01em;white-space:nowrap;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;color:#fff;background:linear-gradient(135deg,#3882F6,#2F5BEA);box-shadow:0 10px 24px -12px rgba(56,130,246,.8),0 1px 3px rgba(11,26,58,.16),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s}${p}:hover{transform:translateY(-1px);box-shadow:0 16px 32px -12px rgba(56,130,246,.85),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22)}${p}:active{transform:scale(.97)}${p}:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}${p}[aria-busy=true]{cursor:progress}${p}>span{all:unset}${p}>.blipit-rb-m{position:relative;display:grid;place-items:center;flex:none;width:30px;height:30px;border-radius:99px;background:#fff;box-shadow:0 0 0 1px rgba(11,26,58,.08),0 1px 2px rgba(11,26,58,.12)}${p} svg{display:block;width:19px;height:17px}${p}[data-size=sm]{height:32px;gap:7px;padding-inline:4px 13px;font-size:13px}${p}[data-size=sm]>.blipit-rb-m{width:24px;height:24px}${p}[data-size=sm] svg{width:15px;height:13px}${p}[data-variant=outline],${p}[data-variant=ghost]{color:#0B1A3A;background:transparent;box-shadow:inset 0 0 0 1px #CBD7EA}${p}[data-variant=ghost]{box-shadow:none}${p}[data-variant=outline]:hover,${p}[data-variant=ghost]:hover{transform:none;background:rgba(56,130,246,.08);box-shadow:inset 0 0 0 1px rgba(56,130,246,.45)}${p}[data-variant=ghost]:hover{box-shadow:none}${p}[data-theme=dark]{background:linear-gradient(135deg,#5B9BFF,#3D6BF0);box-shadow:0 10px 24px -12px rgba(91,155,255,.7),inset 0 1px 0 rgba(255,255,255,.2)}${p}[data-theme=dark][data-variant=outline],${p}[data-theme=dark][data-variant=ghost]{color:#E8EEF8;background:transparent;box-shadow:inset 0 0 0 1px rgba(255,255,255,.16)}${p}[data-theme=dark][data-variant=ghost]{box-shadow:none}${p}[data-theme=dark][data-variant=outline]:hover,${p}[data-theme=dark][data-variant=ghost]:hover{background:rgba(91,155,255,.16);box-shadow:inset 0 0 0 1px rgba(91,155,255,.45)}${p}[data-theme=dark][data-variant=ghost]:hover{box-shadow:none}${p}[data-theme=dark]>.blipit-rb-m{box-shadow:0 0 0 1px rgba(255,255,255,.1)}${p}[aria-busy=true] svg{visibility:hidden}${p}[aria-busy=true]>.blipit-rb-m::after{content:"";position:absolute;inset:4px;border:2px solid #3882F6;border-right-color:transparent;border-radius:50%;animation:blipit-rb-r .8s linear infinite}@keyframes blipit-rb-r{to{transform:rotate(1turn)}}@media(pointer:coarse){${p}{min-height:44px}}@media(prefers-reduced-motion:reduce){${p}{transition:none}${p}:hover,${p}:active{transform:none}${p}[aria-busy=true]>.blipit-rb-m::after{animation-duration:3s}}@media(forced-colors:active){${p}{border:1px solid ButtonText}}`,Je=0;function Ee(e,t={}){if(!document.getElementById("blipit-rb-css")){let o=document.createElement("style");o.id="blipit-rb-css",o.textContent=Ye,document.head.append(o)}let n=++Je,i=document.createElement("span");i.className="blipit-rb-m",i.innerHTML=Se.replace(/bm(\d)/g,`bm$1-${n}`);let r=document.createElement("span");r.textContent=e.textContent,e.replaceChildren(i,r),e.classList.add("blipit-rb"),e.setAttribute("data-variant",t.variant==="outline"||t.variant==="ghost"?t.variant:"solid"),e.setAttribute("data-size",t.size==="sm"?"sm":"md"),e.setAttribute("data-theme",re(t.theme==="light"||t.theme==="dark"?t.theme:void 0))}var m,Re=new Set;function $e(e,t){Re.has(t)||(Re.add(t),console[e](t))}var Ze="[blipit] init() has no key, so error tracking and the Report a bug button are off. Pass your public key (blipit_pk_...) from app.blipit.io, API keys.",Qe="[blipit] init() got a secret key (blipit_sk_...), so Blipit did not start: secret keys must never be in browser code. Use the public key (blipit_pk_...) and create a new secret key in app.blipit.io, API keys.";function Nt(e){if(m)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return $e("warn",Ze);if(t.startsWith("blipit_sk_"))return $e("error",Qe);if(m=new U({...e,key:t}),e.user){let{id:n,name:i,email:r,username:o}=e.user;m.setUser({id:n===void 0?void 0:String(n),email:r,username:o??i})}ue(m),e.webVitals!==!1&&typeof window<"u"&&le(e.endpoint??D,t,e.instance),e.replay&&(m.replay=fe(e.replay,e.endpoint??D,t,e.instance,P)),typeof window<"u"&&Z(m),e.debug&&console.log(`[blipit] ${W}@${M} initialized`)}function Ft(e){return m?.captureException(e,!0)}function Ut(e,t){return m?.captureMessage(e,t)}function Pt(e){return m?.captureSecurity(e)}function Dt(e){m?.setUser(e)}function zt(e,t){m?.setTag(e,t)}function Kt(e){m?.addBreadcrumb(e)}function jt(e={}){m&&z(S(m.endpoint,"/api/v1/feedback"),m.options.key,{...e,eventId:e.eventId??m.lastEventId})}function Be(){m&&K(m)}function qt(e){e.addEventListener("click",t=>{t.preventDefault(),Be()})}function Wt(e={}){let t=xe(e.label,Be);return Ee(t,e),t}function Ht(e){m&&ke(m,e)}function Xt(){return m?.flush()??Promise.resolve()}export{Kt as addBreadcrumb,qt as attachReport,Ft as captureException,Ut as captureMessage,Pt as captureSecurity,Xt as flush,Nt as init,Be as openReport,Wt as reportButton,Ve as setReportMetadata,zt as setTag,Dt as setUser,jt as showFeedback,Ht as updateWidget};
|
|
1
|
+
var te={en:["Report {ref} sent.","We will email you updates."],ar:["\u062A\u0645 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0628\u0644\u0627\u063A {ref}.","\u0633\u0646\u0631\u0627\u0633\u0644\u0643 \u0628\u0627\u0644\u062A\u062D\u062F\u064A\u062B\u0627\u062A."],de:["Meldung {ref} gesendet.","Wir informieren Sie per E-Mail."],es:["Reporte {ref} enviado.","Te enviaremos novedades por correo."],fr:["Signalement {ref} envoy\xE9.","Nous vous tiendrons au courant par e-mail."],it:["Segnalazione {ref} inviata.","Ti invieremo aggiornamenti via email."],ja:["\u5831\u544A {ref} \u3092\u9001\u4FE1\u3057\u307E\u3057\u305F\u3002","\u9032\u6357\u306F\u30E1\u30FC\u30EB\u3067\u304A\u77E5\u3089\u305B\u3057\u307E\u3059\u3002"],nl:["Melding {ref} verstuurd.","We mailen je updates."],pt:["Relato {ref} enviado.","Vamos enviar novidades por e-mail."],tr:["{ref} numaral\u0131 bildirim g\xF6nderildi.","Geli\u015Fmeleri e-postayla bildirece\u011Fiz."],zh:["\u62A5\u544A {ref} \u5DF2\u53D1\u9001\u3002","\u6211\u4EEC\u4F1A\u901A\u8FC7\u90AE\u4EF6\u544A\u77E5\u8FDB\u5C55\u3002"]};function Oe(e,t,n){if(typeof e!="string"||!/^BR-\d{1,12}$/.test(e))return null;let[i,r]=te[n.toLowerCase().split(/[-_]/)[0]]??te.en;return`${i.replace("{ref}",e)}${t===!0?` ${r}`:""}`}function x(e,t,n){let i=document.createElement(e);return i.style.cssText=t,n!==void 0&&(i.textContent=n),i}var j="display:block;width:100%;box-sizing:border-box;margin:4px 0 12px;padding:8px 10px;font:inherit;border:1px solid #c5ccd6;border-radius:6px;background:#fff;color:#111",ne="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",W=!1;function ie(e,t,n){if(W||typeof document>"u"||!document.body)return;W=!0;let i=x("dialog","max-width:420px;width:calc(100% - 32px);padding:20px;border:1px solid #c5ccd6;border-radius:10px;font:14px/1.45 system-ui,sans-serif;color:#111;background:#fff");i.setAttribute("aria-labelledby","blipit-fb-title");let r=x("form","margin:0"),o=x("h2","margin:0 0 12px;font-size:17px",n.title??"Tell us what happened");o.id="blipit-fb-title";let c=(b,$,k)=>{let B=x("label","display:block;font-weight:600",b);B.htmlFor=k,$.id=k,r.append(B,$)},d=x("input",j);d.type="text",d.maxLength=128,d.autocomplete="name",d.value=n.name??"";let a=x("input",j);a.type="email",a.maxLength=254,a.autocomplete="email",a.value=n.email??"";let s=x("textarea",`${j};min-height:110px;resize:vertical`);s.required=!0,s.maxLength=5e3;let p=x("p","margin:0 0 12px;min-height:1.2em;font-size:13px");p.setAttribute("role","status"),p.setAttribute("aria-live","polite");let h=x("div","display:flex;gap:8px;justify-content:flex-end"),f=x("button",ne,"Cancel");f.type="button";let m=x("button",`${ne};background:#111;color:#fff;border-color:#111`,"Send");m.type="submit",r.append(o),c("Name (optional)",d,"blipit-fb-name"),c("Email (optional)",a,"blipit-fb-email"),c("What went wrong?",s,"blipit-fb-message"),h.append(f,m),r.append(p,h),i.append(r),document.body.append(i);let E=()=>{W=!1,i.remove()},R=()=>typeof i.close=="function"&&i.open?i.close():E();f.addEventListener("click",R),i.addEventListener("close",E),r.addEventListener("submit",async b=>{b.preventDefault();let $=s.value.trim();if(!$){p.textContent="Please describe what happened.",s.focus();return}m.disabled=!0,f.disabled=!0,m.setAttribute("aria-busy","true"),m.textContent="Sending\u2026",p.textContent="";try{let k=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":t},body:JSON.stringify({name:d.value.trim()||void 0,email:a.value.trim()||void 0,message:$,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!k.ok)throw new Error(String(k.status));let B=await k.json().catch(()=>({})),A=Oe(B.ref,B.emails,typeof navigator>"u"?"en":navigator.language??"en");p.textContent=A??"Thanks, your message was sent.",m.textContent="Sent",setTimeout(R,A?4e3:1200)}catch{p.textContent="That did not send. Please try again.",m.disabled=!1,f.disabled=!1,m.removeAttribute("aria-busy"),m.textContent="Send"}}),typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),s.focus()}var re=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var F=class{constructor(t,n,i,r){this.endpoint=t;this.key=n;this.debug=i;this.instance=r;typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flushWithBeacon()})}endpoint;key;debug;instance;queue=[];timer;sending=!1;enqueue(t){this.queue.push(t),this.queue.length>30&&this.queue.shift(),this.timer||(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},1e3))}async flush(){if(!this.sending){this.sending=!0;try{for(;this.queue.length>0;){let t=this.queue[0];if(!await this.send(t))break;this.queue.shift()}}finally{this.sending=!1}}}async send(t,n=0){try{let i=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key,...this.instance?{"X-Blipit-Instance":this.instance}:{}},body:JSON.stringify(t),keepalive:!0});return i.status===429||i.status>=500?this.retry(t,n):(this.debug&&i.status>=400&&console.warn("[blipit] event rejected",i.status,await i.text()),!0)}catch{return this.retry(t,n)}}async retry(t,n){return n>=2?(this.debug&&console.warn("[blipit] dropping event after retries",t.event_id),!0):(await new Promise(i=>setTimeout(i,1e3*2**n)),this.send(t,n+1))}flushWithBeacon(){if(!(typeof navigator>"u"||!navigator.sendBeacon))for(;this.queue.length>0;){let t=this.queue.shift(),n=`key=${encodeURIComponent(this.key)}${this.instance?`&instance=${encodeURIComponent(this.instance)}`:""}`,i=`${this.endpoint}${this.endpoint.includes("?")?"&":"?"}${n}`;navigator.sendBeacon(i,JSON.stringify(t))}}};function L(){let e=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0");return t}function v(){return new Date().toISOString()}var Ie=/token|key|password|secret|auth|session|passwd|api/i;function C(e){let t=e.indexOf("?");if(t===-1)return e.slice(0,2048);let n=e.slice(0,t),r=e.slice(t+1).split("&").map(o=>{let c=o.indexOf("=");if(c===-1)return o;let d=o.slice(0,c);return Ie.test(d)?`${d}=[redacted]`:o}).join("&");return`${n}?${r}`.slice(0,2048)}var Ae=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function oe(e){return e.replace(Ae,"$1[redacted]")}function l(e,t){return e.length>t?e.slice(0,t):e}var se=".blipit-mask,[data-blipit-mask]";function q(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function w(e,t,n){e.push(t),e.length>n&&e.shift()}function H(e){let t=e.id?`#${e.id}`:"",n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return l(`${e.tagName.toLowerCase()}${t}${n}`,128)}function N(e,t){try{let n=new CSSStyleSheet;n.replaceSync(t),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]}catch{let n=document.createElement("style");n.textContent=t,(e===document?document.head:e).append(n)}}function T(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function ae(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}function Fe(e){let t=e.match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?/);if(!t||(t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]))<.5)return null;let[i,r,o]=[t[1],t[2],t[3]].map(c=>{let d=parseFloat(c)/255;return d<=.03928?d/12.92:((d+.055)/1.055)**2.4});return .2126*i+.7152*r+.0722*o}function de(e){if(e==="light"||e==="dark")return e;if(typeof document<"u"){for(let n of[document.body,document.documentElement]){if(!n)continue;let i=Fe(getComputedStyle(n).backgroundColor);if(i!==null)return i<.4?"dark":"light"}let t=getComputedStyle(document.documentElement).colorScheme;if(t==="dark")return"dark";if(t&&t!=="normal"&&!t.includes("dark"))return"light"}return typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ce={ok:0,errored:1,crashed:2},D=class{constructor(t,n,i,r){this.url=t;this.key=n;this.release=i;this.environment=r;this.start(),typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.end():this.sid||this.start()})}url;key;release;environment;sid="";started="";status="ok";errors=0;did;setUser(t){this.did=t}markError(t){if(!this.sid)return;this.errors+=1;let n=t?"crashed":"errored";ce[n]<=ce[this.status]||(this.status=n,this.send(!1))}start(){this.sid=L(),this.started=v(),this.status="ok",this.errors=0,this.send(!1)}end(){this.sid&&(this.send(!0),this.sid="")}send(t){let n=JSON.stringify({sid:this.sid,did:this.did,status:this.status==="ok"&&t?"exited":this.status,errors:this.errors,started:this.started,release:this.release,environment:this.environment}),i=`${this.url}?key=${encodeURIComponent(this.key)}`;try{if(t&&typeof navigator<"u"&&navigator.sendBeacon){navigator.sendBeacon(i,n);return}if(typeof fetch>"u")return;fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key},body:n,keepalive:!0}).catch(()=>{})}catch{return}}};var Ne=/^\s*at (?:async )?(?:new )?(?:(.+?) )?\(?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack):.*?|[^()]+?)(?::(\d+))?(?::(\d+))?\)?\s*$/,De=/^\s*(?:(.*?)@)?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack).*?|[^@]*?)(?::(\d+))?(?::(\d+))?\s*$/,ue=/^(chrome|moz|safari-web)-extension:/;function Pe(){if(typeof location<"u"&&location.origin)return location.origin}function Ue(e){if(ue.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=Pe();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function pe(e){if(!e)return[];let t=[];for(let n of e.split(`
|
|
2
|
+
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let i=Ne.exec(n)??De.exec(n);if(!i)continue;let[,r,o,c,d]=i;if(!o)continue;let a={filename:l(o,1024),in_app:Ue(o)};r&&(a.function=l(r,512)),c&&(a.lineno=Number(c)),d&&(a.colno=Number(d)),t.push(a)}return t.reverse(),t.slice(-128)}function le(e){return e.length===0?!1:e.every(t=>ue.test(t.filename))}var X="@blipit/browser",M="0.3.8",U=ae(typeof document<"u"?document.currentScript?.src:void 0,M),z="https://in.blipit.io/api/v1/events",ze=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Ke={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},je={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function We(e){if(!re.includes(e?.kind))return;let t=l(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=l(String(e.actorId),128)),e.ip&&(n.ip=l(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=l(String(e.userAgent),512)),e.database&&(n.database=l(String(e.database),64)),e.outcome&&(n.outcome=l(String(e.outcome),64)),e.target&&(n.target=l(String(e.target),256)),n}var P=class{constructor(t){this.options=t;this.endpoint=t.endpoint??z,this.transport=new F(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new D(T(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...ze,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;captured=new WeakSet;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[l(t,64)]=l(n,256)}addBreadcrumb(t){let n={timestamp:v(),...t};n.message&&(n.message=oe(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:C(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){if(t&&typeof t=="object"){if(this.captured.has(t))return;this.captured.add(t)}let i=t instanceof Error?t:new Error(String(t)),r={type:i.name||"Error",value:l(i.message||String(i),4096),handled:n},o=pe(i.stack);return o.length>0&&(r.stacktrace={frames:o}),this.processAndSend({exception:r,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:l(t,8192),level:n})}captureSecurity(t){let n=We(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${Ke[n.kind]} for ${n.actor}`,level:je[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let i=t.exception?.value??t.message??"";if(n){for(let d of this.ignoreErrors)if(typeof d=="string"?i.includes(d):d.test(i))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&le(t.exception.stacktrace.frames))return;let c=`${t.exception?.type??""}|${i}`;if(t.exception?.handled===!1){if(this.seen.has(c)&&this.seen.size<100)return;this.seen.add(c),setTimeout(()=>this.seen.delete(c),5e3)}}let r={event_id:L(),timestamp:v(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:C(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:X,version:M},...t};for(let c of Object.keys(r))r[c]===void 0&&delete r[c];let o=this.replay?.active()&&(r.level==="error"||r.level==="fatal")?this.replay:void 0;if(o&&(r.tags={...r.tags,replay_id:o.id}),this.options.beforeSend){let c=this.options.beforeSend(r);if(!c)return;r=c}return this.transport.enqueue(r),this.lastEventId=r.event_id,(r.level==="error"||r.level==="fatal")&&w(this.errorIds,r.event_id,20),r.exception&&this.session?.markError(r.exception.handled===!1),o?.error(r.event_id),r.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",i=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;i&&(t.browser={name:i[1],version:i[2]});let r=/\(([^)]+)\)/.exec(n);return r&&r[1]&&(t.os={name:l(r[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};var G={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},qe="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",He='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',me,V={},ge,S,Y=()=>{},_,fe=0;function O(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function Xe(e){me=e}function Ve(e,t){return V[t]??=new Promise((n,i)=>{let r=document.createElement("script");r.src=e,r.async=!0,r.onload=()=>{let o=window[t];o?n(o):i(new Error(t))},r.onerror=i,document.head.appendChild(r)}).catch(n=>{throw delete V[t],n}),V[t]}function he(){let e=(navigator.language??"en").slice(0,2);return G[e]?e:"en"}function be(e,t){let n=document.createElement("button");return n.type="button",n.className="blipit-rb",n.setAttribute("aria-haspopup","dialog"),e?n.textContent=e:(n.lang=he(),n.textContent=G[n.lang][0]),n.addEventListener("click",()=>n.hasAttribute("aria-busy")||t()),n}var ye=()=>{};function ve(e){ye=e}function J(e,t){ye(T(e.endpoint,"/api/v1/feedback"),e.options.key,t)}function K(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{},n=document.querySelectorAll("button.blipit-rb"),i=r=>{Y(r),n.forEach(o=>r?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))};i(!0),Promise.all([Ve(t.src??`${U}blipit-report.js`,"BlipitReport"),ge??=xe(e)]).then(([r,o])=>o.enabled!==!1&&r.open(e,{metadata:me,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:c=>S&&(S.style.display=c?"none":"")}),()=>J(e,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>i(!1))}async function xe(e){let t=`blipit_fb_${M}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(T(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return O(e,`widget settings failed (HTTP ${n.status}), using defaults`),{};let i=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:i}))}catch{}return i}catch{return O(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function Z(e){let t=e.options.feedbackWidget,n=++fe;if(typeof document>"u")return;if(t===!1)return O(e,"Report a bug button off: feedbackWidget is false");let i=await(ge??=xe(e));if(n!==fe)return;if(i.enabled===!1)return O(e,"Report a bug button hidden by the project's Bug report widget setting");let r={...i,...typeof t=="object"?t:{}},[o,c]=G[he()],d=r.text||o;S=document.createElement("div"),S.setAttribute("data-blipit-ui","");let a=S.attachShadow({mode:"open"}),s=document.createElement("button");s.type="button";let[p,h]=(/^(bottom|middle)-(left|right)$/.test(r.position??"")?r.position:"bottom-right").split("-");s.style.cssText=`${r.color?`--c:${r.color};`:""}${h}:calc(20px + env(safe-area-inset-${h},0px));${p==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,s.setAttribute("aria-haspopup","dialog"),r.style==="icon"&&(s.className="o",s.title=d);let f=b=>{s.disabled=b,s.setAttribute("aria-label",b?c:d),s.innerHTML=b?"<i></i><span></span>":`${He}<span></span>`,s.lastChild.textContent=b?c:d};Y=f,f(!1),s.addEventListener("click",()=>K(e)),N(a,qe),a.append(s);let m=r.shortcut?.toLowerCase().replace(/\s/g,"");_&&document.removeEventListener("keydown",_),_=void 0,m&&(_=b=>{[b.ctrlKey&&"ctrl",b.shiftKey&&"shift",b.altKey&&"alt",b.metaKey&&"meta",b.key.toLowerCase()].filter(Boolean).join("+")===m&&(b.preventDefault(),K(e))},document.addEventListener("keydown",_));let E=S,R=()=>{S===E&&(document.body.append(E),O(e,`Report a bug button shown at ${p}-${h}`))};document.body?R():document.addEventListener("DOMContentLoaded",R)}function ke(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},S?.remove(),S=void 0,_&&document.removeEventListener("keydown",_),_=void 0,Y=()=>{},Z(e)}function Q(e){return typeof e=="string"?e.length:e?.size}function we(e){return e&&Number(e)||void 0}function Ge(e,t){return async(n,i)=>{let r=typeof n=="string"?n:n instanceof URL?n.href:n.url,o=(i?.method??n.method??"GET").toUpperCase(),c=Date.now();try{let d=await e(n,i);return t(o,r,d.status,c,Q(i?.body),we(d.headers.get("content-length"))),d}catch(d){throw t(o,r,0,c,Q(i?.body)),d}}}function Ye(e,t){let n=e.open,i=e.send;e.open=function(r,o){return this._blipit=[String(r).toUpperCase(),String(o)],n.apply(this,arguments)},e.send=function(r){let o=this._blipit;if(o){let c=Date.now();this.addEventListener("loadend",()=>t(o[0],o[1],this.status,c,Q(r),we(this.getResponseHeader("content-length"))))}return i.apply(this,arguments)}}function Se(e){if(typeof window>"u")return;let t=T(e.endpoint,""),{console:n,network:i,actions:r}=e.logs;window.addEventListener("error",a=>{e.captureException(a.error??a.message,!1)}),window.addEventListener("unhandledrejection",a=>{e.captureException(a.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",a=>{let s=a.target;if(!(s instanceof Element)||s.closest("[data-blipit-ui]"))return;let p=H(s);e.addBreadcrumb({category:"ui.click",message:`Clicked ${p}`});let h=s.closest(se)?"***":l((s.textContent??"").trim().replace(/\s+/g," "),80);w(r,{timestamp:v(),type:"click",selector:p,text:h},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",a=>{let s=a.target;s instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(s.tagName)&&w(r,{timestamp:v(),type:"focus",selector:H(s)},50)},{capture:!0,passive:!0}));let o=(a,s,p,h,f,m)=>{t&&s.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${a} ${C(s)} \u2192 ${p||"network error"}`,level:p>=400||!p?"error":"info",data:{url:C(s),method:a,status_code:p||void 0}}),w(i,{timestamp:v(),method:a,url:q(s),status:p,duration:Date.now()-h,request_size:f,response_size:m},50))};typeof window.fetch=="function"&&(window.fetch=Ge(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&Ye(XMLHttpRequest.prototype,o);for(let a of["log","info","debug","warn","error"]){let s=console[a].bind(console);console[a]=(...p)=>{let h=l(p.map(f=>typeof f=="string"?f:Je(f)).join(" "),1024);if(a==="warn"||a==="error"){e.addBreadcrumb({category:"console",level:a==="warn"?"warning":"error",message:h});let f=p.find(m=>m instanceof Error);w(n,{timestamp:v(),level:a,message:h,stack:l((f??new Error).stack??"",2e3)},100)}else w(n,{timestamp:v(),level:a,message:h},100);s(...p)}}let c=()=>w(r,{timestamp:v(),type:"navigation",url:q(location.href)},50),d=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${C(location.href)}`}),c()};if(c(),window.history){let a=window.history.pushState.bind(window.history);window.history.pushState=(...s)=>{a(...s),d()},window.addEventListener("popstate",d)}}function Je(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function Ee(){let e=0,t=0,n=0,i=0;return r=>(r.hadRecentInput||(t>0&&r.startTime-i<1e3&&r.startTime-n<5e3?t+=r.value:(t=r.value,n=r.startTime),i=r.startTime,t>e&&(e=t)),e)}function Ze(e){if(e.size===0)return;let t=[...e.values()].sort((n,i)=>i-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function Qe(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function I(e,t,n){try{new PerformanceObserver(i=>i.getEntries().forEach(r=>t(r))).observe({type:e,buffered:!0,...n})}catch{}}function Re(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let i=performance.getEntriesByType("navigation")[0],r=i?.activationStart??0,o=y=>Math.max(0,Math.round(y-r)),c=document.visibilityState==="hidden",d=location.pathname,a=i?.type,s={},p=Ee(),h=new Map,f=!1,m=!1;i&&i.responseStart>0&&(s.ttfb=o(i.responseStart)),c||(I("paint",y=>{y.name==="first-contentful-paint"&&(s.fcp=o(y.startTime))}),I("largest-contentful-paint",y=>{f||(s.lcp=o(y.startTime))}));let E=()=>{f=!0};addEventListener("keydown",E,{once:!0,capture:!0}),addEventListener("pointerdown",E,{once:!0,capture:!0}),I("layout-shift",y=>{s.cls=Math.round(p(y)*1e4)/1e4});let R=y=>{if(!y.interactionId)return;h.set(y.interactionId,Math.max(h.get(y.interactionId)??0,y.duration));let ee=Ze(h);ee!==void 0&&(s.inp=Math.round(ee))};I("event",R,{durationThreshold:40}),I("first-input",R);let b=navigator.connection?.effectiveType,$=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,k=()=>{if(m||Object.keys(s).length===0)return;m=!0;let y=JSON.stringify({path:d.slice(0,512),metrics:s,nav:a,connection:b&&/^(slow-2g|2g|3g|4g)$/.test(b)?b:void 0,device:Qe(navigator.userAgent)});try{if(navigator.sendBeacon?.($,y))return}catch{}fetch($,{method:"POST",body:y,keepalive:!0}).catch(()=>{})},B=()=>{location.pathname!==d&&(k(),d=location.pathname,a="route",s={},p=Ee(),h=new Map,f=!0,m=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&k()),addEventListener("pagehide",k),addEventListener("popstate",B);let A=history.pushState;history.pushState=function(...y){A.apply(this,y),B()}}function et(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function $e(e,t,n,i,r){let o=et(e);if(!o||typeof document>"u")return;let c=L(),d,a=document.createElement("script");return a.src=e.src??`${r}blipit-replay.js`,a.async=!0,a.onload=()=>{let s=window.BlipitReplay?.start;d=s?.({id:c,mode:o,endpoint:t,key:n,instance:i})},document.head.appendChild(a),{id:c,active:()=>d?.active()??!1,error:s=>d?.error(s),report:s=>d?.report?.(s)}}var Be='<svg viewBox="0 0 242.4 208.7" aria-hidden="true"><defs><linearGradient id="bm1" x1="0" y1="1" x2=".5" y2="0"><stop offset="0" stop-color="#00C2FF"/><stop offset=".35" stop-color="#3882F6"/><stop offset="1" stop-color="#0F172A"/></linearGradient><linearGradient id="bm2" x1="0" y1="1" x2="1" y2="0"><stop offset="0" stop-color="#3882F6"/><stop offset=".5" stop-color="#00C2FF"/><stop offset="1" stop-color="#3882F6"/></linearGradient></defs><path fill="url(#bm1)" d="M115.5,164.5c-3.9,0-7.8-.4-11.5-1.2-3.7-.8-7.3-1.9-10.8-3.4-3.4-1.4-6.7-3.2-9.7-5.3-3.0-2.0-5.9-4.4-8.5-7.0s-4.9-5.4-7.0-8.5c-2.1-3.1-3.9-6.3-5.3-9.8-1.5-3.5-2.6-7.1-3.4-10.8-.8-3.8-1.2-7.7-1.2-11.5V19.1c0-6.6,5.4-12.0,12.0-12.0s12.0,5.4,12.0,12.0v88.2c0,2.2.2,4.5.7,6.7.4,2.1,1.1,4.2,1.9,6.2.8,2.0,1.9,3.9,3.1,5.7,1.2,1.8,2.6,3.4,4.1,4.9s3.2,2.9,4.9,4.1c1.8,1.2,3.7,2.2,5.6,3.1,2.0.8,4.1,1.5,6.2,1.9,4.4.9,9.1.9,13.4,0,2.1-.4,4.2-1.1,6.2-1.9,2.0-.8,3.9-1.9,5.7-3.1,1.8-1.2,3.4-2.6,4.9-4.1s2.9-3.2,4.1-4.9c1.2-1.8,2.2-3.7,3.1-5.7.8-2.0,1.5-4.1,1.9-6.2.5-2.2.7-4.5.7-6.7s-.2-4.5-.7-6.7c-.4-2.1-1.1-4.2-1.9-6.2-.8-2.0-1.9-3.9-3.1-5.7-1.2-1.8-2.6-3.4-4.1-4.9s-3.2-2.9-4.9-4.1c-1.8-1.2-3.7-2.2-5.7-3.1-2.0-.8-4.1-1.5-6.2-1.9-4.4-.9-9.1-.9-13.4,0-6.5,1.3-12.9-2.9-14.2-9.4-1.3-6.5,2.9-12.9,9.4-14.2,7.6-1.6,15.5-1.6,23.1,0,3.7.8,7.3,1.9,10.8,3.4,3.4,1.4,6.7,3.2,9.7,5.3,3.0,2.0,5.9,4.4,8.5,7.0s4.9,5.4,7.0,8.5c2.1,3.1,3.9,6.3,5.3,9.8,1.5,3.5,2.6,7.1,3.4,10.8.8,3.8,1.2,7.7,1.2,11.5s-.4,7.8-1.2,11.5c-.8,3.7-1.9,7.3-3.4,10.8-1.4,3.4-3.2,6.7-5.3,9.7-2.0,3.0-4.4,5.9-7.0,8.5s-5.4,4.9-8.5,7.0c-3.1,2.1-6.3,3.9-9.8,5.3-3.5,1.5-7.1,2.6-10.8,3.4-3.8.8-7.7,1.2-11.5,1.2Z"/><path fill="url(#bm2)" d="M208.1,103.0c-.0-.6-.8-.9-1.2-.5-3.2,3.1-7.6,5.0-12.4,5.0-3.9,0-9.1-1.6-10.2-2.5-.3-.1-.1,1.4-.1,2.5,0,40.5-34.4,73.0-75.5,70.0-33.4-2.5-60.8-28.8-64.4-62.1-1.0-9.4-.2-18.6,2.2-27.0,1.6-5.6,2.6-11.4,2.6-17.3v-22.4c0-3.4-4.3-5.0-6.5-2.4-13.2,15.4-21.6,35.1-22.7,56.6-2.6,54.1,40.6,98.9,94.1,98.9s94.2-42.3,94.2-94.2c0-1.5-.1-3.0-.1-4.5Z"/><path fill="url(#bm2)" d="M201.2,70.1c-14.8-35.8-50.9-60.5-92.3-58.3h-.1c-8.2.5-14.6,7.4-14.6,15.7v.1c0,5.4,4.7,9.6,10.0,8.8,3.2-.5,6.5-.7,9.9-.7,28.7,0,53.5,17.4,64.3,42.1.2.5.9.6,1.2.1,3.2-4.8,8.7-7.9,14.9-7.9,2.0,0,4.0.3,5.8,1.0.6.2,1.1-.4.9-1.0Z"/><circle fill="#00C2FF" cx="194.5" cy="88" r="15.8"/></svg>';var u=".blipit-rb.blipit-rb",tt=`${u}{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:9px;height:40px;padding-inline:5px 17px;border-radius:99px;font:600 14px/1 system-ui,-apple-system,"Segoe UI",sans-serif;letter-spacing:-.01em;white-space:nowrap;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;color:#fff;background:linear-gradient(135deg,#3882F6,#2F5BEA);box-shadow:0 10px 24px -12px rgba(56,130,246,.8),0 1px 3px rgba(11,26,58,.16),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s}${u}:hover{transform:translateY(-1px);box-shadow:0 16px 32px -12px rgba(56,130,246,.85),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22)}${u}:active{transform:scale(.97)}${u}:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}${u}[aria-busy=true]{cursor:progress}${u}>span{all:unset}${u}>.blipit-rb-m{position:relative;display:grid;place-items:center;flex:none;width:30px;height:30px;border-radius:99px;background:#fff;box-shadow:0 0 0 1px rgba(11,26,58,.08),0 1px 2px rgba(11,26,58,.12)}${u} svg{display:block;width:19px;height:17px}${u}[data-size=sm]{height:32px;gap:7px;padding-inline:4px 13px;font-size:13px}${u}[data-size=sm]>.blipit-rb-m{width:24px;height:24px}${u}[data-size=sm] svg{width:15px;height:13px}${u}[data-variant=outline],${u}[data-variant=ghost]{color:#0B1A3A;background:transparent;box-shadow:inset 0 0 0 1px #CBD7EA}${u}[data-variant=ghost]{box-shadow:none}${u}[data-variant=outline]:hover,${u}[data-variant=ghost]:hover{transform:none;background:rgba(56,130,246,.08);box-shadow:inset 0 0 0 1px rgba(56,130,246,.45)}${u}[data-variant=ghost]:hover{box-shadow:none}${u}[data-theme=dark]{background:linear-gradient(135deg,#5B9BFF,#3D6BF0);box-shadow:0 10px 24px -12px rgba(91,155,255,.7),inset 0 1px 0 rgba(255,255,255,.2)}${u}[data-theme=dark][data-variant=outline],${u}[data-theme=dark][data-variant=ghost]{color:#E8EEF8;background:transparent;box-shadow:inset 0 0 0 1px rgba(255,255,255,.16)}${u}[data-theme=dark][data-variant=ghost]{box-shadow:none}${u}[data-theme=dark][data-variant=outline]:hover,${u}[data-theme=dark][data-variant=ghost]:hover{background:rgba(91,155,255,.16);box-shadow:inset 0 0 0 1px rgba(91,155,255,.45)}${u}[data-theme=dark][data-variant=ghost]:hover{box-shadow:none}${u}[data-theme=dark]>.blipit-rb-m{box-shadow:0 0 0 1px rgba(255,255,255,.1)}${u}[aria-busy=true] svg{visibility:hidden}${u}[aria-busy=true]>.blipit-rb-m::after{content:"";position:absolute;inset:4px;border:2px solid #3882F6;border-right-color:transparent;border-radius:50%;animation:blipit-rb-r .8s linear infinite}@keyframes blipit-rb-r{to{transform:rotate(1turn)}}@media(pointer:coarse){${u}{min-height:44px}}@media(prefers-reduced-motion:reduce){${u}{transition:none}${u}:hover,${u}:active{transform:none}${u}[aria-busy=true]>.blipit-rb-m::after{animation-duration:3s}}@media(forced-colors:active){${u}{border:1px solid ButtonText}}`,Te=0;function _e(e,t={}){Te||N(document,tt);let n=++Te,i=document.createElement("span");i.className="blipit-rb-m",i.innerHTML=Be.replace(/bm(\d)/g,`bm$1-${n}`);let r=document.createElement("span");r.textContent=e.textContent,e.replaceChildren(i,r),e.classList.add("blipit-rb"),e.setAttribute("data-variant",t.variant==="outline"||t.variant==="ghost"?t.variant:"solid"),e.setAttribute("data-size",t.size==="sm"?"sm":"md"),e.setAttribute("data-theme",de(t.theme==="light"||t.theme==="dark"?t.theme:void 0))}var g,Ce=new Set;function Le(e,t){Ce.has(t)||(Ce.add(t),console[e](t))}var nt="[blipit] init() has no key, so error tracking and the Report a bug button are off. Pass your public key (blipit_pk_...) from app.blipit.io, API keys.",it="[blipit] init() got a secret key (blipit_sk_...), so Blipit did not start: secret keys must never be in browser code. Use the public key (blipit_pk_...) and create a new secret key in app.blipit.io, API keys.";function Dt(e){if(g)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return Le("warn",nt);if(t.startsWith("blipit_sk_"))return Le("error",it);if(g=new P({...e,key:t}),e.user){let{id:n,name:i,email:r,username:o}=e.user;g.setUser({id:n===void 0?void 0:String(n),email:r,username:o??i})}Se(g),e.webVitals!==!1&&typeof window<"u"&&Re(e.endpoint??z,t,e.instance),e.replay&&(g.replay=$e(e.replay,e.endpoint??z,t,e.instance,U)),typeof window<"u"&&Z(g),e.debug&&console.log(`[blipit] ${X}@${M} initialized`)}function Pt(e){return g?.captureException(e,!0)}function Ut(e,t){return g?.captureMessage(e,t)}function zt(e){return g?.captureSecurity(e)}function Kt(e){g?.setUser(e)}function jt(e,t){g?.setTag(e,t)}function Wt(e){g?.addBreadcrumb(e)}function qt(e={}){g&&J(g,{...e,eventId:e.eventId??g.lastEventId})}function Me(){g&&K(g)}function Ht(e){e.addEventListener("click",t=>{t.preventDefault(),Me()})}function Xt(e={}){let t=be(e.label,Me);return _e(t,e),t}function Vt(e){g&&ke(g,e)}function Gt(){return g?.flush()??Promise.resolve()}ve(ie);export{Wt as addBreadcrumb,Ht as attachReport,Pt as captureException,Ut as captureMessage,zt as captureSecurity,Gt as flush,Dt as init,Me as openReport,Xt as reportButton,Xe as setReportMetadata,jt as setTag,Kt as setUser,qt as showFeedback,Vt as updateWidget};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blipit/browser",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "Blipit error monitoring SDK for browsers. Know your app broke before your users tell you.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"logging"
|
|
48
48
|
],
|
|
49
49
|
"scripts": {
|
|
50
|
-
"build": "tsup src/
|
|
50
|
+
"build": "tsup --entry.index src/npm.ts --format esm,cjs --dts --minify --clean && tsup --entry.index src/global.ts --format iife --global-name Blipit --minify --no-dts && tsup src/replay.ts --format iife --global-name BlipitReplay --minify --no-dts --out-dir served --clean && tsup src/report.ts --format iife --global-name BlipitReport --minify --no-dts --out-dir served && tsup src/button.ts --format iife --global-name BlipitButton --minify --no-dts --out-dir served && tsup src/feedback.ts --format iife --global-name BlipitFeedback --minify --no-dts --out-dir served && node scripts/serve-files.mjs",
|
|
51
51
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
52
|
-
"size": "gzip -c dist/index.global.js | wc -c && gzip -c served/replay.global.js | wc -c && gzip -c served/report.global.js | wc -c && gzip -c served/button.global.js | wc -c"
|
|
52
|
+
"size": "gzip -c dist/index.global.js | wc -c && gzip -c served/replay.global.js | wc -c && gzip -c served/report.global.js | wc -c && gzip -c served/button.global.js | wc -c && gzip -c served/feedback.global.js | wc -c"
|
|
53
53
|
}
|
|
54
54
|
}
|