@hullop/tlm 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ /*! @hullop/tlm 0.2.0 | MIT */
2
+ function Z(t){let e;try{e=new URL(t);}catch{return null}if(e.protocol!=="https:"&&e.protocol!=="http:"||e.username==="")return null;let n=e.origin+e.pathname.replace(/\/+$/,""),r=e.username;return {url:`${n}/api/events?key=${r}`,heartbeatUrl:`${n}/api/heartbeats?key=${r}`,pageviewsUrl:`${n}/api/pageviews?key=${r}`,base:n,key:r}}function ee(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let t=crypto.getRandomValues(new Uint8Array(16));t[6]=(t[6]??0)&15|64,t[8]=(t[8]??0)&63|128;let e=Array.from(t,n=>n.toString(16).padStart(2,"0")).join("");return `${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function T(t,e){if(t.length<=e)return t;let n=t.charCodeAt(e-1);return t.slice(0,n>=55296&&n<=56319?e-1:e)}function H(t,e=8192){return T(_e(t),e)}function _e(t){if(typeof t=="string")return t;if(t===void 0||typeof t=="function"||typeof t=="symbol"||typeof t=="bigint")return String(t);let e=new WeakSet;try{return JSON.stringify(t,(n,r)=>{if(typeof r=="bigint")return r.toString();if(typeof r=="object"&&r!==null){if(e.has(r))return "[Circular]";e.add(r);}return r})}catch{try{return String(t)}catch{return "[unserializable]"}}}function g(t){let e=t.search(/[?#]/);return e===-1?t:t.slice(0,e)}var ke=500;function te(t,e){try{let n=new URL(e,t);return n.protocol!=="http:"&&n.protocol!=="https:"?void 0:(n.origin+n.pathname).slice(0,ke)}catch{return}}var Oe=250,Le=/^\s*at (?:(.+?) \()?(.+?):(\d+):(\d+)\)?$/,Ae=/^(.*?)@(.*):(\d+):(\d+)$/,Ue=/\((\S+?):(\d+):(\d+)\)/,Ne=/^(.*?) line (\d+) > (?:eval|Function)/,$e=new Set(["global code","module code","eval code"]);function ne(t){let e=[];for(let n of t.split(`
3
+ `)){let r=De(n)??Ie(n);r&&e.push(r);}return e}function De(t){let e=Le.exec(t);if(e?.[2]===void 0)return;let n=e[2],r=Number(e[3]),i=Number(e[4]);if(n.startsWith("eval at ")){let s=Ue.exec(n);if(s?.[1]===void 0)return;n=s[1],r=Number(s[2]),i=Number(s[3]);}return {function:W(e[1]),url:n,line:r,column:i}}function Ie(t){let e=Ae.exec(t);if(e?.[2]===void 0||e[2]==="")return;let n=e[1],r=/^([^*]*)\*(.*)$/.exec(n??"");if(r){if(r[1]!=="async")return;n=r[2];}let i=Ne.exec(e[2]);return i?.[1]!==void 0&&i[1]!==""?{function:W(n),url:i[1],line:Number(i[2]),column:void 0}:{function:W(n),url:e[2],line:Number(e[3]),column:Number(e[4])}}function W(t){if(t===void 0||t===""||$e.has(t))return;let e=t.replace(/^async\*/,"").replace(/^(?:async|new) /,"").replace(/ \[as [^\]]*\]$/,"").replace(/[/<]+$/,""),n=e.slice(Math.max(e.lastIndexOf("."),e.lastIndexOf("/"))+1);return n!==""&&n!=="<anonymous>"?n:void 0}function K(t){return /^(?:chrome|moz|safari|safari-web)-extension:\/\//.test(t)}var Me=[/\/node_modules\//,/\/\.vite\/deps\//,/\/vendors?(?:\/|[-.~][^/]*$)/,/chunk-vendors/,/vendors~/,/\/@vite\//,/\/@react-refresh/,/\/_next\/static\/chunks\/(?:framework|main|webpack)[-.]/],Be=/[-.~]([A-Za-z0-9_]{8,}|[A-Za-z0-9_-]{8})(?=\.)/g;function Pe(t){return /\d/.test(t)?true:t.length!==8?false:/[_-]/.test(t)||/[A-Z]/.test(t)&&/[a-z]/.test(t)&&!/[a-z]{3}/.test(t)}function X(t){let e=g(t),n=e.lastIndexOf("/")+1,r=e.slice(n).replace(Be,(i,s)=>Pe(s)?"":i);return e.slice(0,n)+r}function re(t,e){let n=[];for(let r of t)if(r.function?.startsWith("__tlm")!==true){if(n.length===Oe)break;n.push(Fe(r,e));}return n}function Fe(t,{origin:e,inAppUrls:n,isDependency:r,ownUrl:i}){let s;try{s=new URL(t.url,e);}catch{s=void 0;}let o=t.url.startsWith("webpack-internal://"),d=s?.origin===e||o,c=g(t.url);s&&!o&&(c=d?s.pathname:g(s.href));let u=s?g(s.href):void 0,a=u!==void 0&&u===i,l=u!==void 0&&r?.(u)===true,h=!a&&(n?n.some(v=>typeof v=="string"?t.url.includes(v):v.test(t.url)):d&&!K(t.url)&&!Me.some(v=>v.test(c))&&!l),m={module:X(c),function:t.function??"?",file:c,in_app:h};return t.line!==void 0&&(m.line=t.line),t.column!==void 0&&(m.column=t.column),m}var G=8192,Ce=new Set(["fatal","error","warning","info"]),je={debug:"info",log:"info",warn:"warning",critical:"fatal"};function qe(t){return typeof t!="string"?"error":Ce.has(t)?t:je[t]??"error"}var x="@hullop/tlm";function He(t){if(t instanceof Error)return true;if(typeof t!="object"||t===null)return false;let e=t;return typeof e.message=="string"&&(typeof e.name=="string"||typeof e.stack=="string")}function We(t){if(typeof t.name=="string"&&t.name!=="")return t.name;let e=t.constructor?.name;return typeof e=="string"&&e!==""&&e!=="Object"?e:"Error"}function V(t,e,n,r="manual"){let i=se(e,n);if(He(t)){let s=typeof t.stack=="string"?re(ne(t.stack),{origin:e.origin,inAppUrls:e.options.inAppUrls,isDependency:e.isDependency,ownUrl:e.ownUrl}):[];i.exception={type:We(t),message:T(String(t.message),G)},s.length>0&&(i.exception.frames=s);}else i.exception={type:r==="onunhandledrejection"?"UnhandledRejection":"NonError",message:H(t,G)};return i}function ie(t,e,n){let r=se(e,n);return r.message=H(t,G),r}function Ke(){return typeof __TLM_RELEASE__=="string"?__TLM_RELEASE__:void 0}function _(t){let e=t.release??Ke();return e===""?void 0:e}function k(t){return typeof t.environment=="string"&&t.environment!==""?t.environment:void 0}function se({options:t,scope:e,href:n,userAgent:r,session:i},s={}){let o={v:1,uuid:ee(),timestamp:new Date().toISOString(),platform:"javascript",level:qe(s.level),request:{url:t.stripQuery===false?n:g(n),headers:{"user-agent":r}},sdk:{name:x,version:"0.2.0"}},d=k(t);d!==void 0&&(o.environment=d);let c=_(t);c!==void 0&&(o.release=c),i!==void 0&&(o.session=i),s.fingerprint&&s.fingerprint.length>0&&(o.fingerprint=s.fingerprint.map(String));let u=s.user?{id:String(s.user.id)}:e.user;u&&(o.user=u);let a={...e.tags,...s.tags};Object.keys(a).length>0&&(o.tags=a);let l=e.getBreadcrumbs();return l.length>0&&(o.breadcrumbs=l),o}var oe=["ResizeObserver loop limit exceeded","ResizeObserver loop completed with undelivered notifications",/^(?:Error: )?Script error\.?$/];function ae(t){let{exception:e}=t;return e?e.message!==void 0&&e.message!==""?`${e.type}: ${e.message}`:e.type:t.message??""}function ue(t,e){let n=t.exception?.frames;if(n!==void 0&&n.length>0&&n.every(i=>K(i.file)))return true;let r=ae(t);return e.some(i=>typeof i=="string"?r.includes(i):i.test(r))}var U=class{constructor(e=1e3){this.windowMs=e;this.lastAt=0;}isDuplicate(e,n){let r=(e.exception?.frames??[]).slice(0,5).map(o=>`${o.file}:${String(o.line)}:${String(o.column)}`),i=`${ae(e)}
4
+ ${r.join(`
5
+ `)}`,s=i===this.last&&n-this.lastAt<=this.windowMs;return this.last=i,this.lastAt=n,s}},N=class{constructor(e=30,n=1e4){this.max=e;this.windowMs=n;this.times=[];}take(e){return this.times=this.times.filter(n=>e-n<this.windowMs),this.times.length>=this.max?false:(this.times.push(e),true)}};function de(t,e,n){let r=s=>{try{if(typeof s.target?.nodeType=="number")return;let o=s;e(o.error??Ge(o),"onerror");}catch{}},i=s=>{try{e(s.reason,"onunhandledrejection");}catch{}};return n.onerror&&t.addEventListener("error",r),n.onunhandledrejection&&t.addEventListener("unhandledrejection",i),()=>{t.removeEventListener("error",r),t.removeEventListener("unhandledrejection",i);}}var Xe=/^(?:Uncaught |uncaught exception: )?(null|undefined)$/;function Ge(t){let e=Xe.exec(t.message),n=new Error(e?.[1]??(t.message!==""?t.message:"Unknown error"));return e&&(n.name="NonError"),n.stack=typeof t.filename=="string"&&t.filename!==""?`${n.name}: ${n.message}
6
+ at ? (${t.filename}:${String(t.lineno)}:${String(t.colno)})`:"",n}var ce=5e3,Ve="tlm:heartbeat:",le=new Set;function fe(t){let e,n=()=>{Qe(t);},r=setTimeout(()=>{"requestIdleCallback"in globalThis?e=requestIdleCallback(n,{timeout:ce}):n();},ce);return ()=>{clearTimeout(r),e!==void 0&&cancelIdleCallback(e);}}function ze(t){try{return localStorage.getItem(t)}catch{return null}}async function Qe({url:t,key:e,fetch:n,options:r,logger:i}){let s=_(r),o=k(r),d=Ve+e,c=JSON.stringify([new Date().toISOString().slice(0,10),s??"",o??""]);if(ze(d)===c||le.has(d+c))return;let u;try{let a=JSON.stringify({v:1,sdk:{name:x,version:"0.2.0"},environment:o,release:s});({status:u}=await n(t,{method:"POST",body:a,headers:{"Content-Type":"text/plain;charset=UTF-8"},keepalive:!0,credentials:"omit"}));}catch(a){i.debug("heartbeat not sent",a);return}if(!(u===429||u>=500))try{localStorage.setItem(d,c);}catch{le.add(d+c);}}function w(t,e){let n=t.querySelector(`meta[name="tlm-${e}"]`)?.getAttribute("content")?.trim();return n===""?void 0:n}var Je=t=>!/^(?:\.{0,2}\/|[a-z][a-z\d+.-]*:)/i.test(t);function Ye(t,e){let n=[];for(let r of t.querySelectorAll('script[type="importmap"]')){let i;try{i=JSON.parse(r.textContent);}catch{continue}let s=typeof i=="object"&&i!==null&&"imports"in i?i.imports:void 0;if(!(typeof s!="object"||s===null)){for(let[o,d]of Object.entries(s))if(!(!Je(o)||typeof d!="string"))try{n.push({specifier:o,url:g(new URL(d,e).href)});}catch{}}}return n}function Ze({specifier:t,url:e}){let n=t.replace(/\/$/,""),r=X(new URL(e).pathname).replace(/\.m?js$/,"").replace(/\/$/,"");return r.endsWith(`/${n}`)||r.endsWith(`/${n}/index`)}function et(t,e){return t.some(n=>n.endsWith("/")?e.startsWith(n)||e===n.slice(0,-1):e===n)}function pe(t,e){let n=w(t,"in-app")?.split(/\s+/),r=o=>n?!et(n,o.specifier):o.specifier.startsWith("@")||!Ze(o),i=new Set,s=[];for(let o of Ye(t,e))r(o)&&(o.specifier.endsWith("/")?s.push(o.url):i.add(o.url));return o=>i.has(o)||s.some(d=>o.startsWith(d))}var $=10,tt=100;function D(t,e=false){if(typeof t=="string")return e?JSON.stringify(T(t,tt)):t;if(t===null||typeof t!="object")return typeof t=="function"?`[Function ${t.name!==""?t.name:"anonymous"}]`:String(t);let n=t;if(t instanceof Error||typeof n.message=="string"&&typeof n.name=="string")return `${String(n.name)}: ${String(n.message)}`;if(typeof n.nodeType=="number")return typeof n.tagName=="string"?`<${n.tagName.toLowerCase()}>`:"[Node]";if(e)return Array.isArray(t)?`[Array(${String(t.length)})]`:"{\u2026}";if(Array.isArray(t))return `[${t.slice(0,$).map(i=>D(i,true)).join(", ")}${t.length>$?", \u2026":""}]`;try{let r=Object.keys(t);return `{${r.slice(0,$).map(s=>`${s}: ${D(t[s],!0)}`).join(", ")}${r.length>$?", \u2026":""}}`}catch{return "{\u2026}"}}var me="__tlm_original__";function E(t,e,n){let r=t[e];if(typeof r!="function"||r[me]!==void 0)return ()=>true;let i=n(r);return Object.defineProperty(i,me,{value:r}),t[e]=i,()=>t[e]!==i?false:(t[e]=r,true)}function p(t){try{t();}catch{}}function R(t,e,n){let r=e;try{let i=new URL(e,t.location.href);i.username="",i.password="",r=i.origin===t.location.origin?i.pathname+i.search+i.hash:i.href;}catch{}return n?g(r):r}function I(t,e,n,r){let i=t.onRequest?te(e.location.href,r):void 0;if(i===void 0)return ()=>{};let s=performance.now(),o=t.onRequestStart?.();return d=>{t.onRequest?.({method:n.toUpperCase(),url:i,status:d??0,start:s,end:performance.now()},o);}}function M(t,e){try{return new URL(e,t.location.href).href}catch{return e}}function B(t){return t===void 0||t>=500?"error":t>=400?"warning":"info"}function P(t,e,n){return `${t.toUpperCase()} ${e} \u2192 ${n===void 0?"failed":String(n)}`}var ge={error:"error",warn:"warning",log:"info",info:"info"};function he(t,e,n){let r=t.console,i=Object.keys(ge).map(s=>E(r,s,o=>function(...c){p(()=>{e({category:"console",level:ge[s],message:T(c.map(u=>D(u)).join(" "),500)});}),o.apply(this,c);}));return ()=>i.map(s=>s()).every(Boolean)}var nt=3;function rt(t){let e=[],n=t;for(;n&&e.length<nt&&n.tagName!=="BODY"&&n.tagName!=="HTML";){let r=n.tagName.toLowerCase();n.id!==""&&(r+=`#${n.id}`);for(let i of Array.from(n.classList))r+=`.${i}`;e.unshift(r),n=n.parentElement;}return e.join(" > ")}function ye(t,e,n){let r=i=>{p(()=>{let s=i.target;if(s?.nodeType!==1)return;let o=rt(s);o!==""&&e({category:"ui.click",level:"info",message:o});});};return t.document.addEventListener("click",r,true),()=>(t.document.removeEventListener("click",r,true),true)}function it(t,e){let n=typeof Request<"u"&&t instanceof Request,r;return n?r=t.url:t instanceof URL?r=t.href:r=String(t),{method:e?.method??(n?t.method:"GET"),url:r}}function be(t,e,n){return E(t,"fetch",r=>async function(s,o){let d=r.apply(this,arguments),c=u=>{};return p(()=>{let{method:u,url:a}=it(s,o);if(n.skipUrl(M(t,a)))return;let l=R(t,a,n.stripQuery),h=I(n,t,u,a);c=m=>{p(()=>{h(m),e({category:"fetch",level:B(m),message:P(u,l,m)});});};}),d.then(u=>(c(u.status),u),u=>{throw c(void 0),u})})}function ve(t,e,n){let r=()=>{let a=R(t,t.location.href,n.stripQuery),{hash:l}=t.location;return !n.stripQuery||!/^#!?\//.test(l)?a:`${a}#${g(l.slice(1))}`},i=r(),s=()=>{p(()=>{let a=r();a!==i&&(e({category:"navigation",level:"info",message:`${i} \u2192 ${a}`}),i=a);});},o=a=>E(t.history,a,l=>function(...m){l.apply(this,m),s(),d();}),d=()=>{p(()=>{n.onNavigate?.();});},c=()=>{s(),d();},u=[o("pushState"),o("replaceState")];return t.addEventListener("popstate",c),t.addEventListener("hashchange",s),()=>u.map(a=>a()).every(Boolean)?(t.removeEventListener("popstate",c),t.removeEventListener("hashchange",s),true):false}function Te(t,e,n){let r=t.XMLHttpRequest;if(!r)return ()=>true;let i=r.prototype,s=new WeakMap,o=E(i,"open",c=>function(...a){p(()=>{let[l,h]=a;s.set(this,{method:String(l),url:h instanceof URL?h.href:String(h)});}),c.apply(this,a);}),d=E(i,"send",c=>function(a){p(()=>{let l=s.get(this);if(!l||n.skipUrl(M(t,l.url)))return;let h=R(t,l.url,n.stripQuery),m=I(n,t,l.method,l.url);this.addEventListener("loadend",()=>{p(()=>{let v=this.status!==0?this.status:void 0;m(v),e({category:"xhr",level:B(v),message:P(l.method,h,v)});});},{once:!0});}),c.call(this,a);});return ()=>[o(),d()].every(Boolean)}function we(t){let e=new Set,{debug:n,info:r,warn:i}=console;return {debug(...s){t()&&n.call(console,"[tlm]",...s);},warnOnce(s){e.has(s)||(e.add(s),i.call(console,`[tlm] ${s}`));},info(s){r.call(console,`[tlm] ${s}`);},warn(s){i.call(console,`[tlm] ${s}`);}}}var st=500,S=class{constructor(){this.tags={};this.breadcrumbs=[];}setUser(e){this.user=e?{id:String(e.id)}:void 0;}setTag(e,n){this.tags[e]=String(n);}setTags(e){for(let[n,r]of Object.entries(e))this.setTag(n,r);}addBreadcrumb(e,n){this.breadcrumbs.push({...e,timestamp:e.timestamp??new Date().toISOString(),message:T(String(e.message),st)}),this.breadcrumbs.length>n&&this.breadcrumbs.splice(0,this.breadcrumbs.length-n);}getBreadcrumbs(){return this.breadcrumbs.map(e=>({...e}))}clear(){this.user=void 0,this.tags={},this.breadcrumbs=[];}};function O(t,e){let{onAnswer:n}=t;t.onAnswer=void 0,n?.(e);}var z=1e3,ot=6e4,at=8,ut=60,Ee=6e4,Q=1e6,dt=50,ct=new TextEncoder,L=t=>ct.encode(t).length,F=class{constructor(e){this.deps=e;this.disabled=false;this.queue=[];this.inFlight=false;this.paused=false;this.backoff=z;this.inFlightKeepaliveBytes=0;this.idleWaiters=[];this.maxQueue=e.maxQueue??30;}send(e,n){if(!this.disabled){if(this.queue.length>=this.maxQueue){let r=this.queue.shift();r&&O(r,{error:new Error("dropped: too many events queued")}),this.deps.logger.debug("queue full, dropped the oldest event");}this.queue.push({event:e,attempts:0,...n?{onAnswer:n}:{}}),this.dispatch();}}async flush(e=2e3){return this.isIdle()?Promise.resolve(true):new Promise(n=>{let r=setTimeout(()=>{this.idleWaiters=this.idleWaiters.filter(s=>s!==i),n(false);},e),i=()=>{clearTimeout(r),n(true);};this.idleWaiters.push(i);})}sendQueuedNow(){if(this.disabled||this.paused)return;let e=Ee-this.inFlightKeepaliveBytes;for(let{event:n}of this.queue.splice(0)){let r=Se(n);if(r===void 0)continue;let i=L(r),s=i<=e;s&&(e-=i);try{this.deps.fetch(this.deps.url,{method:"POST",body:r,headers:{"Content-Type":"text/plain;charset=UTF-8"},keepalive:s,credentials:"omit"}).catch(()=>{});}catch{}}this.notifyIfIdle();}isIdle(){return !this.inFlight&&(this.queue.length===0||this.disabled)}dispatch(){let e=this.inFlight||this.paused||this.disabled?void 0:this.queue.shift();if(!e){this.notifyIfIdle();return}let n=Se(e.event);if(n===void 0){this.deps.logger.debug("dropped an event that is over 1 MB or not JSON-encodable",e.event.uuid),O(e,{error:new Error("dropped: over 1 MB or not JSON-encodable")}),this.dispatch();return}this.inFlight=true;let r=L(n),i=r<=Ee;this.inFlightKeepaliveBytes=i?r:0;let s;try{s=this.deps.fetch(this.deps.url,{method:"POST",body:n,headers:{"Content-Type":"text/plain;charset=UTF-8"},keepalive:i,credentials:"omit"});}catch(o){s=Promise.reject(o instanceof Error?o:new Error(String(o)));}s.then(o=>{this.handle(e,o);},o=>{this.retry(e,o);});}handle(e,n){this.inFlight=false,this.inFlightKeepaliveBytes=0;let{status:r}=n;if(O(e,{status:r}),r>=200&&r<300)this.backoff=z;else if(r===429)this.backoff=z,this.pause(lt(n.headers.get("Retry-After"))*1e3);else if(r===401||r===403)this.disable(r);else if(r>=500){this.retry(e,`HTTP ${String(r)}`);return}else {let{logger:i}=this.deps;n.text().then(s=>{i.debug(`Tlm rejected an event (HTTP ${String(r)})`,e.event.uuid,s);},()=>{i.debug(`Tlm rejected an event (HTTP ${String(r)})`,e.event.uuid);});}this.dispatch();}retry(e,n){O(e,{error:n}),this.inFlight=false,this.inFlightKeepaliveBytes=0,e.attempts+=1,e.attempts>=at?this.deps.logger.debug(`gave up on an event after ${String(e.attempts)} tries`,n):(this.deps.logger.debug("sending failed, will retry",n),this.queue.unshift(e));let r=this.backoff;this.backoff=Math.min(this.backoff*2,ot),this.pause(r);}pause(e){this.paused=true,setTimeout(()=>{this.paused=false,this.dispatch();},e);}disable(e){this.disabled=true;for(let r of this.queue.splice(0))O(r,{error:new Error(`dropped: Tlm rejected this DSN (HTTP ${String(e)})`)});this.deps.onDisable?.();let n=this.deps.origin??"unknown origin";this.deps.logger.warnOnce(e===401?"Tlm rejected the key (HTTP 401): check the DSN on your project's setup page. Nothing more will be sent from this page.":`This site's domain (${n}) is blocked for this project in Tlm (HTTP 403). Events won't be sent from this page. A project admin can unblock it in the project's settings.`);}notifyIfIdle(){if(!this.isIdle())return;let e=this.idleWaiters;this.idleWaiters=[];for(let n of e)n();}};function lt(t){let e=Number.parseInt(t??"",10);return e>=0?e:ut}function Se(t){try{return ft(t)}catch{return}}function ft(t){let e=JSON.stringify(t);if(L(e)<=Q)return e;let n={...t};if(delete n.breadcrumbs,e=JSON.stringify(n),L(e)<=Q||n.exception?.frames&&(n.exception={...n.exception,frames:n.exception.frames.slice(0,dt)},e=JSON.stringify(n),L(e)<=Q))return e}var pt={console:he,dom:ye,fetch:be,xhr:Te,history:ve},mt=50,gt=import.meta.url,Re=1e4;function ht(t){if("error"in t)return `couldn't reach Tlm (${t.error instanceof Error?t.error.message:String(t.error)}). Check the DSN's host, your network, and your Content-Security-Policy's connect-src.`;let{status:e}=t;if(!(e>=200&&e<300))return e===401?"Tlm rejected the key (HTTP 401). Check the DSN on your project's setup page.":e===403?"this site's domain is blocked for the project (HTTP 403). A project admin can unblock it in the project's settings.":e===429?"Tlm asked to slow down (HTTP 429). Try again in a minute.":e>=500?`Tlm had an error (HTTP ${String(e)}). The event will be retried.`:`Tlm rejected the event (HTTP ${String(e)}).`}var y,C=new Map,yt={skipUrl:t=>y?.isOwnUrl(t)??false,get stripQuery(){return y?.options.stripQuery!==false},onRequestStart:()=>y?.rum?.requestStart(),onRequest:(t,e)=>{y?.rum?.request(t,e);},onNavigate:()=>{y?.rum?.navigate();}},bt=new Set(["fetch","xhr","history"]),xe=new Set,vt=t=>e=>{y&&y.options.breadcrumbs?.[t]!==false&&y.addBreadcrumb(e);};function Tt(t){return t.__tlm_original__??t}var j=class{constructor(e,n,r=new S){this.options=e;this.win=n;this.scope=r;this.cleanups=[];this.deduper=new U;this.rateGuard=new N;this.closed=false;if(this.logger=we(()=>e.debug===true),this.ignore=[...oe,...e.ignoreErrors??[]],e.enabled===false){this.logger.debug("disabled (enabled: false): nothing will be sent"),this.inactive="the SDK is off (enabled: false).";return}if(typeof e.dsn!="string"||e.dsn===""){this.logger.debug("no DSN given: nothing will be sent"),this.inactive='no DSN given to init() or in <meta name="tlm-dsn">.';return}let i=Z(e.dsn);if(!i){this.logger.debug("invalid DSN: nothing will be sent",e.dsn),this.inactive="invalid DSN. Copy it from your project's setup page.";return}this.endpointBase=i.base;let s=Tt(n.fetch).bind(n),{url:o}=i;this.transport=new F({url:o,fetch:s,logger:this.logger,origin:n.location.origin,onDisable:()=>xe.add(o)}),xe.has(o)?(this.transport.disabled=true,this.logger.debug("Tlm already rejected this DSN on this page: nothing will be sent")):e.heartbeat!==false&&this.cleanups.push(fe({url:i.heartbeatUrl,key:i.key,fetch:s,options:e,logger:this.logger}));let d=e.autoCapture;if(d!==false&&this.cleanups.push(de(n,(a,l)=>this.captureException(a,void 0,l),{onerror:d?.onerror!==false,onunhandledrejection:d?.onunhandledrejection!==false})),e.rum&&!this.transport.disabled)try{this.rum=e.rum.start({win:n,url:i.pageviewsUrl,fetch:s,logger:this.logger,options:e,sdk:{name:x,version:"0.2.0"},environment:k(e),release:_(e)});}catch(a){this.logger.debug("RUM didn't start",a);}y=this;for(let[a,l]of Object.entries(pt))if(!(!(e.breadcrumbs?.[a]!==false||this.rum!==void 0&&bt.has(a))||C.has(a)))try{C.set(a,l(n,vt(a),yt));}catch(m){this.logger.debug(`couldn't record ${a} breadcrumbs`,m);}this.isDependency=pe(n.document,n.location.href),this.followMeta();let c=()=>{this.rum?.navigate(),this.followMeta();};n.document.addEventListener("turbo:load",c),this.cleanups.push(()=>{n.document.removeEventListener("turbo:load",c);});let u=()=>{this.transport?.sendQueuedNow();};n.addEventListener("pagehide",u),this.cleanups.push(()=>{n.removeEventListener("pagehide",u);});}captureException(e,n,r="manual"){return this.capture(()=>V(e,this.env(),n,r))}captureMessage(e,n){let r=typeof n=="string"?{level:n}:n;return this.capture(()=>ie(e,this.env(),r))}async test(){let e=s=>(this.logger.warn(`Test event not sent: ${s}`),{ok:false,reason:s}),{transport:n}=this;if(this.closed)return Promise.resolve(e("the SDK was closed."));if(!n)return Promise.resolve(e(this.inactive??"the SDK isn't sending."));if(n.disabled)return Promise.resolve(e("Tlm already rejected this DSN on this page (HTTP 401/403)."));let r;try{let s=new Error("Test event from Tlm.test(). If you can see it in Tlm, your setup works.");throw s.name="TlmTest",s}catch(s){r=V(s,this.env(),{tags:{"tlm.test":"true"},fingerprint:["tlm.test"]});}let i=this.beforeSend(r)??r;return new Promise(s=>{let o=false,d=u=>{o||(o=true,clearTimeout(c),s(u));},c=setTimeout(()=>{d(e(`no answer from Tlm within ${String(Re/1e3)} s.`));},Re);n.send(i,u=>{if(o)return;let a=ht(u);if(a!==void 0){d(e(a));return}this.logger.info(`Test event sent (${"status"in u?String(u.status):"?"}). Look for "TlmTest" in your project: ${i.uuid}`),d({ok:true,id:i.uuid});});})}addBreadcrumb(e){this.scope.addBreadcrumb(e,this.options.maxBreadcrumbs??mt);}async flush(e){return this.transport?this.transport.flush(e):Promise.resolve(true)}setRoute(e){this.rum?.setRoute(e);}isOwnUrl(e){return this.endpointBase!==void 0&&e.startsWith(`${this.endpointBase}/`)}close(){this.closed=true;try{this.rum?.close();}catch(e){this.logger.debug("RUM didn't close cleanly",e);}if(y===this){y=void 0;for(let[e,n]of C)try{n()&&C.delete(e);}catch{}}for(let e of this.cleanups.splice(0).reverse())try{e();}catch(n){this.logger.debug("cleanup failed",n);}}followMeta(){let e=this.win.document,n=w(e,"user"),r=this.scope.user?.id;(r===void 0||r===this.metaUser)&&this.scope.setUser(n===void 0?null:{id:n}),this.metaUser=n;let i=w(e,"route");i!==void 0&&this.setRoute(i);}env(){let{win:e}=this;return {options:this.options,scope:this.scope,origin:e.location.origin,href:e.location.href,userAgent:e.navigator.userAgent,session:this.rum?.session,isDependency:this.isDependency,ownUrl:gt}}capture(e){let n=this.transport;if(!n||this.closed||n.disabled)return;let r=e();if(ue(r,this.ignore)){this.logger.debug("ignored",r.exception?.type??r.message);return}let i=Date.now();if(this.deduper.isDuplicate(r,i))return;let s=this.beforeSend(r);if(s){if(!this.rateGuard.take(i)){this.logger.debug("too many events, dropped one");return}return n.send(s),s.uuid}}beforeSend(e){let n=this.options.beforeSend;if(!n)return e;let r;try{r=n(e);}catch(i){return this.logger.debug("beforeSend threw; sending the event unchanged",i),e}if(r!==null){if((typeof r=="object"||typeof r=="function")&&"then"in r&&typeof r.then=="function"){this.logger.warnOnce("beforeSend returned a Promise, so the event was dropped. It must return the event (or null) right away, not async.");return}if(typeof r!="object"||Array.isArray(r)||!("uuid"in r)||typeof r.uuid!="string"){this.logger.debug("beforeSend returned neither an event nor null; dropped",r);return}return r}}};var On="0.2.0",f,A,Y=new S;function q(){return f?.scope??Y}function b(t,e){try{return t()}catch(n){return f?.logger.debug("internal error",n),e}}function wt(t,e){return {...t,dsn:t.dsn??w(e,"dsn"),environment:t.environment??w(e,"environment"),release:t.release??w(e,"release")}}function Ln(t={}){b(()=>{if(typeof window>"u")return;let e=q();f?.close(),f=new j(wt(t,window.document),window,e),A&&f.setRoute(A.name),A=void 0,t.debug===!0?Object.defineProperty(window,J,{value:{test:Et},configurable:!0,writable:!0}):Reflect.deleteProperty(window,J);},void 0);}var J="__tlm";async function Et(){let t=()=>{let e="init() hasn't run on this page (or this isn't a browser).";return console.warn(`[tlm] Test event not sent: ${e}`),{ok:false,reason:e}};return b(async()=>f?f.test():Promise.resolve(t()),Promise.resolve({ok:false,reason:"internal error."}))}function An(t,e){return b(()=>f?.captureException(t,e),void 0)}function Un(t,e){return b(()=>f?.captureMessage(t,e),void 0)}function Nn(t){b(()=>{q().setUser(t);},void 0);}function $n(t,e){b(()=>{q().setTag(t,e);},void 0);}function Dn(t){b(()=>{q().setTags(t);},void 0);}function In(t){b(()=>{f?f.addBreadcrumb(t):Y.addBreadcrumb(t,50);},void 0);}async function Mn(t){return b(async()=>f?.flush(t)??Promise.resolve(true),Promise.resolve(false))}function Bn(t){b(()=>{f?f.setRoute(t):A={name:t};},void 0);}function Pn(){b(()=>{f?.close(),f=void 0,Y=new S,A=void 0,typeof window<"u"&&Reflect.deleteProperty(window,J);},void 0);}
7
+ export{On as SDK_VERSION,In as addBreadcrumb,An as captureException,Un as captureMessage,Pn as close,Mn as flush,Ln as init,Bn as setRoute,$n as setTag,Dn as setTags,Nn as setUser,Et as test};
@@ -0,0 +1,179 @@
1
+ interface Logger {
2
+ debug: (...args: unknown[]) => void;
3
+ /** For misconfigurations the developer must see, even without `debug`. Once per message. */
4
+ warnOnce: (message: string) => void;
5
+ /** Always shown, for answers to something the developer asked for (like `test()`). */
6
+ info: (message: string) => void;
7
+ warn: (message: string) => void;
8
+ }
9
+
10
+ /** How bad an event is. Tlm accepts exactly these four. */
11
+ type Level = "fatal" | "error" | "warning" | "info";
12
+ /** One stack frame, innermost first, as the protocol defines it. */
13
+ interface Frame {
14
+ /** Script path with content hashes removed, e.g. `/assets/index.js`. Used for grouping. */
15
+ module: string;
16
+ /** Function name, or `"?"` for anonymous functions. */
17
+ function: string;
18
+ /** Script path as loaded, e.g. `/assets/index-a1b2c3d4.js`. Shown, not grouped on. */
19
+ file: string;
20
+ line?: number;
21
+ column?: number;
22
+ /** True for the app's own code; this decides how errors group into issues. */
23
+ in_app: boolean;
24
+ }
25
+ /** Something that happened before an error: a click, a request, a log line. */
26
+ interface Breadcrumb {
27
+ /** ISO 8601; set to now when missing. */
28
+ timestamp?: string;
29
+ level?: Level;
30
+ /** e.g. `ui.click`, `fetch`, `xhr`, `navigation`, `console`. */
31
+ category?: string;
32
+ message: string;
33
+ }
34
+
35
+ /** One fetch or XHR call, as the RUM plugin sees it. Times are `performance.now()` ms. */
36
+ interface RequestTiming {
37
+ method: string;
38
+ /** Absolute, without credentials, query or fragment. */
39
+ url: string;
40
+ /** `0` when there was no answer. */
41
+ status: number;
42
+ start: number;
43
+ end: number;
44
+ }
45
+ /** What the core hands the RUM plugin when it starts. */
46
+ interface RumContext {
47
+ win: Window;
48
+ /** `POST` URL for page views, key included. */
49
+ url: string;
50
+ /** The unwrapped `fetch`, so RUM's own requests are never measured. */
51
+ fetch: typeof fetch;
52
+ logger: Logger;
53
+ options: TlmOptions;
54
+ sdk: {
55
+ name: string;
56
+ version: string;
57
+ };
58
+ environment: string | undefined;
59
+ release: string | undefined;
60
+ }
61
+ /** A running RUM plugin, as the core drives it. */
62
+ interface RumHandle {
63
+ /** The tab's session id, only when RUM sampled this tab. Events carry it. */
64
+ readonly session: string | undefined;
65
+ /** A request started. What it returns comes back with its `request()` when it ends. */
66
+ requestStart: () => unknown;
67
+ request: (timing: RequestTiming, token?: unknown) => void;
68
+ /** The URL may have changed (pushState, replaceState, popstate). */
69
+ navigate: () => void;
70
+ setRoute: (name: string | undefined) => void;
71
+ close: () => void;
72
+ }
73
+ /** What `rum()` from `@hullop/tlm/rum` returns, for `init({ rum })`. */
74
+ interface RumPlugin {
75
+ start: (ctx: RumContext) => RumHandle;
76
+ }
77
+ /** An event as sent to Tlm (protocol v1). */
78
+ interface TlmEvent {
79
+ v: 1;
80
+ uuid: string;
81
+ timestamp: string;
82
+ platform: "javascript";
83
+ level: Level;
84
+ environment?: string;
85
+ release?: string;
86
+ exception?: {
87
+ type: string;
88
+ message?: string;
89
+ frames?: Frame[];
90
+ };
91
+ message?: string;
92
+ fingerprint?: string[];
93
+ request?: {
94
+ url: string;
95
+ headers: Record<string, string>;
96
+ };
97
+ user?: {
98
+ id: string;
99
+ };
100
+ tags?: Record<string, string>;
101
+ breadcrumbs?: Breadcrumb[];
102
+ sdk: {
103
+ name: string;
104
+ version: string;
105
+ };
106
+ /** The tab's RUM session, so the error links to its visit. Only from tabs RUM sampled. */
107
+ session?: string;
108
+ }
109
+ /** Extra details for one captured event. They merge over what `setUser`/`setTag` set. */
110
+ interface CaptureContext {
111
+ level?: Level;
112
+ tags?: Record<string, string>;
113
+ /** Overrides how Tlm groups this event into an issue. */
114
+ fingerprint?: string[];
115
+ user?: {
116
+ id: string | number;
117
+ };
118
+ }
119
+ /** What `test()` resolves to: the event's id, or why it wasn't accepted. */
120
+ type TestResult = {
121
+ ok: true;
122
+ id: string;
123
+ } | {
124
+ ok: false;
125
+ reason: string;
126
+ };
127
+ type BreadcrumbKind = "console" | "dom" | "fetch" | "xhr" | "history";
128
+ interface TlmOptions {
129
+ /** Your project's DSN, from its setup page in Tlm. Default: `<meta name="tlm-dsn">`. Without one, nothing is sent. */
130
+ dsn?: string;
131
+ /** e.g. `"production"`, `"staging"`. Issues are counted per environment. Default: `<meta name="tlm-environment">`. */
132
+ environment?: string;
133
+ /** Your app's version or git sha, e.g. `"web@1.4.2"`. Default: `<meta name="tlm-release">`. */
134
+ release?: string;
135
+ /** Logs what the SDK does to the console, prefixed `[tlm]`. Default `false`. */
136
+ debug?: boolean;
137
+ /** Set to `false` to turn the SDK off entirely. Default `true`. */
138
+ enabled?: boolean;
139
+ /**
140
+ * Last chance to edit or drop an event before it's sent. Return the event
141
+ * (changed or not) to send it, or `null` to drop it.
142
+ */
143
+ beforeSend?: (event: TlmEvent) => TlmEvent | null;
144
+ /**
145
+ * Errors to ignore: strings match anywhere in `"Type: message"`, regexps are
146
+ * tested against it. Added to the built-in list of well-known browser noise.
147
+ */
148
+ ignoreErrors?: (string | RegExp)[];
149
+ /**
150
+ * Which script URLs are your app's own code. When set, a frame is in-app only
151
+ * if its URL matches. Default: same origin as the page, except vendor chunks.
152
+ */
153
+ inAppUrls?: (string | RegExp)[];
154
+ /** Remove `?query` and `#hash` from URLs sent to Tlm. Default `true`. */
155
+ stripQuery?: boolean;
156
+ /** Which breadcrumbs to record automatically. All on by default. */
157
+ breadcrumbs?: Partial<Record<BreadcrumbKind, boolean>>;
158
+ /** How many breadcrumbs to keep. Default `50`. */
159
+ maxBreadcrumbs?: number;
160
+ /**
161
+ * Tell Tlm once a day that the app is running (its release and
162
+ * environment, nothing about the user), so it shows as set up before any
163
+ * error. Default `true`.
164
+ */
165
+ heartbeat?: boolean;
166
+ /**
167
+ * Real User Monitoring, off by default. Import it separately so apps
168
+ * without it don't ship it: `import { rum } from "@hullop/tlm/rum"`,
169
+ * then `init({ rum: rum({ sampleRate: 0.1 }) })`.
170
+ */
171
+ rum?: RumPlugin;
172
+ /** Report uncaught errors and unhandled promise rejections. Default: both on. */
173
+ autoCapture?: false | {
174
+ onerror?: boolean;
175
+ onunhandledrejection?: boolean;
176
+ };
177
+ }
178
+
179
+ export type { Breadcrumb as B, CaptureContext as C, Frame as F, Level as L, RequestTiming as R, TlmOptions as T, TestResult as a, BreadcrumbKind as b, RumContext as c, RumHandle as d, RumPlugin as e, TlmEvent as f };
@@ -0,0 +1,179 @@
1
+ interface Logger {
2
+ debug: (...args: unknown[]) => void;
3
+ /** For misconfigurations the developer must see, even without `debug`. Once per message. */
4
+ warnOnce: (message: string) => void;
5
+ /** Always shown, for answers to something the developer asked for (like `test()`). */
6
+ info: (message: string) => void;
7
+ warn: (message: string) => void;
8
+ }
9
+
10
+ /** How bad an event is. Tlm accepts exactly these four. */
11
+ type Level = "fatal" | "error" | "warning" | "info";
12
+ /** One stack frame, innermost first, as the protocol defines it. */
13
+ interface Frame {
14
+ /** Script path with content hashes removed, e.g. `/assets/index.js`. Used for grouping. */
15
+ module: string;
16
+ /** Function name, or `"?"` for anonymous functions. */
17
+ function: string;
18
+ /** Script path as loaded, e.g. `/assets/index-a1b2c3d4.js`. Shown, not grouped on. */
19
+ file: string;
20
+ line?: number;
21
+ column?: number;
22
+ /** True for the app's own code; this decides how errors group into issues. */
23
+ in_app: boolean;
24
+ }
25
+ /** Something that happened before an error: a click, a request, a log line. */
26
+ interface Breadcrumb {
27
+ /** ISO 8601; set to now when missing. */
28
+ timestamp?: string;
29
+ level?: Level;
30
+ /** e.g. `ui.click`, `fetch`, `xhr`, `navigation`, `console`. */
31
+ category?: string;
32
+ message: string;
33
+ }
34
+
35
+ /** One fetch or XHR call, as the RUM plugin sees it. Times are `performance.now()` ms. */
36
+ interface RequestTiming {
37
+ method: string;
38
+ /** Absolute, without credentials, query or fragment. */
39
+ url: string;
40
+ /** `0` when there was no answer. */
41
+ status: number;
42
+ start: number;
43
+ end: number;
44
+ }
45
+ /** What the core hands the RUM plugin when it starts. */
46
+ interface RumContext {
47
+ win: Window;
48
+ /** `POST` URL for page views, key included. */
49
+ url: string;
50
+ /** The unwrapped `fetch`, so RUM's own requests are never measured. */
51
+ fetch: typeof fetch;
52
+ logger: Logger;
53
+ options: TlmOptions;
54
+ sdk: {
55
+ name: string;
56
+ version: string;
57
+ };
58
+ environment: string | undefined;
59
+ release: string | undefined;
60
+ }
61
+ /** A running RUM plugin, as the core drives it. */
62
+ interface RumHandle {
63
+ /** The tab's session id, only when RUM sampled this tab. Events carry it. */
64
+ readonly session: string | undefined;
65
+ /** A request started. What it returns comes back with its `request()` when it ends. */
66
+ requestStart: () => unknown;
67
+ request: (timing: RequestTiming, token?: unknown) => void;
68
+ /** The URL may have changed (pushState, replaceState, popstate). */
69
+ navigate: () => void;
70
+ setRoute: (name: string | undefined) => void;
71
+ close: () => void;
72
+ }
73
+ /** What `rum()` from `@hullop/tlm/rum` returns, for `init({ rum })`. */
74
+ interface RumPlugin {
75
+ start: (ctx: RumContext) => RumHandle;
76
+ }
77
+ /** An event as sent to Tlm (protocol v1). */
78
+ interface TlmEvent {
79
+ v: 1;
80
+ uuid: string;
81
+ timestamp: string;
82
+ platform: "javascript";
83
+ level: Level;
84
+ environment?: string;
85
+ release?: string;
86
+ exception?: {
87
+ type: string;
88
+ message?: string;
89
+ frames?: Frame[];
90
+ };
91
+ message?: string;
92
+ fingerprint?: string[];
93
+ request?: {
94
+ url: string;
95
+ headers: Record<string, string>;
96
+ };
97
+ user?: {
98
+ id: string;
99
+ };
100
+ tags?: Record<string, string>;
101
+ breadcrumbs?: Breadcrumb[];
102
+ sdk: {
103
+ name: string;
104
+ version: string;
105
+ };
106
+ /** The tab's RUM session, so the error links to its visit. Only from tabs RUM sampled. */
107
+ session?: string;
108
+ }
109
+ /** Extra details for one captured event. They merge over what `setUser`/`setTag` set. */
110
+ interface CaptureContext {
111
+ level?: Level;
112
+ tags?: Record<string, string>;
113
+ /** Overrides how Tlm groups this event into an issue. */
114
+ fingerprint?: string[];
115
+ user?: {
116
+ id: string | number;
117
+ };
118
+ }
119
+ /** What `test()` resolves to: the event's id, or why it wasn't accepted. */
120
+ type TestResult = {
121
+ ok: true;
122
+ id: string;
123
+ } | {
124
+ ok: false;
125
+ reason: string;
126
+ };
127
+ type BreadcrumbKind = "console" | "dom" | "fetch" | "xhr" | "history";
128
+ interface TlmOptions {
129
+ /** Your project's DSN, from its setup page in Tlm. Default: `<meta name="tlm-dsn">`. Without one, nothing is sent. */
130
+ dsn?: string;
131
+ /** e.g. `"production"`, `"staging"`. Issues are counted per environment. Default: `<meta name="tlm-environment">`. */
132
+ environment?: string;
133
+ /** Your app's version or git sha, e.g. `"web@1.4.2"`. Default: `<meta name="tlm-release">`. */
134
+ release?: string;
135
+ /** Logs what the SDK does to the console, prefixed `[tlm]`. Default `false`. */
136
+ debug?: boolean;
137
+ /** Set to `false` to turn the SDK off entirely. Default `true`. */
138
+ enabled?: boolean;
139
+ /**
140
+ * Last chance to edit or drop an event before it's sent. Return the event
141
+ * (changed or not) to send it, or `null` to drop it.
142
+ */
143
+ beforeSend?: (event: TlmEvent) => TlmEvent | null;
144
+ /**
145
+ * Errors to ignore: strings match anywhere in `"Type: message"`, regexps are
146
+ * tested against it. Added to the built-in list of well-known browser noise.
147
+ */
148
+ ignoreErrors?: (string | RegExp)[];
149
+ /**
150
+ * Which script URLs are your app's own code. When set, a frame is in-app only
151
+ * if its URL matches. Default: same origin as the page, except vendor chunks.
152
+ */
153
+ inAppUrls?: (string | RegExp)[];
154
+ /** Remove `?query` and `#hash` from URLs sent to Tlm. Default `true`. */
155
+ stripQuery?: boolean;
156
+ /** Which breadcrumbs to record automatically. All on by default. */
157
+ breadcrumbs?: Partial<Record<BreadcrumbKind, boolean>>;
158
+ /** How many breadcrumbs to keep. Default `50`. */
159
+ maxBreadcrumbs?: number;
160
+ /**
161
+ * Tell Tlm once a day that the app is running (its release and
162
+ * environment, nothing about the user), so it shows as set up before any
163
+ * error. Default `true`.
164
+ */
165
+ heartbeat?: boolean;
166
+ /**
167
+ * Real User Monitoring, off by default. Import it separately so apps
168
+ * without it don't ship it: `import { rum } from "@hullop/tlm/rum"`,
169
+ * then `init({ rum: rum({ sampleRate: 0.1 }) })`.
170
+ */
171
+ rum?: RumPlugin;
172
+ /** Report uncaught errors and unhandled promise rejections. Default: both on. */
173
+ autoCapture?: false | {
174
+ onerror?: boolean;
175
+ onunhandledrejection?: boolean;
176
+ };
177
+ }
178
+
179
+ export type { Breadcrumb as B, CaptureContext as C, Frame as F, Level as L, RequestTiming as R, TlmOptions as T, TestResult as a, BreadcrumbKind as b, RumContext as c, RumHandle as d, RumPlugin as e, TlmEvent as f };
package/package.json CHANGED
@@ -1,6 +1,73 @@
1
1
  {
2
2
  "name": "@hullop/tlm",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Reports your browser app's errors to Tlm.",
5
+ "keywords": [
6
+ "error-tracking",
7
+ "error-reporting",
8
+ "exceptions",
9
+ "monitoring",
10
+ "browser",
11
+ "tlm"
12
+ ],
13
+ "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/cirope/tlm-javascript.git",
17
+ "directory": "packages/tlm"
18
+ },
19
+ "type": "module",
20
+ "sideEffects": false,
21
+ "main": "./dist/index.cjs",
22
+ "module": "./dist/index.js",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "import": {
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js"
29
+ },
30
+ "require": {
31
+ "types": "./dist/index.d.cts",
32
+ "default": "./dist/index.cjs"
33
+ }
34
+ },
35
+ "./rum": {
36
+ "import": {
37
+ "types": "./dist/rum.d.ts",
38
+ "default": "./dist/rum.js"
39
+ },
40
+ "require": {
41
+ "types": "./dist/rum.d.cts",
42
+ "default": "./dist/rum.cjs"
43
+ }
44
+ },
45
+ "./package.json": "./package.json"
46
+ },
47
+ "files": [
48
+ "dist",
49
+ "CHANGELOG.md"
50
+ ],
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "scripts": {
55
+ "build": "rm -rf dist && tsup",
56
+ "test": "vitest run --project unit",
57
+ "test:browser": "vitest run --project browser",
58
+ "typecheck": "tsc --noEmit",
59
+ "size": "size-limit",
60
+ "check": "npm run typecheck && npm test && npm run build && node scripts/check-standalone.mjs && npm run size",
61
+ "prepublishOnly": "npm run check"
62
+ },
63
+ "devDependencies": {
64
+ "@size-limit/preset-small-lib": "^14.3.0",
65
+ "@vitest/browser-playwright": "^5.1.0",
66
+ "jsdom": "^31.0.1",
67
+ "playwright": "^1.65.1",
68
+ "size-limit": "^14.3.0",
69
+ "tsup": "^9.0.0",
70
+ "typescript": "^6.0.3",
71
+ "vitest": "^5.1.0"
72
+ }
73
+ }