@xcodleox/devinspector 3.2.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var y=(o,e)=>{for(var t in e)s(o,t,{get:e[t],enumerable:!0})},E=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of f(e))!g.call(o,n)&&n!==t&&s(o,n,{get:()=>e[n],enumerable:!(r=h(e,n))||r.enumerable});return o};var m=o=>E(s({},"__esModule",{value:!0}),o);var w={};y(w,{AuditErrorBoundary:()=>d});module.exports=m(w);var u=require("react");var c=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((r,n)=>{let i=r instanceof Error?r:new Error(String(r?.message||r||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!n}),t&&t(r,n)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let r=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(r,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",r=>{this.captureError(r,{type:"uncaught_exception"})}),t.on("unhandledRejection",r=>{let n=r instanceof Error?r:new Error(String(r));this.captureError(n,{type:"unhandled_rejection"})})}}truncate(e,t=5e3){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){let r={};for(let[n,i]of Object.entries(e))r[n]=this.truncate(i,t);return r}return e}captureError(e,t={}){let r=e.message||"Erro Desconhecido",n=e.stack||"",i={type:"error",message:this.truncate(r,500),stackTrace:this.truncate(n,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let r={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(r)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});r.ok||console.error(`[DevInspector] Erro na API (${r.status}): ${r.statusText}`)}catch(r){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",r)}}},a="__DEVINSPECT_AUDIT_CORE_INSTANCE__",b=()=>{let o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return o[a]||(o[a]=new c),o[a]},p=b();var l=require("react/jsx-runtime"),d=class extends u.Component{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,r){p.captureError(t,{componentStack:r.componentStack})}render(){return this.state.hasError?this.props.fallback||(0,l.jsx)("h1",{children:"Algo deu errado na aplica\xE7\xE3o."}):this.props.children}};0&&(module.exports={AuditErrorBoundary});
1
+ "use strict";var c=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var w=(n,e)=>{for(var t in e)c(n,t,{get:e[t],enumerable:!0})},m=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of g(e))!y.call(n,o)&&o!==t&&c(n,o,{get:()=>e[o],enumerable:!(r=h(e,o))||r.enumerable});return n};var E=n=>m(c({},"__esModule",{value:!0}),n);var S={};w(S,{AuditErrorBoundary:()=>p,auditFetch:()=>v});module.exports=E(S);var l=require("react");var u=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((r,o)=>{let i=r instanceof Error?r:new Error(String(r?.message||r||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!o}),t&&t(r,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let r=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(r,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",r=>{this.captureError(r,{type:"uncaught_exception"})}),t.on("unhandledRejection",r=>{let o=r instanceof Error?r:new Error(String(r));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,t=5e3){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){let r={};for(let[o,i]of Object.entries(e))r[o]=this.truncate(i,t);return r}return e}captureError(e,t={}){let r=e.message||"Erro Desconhecido",o=e.stack||"",i={type:"error",message:this.truncate(r,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let r={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(r)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});r.ok||console.error(`[DevInspector] Erro na API (${r.status}): ${r.statusText}`)}catch(r){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",r)}}},d="__DEVINSPECT_AUDIT_CORE_INSTANCE__",b=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[d]||(n[d]=new u),n[d]},s=b();var f=require("react/jsx-runtime"),p=class extends l.Component{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,r){s.captureError(t,{framework:"React",componentStack:r.componentStack,url:typeof window<"u"?window.location.href:""})}render(){return this.state.hasError?this.props.fallback||(0,f.jsx)("h1",{children:"Algo deu errado na aplica\xE7\xE3o."}):this.props.children}};async function v(n,e){let t=typeof n=="string"?n:n instanceof URL?n.toString():n.url;if(t.includes("devinspector.com.br"))return fetch(n,e);let r=e?.method||"GET",o=typeof performance<"u"?performance.now():Date.now();try{let i=await fetch(n,e),a=Math.round((typeof performance<"u"?performance.now():Date.now())-o);return(i.status>=400||a>=300)&&s.captureRequest({method:r,url:t,statusCode:i.status,durationMs:a,userAgent:typeof navigator<"u"?navigator.userAgent:"",route:t}),i}catch(i){let a=Math.round((typeof performance<"u"?performance.now():Date.now())-o);throw s.captureRequest({method:r,url:t,statusCode:0,durationMs:a,userAgent:typeof navigator<"u"?navigator.userAgent:"",route:t}),s.captureException(i instanceof Error?i:new Error(String(i)),{url:t,method:r,type:"network_error"}),i}}0&&(module.exports={AuditErrorBoundary,auditFetch});
package/dist/react.d.cts CHANGED
@@ -13,5 +13,6 @@ declare class AuditErrorBoundary extends Component<Props, State> {
13
13
  componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
14
14
  render(): ReactNode;
15
15
  }
16
+ declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
16
17
 
17
- export { AuditErrorBoundary };
18
+ export { AuditErrorBoundary, auditFetch };
package/dist/react.d.ts CHANGED
@@ -13,5 +13,6 @@ declare class AuditErrorBoundary extends Component<Props, State> {
13
13
  componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
14
14
  render(): ReactNode;
15
15
  }
16
+ declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
16
17
 
17
- export { AuditErrorBoundary };
18
+ export { AuditErrorBoundary, auditFetch };
package/dist/react.js CHANGED
@@ -1 +1 @@
1
- import{Component as u}from"react";var a=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((r,n)=>{let i=r instanceof Error?r:new Error(String(r?.message||r||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!n}),t&&t(r,n)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let r=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(r,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",r=>{this.captureError(r,{type:"uncaught_exception"})}),t.on("unhandledRejection",r=>{let n=r instanceof Error?r:new Error(String(r));this.captureError(n,{type:"unhandled_rejection"})})}}truncate(e,t=5e3){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){let r={};for(let[n,i]of Object.entries(e))r[n]=this.truncate(i,t);return r}return e}captureError(e,t={}){let r=e.message||"Erro Desconhecido",n=e.stack||"",i={type:"error",message:this.truncate(r,500),stackTrace:this.truncate(n,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let r={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(r)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});r.ok||console.error(`[DevInspector] Erro na API (${r.status}): ${r.statusText}`)}catch(r){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",r)}}},s="__DEVINSPECT_AUDIT_CORE_INSTANCE__",p=()=>{let o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return o[s]||(o[s]=new a),o[s]},c=p();import{jsx as l}from"react/jsx-runtime";var d=class extends u{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,r){c.captureError(t,{componentStack:r.componentStack})}render(){return this.state.hasError?this.props.fallback||l("h1",{children:"Algo deu errado na aplica\xE7\xE3o."}):this.props.children}};export{d as AuditErrorBoundary};
1
+ import{Component as l}from"react";var d=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((r,i)=>{let n=r instanceof Error?r:new Error(String(r?.message||r||"Erro React Native desconhecido"));this.captureError(n,{type:"react_native_error",isFatal:!!i}),t&&t(r,i)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let r=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(r,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",r=>{this.captureError(r,{type:"uncaught_exception"})}),t.on("unhandledRejection",r=>{let i=r instanceof Error?r:new Error(String(r));this.captureError(i,{type:"unhandled_rejection"})})}}truncate(e,t=5e3){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){let r={};for(let[i,n]of Object.entries(e))r[i]=this.truncate(n,t);return r}return e}captureError(e,t={}){let r=e.message||"Erro Desconhecido",i=e.stack||"",n={type:"error",message:this.truncate(r,500),stackTrace:this.truncate(i,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(n)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let r={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(r)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});r.ok||console.error(`[DevInspector] Erro na API (${r.status}): ${r.statusText}`)}catch(r){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",r)}}},c="__DEVINSPECT_AUDIT_CORE_INSTANCE__",p=()=>{let o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return o[c]||(o[c]=new d),o[c]},s=p();import{jsx as f}from"react/jsx-runtime";var u=class extends l{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,r){s.captureError(t,{framework:"React",componentStack:r.componentStack,url:typeof window<"u"?window.location.href:""})}render(){return this.state.hasError?this.props.fallback||f("h1",{children:"Algo deu errado na aplica\xE7\xE3o."}):this.props.children}};async function b(o,e){let t=typeof o=="string"?o:o instanceof URL?o.toString():o.url;if(t.includes("devinspector.com.br"))return fetch(o,e);let r=e?.method||"GET",i=typeof performance<"u"?performance.now():Date.now();try{let n=await fetch(o,e),a=Math.round((typeof performance<"u"?performance.now():Date.now())-i);return(n.status>=400||a>=300)&&s.captureRequest({method:r,url:t,statusCode:n.status,durationMs:a,userAgent:typeof navigator<"u"?navigator.userAgent:"",route:t}),n}catch(n){let a=Math.round((typeof performance<"u"?performance.now():Date.now())-i);throw s.captureRequest({method:r,url:t,statusCode:0,durationMs:a,userAgent:typeof navigator<"u"?navigator.userAgent:"",route:t}),s.captureException(n instanceof Error?n:new Error(String(n)),{url:t,method:r,type:"network_error"}),n}}export{u as AuditErrorBoundary,b as auditFetch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcodleox/devinspector",
3
- "version": "3.2.1",
3
+ "version": "5.0.0",
4
4
  "description": "SDK de monitoramento e auditoria de erros em tempo real | Dev Inspector",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",