UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 2.16 kB
import{makeOfflineTransport as l}from"@sentry/core";import{captureException as s,init as u,makeFetchTransport as f,setTag as a,setUser as d}from"@sentry/react";const c=process.env.NODE_ENV||"development",E=process.env.SENTRY_RELEASE||void 0;function S(){const r="sentry_offline_queue";return{async push(t){try{const e=JSON.parse(localStorage?.getItem(r)||"[]");e.push({envelope:t,timestamp:Date.now()}),e.length>50&&e.shift(),localStorage?.setItem(r,JSON.stringify(e))}catch{}},async unshift(t){try{const e=JSON.parse(localStorage?.getItem(r)||"[]");e.unshift({envelope:t,timestamp:Date.now()}),e.length>50&&e.pop(),localStorage?.setItem(r,JSON.stringify(e))}catch{}},async shift(){try{const t=JSON.parse(localStorage?.getItem(r)||"[]");if(t.length===0){localStorage?.removeItem(r);return}const e=t.shift();return t.length===0?localStorage?.removeItem(r):localStorage?.setItem(r,JSON.stringify(t)),e?.envelope}catch{return}}}}export function initSentry(r){const n=l(f);u({dsn:"https://b2eafc5a038fa2c535099e431de219f2@o4510697102114816.ingest.us.sentry.io/4510697103097856",release:E,environment:c,sendDefaultPii:!0,transport:t=>n({...t,createStore:()=>S(),flushAtStartup:!0,shouldStore:async(e,o)=>!!(!navigator.onLine||o&&(o.message?.includes("Failed to fetch")||o.message?.includes("NetworkError")||o.message?.includes("Network request failed")))}),tracesSampleRate:.1,ignoreErrors:[/loading chunk \d{1,2}\b/i,/zaloJS/i,/e\.target\.name/i,/ResizeObserver loop/i,/ChunkLoadError/i,/FloorPlan not ready/i,/NetworkError/i,/network error occurred/i,/network request failed/i,/failed to fetch/i,/abort/i],beforeSend(t){return c!=="production"?null:t}}),r.eventId&&a("eventId",r.eventId),a("isWebview",r.isWebview),a("source","vite-main"),d({ip_address:"{{auto}}"}),m()}function m(){window.addEventListener("unhandledrejection",n=>{s(n.reason,{contexts:{unhandledRejection:{promise:n.promise}}})});const r=window.onerror;window.onerror=(n,t,e,o,i)=>(i&&s(i,{contexts:{windowError:{message:n,source:t,lineno:e,colno:o}}}),r&&r.call(window,n,t,e,o,i),!1),window.addEventListener("online",()=>{const n=window.__SENTRY__?.hub?.getClient();n&&n.flush().catch(()=>{})})}